


var site_root = 'http://drakesbad.com/';


//	Browser d-tect
var w3c = (document.getElementById) ? true : false;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;


if (w3c) {
	var write_in_styles = '';
	write_in_styles += '<style type="text/css">';
	
	write_in_styles += '#content, #banner { visibility: hidden; }';
	
	write_in_styles += '</style>';
	document.write(write_in_styles);
}

var content_div;

var flash_pages = new Array();
// [Folder+PageName],[SWFFilePath],[ElementID],[SWFHeight],[SWFWidth]
//flash_pages[0] = new Array('CalParks/site/','flash_banner.swf','banner',271,760);



if (location.href.substring((location.href.length-4),(location.href.length)) == 'www/') {
	top.location.href = site_root + 'index.php';
}

/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	INIT FUNCTION
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */
function init() {
	
	content_div = document.getElementById('content');
	
	/* *************************************************** */
	/* ****************** Flash Control ****************** */
	if (hasRightVersion) {
		for (var aa=0; aa<flash_pages.length; aa++) {
			location_lc = top.location.href.toLowerCase();
			current_item_lc = flash_pages[aa][0].toLowerCase();
			if(location_lc.indexOf(current_item_lc) != -1 && document.getElementById(flash_pages[aa][2])) {
				insertFlash(flash_pages[aa][1],flash_pages[aa][2],flash_pages[aa][3],flash_pages[aa][4]);
			}
		}
		if (document.getElementById('homePage')) {
			insertFlash(site_root + 'flash_banner.swf','banner',340,760);
		}
	}
	/* **************** End Flash Control **************** */
	/* *************************************************** */
	
	all_DL = document.getElementsByTagName('DL');
	for (var pp=0; pp<all_DL.length; pp++) {
		if (all_DL[pp].className == 'setInfoPairs') {
			setInfoPairClicker(all_DL[pp]);
		}
	}
	
	setPopUpLinks();
	
	
	/* :::::::::: Picture Viewer :::::::::: */
	if (top.location.href.indexOf('picture_viewer.php') != -1) {
		var the_pic = document.createElement('IMG');
		the_pic.src = location.search.substring(1);
		
		document.getElementById('thePicture').appendChild(the_pic);
		the_pic.onload = function() {
			top.resizeTo(the_pic.width+30,the_pic.height+80);
		}
		//if (the_pic.width > 1000 || the_pic.height > 760) {
		//	top.resizeTo(1000,760);
		//} else {
		//}
	}
	/* :::::::::: End Picture Viewer :::::::::: */

	
	
	if (document.getElementById('content')) {
		document.getElementById('content').style.visibility = 'visible';
	}
	if (document.getElementById('banner')) {
		document.getElementById('banner').style.visibility = 'visible';
	}
}

if (w3c) { window.onload = init; }







// Target, Params
var targets_to_pop = new Array();
targets_to_pop[0] = new Array('EnlargePhoto','width=400,height=300,status=yes,resizable=yes,scrollbars=yes');
targets_to_pop[1] = new Array('calParksLinks','width=700,height=550,status=yes,resizable=yes,scrollbars=yes');
targets_to_pop[2] = new Array('relatedLinks','width=700,height=550,status=yes,resizable=yes,scrollbars=yes');
targets_to_pop[3] = new Array('mapLinks','width=700,height=550,status=yes,resizable=yes,scrollbars=yes');

function setPopUpLinks() {
	var page_links = document.getElementsByTagName('A');
	
	for (var aa=0; aa<targets_to_pop.length; aa++) {
		
		for (var bb=0; bb<page_links.length; bb++) {
			if (page_links[bb].target.toLowerCase() == targets_to_pop[aa][0].toLowerCase()) {
				page_links[bb].param_specs = targets_to_pop[aa][1];
				page_links[bb].onclick = function () {
					if (this.toString().indexOf('.jpg') != -1) {
						this.assoc_win = createNewWindow(site_root + 'picture_viewer.php?' + this, this.param_specs);
					} else {
						this.assoc_win = createNewWindow(this, this.param_specs);
					}
					return false;
				}
			}
		}
	}
}

function createNewWindow(elem, params) {
	var the_win = window.open(elem,elem.target,params);
	the_win.focus();
}

function popWin(page_name,the_width,the_height,win_name) {
	//win_name = (win_name) ? 'OpeningNewWindow' : win_name;
	var the_win = window.open(page_name,win_name,'status=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,resizable=yes,width='+the_width+',height='+the_height+',screenX=0,screenY=0,top=0,left=0');
	the_win.focus();
}


function setInfoPairClicker(infoPair_DL) {
	//var infoPair_DL = document.getElementById('stsInformation');
	var infoPair_DT = infoPair_DL.getElementsByTagName('DT');
	var infoPair_DD = infoPair_DL.getElementsByTagName('DD');
	var DT_topMargin = 1.4;
	
	infoPair_DL.className = 'infoPairs';
	
	for (aa=0; aa<infoPair_DT.length; aa++) {
		infoPair_DT[aa].style.top = (aa * DT_topMargin) + 'em';
		infoPair_DT[aa].related_dd = infoPair_DD[aa];
		infoPair_DT[aa].related_heading = infoPair_DT[aa].firstChild.nodeValue;
		
		infoPair_DT[aa].onclick = function() {
			for (bb=0; bb<infoPair_DT.length; bb++) {
				infoPair_DD[bb].style.display = 'none';
				infoPair_DT[bb].className = 'xyz';
			}
			this.related_dd.style.display = 'block';
			this.className = 'selected';
		}
		
		h2_tag = document.createElement('H2');
		heading_text = document.createTextNode(infoPair_DT[aa].related_heading);
		h2_tag.appendChild(heading_text);
		
		infoPair_DD[aa].insertBefore(h2_tag,infoPair_DD[aa].childNodes[0]);
		infoPair_DD[aa].style.marginTop = (infoPair_DT.length * (DT_topMargin + .2)) + 'em';
	}
	infoPair_DT[0].className = 'selected';
	infoPair_DD[0].style.display = 'block';
}




//	FLASH PLAYER CHECK
//	Checks for Flash 4,5,6,7 plug-in. This works with Netscape, Mozilla, IE Win and IE5 Mac.
//	Variable [hasRightVersion] will be set to true or false
var hasFlash2 = false;
var hasFlash3 = false;
var hasFlash4 = false;
var hasFlash5 = false;
var hasFlash6 = false;
var hasFlash7 = false;
var hasFlash8 = false;
var hasFlash9 = false;
var hasFlash10 = false;
var hasFlash11 = false;
var hasFlash12 = false;

var requiredVersion = 6;
var maxVersion = 12;
var actualVersion = 0;
var hasRightVersion = false;	


if (navigator.plugins) {
	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]
	&& navigator.mimeTypes["application/x-shockwave-flash"] 
	&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {		
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		
		hasFlash4 = flashVersion == 4;
		hasFlash5 = flashVersion == 5;
		hasFlash6 = flashVersion == 6; 
		hasFlash7 = flashVersion >= 7; 
		hasFlash8 = flashVersion == 8;
		hasFlash9 = flashVersion == 9;
		hasFlash10 = flashVersion == 0;
		hasFlash11 = flashVersion == 1;
		hasFlash12 = flashVersion == 2;
	}
}

//	Write VBScript on IE Windows
if (isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  	document.write('on error resume next \n');
  	document.write('hasFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('hasFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('hasFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');	
	document.write('hasFlash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');	
	document.write('hasFlash9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('hasFlash10 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
	document.write('hasFlash11 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.11"))) \n');
	document.write('hasFlash12 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.12"))) \n');
  	document.write('</SCR' + 'IPT\> \n');
}
for (var i=2; i <= maxVersion; i++) {  
	if (eval("hasFlash" + i) == true) {
		actualVersion = i;
	}
}
if (actualVersion >= requiredVersion) {
	hasRightVersion = true;
}//	End Flash Player check

//	var site_bg = '#fdfaf3';

//	This function returns the <object> and <embed> tags in variable [oeTags]
function makeFlashTags(the_swf,the_height,the_width,w_mode) {
	if (hasRightVersion) {
		var flashTag;
		if (isIE && isWin) {
			flashTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<param name="movie" value="'+the_swf+'" />'
			+ '<param name="play" value="true" />'
			+ '<param name="quality" value="high" />'
			+ '<param name="menu" value="false" />'
			+ '<param name="wmode" value="'+w_mode+'" />'
			//+ '<param name="allowScriptAccess" value="sameDomain" />'
			//+ '<param name="swLiveConnect" value="true">'
			//+ '<param name="loop" value="false" />'
			//+ '<param name="bgcolor" value="#FDFAF3" />'
			+ '</object>';
		} else {
			flashTag = '<embed src="'+the_swf+'"'
			+ ' width="'+the_width+'" height="'+the_height+'"'
			+ ' play="true"'
			+ ' quality="high"'
			+ ' menu="false"'
			//+ ' bgcolor="#FDFAF3"'
			+ ' type="application/x-shockwave-flash"'
			+ ' wmode="'+w_mode+'"'
			+ ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"'
			//	+ 'loop="false"'
			//+ ' allowScriptAccess="sameDomain"'
			//+ ' swLiveConnect="true"'
			+ '>'
			+ '</embed>';			
		}
		return flashTag;
	}
}
//	This function swaps innerHTML of [the_container] with makeOETags()
function insertFlash(the_swf,the_container,the_height,the_width,w_mode) {
	if (hasRightVersion) {
		if (!w_mode) w_mode = 'window';
		//document.getElementById(the_container).style.height = the_height+'px';
		document.getElementById(the_container).innerHTML = makeFlashTags(the_swf,the_height,the_width,w_mode);
	}
}













