function notYet()
{
	alert("Sorry this item is not available yet")
}

function printThis()
{
if (window.print != null) 
{ window.print(); }
 else
 { alert('Unfortunately, your browser does not support this shortcut. Please select Print from the File menu.'); }
}

function checkDataEntry(obj)
{
	var mycode
	var count=0;
	if(obj.length!=0)
	{
		for(i=0; i<obj.length; i++)
		{
			mycode = obj.charCodeAt(i);
			if((mycode>47 && mycode<58) || (mycode>64 && mycode<91) || (mycode>96 && mycode<123) || (mycode>3584 && mycode<3631) || (mycode>3647 && mycode<3653))
			{
				count=count+1;
			}
		}
	}
	return count;
}

function checkEmailValid(emailStr,msg)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var errMsg="";   
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) 
	{
	   errMsg=errMsg+msg+" Email Address seems incorrect";
	   return errMsg;
	}
	else
	{
	  var user=matchArray[1]
	  var domain=matchArray[2]
	  if (user.match(userPat)==null) 
	  {
		errMsg=errMsg+msg+" Email Address seems incorrect";
		return errMsg;       
	  }
	  var IPArray=domain.match(ipDomainPat)
	  if (IPArray!=null) 
	  {
		  for (var i=1;i<=4;i++) 
			  {
			if (IPArray[i]>255) 
				{
				errMsg=errMsg+msg+" Email Address seems incorrect";
				return errMsg;
				}//IF
			  }//for
	   }//IP Array
	   var domainArray=domain.match(domainPat)
	   if (domainArray==null) 
	   {
		 errMsg=errMsg+msg+" Email Address seems incorrect";
		 return errMsg;
	   }
	   var atomPat=new RegExp(atom,"g")
	   var domArr=domain.match(atomPat)
	   var len=domArr.length
	   if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
	   {
		 errMsg=errMsg+msg+" Email Address seems incorrect";
		 return errMsg;	
	   } 
	   if (len<2) 
	   {
		 errMsg=errMsg+msg+" Email Address seems incorrect";
		 return errMsg;	 
	   } 
	 }//End  Match
	return "0";
}

function checkContactForm()
{
	var param="";
	var newcn="";
	var newe="";
	var newpn="";
	var newmsg="";

	var cn=document.frmData.strContactName.value;
	var pn=document.frmData.strTelephone.value;
	var msg=document.frmData.strMessage.value;
	var e=document.frmData.strEmail.value;
	
	//check required fields first
	if(checkDataEntry(cn)==0)
	{
		alert("Please enter your Contact Name");
		return false;
	}
	else
	{
		var i=0;
		var mycode=0;
		var myChar;

		for(i=0; i<cn.length; i++)
		{
			mycode = cn.charCodeAt(i);
			if(mycode==38)
			{
				myChar="(amp)";
			}
			else if(mycode==35)
			{
				myChar="(hash)";
			}
			else if(mycode==37)
			{
				myChar="(percentage)";
			}
			else if(mycode==43)
			{
				myChar="(plus)";
			}
			else
			{
				myChar=cn.substr(i,1);
			}
			newcn=newcn+myChar;
		}
		param="?cn="+newcn;
	}

	if(checkDataEntry(e)==0)
	{
		alert("Please enter your Email Address");
		return false;
	}
	else
	{
		if (checkEmailValid(e)!="0") 
		{
			alert(checkEmailValid(e,'Your'));
			return false;	
		}
		else
		{
			var i=0;
			var mycode=0;
			var myChar;
	
			for(i=0; i<e.length; i++)
			{
				mycode = e.charCodeAt(i);
				if(mycode==38)
				{
					myChar="(amp)";
				}
				else if(mycode==35)
				{
					myChar="(hash)";
				}
				else if(mycode==37)
				{
					myChar="(percentage)";
				}
				else if(mycode==43)
				{
					myChar="(plus)";
				}
				else
				{
					myChar=e.substr(i,1);
				}
				newe=newe+myChar;
			}
			param=param+"&e="+newe;
		}
	}
	
	if(checkDataEntry(pn)!=0)
	{
		var i=0;
		var mycode=0;
		var myChar;

		for(i=0; i<pn.length; i++)
		{
			mycode = pn.charCodeAt(i);
			if(mycode==38)
			{
				myChar="(amp)";
			}
			else if(mycode==35)
			{
				myChar="(hash)";
			}
			else if(mycode==37)
			{
				myChar="(percentage)";
			}
			else if(mycode==43)
			{
				myChar="(plus)";
			}
			else
			{
				myChar=pn.substr(i,1);
			}
			newpn=newpn+myChar;
		}
		param=param+"&pn="+newpn;
	}

	if(checkDataEntry(msg)==0)
	{
		alert("Please enter your Message");
		return false;
	}
	else
	{
		var i=0;
		var mycode=0;
		var myChar;

		for(i=0; i<msg.length; i++)
		{
			mycode = msg.charCodeAt(i);
			if(mycode==38)
			{
				myChar="(amp)";
			}
			else if(mycode==35)
			{
				myChar="(hash)";
			}
			else if(mycode==37)
			{
				myChar="(percentage)";
			}
			else if(mycode==43)
			{
				myChar="(plus)";
			}
			else if(mycode==13)
			{
				myChar="";
			}
			else if(mycode==10)
			{
				myChar="<br />";
			}
			else
			{
				myChar=msg.substr(i,1);
			}
			newmsg=newmsg+myChar;
		}
		param=param+"&msg="+newmsg;
	}
	
	//if we got here then all data is valid
	
	var objTemp= document.getElementById("contactright");
	
	objTemp.innerHTML="<p><img src='images/lightgrayindicator.gif' align='absmiddle' />&nbsp;Processing your request...</p>";
	var doc = null; 
 
	// Make a new XMLHttp object
	if (typeof window.ActiveXObject != 'undefined' ) 
   { 
	   doc = new ActiveXObject("Microsoft.XMLHTTP"); 
   } 
   else 
   { 
	   doc = new XMLHttpRequest(); 
	
   } 
  
	doc.onreadystatechange = handleStateChange;  
	  
	// Load the result from the response page
	// Note the response page can be any page that returns the right result. 
	// I used ASP. PHP, PERL... etc could acheive the same result
	 
	// ** As far a I know firefox will only load a document on the SAME domain!!
	doc.open("GET", "processcontact.php"+param, true);
	doc.send(null);
	
	function handleStateChange()
	{        
		if (doc.readyState == 4)
		{
			objTemp.innerHTML=doc.responseText;
			//needs a return false to make it work for safari
			return false;
		}
	}	
}

function showMap()
{
	if(document.getElementById("startmap").style.display=="")
	{
		document.getElementById("startmap").style.display="none";
		document.getElementById("mapprint").style.display="";
		document.getElementById("linkTxt").innerHTML="<a href='JavaScript:showMap()' class='textlink' title=' Click here for the Color Version '>Color Map</a> | <a href='JavaScript:printThis()' class='textlink' title=' Click here to print '>Print</a>";
	}
	else
	{
		document.getElementById("startmap").style.display="";
		document.getElementById("mapprint").style.display="none";
		document.getElementById("linkTxt").innerHTML="<a href='JavaScript:showMap()' class='textlink' title=' Click here for the Printer Friendly Version '>Printer Friendly Version</a>";
	}
}

function setCookie()
{
	document.cookie="subopened|tabopened";
}

function setTabMenu()
{
	if(document.cookie.indexOf("subopened")!=-1)
	{
		document.cookie="tabopened";
	}
	else if((document.cookie.indexOf("mainopened")!=-1) || (document.cookie.indexOf("tabopened")!=-1))
	{
		document.cookie="tabclosed";
	}
}

function signInButtton()
{
	var un=document.frmData.strUsername.value;
	var pwd=document.frmData.strPassword.value;
	
	if(checkDataEntry(un)==0)
	{
		alert("Please enter your username");
		return false;
	}
	
	if(checkDataEntry(pwd)==0)
	{
		alert("Please enter your password");
		return false;
	}

	var sector=document.getElementById("errDiv");
	sector.innerHTML="<span class='graytext'><img src='images/lightgrayindicator.gif' align='absmiddle' /> Signing In...</span>";
	var doc = null; 
 
	// Make a new XMLHttp object
	 if (typeof window.ActiveXObject!='undefined' ) 
	{ 
	   doc = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	else 
	{ 
	   doc = new XMLHttpRequest(); 
	//doc.setRequestHeader 'Content-Type', 'text/xml';
	} 
	doc.onreadystatechange = handleStateChange;  
	  
	// Load the result from the response page
	// Note the response page can be any page that returns the right result. 
	// I used ASP. PHP, PERL... etc could acheive the same result
	 
	// ** As far a I know firefox will only load a document on the SAME domain!!
	//doc.setRequestHeader "Content-Type", "text/xml"
	doc.open("GET", "processsignin.php", true);
	doc.send(null);
	//destination.innerHTML = doc.responseText;
	
	function handleStateChange()
	{        
		if (doc.readyState==4)
		{
			sector.innerHTML=doc.responseText;
		}
	}
}

function goLanguage()
{
	var newLoc=document.getElementById("langswap").innerHTML;
	document.location.href=newLoc;
}

function resetClass(clsname)
{
	document.getElementById("lang").style.className=clsname;
}