// JavaScript Document

function GGGValidator()
{
	//FirstName
	if("First Name"==document.form.FirstName.value)
		{
			document.form.FirstName.value='';
			document.form.FirstName.focus();
			return false;
		}
	//LastName
	if("Last Name"==document.form.LastName.value)
		{
			document.form.LastName.value='';
			document.form.LastName.focus();
			return false;
		}
	//Phone
	if("Phone"==document.form.Phone.value)
		{
			document.form.Phone.value='';
			document.form.Phone.focus();
			return false;
		}
	//Email
	if("Email"==document.form.EMAIL.value)
		{
			document.form.EMAIL.value='';
			document.form.EMAIL.focus();
			return false;
		}
	//Company
	if("Company"==document.form.Company.value)
		{
			document.form.Company.focus();
			return false;
		}
	//Country
	if(""==document.form.Country.value)
		{
			document.form.Country.focus();
			return false;
		}
}

function Oreo()
	{
		GGGWhere('UVTripPlanner Request Information','Form_UVTPRequestInfo');
		GGGValidator();
		GGGEmailValidator();
		
		cookiejar.crumble ('uwadcrtrac');
		
		var firstname=document.form.FirstName.value;
		var lastname=document.form.LastName.value;
		var title=document.form.Title.value;
		var phone=document.form.Phone.value;
		var email=document.form.EMAIL.value;
		var company=document.form.Company.value;
		var country=document.form.Country.value;
		var refform='UVTPRI';
		
		for (loopy=0;loopy<document.form.UniversalClient.length;loopy++)
			{
				if (document.form.UniversalClient[loopy].checked)
					{
						var uwac = document.form.UniversalClient[loopy].value;
					}
			}
			
		for (loopy=0;loopy<document.form.UVTPInterestedInOrdering.length;loopy++)
			{
				if (document.form.UVTPInterestedInOrdering[loopy].checked)
					{
						var tporder = document.form.UVTPInterestedInOrdering[loopy].value;
					}
			}
			
		for (loopy=0;loopy<document.form.UVTPInterestedLicensingData.length;loopy++)
			{
				if (document.form.UVTPInterestedLicensingData[loopy].checked)
					{
						var tpdata = document.form.UVTPInterestedLicensingData[loopy].value;
					}
			}
		for (loopy=0;loopy<document.form.UVTPInterestedAdvertising.length;loopy++)
			{
				if (document.form.UVTPInterestedAdvertising[loopy].checked)
					{
						var tpadv = document.form.UVTPInterestedAdvertising[loopy].value;
					}
			}
			
		var comm=document.form.Comments.value;
		
		subcookiejar.bake ('uwadcrtrac',
			{
			   firstname: firstname,
			   lastname: lastname,
			   title: title,
			   phone: phone,
			   email: email,
			   company: company,
			   country: country,
			   refform: refform,
			   uwac: uwac,
			   tporder: tporder,
			   tpdata: tpdata,
			   tpadv: tpadv,
			   comm: comm
			}, 1);
	}
	
function echeck(str)
	{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1)
			{
			   alert("Invalid e-mail format.");
			   return false;
			}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
			{
				alert("Invalid e-mail format.");
				return false;
			}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
			{
				alert("Invalid e-mail format.");
				return false;
			}
			
		if (str.indexOf(at,(lat+1))!=-1)
			{
				alert("Invalid e-mail format.");
				return false;
			}
			
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
			{
				alert("Invalid e-mail format.");
				return false;
			}

		 if (str.indexOf(dot,(lat+2))==-1)
		 	{
				alert("Invalid e-mail format.");
				return false;
			}
		
		 if (str.indexOf(" ")!=-1)
		 	{
				alert("Invalid e-mail format.");
				return false;
			}

 		 return true;					
	}


function GGGEmailValidator()
	{
		if ((document.form.EMAIL.value==null)||(document.form.EMAIL.value==""))
		{
			alert("Invalid e-mail format.");
			document.form.EMAIL.value='';
			document.form.EMAIL.focus();
			return false;
		}
		
		if (echeck(document.form.EMAIL.value)==false)
		{
			document.form.EMAIL.value='';
			document.form.EMAIL.focus();
			return false;
		}
		return true;
	}

function GGGWhere(FormName,FieldName)
	{
		var whereami=window.location;
		var elementname=FieldName;
		document.form.Form_LastReferenceURL.value=whereami;
		document.form.Form_LastSource.value=FormName;
		document.form.elements[elementname].value='Yes';
	}
