/* --- DO NOT EDIT --- */

var lastID = 0;
function SelectImg(hostedsitepath, imageName) {
	var imgMaxWidth = 250;
	var imgMaxHeight = 250;
	var imgName = document.getElementById('image')
	imgName.src = hostedsitepath + "product_images/info/" + imageName;
	imgName.name = imageName;

	imgName.removeAttribute('width');
	imgName.removeAttribute('height');
	var imgWidth = imgName.naturalWidth || imgName.width;
	var imgHeight = imgName.naturalHeight || imgName.height;

	if (imgWidth > imgMaxWidth)
	{
		imgName.width = imgMaxWidth;
		imgName.height = imgHeight;
	} else if (imgHeight > imgMaxHeight)
	{
		imgName.height = imgMaxHeight;
		imgName.width = imgWidth;
	} else {
		imgName.height = imgHeight;
		imgName.width = imgWidth;
	}
}


// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = false;

// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=auto,statusbar=0,toolbar=0,menubar=0,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(hostedsitepath, imageName,imageTitle,thumb){
	if (thumb) {
		imageURL = hostedsitepath + "product_images/" + imageName
	} else {
		imageURL = hostedsitepath + "product_images/" + document.getElementById('image').name
	}

	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;} img{ border: 0px solid black;} a {color: #000; font: 12px arial;}</style>');
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('	 if (isIE){');
		writeln('		width=document.images[0].width+40;');
		writeln('		height=100-(document.body.clientHeight-document.images[0].height)+50;');
		writeln('		if (height > 600) {');
		writeln('		window.resizeTo(width,600);');
		writeln('		} else {');
		writeln('		window.resizeTo(width,height);');
		writeln('		}}');
		writeln('	 if (isNN){');
		writeln('		width=document.images["img_imageToDisplay"].width+40;');
		writeln('		height=document.images["img_imageToDisplay"].height+40;');
		writeln('		if (height > 600)');
		writeln('		{');
		writeln('		window.innerWidth=width;');
		writeln('		window.innerHeight=600;');
		writeln('		} else {');
		writeln('		window.innerWidth=width;');
		writeln('		window.innerHeight=height;');
		writeln('		}');
		writeln('		}');
		writeln('}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('</sc'+'ript>');
		if (!AutoClose) 
			writeln('</head><body bgcolor="#FFFFFF" scroll="auto" onload="reSizeToImage();doTitle();self.focus()">')
		else 
			writeln('</head><body bgcolor="#FFFFFF" scroll="auto" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<CENTER><div id="largeImage"><a href="javascript:window.close();"><img name="img_imageToDisplay" src='+imageURL+' style="display:block"><BR />Close window</a></CENTER></body></html>');
		close();
	}
}
function SwitchMenu(obj){
	if(document.getElementById){
	var tab = document.getElementById("tabs").getElementsByTagName("a");
	var el = document.getElementById(obj);
	var ar = document.getElementById("cont").getElementsByTagName("DIV");
		if(ar[obj].style.display != "block") {
			if(el.style.display == "none"){
				for (var i=0; i<ar.length; i++){
					tab['menu_'+i].className = 'inactive';
					ar[i].style.display = "none";
				}
				tab['menu_'+obj].className = 'active';
				el.style.display = "block";
			}
		}
	}
}

function hideWarranty(t){
	el = document.getElementById(t);
	el.style.display="none";
}


function init() {
	centralise('main');
}

function focusForm(){
	if(!document.forms){
		return;
		}
		if(document.forms.length<1){
		return;
	}
	document.forms[0].elements[0].focus();
}

function message(message){
	alert(message);
}

function decision(message, url){
	if(confirm(message)) location.href = url;
}

function navigateTo(url){
	location.href = '/' + url
}
function navigateToAdmin(url){
	location.href = '/admin/' + url
}


function navigateToSecure(url){
	location.href = url
}


function colourChooser(div_id, colour, formName){
	var myElement = document.getElementById(div_id);
	var myElementText = document.getElementById('colourHex');
	myElementText.innerHTML = colour;
	myElement.style.backgroundColor = colour;
	eval("document." + formName+ ".hidden_colour.value = colour;");
}

function clearForm(formName){
	var element;
	var elementCount;
	eval("elementCount=" + formName + ".length;")
	for (var i = 0; i < elementCount; i++)
	{
		eval("element=" + formName + ".elements[i];")
		if (element.type == "text" || element.type == "textarea")
			{
			element.value='';
			}
		}
	}


function submitForm(formName,qString,actionURL,encType){
if (typeof(actionURL) != 'undefined')
	{
		eval("document." + formName + ".action = actionURL;")
	}
if (typeof(encType) != 'undefined')
	{
		eval("document." + formName + ".encoding = encType;")
	}
if (typeof(qString) == 'undefined')
	{
		eval("document." + formName+ ".submit();");
	}
else
	{
		eval("document." + formName + ".action = document." + formName + ".action + qString;")
		eval("document." + formName + ".submit();")
	}
}

function checkForm(formName,qString,actionURL,encType) {
	var boxesFound = 0;
	var boxesChecked = 0;
	var elementCount;
	var element;
	returnval=true;
	eval("elementCount=" + formName + ".length;")
	for (var j = 0; j < elementCount; j++)
	{
	eval("element=" + formName + ".elements[j];")
	indx = element.name.indexOf('_required');
	if (indx != -1)
	{
	fieldname=element.name.substring(0,indx);
	eval("element2=" + formName + ".elements[fieldname];")
	if (element2.value.length == 0)
	{
	alert(element.value);
	j = (elementCount);
	if (element2.type != "hidden")
	{
	element2.focus();
	}
	returnval = false;
	}
	}
	indx = element.name.indexOf('_checkbox');
	if (indx != -1)
	{
	boxesFound ++;
	if (element.checked)
	{
	boxesChecked ++;
	}
	}
	indx = element.name.indexOf('_number');
	if (indx != -1)
	{
	fieldname=element.name.substring(0,indx);
	eval("element2=" + formName + ".elements[fieldname];")
	if (isNaN(parseInt(element2.value))==true && element2.value.length!=0)
	{
	alert(element.value);
	j = (elementCount);
	if (element2.type != "hidden"){
	element2.focus();
	}
	returnval = false;
	}
}

function postcodeValidate(strFieldName) {
var strInput;
eval ('strInput=' + formName + '.' + strFieldName + '.value')
if (strInput=='') {
return (true);
}
var j;
var blnOutPre = (false);
var blnOutSuf = (false);
var strOutPrefix = '';
var strOutSuffix = '';
var strInDigit = '';
var strInChars ='';
var blnValid = (true);
strInput = toAlNum(strInput);
for (j=0;j<strInput.length;j++) {
if (blnOutPre==false) {
if (j==0 && isNaN(strInput.charAt(j))==false) {
blnValid = (false);
}
if (j>1 && isNaN(strInput.charAt(j))) {
blnValid = (false);
}
if (isNaN(strInput.charAt(j))==false) {
blnOutPre = (true);
} else {
strOutPrefix = strOutPrefix + strInput.charAt(j);
}
}
if (blnOutPre && blnOutSuf==false) {
if (strOutSuffix.length > 2) blnValid = (false);
if (j < (strInput.length - 3)) {
strOutSuffix = strOutSuffix + strInput.charAt(j);
} else {
blnOutSuf = (true);
}
}
if (blnOutSuf) {
if (isNaN(strInput.charAt(j)) && strInput.charAt(j).toUpperCase()!='O') blnValid = (false);
if(strInput.charAt(j).toUpperCase()=='O') {
strInDigit = '0';
} else {
strInDigit = strInput.charAt(j);
}
if (isNaN(strInput.charAt(j+1))==false || isNaN(strInput.charAt(j+2))==false) blnValid = (false);
strInChars = strInput.charAt(j+1) + strInput.charAt(j+2);
if (blnValid) {
return (true);
}
}
}
return (false);
}


indx = element.name.indexOf('_hex');
if (indx != -1)
{
fieldname=element.name.substring(0,indx);
eval("element2=" + formName + ".elements[fieldname];")
if (isHex(element2.value)==false && element2.value.length!=0)

{
alert(element.value);
j = (elementCount);
if (element2.type != "hidden"){
element2.focus();
}
returnval = false;
}
}

}

if (boxesFound > 0 && boxesChecked < 1)
{
alert('You must choose at least one Check Box.'); returnval = false;
} 

if (returnval == true)
{
	if(formName == 'enquiry_form')
		{
			if (document.enquiry_form.wacEmailCheck.value.toLowerCase() != document.enquiry_form.wacEmail.value.toLowerCase())
			{
		 		alert ( 'Your email addresses do no match. Please re-enter.' );
				returnval = false;
			}
		}
}

if (returnval == true)
{
submitForm(formName,qString,actionURL,encType);
indx = element.name.indexOf('submitButton');
if (indx != -1)
{
disableButton(formName);
}
}
}

function isHex(string){
	var hexchars = "0123456789ABCDEFabcdef";
	for (var i=0; i< string.length; i++){
		if (hexchars.indexOf(string.charAt(i)) == -1) {
			return false;
		}
	}
	return true;
}

function dom_check(){
	if (document.getElementById) 
	dom='yes'  
	//alert("DOM compliant!");
	else
	dom='no'
	location.href='non_dom.asp?usrID=E7E1F89A-B799-49BF-B712-E713293263DA';
}

function centralise(div_id) {
var innerWidth = window.innerWidth?1:0
var myElement = document.getElementById(div_id);

var box_left, box_top, schMarginHeight, schContentWidth, magic_offset, screen_width;

schContentWidth = 760; 
schMarginHeight = 8;

if(innerWidth==1) {
	screen_width = window.innerWidth
} else {
	screen_width = document.body.clientWidth
}

if ((screen_width)-(schMarginHeight*2)<=schContentWidth){
	box_left = schMarginHeight;
} else {
	box_left = (screen_width-schContentWidth)/2;
}

myElement.style.left = box_left + "px";
myElement.style.top = schMarginHeight + "px";
myElement.style.width = schContentWidth +"px";
}

function changecolor(div_id, action){
var myElement = document.getElementById(div_id);
	if (action=='nav_on'){
		myElement.style.backgroundColor = '#FFFFCC';
		myElement.style.color = '';
	} else {
		myElement.style.backgroundColor = '';
		myElement.style.color = '';
	}
}

function makevisible(div_id){
	var myElement = document.getElementById(div_id);
	myElement.style.visibility = 'visible';
}

function itemMouseOver(itemID, action) {
	for(i=0;i<array.length;i++) {
		if(array[i][0]==itemID) {
			if(array[i][2]!='') {
				changevisibility(action,array[i][2]);
			}
				if(array[i][1]!='idN0') {
				if(action=='hide') {
				changecolor(array[i][1],'nav_off');
			} else {
				changecolor(array[i][1],'nav_on');
			}
				itemMouseOver(array[i][1],action);
			}
		}
	}
}

function changevisibility(status,values){
	var value_array = values.split("~");
	for (loop=0; loop < value_array.length;loop++)
	{
		var myElement = document.getElementById(value_array[loop]);
		if (status == 'hide') {
			myElement.style.visibility = 'hidden';
		} else {
			myElement.style.visibility = 'visible';
		}
	}
}

function togglevisibility(div_id){
	var myElement = document.getElementById(div_id);
	if (myElement.style.visibility == 'visible' | myElement.style.visibility == '')
	{
		myElement.style.visibility = 'hidden';
	} else {
		myElement.style.visibility = 'visible';
	}
}

function openWindow(url,window_name,width,height){
	var options='';
	options='menubar=1,toolbar=1,location=1,statusbar=1,scrollbars=1,resizable=1,width=600px,height=400px';
	window.open(url,name,options);
}

function closeWindow(name){
	window.close(name);
}

function check(div_id){
	var myElement = document.getElementById(div_id);
	var l = myElement.style.left;
	var t = myElement.style.top;
	var w = myElement.style.width;
	var h = myElement.style.height;
	alert("Position is: left " + l + ", top " + t + ", width " + w +", height "  + h);
} 

function disableButton(formName){
	var buttonLocation = eval(formName + ".submitButton");
	buttonLocation.disabled = true;
	buttonLocation.value = '... Please wait...';
}

function toAlNum(strInput) {
	var strOutput;
	strOutput = '';
	for (j=0;j<strInput.length;j++) {

	if((strInput.charCodeAt(j) > 47 && strInput.charCodeAt(j) < 58) || (strInput.charCodeAt(j) > 64 && strInput.charCodeAt(j) < 91) || (strInput.charCodeAt(j) > 96 && strInput.charCodeAt(j) < 123)) strOutput = strOutput + strInput.charAt(j);
	}
	return strOutput;
}

function focusField(formName,formField){
eval("element=document." + formName + "." + formField +";")
element.focus();
}

function changeZIndex(div_id,zindex){
var myElement = document.getElementById(div_id);
myElement.style.zIndex = 10;
}

