// JavaScript Document
/** Returns the value of the cookie given in 'name'   **/
/** If the cookie value doesn't exist, 0 is returned. **/
function readCookie(name){
	var nameEQ = name + "="; 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 '0';
}

var randNum=new Date().getTime();

function showHomepagePopUp(windowsource,windowname,width,height,scrollbars,directories,location,menubar,status,toolbar,resizable,cookieLabel){
	var theLabel=cookieLabel+'=true';
  var date = new Date();
	date.setTime(date.getTime()+(24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
  var path = "; path=/";
  if (document.cookie.indexOf(cookieLabel)==-1){
      RenderPopup(windowsource,windowname,width,height,scrollbars,directories,location,menubar,status,toolbar,resizable);
      document.cookie=theLabel+expires+path;
  }
}

function RTeCollector(strParam) {
	intHeight = 460;
	intWidth  = 640;
	intTop=(screen.height/2)-(intHeight/2)
	intLeft=(screen.width/2)-(intWidth/2)
	strFeatures='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height='+intHeight+',width='+intWidth+',top='+intTop+',left='+intLeft;
	winEcollector=window.open('http://ecollector.responsetek.com/eCollector.asp?' + strParam, 'eCollector', strFeatures);
}
function sTime(){
	document.getElementById('holding_message').style.display='block';document.getElementById('master').style.display='none';	
}
function eTime(){
	var elapsedTime = new Date(endTime-startTime);
	document.write('<span class=t1>'+elapsedTime.getSeconds()+'</span>');	
	document.getElementById('holding_message').style.display='none';document.getElementById('master').style.display='block';	
}
function RenderPopup(windowsource,windowname,width,height,scrollbars,directories,location,menubar,status,toolbar,resizable) {
	var windowfeatures = 'width=' + width +
	',height=' + height + ',directories=' + directories +
	',location=' + location + ',menubar=' + menubar +
	',scrollbars=' + scrollbars + ',status=' + status +
	',toolbar=' + toolbar + ',resizable=' + resizable;
	window.open(windowsource, windowname, windowfeatures);
}

isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

var gSafeOnload = new Array();
function SafeAddOnload(f){
  if (IEmac && IE4)	{window.onload = SafeOnload;gSafeOnload[gSafeOnload.length] = f;}
	else if (window.onload){
		if (window.onload != SafeOnload){gSafeOnload[0] = window.onload;window.onload = SafeOnload;}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else window.onload = f;
}
function SafeOnload(){for (var i=0;i<gSafeOnload.length;i++) gSafeOnload[i]();}

// shows or hides layer. layer in question is specified by <lyrName>. Shows layer if <show> is true, hides if false
function LMN_showhidelayer(lyrName, show) {
	if(document.layers)	document.layers[lyrName].display = show ? "block" : "none";
	else if(document.getElementById) {var obj = document.getElementById(lyrName);obj.style.display = show ? "block" : "none";}
	else if(document.all) document.all[lyrName].style.display = show ? "block" : "none";
}
// pops open a little window for users that cannot view the
// Opening times and Call oost layers
function LMN_popuplayeralt(url,obj) {window.open(url,'mastheadpop','width=130,height=130');obj.href = '';return false;}

function isValidEmail(emailAddress)
{   
   var atIndex     = emailAddress.indexOf('@')
   var dotIndex    = emailAddress.indexOf('.',atIndex)
   // check 0 < atIndex < dotindex < length
   if( (0 < atIndex) && (atIndex < dotIndex) && (dotIndex < emailAddress.length-1) )
   { 
           // first character is a letter and all other are not whitespace
      var firstChar = emailAddress.charAt(0)
      
      if( (firstChar>='a' && firstChar<='z') ||  
          (firstChar>='A' && firstChar<='Z') ||
          (firstChar>='0' && firstChar<='9') )
      { 
         for(var i=1;i<emailAddress.length;++i){
            if(emailAddress.charCodeAt(i) <= 0x20){
               if(emailAddress.charAt(i) == ' ')
                  alert("There are no spaces allowed in your email address")
               else 
                  alert("The character \"" + emailAddress.charAt(i) + "\" is not allowed in your email address")
               return false;
            }    
         }
         return true;
          
      }
      alert("The first character in your email address, \"" + firstChar + "\" is not allowed")
   }
   alert("Please enter a full email address")
   return false;
}