function openTerms()
{
	newwin = window.open("/terms.aspx","terms","width=405,height=400,scrollbars=yes");
}

function openPrivacy()
{
	newwin = window.open("/privacy.aspx","privacy","width=405,height=400,scrollbars=yes");
}

function navOver(imgName)
{
	var theImage = document.getElementById(imgName);
	
	if(theImage.src.indexOf("_off.gif") != -1)
	{
		theImage.src = theImage.src.replace("_off.gif","_over.gif");
	}
	
	else
	{
		theImage.src = theImage.src.replace("_over.gif","_off.gif");
	}
}

function getWindowWidth() 
{
	var windowWidth = 0;
	
	if (typeof(window.innerWidth) == 'number') 
	{		
		windowWidth = window.innerWidth;				
		
		theDiv = document.getElementById("mainContainer");
		theWidth = theDiv.offsetLeft * 2 + theDiv.offsetWidth;

		if(window.innerWidth > theWidth)
		{
		  windowWidth = theWidth;
		}  
	}
	else 
	{
		if (document.documentElement && document.documentElement.clientWidth) 
		{		
			windowWidth = document.documentElement.clientWidth;
		}
		
		else 
		{
			if (document.body && document.body.clientWidth) 
			{
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}


function displayMenu(menuId)
{
	document.getElementById(menuId).style.visibility = "visible";
}

function hideMenu(menuId)
{
	document.getElementById(menuId).style.visibility = "hidden";
}

function positionMenus()
{		
	// var browserHeight = (navigator.appName.indexOf("Microsoft")!=-1) ? document.body.clientHeight : window.innerHeight;
 	// var browserWidth = (navigator.appName.indexOf("Microsoft")!=-1) ? document.body.clientWidth : window.innerWidth;
	
	var windowWidth = getWindowWidth();
	navLeft = (windowWidth - 926) / 2;	
	
	if (navigator.appName.indexOf('Netscape') != -1)
	{		
		document.getElementById("module_difference").style.left = (navLeft + 278) + "px";
		document.getElementById("module_whatsInside").style.left = (navLeft + 279) + "px";		
		document.getElementById("module_whatsImportant").style.left = (navLeft + 279) + "px";				
	}
	else
	{
		if(navigator.userAgent.indexOf('MSIE 6') == -1)				
		{
			document.getElementById("module_difference").style.left = (navLeft + 278) + "px";
			document.getElementById("module_whatsInside").style.left = (navLeft + 279) + "px";		
			document.getElementById("module_whatsImportant").style.left = (navLeft + 279) + "px";						
		}
		else
		{			
			document.getElementById("module_difference").style.left = (navLeft + 276) + "px";
			document.getElementById("module_whatsInside").style.left = (navLeft + 277) + "px";
			document.getElementById("module_whatsImportant").style.left = (navLeft + 277) + "px";
		}
	}	
}

function validateForm(theForm)
{
	
	valid = true;
	message = "Please enter the following sections before proceeding:\n\n";
	
	if(theForm.elements["firstname"].value == "")
	{
		message += "Your first name\n";
		valid = false;
	}
	
	if(theForm.elements["surname"].value == "")
	{
		message += "Your surname\n";
		valid = false;
	}

	if(theForm.elements["email"].value == "")
	{
		message += "Your email address\n";
		valid = false;
	}
	
	
	if(theForm.elements["email"].value != "")	
	{	
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "Valid email address\n";
			valid = false;
		}
	}	
	
	if(valid)
	{			
		return true;
	}
	else
	{		
		alert(message);
		return false;
	}		
}

function validateEnquiry(theForm)
{
	
	valid = true;
	message = "Please enter the following sections before proceeding:\n\n";
	
	if(theForm.elements["firstname"].value == "")
	{
		message += "Your first name\n";
		valid = false;
	}
	
	if(theForm.elements["surname"].value == "")
	{
		message += "Your surname\n";
		valid = false;
	}
	
	if(theForm.elements["property"].value == "")
	{
		message += "Your property name\n";
		valid = false;
	}

	if(theForm.elements["suburb"].value == "")
	{
		message += "Your town/suburb\n";
		valid = false
	}

	if(theForm.elements["telephone"].value == "")
	{
		message += "Your telephone number\n";
		valid = false
	}
		
	if(theForm.elements["email"].value == "")
	{
		message += "Your email address\n";
		valid = false
	}
			
	if(theForm.elements["email"].value!= "")
	{
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "Valid email address\n";
			valid = false;
		}
	}	
			
	if(valid)
	{			
		return true;
	}
	else
	{		
		alert(message);
		return false;
	}		
}

function changeBorder(id)
{		
	document.getElementById(id).style.borderColor = "#000000";											
}
function resetBorder(id)
{		
	document.getElementById(id).style.borderColor = "#cccccc";									
}	

function callSiFR()
{
	if(typeof sIFR == 'function')
	{			
		sIFR.replaceElement('h2', named({sFlashSrc: '/flash/myriadpro.swf',sColor: '#003b81' ,sLinkColor:"#999999",sHoverColor:"333333",sBgColor: '#ffffff', sWmode:'transparent'}));		
		sIFR.replaceElement('h3', named({sFlashSrc: '/flash/handwriting.swf',sColor: '#b587ab' ,sLinkColor:"#999999",sHoverColor:"333333",sBgColor: '#ffffff',sFlashVars: 'textalign=right', sWmode:'transparent'}));		
		/*
		sIFR.replaceElement('h2', named({sFlashSrc: 'sifr.swf',sColor: '#4a3929' ,sLinkColor:"#999999",sHoverColor:"333333",sBgColor: '#ffffff',sFlashVars: 'textalign=center', sWmode:'transparent'}));				
		sIFR.replaceElement('h3', named({sFlashSrc: 'sifr.swf',sColor: '#d66e7d' ,sLinkColor:"#999999",sHoverColor:"333333",sBgColor: '#ffffff', sWmode:'transparent'}));		
		sIFR.replaceElement('h4', named({sFlashSrc: 'sifr.swf',sColor: '#4a3828' ,sLinkColor:"#999999",sHoverColor:"333333",sBgColor: '#ffffff',sFlashVars: 'textalign=center', sWmode:'transparent'}));		
		*/
	}
}		
	
