//  BEGIN TRAVELATRO SITE-SNIFFER
function getSiteName(){
var url = ""
url = "" + window.location
if(url.indexOf("stg.harborsideresort.svoreview.com")>0){
   s_server = "HRA_STAGE";
} else {
   s_server = "HRA";
} //end if
return s_server;
} //end function
// END TRAVELATRO SITE-SNIFFER



// BEGIN FORM VALIDATION

function notEmpty()
{
	var ok = true;
	var arg = notEmpty.arguments;
	
	// special processing to handle custom form (not forms[0])
	var formName = "forms[0]";
	var startIndex = 0;
	if (arg.length > 0 && arg[0] == "custom") {
		formName = arg[1];
		startIndex = 2;
	}
	
	for(i=startIndex; i<arg.length; i+=2)
	{
		var val= eval("document."+formName+"."+arg[i]+".value");
		if (trim(val)=="")
		{
			ok=false;
			alert(arg[i+1]);
			eval("document."+formName+"."+arg[i]+".focus();");
			break;
		}
	}

	
	return ok;
}

function checkEmailNoAlerts (emailStr)
{

	/* Check to see the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	var checkTLD=1;

	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

	/* The following pattern is used to check if the entered e-mail address
	fits the user@domain format.*/

	var emailPat=/^(.+)@(.+)$/;

	//Special chars:
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the user is a quoted string ->NO RULES!
	For instance, "alexthebest"@travelatro.com is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following applies for domains that are IP addresses,
	rather than symbolic names. Ex: alex@[123.124.233.4] is ok.*/

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in alex.it@travelatro.com, alex and it are words.*/


	var word="(" + atom + "|" + quotedUser + ")";


	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

		
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	//Validation:

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null)
	{

	//Address does not match the basic pattern.

		return false;
	}
	
	var user=matchArray[1];
	var domain=matchArray[2];


	for (i=0; i<user.length; i++) 
	{
	 	if (user.charCodeAt(i)>127)
		{
			return false;
		}
    }
	for (i=0; i<domain.length; i++)
	{
		if (domain.charCodeAt(i)>127)
		{
			return false;
		}
	}

	//Is user ok?
	if (user.match(userPat)==null)
	{

	// NO!
		return false;
	}

	//Is the ip address valid? (If used one)?

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
	{
		//yes.

		for (var i=1;i<=4;i++)
		{
		
			if (IPArray[i]>255) 
			{
				return false;
			}
		}
		return true;
	}

	// Domain NAME -is it ok?
	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
	{
		if (domArr[i].search(atomPat)==-1)
		{
			return false;
	   }
	}


	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].toLowerCase().search(knownDomsPat)==-1) 
	{
		return false;
	}

// Make sure there's a host name preceding the domain.

	if (len<2)
	{
		return false;
	}

	// If nothing happened so far, we are cool.
	return true;
}

function ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}

function trim ( s )
{
	return rtrim(ltrim(s));
}



// END FORM VALIDATION






 


