 /*
	Application:	General browser detection Javascripts to be used throughout a page
	Description:	various scripts
	Date:			8/29/2001 1:56:25 PM
	Version:		1.0
	Last Change:	8/29/2001 1:56:25 PM
*/

var SessionDialogBox='';

baseHref = "http://event.expobook.com/"     
if(window.location.protocol=='https:')
{
	baseHref="https://event.expobook.com/"    
} 

// this sets the available shockwave object for use with Flash throughout the page.
//
	if (navigator.mimeTypes["application/x-shockwave-flash"]) 
  	{var shockObj = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin}
	else
  	{var shockObj = navigator.mimeTypes["application/x-shockwave-flash"]}

// define the current browser
//
	NN4 = ((parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<5)&&(navigator.appName.indexOf("Netscape")!=-1))? 1:0;
	NN6 = ((parseInt(navigator.appVersion)>=5)&&(navigator.appName.indexOf("Netscape")!=-1))? 1:0;
	MS4 = ((parseInt(navigator.appVersion)>=4)&&(parseInt(navigator.appVersion)<5)&&(navigator.appName.indexOf("Microsoft")!=-1))? 1:0;
	CH4 = ((parseInt(navigator.appVersion)>=4) &&(navigator.userAgent.toLowerCase().indexOf("chrome")!=-1))? 1:0;
    OP10= ((parseInt(navigator.appVersion)>=9)&&(navigator.appName.toLowerCase().indexOf("opera")!=-1))? 1:0;    
    SF4=  ((parseInt(navigator.appVersion)>=4)&&(navigator.userAgent.toLowerCase().indexOf("safari")!=-1))? 1:0;    
    
// 1 - define the correct style sheet for browsers
// 2 - this clears out the wait message from the "processing state" from the command handler
//	
//	if ((navigator.appName == "Netscape") && (navigator.appVersion.substring(0,1)) < 5)
	if (navigator.appName == "Netscape")
  { 
    if( document.getElementById('waitMsg') != null ) { document.getElementById('waitMsg').style.display='none'; }
  }
	else
	{ 
    if( document.all["waitMsg"] != null ) { document.all['waitMsg'].style.display='none'; }
  }
  
  var calArray = new Array();
  var startarray = new Array();
  var endarray = new Array();
   
  function findPosX(a) {
    var curleft = 0;
	while(a) {
		tn=a.tagName.toUpperCase();
        var bAbsolute = false;
		if(tn == "DIV")
		{
		    if(a.style.position.toLowerCase() == 'relative')
		    {
		        a=a.offsetParent;
		        continue;
		    }
		    else if(a.style.position.toLowerCase() == 'absolute')
		    {
		       bAbsolute = true;
		    }
		    else 
		    {
		        if(a.currentStyle)
		        {
		            var elem = a.currentStyle["position"]
		            if(elem != null && elem.toLowerCase() == 'relative')
		            {
		                  a=a.offsetParent;
		                  continue;
		            }
		            else if(elem != null && elem.toLowerCase() == 'absolute' )
		                bAbsolute = true;
		        }
		        else
		        {
		            var elem = document.defaultView.getComputedStyle(a,null).getPropertyValue("position")
		            if(elem != null && (elem.toLowerCase() == 'relative' || elem.toLowerCase() == 'static'))
		            {
		                  a=a.offsetParent;
		                  continue;
		            }  
		            else if(elem != null && elem.toLowerCase() == 'absolute' )
		                 bAbsolute = true;
		        }
		     }
		    
		     
		}
		
		
        
        if(!bAbsolute)
        {
	        curleft+=a.offsetLeft;
	    }
		if (tn=="BODY") break;
    		a=a.offsetParent;
	}
	return curleft;
}

function CanProceedWithExclusiveHotelFind(findbuttonid,demogdropdownid)
{
    var demogdropdown = document.getElementById(demogdropdownid);
    var findbutton = document.getElementById(findbuttonid);
    if(findbutton)
    {
        var DemogError = document.getElementById('DemogSelectError');
        if(demogdropdown && demogdropdown.selectedIndex > 0 && demogdropdown.length > 1)
        {
            DemogError.style.display='none';
        }
        else
        {
            DemogError.style.display='';
            return false;
        }        
            
        return true;
    }
}

function validateChar(evt)
{
	evt = (evt) ? evt : event;
	var keycd = (evt.which) ? evt.which : evt.keyCode;

	if (keycd == 60 || keycd == 62) 
	{
		return false;
	}
	else if(keycd == 64  || keycd == 47  || keycd == 35  || keycd == 45  || keycd == 42) //if its @,-,#,/,* then do more inspection
	{
		if (!evt.target) 
            evt.target=evt.srcElement 
       var element = evt.target;
       var elemtype = evt.target.getAttribute('type');
       
       switch(elemtype.toLowerCase())
       {
             case 'textbox':
             case 'text':
             case 'textarea':
                var lastchar = element.value.charAt(element.value.length-1);
                //no two @@
                if(keycd == 64 && lastchar == '@')
                    return false;
                 else if(keycd == 45 && lastchar == '-') //no two --
                    return false;
                 else if(keycd == 35) //no #
                    return false;
                 else if(keycd == 42 && lastchar == '/') //no /*
                    return false;
                break;
             default:
                break;
        }     
	}
}

function findPosY(obj)
{
    var curtop = 0;var printstring = '';
    if (obj.offsetParent)
    { 
        while (obj.offsetParent) 
        {
            if(obj.style.position == null || (obj.style.position.toLowerCase() != 'relative')) 
                curtop += obj.offsetTop; obj = obj.offsetParent;	
        }
    } 
    else if (obj.y)	curtop += obj.y;
    return curtop;
}

function IsEnterKeyPressed(evt)
{
	evt = (evt) ? evt : event;
	var keycd = (evt.which) ? evt.which : evt.keyCode;
	if (keycd == 13) 
		return true;
	else
	    return false;
}

function checkemail2(email)
{
	var bOk;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if (filter.test(email))
	{
		bOk=true;
	}
	else
	{
	  bOk=false;
	}
	return (bOk);
}

function checkemail(email)
{
	if (document.layers||document.getElementById||document.all)
	{
 	  return checkemail2(email);
	}
	else
	{
		return true;
	}
}

function validateDropDown(oSrc,args)
{
    args.IsValid = (args.Value!= '-1');
}

function onAllHotelsSelected(selectList)
{
    if(selectList.selectedIndex == 0) 
    { 
        if(selectList.options[0].getAttribute('AllHotelsSel') == null || selectList.options[0].getAttribute('AllHotelsSel') == '0')
        {
            selectList.options[0].setAttribute('AllHotelsSel','1');
            for(i=1;i<selectList.options.length;++i) 
                  selectList.options[i].selected = true;  
        }
        else if(selectList.options[0].getAttribute('AllHotelsSel') == '1')
       {
           selectList.options[0].setAttribute('AllHotelsSel','0');
           selectList.options[0].selected = false;
       }
    } 
    else
        selectList.options[0].setAttribute('AllHotelsSel','0');
}

function CanProceedWithFind(findbuttonid,dropdownid,demogdropdownid)
{
    var hoteldropdown = document.getElementById(dropdownid);
    var demogdropdown = document.getElementById(demogdropdownid);
    var findbutton = document.getElementById(findbuttonid);
    if(findbutton)
    {
        var DemogError = document.getElementById('DemogSelectError');
        if(demogdropdown && demogdropdown.selectedIndex > 0 && demogdropdown.length > 1)
        {
            DemogError.style.display='none';
        }
        else
        {
            DemogError.style.display='';
            return false;
        }

        var HotelListError = document.getElementById('HotelListError');
        //at lease one element selected, and at least there are two items in the dropdown list(a hotel and all hotels), then enable find..
        if(hoteldropdown && hoteldropdown.selectedIndex >= 0 && hoteldropdown.length > 1)
        {
           HotelListError.style.display='none';
           return true;
        }
        else
        {
            HotelListError.style.display='';
        }
            
        return false;
    }
}

function OnCallBackError(sender, eventArgs) 
{ 
    alert("\nPage did not load for the following reason(s):\n         * Back button was used\n         * Your session has expired\n         * The data did not complete loading\n\n      Click 'Ok' to return to the housing home page.");
    location.href = strIndexPagePath; 
}

function OnWindowLoad (func)
{
    if(window.addEventListener)
    {
        window.addEventListener('load', func, false);
    }
    else
    {
        window.attachEvent('onload', func);
    }
}
      
function OnSessionTimeout() 
{ 
   // if(SessionDialogBox!='')
   // {
      //  SessionDialogBox.show();
   // }
   // else
    //{
        alert("Your session has been timed out.\n\n      As a security precaution, sessions are ended after " + intMilliSecondsToSessionExpire/(60*1000) + " minutes of inactivity.\n\n      Click 'Ok' to return to the housing home page.\n\n");
        location.href = strLogOffPagePath; 
   //}
}

function OnSessionRedirect()
{
    location.href = strLogOffPagePath;
}
      
function OnUnloadBookingPage()
{

        alert("Please do not use the 'BACK' button on your browser when navigating through hotel booking process.\nThe tabs provided may be used to toggle between the account, room and confirm booking steps.\n\nIf you are in the middle of a transaction and use the 'BACK' button, the reservation may not process completely and could cause problems.\n\nThank you.");
}

try
{
  setTimeout('OnSessionTimeout();',intMilliSecondsToSessionExpire);
}
catch(e) {}

if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{ 
    //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
    var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ffversion < 1)
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
{ 
    //test for MSIE x.x;
    var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ieversion <=5 )
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
    //test for Chrome/x.x or Chrome x.x (ignoring remaining decimal places);    
    var chversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (chversion <=3 )
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{ 
    //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);    
    var oprversion=new Number(RegExp.$1); // capture x.x portion and store as a number
    if (oprversion <=9 )
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else if(/(\d+\.\d+\.\d+)[\s]Safari/.test(navigator.userAgent))
{        
    var IsiPad = navigator.userAgent.match(/iPad/i);

    var tempExp=RegExp(/(\d+\.\d+\.\d+)[\s]Safari/(navigator.userAgent));
    var tempNo=RegExp(/(\d+\.\d+)/(tempExp));
    
    //test for x.x.x Safari/ (ignoring remaining decimal places);    
    var sfversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (IsiPad == null && sfversion <=3 )
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else if(/(\d+\.\d+)[\s]Safari/.test(navigator.userAgent))
{        
    var IsiPad = navigator.userAgent.match(/iPad/i);

    var tempExp=RegExp(/(\d+\.\d+)[\s]Safari/(navigator.userAgent));
    var tempNo=RegExp(/(\d+\.\d+)/(tempExp));
    
    //test for x.x.x Safari/ (ignoring remaining decimal places);    
    var sfversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (IsiPad == null && sfversion <=3 )
        alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
}
else
    alert("Unsupported Browser\n\nIt appears that you are viewing this page with an unsupported Web browser. This Web site works best with one of these supported browsers:\n\n* Microsoft Internet Explorer 5.5 or higher\n* Mozilla Firefox 1.0 or higher\n* Google Chrome 4.0 or higher\n*Opera 10.0 or higher\n*Safari 4.0 or higher\n\nIf you continue to view our site with your current browser, certain pages may not display correctly and certain features may not work properly for you.");  
     