// JavaScript Document
function ContactICT()
{
	if (!ValidateContactForm())
		return false;
	
	return true;
}
function ValidateContactForm()
{
	// Turn off validation for development
	// return true;
	
	if (IsEmpty(document.ICT_contact.sName.value) || 
		IsEmpty(document.ICT_contact.sEmail.value) ||
		IsEmpty(document.ICT_contact.sDetails.value)
	)
	{
		alert("The name, email and details firled must all be completed before\n" +
			" submitting your request. Please complete the missing information and \n" +
			"submit the request again.");
		return false;
	}
	if (!IsValidEmail(document.ICT_contact.sEmail.value))
	{
		alert("The email address provided is not valid. Please provide a valid email address\n" +
			"and then submit the request again.");
		return false;
	}
	
	return true;
}

function ContactITD()
{
	if (!ValidateITDContactForm())
		return false;
	
	return true;
}
function ValidateITDContactForm()
{
	// Turn off validation for development
	// return true;
	
	if (IsEmpty(document.ITD_reno.sName.value) || 
		IsEmpty(document.ITD_reno.sEmail.value) ||
		IsEmpty(document.ITD_reno.sDetails.value)
	)
	{
		alert("The name, email and details firled must all be completed before\n" +
			" submitting your request. Please complete the missing information and \n" +
			"submit the request again.");
		return false;
	}
	if (!IsValidEmail(document.ITD_reno.sEmail.value))
	{
		alert("The email address provided is not valid. Please provide a valid email address\n" +
			"and then submit the request again.");
		return false;
	}
	
	return true;
}



function GetDomObj(name)	// Supports all browsers except for nested layers in Netscape 4
{
	if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}
function IsEmpty(sStr) {
	return (sStr.length < 1);
}
function IsValidEmail(sEmail)
{
	var sStr = new String(sEmail);
	var index1 = sStr.indexOf("@");
	if (index1 > 0)
	{
		var index2 = sStr.lastIndexOf(".");
		return ((index2 > index1 + 1) && (sStr.length > index2 + 1));
	}
	return false;
}

function CookieGet(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		// if cookie exists
		if (offset != -1) {
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function SessionIsFirstTime() {
	if (CookieGet("FirstTime") == "")
	{
		document.cookie = "FirstTime=false";
		return (CookieGet("FirstTime") != "");	// Handle failure to write cookie
	}
	else
	{
		return false;
	}
}

// Functions and code to handle flash fscommand() calls
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function Header_DoFSCommand(command, args) {
	var HeaderObj = InternetExplorer ? Header : document.Header;
	if (command == "FirstTime" && !SessionIsFirstTime()) {
		// Handle slow loading of SWF - GotoFrame stops at the last loaded frame
		window.document.Header.SetVariable("FirstTime", "no");
		window.document.Header.GotoFrame(14);
		window.document.Header.Play();
	}
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub Header_FSCommand(ByVal command, ByVal args)\n');
	document.write(' call Header_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}
