var rootPath = "http://www.pisec-world.com/"; //live site
var thisLocation = parent.location.host;

if (thisLocation == "uk405") //live site
	rootPath = "http://uk405/pisec/version4/public/";

else 
	if (thisLocation == ("webdev.martex.uk.com")) //webdev site
		rootPath = "http://webdev.martex.uk.com/pisec/version4/public/";
	
else
	if (thisLocation == ("intranet.uk.tarsus.plc")) //intranet site
		rootPath = "http://intranet.uk.tarsus.plc/pisec/version4/public/";
	
else
	if (thisLocation == ("www.pisec-europe.com")) //intranet site
		rootPath = "http://www.pisec-europe.com/";

var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
				&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
				&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var styleCode = '';
//if (is_nav)
//	{
//	var styleCode = '<link href="scripts/publish/show_nav.css" rel="stylesheet" type="text/css">';
//	}

function ValidateComplete(formObj)
{
	if (isEmail(formObj.emailBox) == false)
		alert("If you wish to be contacted by email, you must enter a valid email address")
	else return true;
	
	return false;
}

function emptyField(textObj)
	{
	if (textObj.value.length == 0)
          return true;

	for (var i=0; i<textObj.value.length; ++i)
		{
	  var ch = textObj.value.charAt(i);
	    if (ch != ' ' && ch != '\t')
              return false;
		}
	return true;
	}

function isEmail(elm) {
    if (elm.value.indexOf("@") + "" != "-1" &&
        elm.value.indexOf(".") + "" != "-1" &&
        elm.value != "")
    return true;
    else return false;
}

function validateEmailUpdates(formObj)
	{
	if (isEmail(formObj.email) == false)
		{
		alert("You must supply a valid email address to register for email updates");
		formObj.email.select();
		formObj.email.className = 'lightr_error';
		}
	else
		formObj.submit();
	
	return false;
	}

function validateSendToAFriend(formObj)
	{
	formObj.nameFrom.className = 'light';
	formObj.emailFrom.className = 'light';
	formObj.emailTo.className = 'light';

	if (emptyField(formObj.nameFrom))
		{
		alert("You must supply Your name to send this site link to a friend");
		formObj.nameFrom.focus();
		formObj.nameFrom.className = 'light_error';
		}
	else if (isEmail(formObj.emailFrom) == false)
		{
		alert("Your must supply a valid email address to send this site link to a friend");
		formObj.emailFrom.select();
		formObj.emailFrom.className = 'light_error';
		}
	else if (isEmail(formObj.emailTo) == false)
		{
		alert("You must supply a valid Friend's email address to send this site link to a friend");
		formObj.emailTo.select();
		formObj.emailTo.className = 'light_error';
		}
	else
		formObj.submit();
	
	return false;
	}

function ValidateReg(formObj)
	{
	if (emptyField(formObj.First_Name))
		{
		alert("'Name' is a required field");
		formObj.First_Name.focus();
		}
		
	else
		if (emptyField(formObj.Surname))
			{
			alert("'Surname' is a required field");
			formObj.Surname.focus();
			}
		
	else
		if (emptyField(formObj.Company_Name))
			{
			alert("'Company Name' is a required field");
			formObj.Company_Name.focus();
			}
		
	else
		if (emptyField(formObj.Address1))
			{
			alert("'Address 1' is a required field");
			formObj.Address1.focus();
			}
		
	else
		if (emptyField(formObj.Country))
			{
			alert("'Country' is a required field");
			formObj.Country.focus();
			}
		
	else
		if (emptyField(formObj.Email_Address))
			{
			alert("'Email' is a required field");
			formObj.Email_Address.focus();
			}

	else
		if (isEmail(formObj.Email_Address) == false)
			{
			alert("If you wish to be contacted by email, you must enter a valid email address");
			formObj.Email_Address.focus();
			}

	else
		formObj.submit();

	return false;
	}

function forceChecks(formObj)
	{
	if (!(formObj.Info_On[0].checked) && !(formObj.Info_On[1].checked))
		{
		formObj.Info_On[0].checked = true;
		}
	}

function bgIn(field)
	{
	field.className = 'dark_on';
	}

function bgOut(field)
	{
	field.className = 'dark';
	}
	
function popUp(url,status,tools,w,h)
	{
	var status = status||0;
	var toolbar = tools||0;
	var location = tools||0;
	var menubar = tools||0;
	var width = w||550;
	var height = h||400;
	
	var popup = window.open(url,'popupwin','width='+width+',height='+height+',toolbar=' + toolbar + ',status=' + status + ',location=' + location + ',menubar=' + menubar + ',scrollbars=yes');
	popup.focus();
	}