// JScript File

if (!document.layers&&!document.all&&!document.getElementById){
	event="test";
}


var bIsMSIE = (navigator.appVersion.indexOf("MSIE") >= 0);


//------------------------------------------
// findPos
//------------------------------------------
function findPos(obj) {
	var curleft = 0;
	var curtop  = 0;

	if (obj.offsetParent) {

		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			//The tricky bit: return value of the = operator
			//Now we get to the tricky bit:

		} while (obj = obj.offsetParent);
	}

	return [curleft,curtop];
}



//--------------------------------------
// getMouseXY
//--------------------------------------
function getMouseXY(oElem) {

	if(oElem.pageX) {
		// grab the x-y pos.s if browser is NS
		tempX = oElem.pageX;
		tempY = oElem.pageY;
	}else{
		// grab the x-y pos.s if browser is IE
		 tempX = event.clientX + document.body.scrollLeft;
		 tempY = event.clientY + document.body.scrollTop;
	}
	
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}

	return [tempX,tempY];
}



function PagesPreloadImages(aExtraImages){
			MM_preloadImages(new Array('/media/LeftMenu/TandemRides_Nav.jpg',
									   '/media/LeftMenu/TandemRides_HNav.jpg',
									   '/media/LeftMenu/PilotServices_Nav.jpg',
									   '/media/LeftMenu/PilotServices_HNav.jpg',
									   '/media/LeftMenu/Instructions_Nav.jpg',
									   '/media/LeftMenu/Instructions_HNav.jpg',
									   '/media/LeftMenu/Calendar_Nav.jpg',
									   '/media/LeftMenu/Calendar_HNav.jpg',
									   '/media/LeftMenu/FlRidgeBlog_Nav.jpg',
									   '/media/LeftMenu/FlRidgeBlog_HNav.jpg',
									   '/media/LeftMenu/ProShop_Nav.jpg',
									   '/media/LeftMenu/ProShop_HNav.jpg',
									   '/media/LeftMenu/WebLinks_Nav.jpg',
									   '/media/LeftMenu/WebLinks_HNav.jpg',
									   '/media/logobackstd.jpg',
									   '/media/simpglry_right.gif',
									   '/media/simpglry_play.gif',
									   '/media/simpglry_pause.gif',
									   '/media/simpglry_left.gif',
									   '/media/ajax-loading.gif',
									   '/media/black-70.png'));
							
							
			if(aExtraImages){
				MM_preloadImages(aExtraImages)
			}
							
			
}

//--------------------------------------
// MM_preloadImages
//--------------------------------------
function MM_preloadImages(arrImages) {
  	var d=document; 
  
	if(d.images) { 
  		if(!d.MM_p){
  			d.MM_p=new Array();
  		}
	
		var i; 
		var j=d.MM_p.length;
		var a=arrImages; // MM_preloadImages.arguments; 
	
		for(i=0; i<a.length; i++){
			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
  	}
}



//--------------------------------------
function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//--------------------------------------
function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//--------------------------------------
function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//--------------------------------------
// ShowTip
//--------------------------------------
function ShowTipXY (oElem, sShowTxt, MouseX, MouseY){

    var aTextTitle;
    var sTheTitle = "";
	
    if (document.all||document.getElementById){
		aTextTitle = sShowTxt.split("<br>");

		if (aTextTitle.length>1){
			sTheTitle='';	

			for (var i=0;i<aTextTitle.length;i++){
				sTheTitle += aTextTitle[i];
			}

			oElem.title=sTheTitle;
		}else{
			oElem.title = sShowTxt;
		}
	}else if  (document.layers){
		document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+ sText +'</layer>');
		document.tooltip.document.close();
		document.tooltip.left=MouseX+5;
		document.tooltip.top=MouseY+5;
		document.tooltip.visibility="show";
	}

}
	
//--------------------------------------
//  createCookie
//--------------------------------------
function createCookie(sName,vValue,nDays) {
			
	var dDate = new Date();
	var sExpires  = ""
	
	if (nDays) {
		date.setTime(date.getTime()+(nDays*24*60*60*1000));
		sExpires = "; expires=" + date.toGMTString();
	}

	document.cookie = sName + "=" + vValue + sExpires + "; path=/";
}

//--------------------------------------
//  readCookie
//--------------------------------------
function readCookie(sName) {
	var nameEQ = sName + "=";
	var ca = document.cookie.split(';');
	
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}

		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

//--------------------------------------
//  eraseCookie
//--------------------------------------
function eraseCookie(name) {
	createCookie(name,"",-1);
}
	

//--------------------------------------
// ShowTip
//--------------------------------------
function ShowTip ( oCellCurr,evt,sShowTxt){
	
	var aTextTitle;
	var sTheTitle = "";
	var sText = "";
	
	if (sShowTxt) {
		sText = sShowTxt;
	}else{
		if (oCellCurr.name) {
			sText = oCellCurr.name;
		}else{
			if (oCellCurr.innerText) {
				sText = oCellCurr.innerText;
			}else{
				if (oCellCurr.innerHTML) {
					sText = oCellCurr.innerHTML;
				}else if (oCellCurr.id) {	
					sText = oCellCurr.id;
				}
			}
		}
	}
	
	if (document.all||document.getElementById){
		aTextTitle = sText.split("<br>");

		if (aTextTitle.length>1){
			sTheTitle='';	

			for (var i=0;i<aTextTitle.length;i++){
				sTheTitle += aTextTitle[i];
			}

			oCellCurr.title=sTheTitle;
		}else{
			oCellCurr.title = sText;
		}

	}else if (document.layers){
		document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+ sText +'</layer>');
		document.tooltip.document.close();
		document.tooltip.left=evt.pageX+5;
		document.tooltip.top=evt.pageY+5;
		document.tooltip.visibility="show";
	}
}


//--------------------------------------
// HideTip
//--------------------------------------
function HideTip(){

	if (document.layers){
		document.tooltip.visibility="hidden";
	}
}


//--------------------------------------
// TrimStr
//--------------------------------------
function TrimStr(sTheStr){
	//var sRetVal = ""
	//sRetVal = 
	return sTheStr.replace(/^\s+|\s+$/g, ''); 
	//return sRetVal;
}


//--------------------------------------
// Menu_ClickThis
//--------------------------------------
function Menu_ClickThis(oCell){
	
	var sMenuItem  = "";
	var sPath = "";
	
	if (oCell.innerText){
		sMenuItem = TrimStr(oCell.innerText);
	}else if (oCell.innerHTML){
		sMenuItem = TrimStr(oCell.innerHTML);
	}
	
   oCell.style.border =  "inset 2px #B0C4DE";
   
   if (oCell.ownerDocument.location.pathname.toString().indexOf("pages") == -1) {
   	sPath = "pages/";
   }
       
    
	switch  (sMenuItem){
		 case "NEWS AND EVENTS":
			  window.location = sPath + "caleventsnews.php";
			  //window.location = "pages/caleventsnews.php";
			  break;
		 case "ABOUT THE PARK":
			  window.location = sPath +  "about.php";
			  break;
		 case "FAQ":
			  window.location = sPath + "faq.php";
			  break;
		 case "WEATHER":
			  window.location = sPath + "weather.php";
			  break;
		 case "CONTACT US":
			  window.location = sPath + "contact.php";
			  break;
		 case "DIRECTIONS":
			  window.location = sPath + "directions.php";
			  break;
		 case "ACCOMMODATIONS":
			  window.location = sPath + "accommodations.php";
			  break;
	}
	
	return false;
	
}



//--------------------------------------
// Menu_MouseOver
//--------------------------------------
function Menu_MouseOver(oCell,evt) {
  
  // oCell.style.color = "#FFFFF0";
  // oCell.style.backgroundColor = "#434387";
  
	oCell.style.color = "#FFFFDF";
	oCell.style.backgroundColor = "#526AB4";
	oCell.style.border = "outset 2px #B0C4DE";

 	// color: #FFFFDF;
 	//   background-color: #526AB4;

	ShowTip(oCell,evt);
	
	//oCell.style.cursor = "hand";
	oCell.style.cursor = "pointer";
	
	//alert (oCell.tagName)
}

//--------------------------------------
// Menu_MouseOut
//--------------------------------------
function Menu_MouseOut(oCell) {
	
	oCell.style.color = "";
	oCell.style.backgroundColor = "";
	oCell.style.cursor = "";
	oCell.style.border = "solid 2px #2B2B55";
	
	//alert (oCell.tagName)
	
	HideTip();
	
}


//--------------------------------------
//--------------------------------------
function ShowGalleryandVideos(sToShow){
	
	//debugger;
	//href          	 // The hyperlink for the window
	//title           // Title of window
	//author          // Author of window
	//caption         // The Caption for the window
	//rel             // Set the rel tag
	//top             // Top position of the window
	//left             // Left position of the window
	//type             // The type of the window you want to change it too
	//showImages         // How many images to show
	//height             // The height of the window
	//width             // The width of the window
	//loadingAnimation     // Make the Loading Cover skip the animation
	//iframeEmbed         // Emebed the Media into an iframe instead of a div
	//form             // The name of the form
	//
	
	if (myLightWindow){
		myLightWindow.deactivate();
	}
	
	myLightWindow = new lightwindow();

	switch(sToShow) {
		case "GALLERY":
			myLightWindow.activateWindow({href: '../pages/GalleryPage.htm',
										title: '',
										author: '',
										caption: '',
										top: '285',
										type: 'external',
										height: 507,
										width: 662,
										viewportPadding: 0,
										resizeSpeed: 1,
										hideFlash: true,
										hideGalleryTab: false,
										showGalleryCount: true,
										contentOffset:{height:2,width:2}
										});
			break;

		case "VIDEOS":
			var sWindowOpts = ""
			var sWindowReturn = ""
			var sDestination = ""
			var wHigh = 520
			var wWide = 510
			var wLeft = (screen.width/2)-(wWide/2);
			var wTop = (screen.height/2)-(wHigh/2);
			wTop = wTop +5

			sWindowOpts =  "center:yes; scroll:no; resizable:no; status:no; unadorned:yes; ";
			sWindowOpts += "dialogHeight:" + wHigh + "px; dialogWidth:"+ wWide + "px;";
			sWindowOpts += "dialogLeft:" + wLeft + "px; dialogTop:" + wTop + "px;";

			sDestination = "../pages/VideoMenu.htm";

			document.getElementById('LiteBoxFade').style.display='block';
			sWindowReturn = window.showModalDialog( sDestination, 'VideoMenu', sWindowOpts );
			document.getElementById('LiteBoxFade').style.display='none';


			if (sWindowReturn) {
				if (sWindowReturn=="FirstFligth") {

					// <object width="425" height="344"><param name="movie" 
					// value="http://www.youtube.com/v/nspDwKkvpF8&hl=en_US&fs=1&">
					// </param><param name="allowFullScreen" value="true"></param>
					// <param name="allowscriptaccess" value="always"></param>
					// <embed src="http://www.youtube.com/v/nspDwKkvpF8&hl=en_US&fs=1&" 
						   // type="application/x-shockwave-flash" allowscriptaccess="always" 
						   // allowfullscreen="true" width="425" height="344">
					// </embed>
					// </object>
					
					myLightWindow.activateWindow({href: 'http://www.youtube.com/v/nspDwKkvpF8&autoplay=1&amp;hl=en&amp;rel=0&amp;showinfo=0&amp;fs=1&amp;ap=%2526fmt%3D18',
												  title: '',
												  author: '',
												  caption: '',
												  top: '275',
												  type: 'media',
												  subtype: 'youtube',
												  iframeEmbed: 'false',
												  height: '400',
												  width: '570'
											  });

				}else{
					myLightWindow.activateWindow({href: '../videos/' + sWindowReturn + '.wmv',
												  title: '',
												  author: '',
												  caption: '',
												  top: '300',
												  type: 'media',
												  subtype: 'windowsWMV',
												  iframeEmbed: 'true',
												  height: '425',
												  width: '640'
											  });
				}
			}
			// videos = 856 x 480
			break;

		default:
			break;
	}
}


        //function Flash_ToolTip(oElem,iTop, iLeft, iWidth, iHigh, iMousX, iMousY){
        //    var sTipMessage = ""
        //    //debugger;
        //    if ( (iMousX > iLeft +5) && (iMousX < iWidth + iLeft -5)) {
        //        if ( (iMousY > (iHigh+iTop) -90) && (iMousY < (iHigh + iTop)-5)) {
        //            sTipMessage = "Picture Gallery"
        //        }
        //    }
        //
        //    if (sTipMessage != "") {
        //        debugger;
        //        oElem.setAttribute("style","CURSOR: hand;")
        //
        //        window.document.body.style.cursor ="hand"
        //        oElem.style.cursor ="hand"
        //        oElem.offsetParent.style.cursor ="hand"
        //
        //        //debugger;
        //        //ShowTipXY( oElem, sTipMessage, iMousX,iMousY)
        //    }else{
        //        oElem.style.cursor =""
        //        //HideTip();
        //    }
        //}

        //function Flash_MousePos(objFlash){
        //
        //    var oText = document.getElementById("MOUSEPOSTXT");
        //    var aFindPos;
        //    var aMousePos;
        //
        //    //debugger;
        //    if (oText) {
        //        aFindPos = findPos(objFlash);
        //        aMousePos =  getMouseXY(document);
        //
        //        oText.value = ""
        //        oText.value = oText.value + " left,top=[" + aFindPos.toString() + "]";
        //        oText.value = oText.value + " width,hight=[" + objFlash.width.toString() + "," + objFlash.height.toString() + "]";
        //        oText.value = oText.value + " /  " + aMousePos.toString();
        //    }else{
        //        alert ("could not find text");
        //    }
        //
        //    Flash_ToolTip(objFlash, aFindPos[0],aFindPos[1],parseInt(objFlash.width),parseInt(objFlash.height),aMousePos[0],aMousePos[1]);
        //}




