﻿// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var jsVersion = 1.1;

function createFlashControl(DivID,movie,width,height,bgColor)
{
  if(bgColor == null)
    bgColor = '#ffffff';
  var d = document.getElementById(DivID);
    d.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="Shell" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + movie + '" /><param name="quality" value="high"/><param name="bgcolor" value="#ffffff" /><embed src="' + movie + '" quality="high" bgcolor="' + bgColor + '" width="' + width + '" height="' + height + '" name="Shell" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';
  }
  function createFlashControl2(DivID,movie,width,height,base)
{
  var d = document.getElementById(DivID);
    d.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ' + 'width="' + width + '" height="' + height + '" id="Shell" align="middle"><PARAM NAME="BASE" VALUE="' + base + '" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + movie + '" /><param name="quality" value="high"/><param name="wmode" value="transparent"><embed src="' + movie + '" quality="high" width="' + width + '" height="' + height + '" name="Shell" align="middle" wmode="transparent" base="' + base + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>';
}

function createMediaPlayer(DivID,movie,width,height)
{
var d = document.getElementById(DivID);
d.InnerHTML = '<object width=' + width + ' height=' + height + ' classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="mediaplayer1" viewastext><param name="Filename" value=' + movie + '><param name="AutoStart" value="True"><param name="ShowControls" value="True"><param name="ShowStatusBar" value="True"><param name="ShowDisplay" value="False"><param name="AutoRewind" value="True"><embed type="application/x-mplayer2" width=' + width + ' height=' + height + ' pluginspage="http://www.microsoft.com/windows/windowsmedia/download/default.asp" src=' + movie + ' autostart="True" filename=' + movie + ' showcontrols="True" showstatusbar="True" showdisplay="False" autorewind="True"></embed></object>';
}
function createMarker(lat,lng,letter,toolTip)
 {
    var baseIcon = new GIcon();
    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);
    baseIcon.infoShadowAnchor = new GPoint(18, 25);
    var icon = new GIcon(baseIcon)
    icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
    var point = new GLatLng(lat,lng);
    var marker = new PdMarker(point,icon);
    var loc = '#' + letter;
    if(toolTip != '')
    GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(toolTip);});
    GEvent.addListener(marker, "click", function() {document.location.href=loc;});
    return marker;
 }
 function openWindow(url, height, width) 
		{
		var theURL = url;
		var window_top = (screen.height-height)/2;
		var window_left = (screen.width-width)/2;
		var newfeatures= 'scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no width=' + width + ',height=' + height + ',top=' + window_top + ',left=' + window_left;
		var newWindow=window.open(theURL,'Popup',newfeatures);
		newWindow.focus();
		}
 function openNewWindow(url, height, width) 
		{
		var theURL = url;
		var window_top = (screen.height-height)/2;
		var window_left = (screen.width-width)/2;
		var newfeatures= 'scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no width=' + width + ',height=' + height + ',top=' + window_top + ',left=' + window_left;
		var newWindow=window.open(theURL,'_blank',newfeatures);
		newWindow.focus();
		}
function openDialog(url, height, width)
{
		var theURL = url;
		var window_top = (screen.height-height)/2;
		var window_left = (screen.width-width)/2;
		var newfeatures= 'dialogWidth:' + width + ',dialogHeight:' + height + ',dialogTop"' + window_top + ',dialogLeft:' + window_left;
		window.showModalDialog(theURL,'',newfeatures);
}
function openSearch(url,ControlId)
{
  var d = document.getElementById(ControlId);
  if(d.value != '')
    openWindow(url + escape(d.value),600,400);
}
function saveClick()
		{
		__doPostBack('Save','');
		}
function launchwin(winurl)
	{
		var window_width = 840;
		var window_height = 640;
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
		var newfeatures= 'scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left;
		var newWindow=window.open(winurl,'Popup',newfeatures);
		newWindow.focus();
	}


function getElementbyClass(rootobj, classname)
{
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++)
{
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec)
{
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc])
{
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit)
{
var inc=0
while (ccollect[inc])
{
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid)
{
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0)
{
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0)
{ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent()
{
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus()
{
var inc=0
while (statecollect[inc])
{
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) 
{ 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) 
{
offset = document.cookie.indexOf(search)
if (offset != -1) 
{ 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem()
{
if (get_cookie(window.location.pathname) != "")
{
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate()
{
var inc=0, selectedItem=""
while (ccollect[inc])
{
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}
document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload()
{
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0)
{
    document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
    firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
    if (!firsttimeload)     
        revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

function OpenRoomTypePage()
{
    var r = document.getElementById("ctl00_MainContent_TypeList");
    window.location.href="VRD.aspx?Type=" + r.options[r.selectedIndex].value
}
function checkForCookies()
{
	// CHECK IF COOKIES ARE ENABLED 
	
	var exp = new Date(); 
 	exp.setTime(exp.getTime() + 1800000); 
 
	// first write a test cookie 
 
 	setCookie("cookies", "cookies", exp, false, false, false); 
 	if (document.cookie.indexOf('cookies') == -1) { 
 		alert('Your browser does not have cookies enabled.  Certain features on this site require cookies.  Please enable cookies in your browser preferences before continuing.'); 
 	}
 
 	// now delete the test cookie 

	exp = new Date(); 
  	exp.setTime(exp.getTime() - 1800000); 
  	setCookie("cookies", "cookies", exp, false, false, false); 
}
	function setCookie(name, value, expires, path, domain, secure) { 
		var curCookie = name + "=" + escape(value) + 
		((expires) ? "; expires=" + expires.toGMTString() : "") + 
		((path) ? "; path=" + path : "") + 
		((domain) ? "; domain=" + domain : "") + 
		((secure) ? "; secure" : ""); 
		document.cookie = curCookie; 
} 		
		
