// JavaScript Document

function newUser(arg){
	var a=document.forms[arg];
	var i;
	if(arg==1){
		if(a.forgot.checked && a.chngdetails.checked){alert("Both checkboxes are active?");return;}
		if(a.forgot.checked){
			if(a.email.value == ""){alert("blank email address");a.elements[0].focus();a.forgot.checked=0;return;}
			a.forgot.value='1';
			a.submit();
			return;
		}
		if(a.chngdetails.checked){
			if(a.email.value == ""){
				alert("blank text field");a.elements[0].focus();a.chngdetails.checked=0;return;
			}
			if(a.password.value == ""){
				alert("blank text field");a.elements[1].focus();a.chngdetails.checked=0;return;
			}
			a.chngdetails.value='1';
			a.submit();
			return;
		}
		for(i=0;i<2;i++){
		    if(!a.elements[i].value){
		    	alert("blank text field");a.elements[i].focus();return;
		    }
	      }
	}
	
      for(i=0;i<a.elements.length-1;i++){
          if(a.elements[i].value==""){
          	if(i==2 || i==4 || i==6 || i==8 || i==9 || i==11 || i==12){
          		a.elements[i].value='-';continue;
          	}
		  alert("blank text field");a.elements[i].focus();return;
	     }
	   }
    	
    if(arg == '0'){	
   	 	if(a.url.value!=""){
	   		if(a.elements[11].value.slice(0,7)!="http://"){
	     		a.elements[11].value="http://"+a.elements[11].value;
	    	}
	  	}
	}
	  	
	a.submit();
	return;
}

function stands(arg,vis){
	document.getElementById(arg).style.visibility=vis;
	return;
}

function changefontcolor(arg){
	document.getElementById(arg).style.color='#000066';
	return;
}

function changeback(arg){
	if(document.getElementById(arg).style.borderStyle=='inset'){document.getElementById(arg).style.color='#000066';return;}
	document.getElementById(arg).style.color='#E7CBB5';
	return;
}

function changedown(arg){		
	var tabBtns=new Array("about","products","contact","locations","stockists","newsletter","story");
	var i;
	if(arg == "splash"){
		for(i=0;i<tabBtns.length;i++){
		  document.getElementById(tabBtns[i]).style.borderStyle='outset';
		  document.getElementById(tabBtns[i]).style.color='#E7CBB5';
	      }
	    return;
	}
	
	document.getElementById(arg).style.borderStyle='inset';
	
	var suffix=".htm";
	for(i=0;i<tabBtns.length;i++){
	if(tabBtns[i]==arg){continue;}
		document.getElementById(tabBtns[i]).style.borderStyle='outset';
		document.getElementById(tabBtns[i]).style.color='#E7CBB5';
	}
	if(arg=="locations"){arg="cgi-bin/"+arg;suffix=".pl"}	

	parent.mainframe.document.location.href=arg+suffix;
	return;
}

function chkAllEmail(arg){
	var a=document.forms[0];
	var i;
	for(i=0;i<a.echk.length;i++){a.echk[i].checked=arg;}
	return;
}

function newPrices(input){
	var a = document.forms[1];
	a.mailout.value=input;
	a.approve.value="";
	a.submit();
	return;
}

function doMailout(){
	var a = document.forms[1];
	var b = document.forms[0];
	var i;
	for(i=0;i<b.echk.length;i++){
		if(b.echk[i].checked){
			a.mailout.value=a.mailout.value+b.echk[i].value+"|";
		}
	}

	if(a.mailout.value == ""){alert("You must tick a checkbox");return;}
	a.mailout.value=a.mailout.value.slice(0,-1);
	//if(! a.htmlonoff.checked){a.contents.value=a.contents.value.split('\n').join("<br>");}
	a.mailout.value=a.mailout.value+"!!!"+a.contents.value;
	a.approve.value="";	
	a.submit();
	return;
}

function cgidoOK(){
	var a = document.forms[1];
	a.approve.value="";
	var b = document.forms[0];
	var i;

	for(i=b.ok.length-1;i>-1;i--){
		a.approve.value=a.approve.value+b.ok[i].checked+"|";
	}
	a.approve.value=a.approve.value.slice(0,-1);
	a.approve.value=a.approve.value.split("true").join("1");
	a.approve.value=a.approve.value.split("false").join("0");
	a.mailout.value="";
	a.submit();
}

function initialise(){
var a = document.forms[0];
	var b= unescape(document.cookie);
	if(b.length <35){document.location.href="splash.htm";}
	a.email.value=b.split("userData=")[1].split("|")[0];
	a.password.value=b.split("userData=")[1].split("|")[1];
	a.nationality.value = b.split("userData=")[1].split("|")[2];
	a.businessName.value=b.split("userData=")[1].split("|")[3];
	a.authorisingPerson.value=b.split("userData=")[1].split("|")[9];
	a.shippingAddress.value=b.split("userData=")[1].split("|")[4]+" \n"+b.split("userData=")[1].split("|")[5]+" \n"+b.split("userData=")[1].split("|")[6]+" \n"+b.split("userData=")[1].split("|")[7]+" \n"+b.split("userData=")[1].split("|")[2]+" \n"+b.split("userData=")[1].split("|")[8];
a.OAN1eachWS.value='8';a.OAN2eachWS.value='11';a.OAN3eachWS.value='14';a.OAN4eachWS.value='18';a.OEA1eachWS.value='16';a.OEA2eachWS.value='22';//pricingAustralia1

if(a.nationality.value != 'Australia'){a.OAN1eachWS.value='12';a.OAN2eachWS.value='16.5';a.OAN3eachWS.value='21';a.OAN4eachWS.value='27';a.OEA1eachWS.value='24';a.OEA2eachWS.value='33';}//pricingInternational1
a.oan1a.value=48;a.oan2a.value=24;a.oan3a.value=24;a.oan4a.value=24;a.oea1a.value=12;a.oea2a.value=12;//standa
a.oan1b.value=32;a.oan2b.value=24;a.oan3b.value=24;a.oan4b.value=24;a.oea1b.value=12;a.oea2b.value=12;//standb
a.oan1c.value=16;a.oan2c.value=12;a.oan3c.value=12;a.oan4c.value=12;a.oea1c.value=12;a.oea2c.value=12;//standc
a.sixTierCost.value=decimal((a.oan1a.value*a.OAN1eachWS.value)+(a.oan2a.value*a.OAN2eachWS.value)+(a.oan3a.value*a.OAN3eachWS.value)+(a.oan4a.value*a.OAN4eachWS.value)+(a.oea1a.value*a.OEA1eachWS.value)+(a.oea2a.value*a.OEA2eachWS.value));
a.fiveTierCost.value=decimal((a.oan1b.value*a.OAN1eachWS.value)+(a.oan2b.value*a.OAN2eachWS.value)+(a.oan3b.value*a.OAN3eachWS.value)+(a.oan4b.value*a.OAN4eachWS.value)+(a.oea1b.value*a.OEA1eachWS.value)+(a.oea2b.value*a.OEA2eachWS.value));
a.threeTierCost.value=decimal((a.oan1c.value*a.OAN1eachWS.value)+(a.oan2c.value*a.OAN2eachWS.value)+(a.oan3c.value*a.OAN3eachWS.value)+(a.oan4c.value*a.OAN4eachWS.value)+(a.oea1c.value*a.OEA1eachWS.value)+(a.oea2c.value*a.OEA2eachWS.value));
	if(a.nationality.value != 'Australia'){a.terms[0].checked=false;a.terms[1].checked=false;a.terms[2].checked=true;}

	if(a.terms[1].checked){a.sixTierCost.value=decimal(parseFloat(.95*a.sixTierCost.value));a.fiveTierCost.value=decimal(parseFloat(.95*a.fiveTierCost.value));a.threeTierCost.value=decimal(parseFloat(.95*a.threeTierCost.value));}
	
	
	a.totalExclGST.value=decimal(parseFloat((a.sixTierFloor.checked)?a.sixTierCost.value:0)+parseFloat((a.fiveTierCounter.checked)?a.fiveTierCost.value:0)+parseFloat((a.threeTierCounter.checked)?a.threeTierCost.value:0));
	a.gst.value=decimal((parseFloat(a.totalExclGST.value)+parseFloat(a.freight.value))/10);
	
	if(a.nationality.value != 'Australia'){a.gst.value=0;}
	a.Totfreight.value=decimal(parseFloat(a.totalExclGST.value)+parseFloat(a.freight.value));
        a.totInclGST.value=decimal(parseFloat(a.totalExclGST.value)+parseFloat(a.gst.value)+parseFloat(a.freight.value));
	a.deposit.value=decimal(a.totInclGST.value/10);
	var d=new Date();
	var weekday = new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat","Sun")
	a.date.value=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear()+"  "+d.getHours()+":"+d.getMinutes();
	return;
}

function refill(){
	var a = document.forms[0];
	var b= unescape(document.cookie);
	if(b.length <35){document.location.href="splash.htm";}
	a.email.value=b.split("userData=")[1].split("|")[0];
	a.password.value=b.split("userData=")[1].split("|")[1];
	a.nationality.value = b.split("userData=")[1].split("|")[2];
	a.businessName.value=b.split("userData=")[1].split("|")[3];
	a.authorisingPerson.value=b.split("userData=")[1].split("|")[9];
	a.shippingAddress.value=b.split("userData=")[1].split("|")[4]+" \n"+b.split("userData=")[1].split("|")[5]+" \n"+b.split("userData=")[1].split("|")[6]+" \n"+b.split("userData=")[1].split("|")[7]+" \n"+b.split("userData=")[1].split("|")[2]+" \n"+b.split("userData=")[1].split("|")[8];
a.OAN1dustyBlueAt.value='8';a.OAN2dustyPinkAt.value='11';a.OAN3khakiGreenAt.value='14';a.OAN4goldenTanAt.value='18';a.OEA1purplePlushGoldPlateAt.value='16';a.OEA1purplePlushRhodiumPlateAt.value='16';a.OEA2rusticBrownGoldPlateAt.value='22';a.OEA2rusticBrownRhodiumPlateAt.value='22';//pricingAustralia2
if(a.nationality.value != 'Australia'){a.OAN1dustyBlueAt.value='12';a.OAN2dustyPinkAt.value='16.5';a.OAN3khakiGreenAt.value='21';a.OAN4goldenTanAt.value='27';a.OEA1purplePlushGoldPlateAt.value='24';a.OEA1purplePlushRhodiumPlateAt.value='24';a.OEA2rusticBrownGoldPlateAt.value='33';a.OEA2rusticBrownRhodiumPlateAt.value='33';}//pricingInternational2
a.OAN1dustyBlueTot.value = decimal(parseFloat(a.OAN1dustyBlue.value) * parseFloat(a.OAN1dustyBlueAt.value));
	a.OAN2dustyPinkTot.value = decimal(parseFloat(a.OAN2dustyPink.value) * parseFloat(a.OAN2dustyPinkAt.value));
	a.OAN3khakiGreenTot.value = decimal(parseFloat(a.OAN3khakiGreen.value) * parseFloat(a.OAN3khakiGreenAt.value));
	a.OAN4goldenTanTot.value = decimal(parseFloat(a.OAN4goldenTan.value) * parseFloat(a.OAN4goldenTanAt.value));
	a.OEA1purplePlushGoldPlateTot.value = decimal(parseFloat(a.OEA1purplePlushGoldPlate.value) * parseFloat(a.OEA1purplePlushGoldPlateAt.value));
	a.OEA1purplePlushRhodiumPlateTot.value = decimal(parseFloat(a.OEA1purplePlushRhodiumPlate.value) * parseFloat(a.OEA1purplePlushRhodiumPlateAt.value));
	a.OEA2rusticBrownGoldPlateTot.value = decimal(parseFloat(a.OEA2rusticBrownGoldPlate.value) * parseFloat(a.OEA2rusticBrownGoldPlateAt.value));
	a.OEA2rusticBrownRhodiumPlateTot.value = decimal(parseFloat(a.OEA2rusticBrownRhodiumPlate.value) * parseFloat(a.OEA2rusticBrownRhodiumPlateAt.value));
	a.grandTot.value =decimal( parseFloat(a.OAN1dustyBlueTot.value)+parseFloat(a.OAN2dustyPinkTot.value)+parseFloat(a.OAN3khakiGreenTot.value)+parseFloat(a.OAN4goldenTanTot.value)+parseFloat(a.OEA1purplePlushGoldPlateTot.value)+parseFloat(a.OEA1purplePlushRhodiumPlateTot.value)+parseFloat(a.OEA2rusticBrownGoldPlateTot.value)+parseFloat(a.OEA2rusticBrownRhodiumPlateTot.value));
	a.gst.value=decimal(0.1 * a.grandTot.value);
	if(a.nationality.value != 'Australia'){a.gst.value=0;}
	var d=new Date();
	var weekday = new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat","Sun")
	a.date.value=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear()+"  "+d.getHours()+":"+d.getMinutes();
	
	return;
}

function b4iorderemail(){
	var a = document.forms[0];
	var b= unescape(document.cookie);
	a.from.value=b.split("userData=")[1].split("|")[0];
}


function decimal(input){
	var i;
	var output;
	input = input.toString();
	for(i=0;i< input.length; i++){
		if(input.charAt(i) == "."){output = input.slice(0,(i+3));break;}
		output = input;
	}
	return parseFloat(output);
}

function recRet(){
	var a = document.forms[0];
	var b= unescape(document.cookie);
	if(b.length <35){document.location.href="splash.htm";}
	var nationality = b.split("userData=")[1].split("|")[2];
	
a.oan1w.value='8';a.oan2w.value='11';a.oan3w.value='14';a.oan4w.value='18';a.oea1gpw.value='16';a.oea1rpw.value='16';a.oea2gpw.value='22';a.oea2rpw.value='22';a.h101w.value=4;//wholesaleAust
a.oan1r.value='20';a.oan2r.value='30';a.oan3r.value='40';a.oan4r.value='50';a.oea1gpr.value='40';a.oea1rpr.value='40';a.oea2gpr.value='55';a.oea2rpr.value='55';a.h101r.value=10;//retailAust


if(nationality != 'Australia'){
a.oan1w.value='12';a.oan2w.value='16.5';a.oan3w.value='21';a.oan4w.value='27';a.oea1gpw.value='24';a.oea1rpw.value='24';a.oea2gpw.value='33';a.oea2rpw.value='33';a.h101w.value=4;//wholesaleInt
a.oan1r.value='30';a.oan2r.value='42';a.oan3r.value='52.5';a.oan4r.value='67.5';a.oea1gpr.value='60';a.oea1rpr.value='60';a.oea2gpr.value='82.5';a.oea2rpr.value='82.5';a.h101r.value=10;//retailInt
}
	return;
}

function mtlogout(){
	document.location.href='../splash.htm';
	window.parent.topFrame.document.getElementById('stockists').style.borderStyle='outset';
	window.parent.topFrame.document.getElementById('stockists').style.color='#E7CBB5';
	document.cookie="userData=;path=/;expires=Thu, 01-Jan-70 00:00:01 GMT";
	
}

function hangit(){
	var a = document.forms[0];
	var b= unescape(document.cookie);
	if(b.length <35){document.location.href="splash.htm";}
	a.total.value=a.number.value*a.costeach.value;
	a.email.value=b.split("userData=")[1].split("|")[0];
	a.businessName.value=b.split("userData=")[1].split("|")[3];
	a.authorisingPerson.value=b.split("userData=")[1].split("|")[9];
	a.shippingAddress.value=b.split("userData=")[1].split("|")[4]+" \n"+b.split("userData=")[1].split("|")[5]+" \n"+b.split("userData=")[1].split("|")[6]+" \n"+b.split("userData=")[1].split("|")[7]+" \n"+b.split("userData=")[1].split("|")[2]+" \n"+b.split("userData=")[1].split("|")[8];
	var d=new Date();
	var weekday = new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat","Sun")
	a.date.value=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear()+"  "+d.getHours()+":"+d.getMinutes();
	return;
}


function removeRecord(){
	var b=document.forms[0];
	var a=document.forms[1];
	var i;
	for(i=0;i<b.echk.length;i++){
		if(b.echk[i].checked == true){
			a.sendremove.value=b.echk[i].value;
                        if(!confirm("Are you sure you want to delete "+a.sendremove.value)){return;}
			a.submit();
		}
	}
	if(a.sendremove.value == ""){alert("You must tick a checkbox");return;}
	return;
}

function customerMe(){
	var a=document.forms[1];
	var b=document.forms[0];
	var i;
	for(i=0;i<b.echk.length;i++){
		if(b.echk[i].checked == true){
		a.customer.value=b.echk[i].value;
		a.submit();
		}
	}
	if(a.customer.value == ""){alert("You must tick a checkbox");return;}
	return;
}
function editDetails(){
	var a=document.forms[1];
	var b=document.forms[0];
	var i;
	for(i=0;i<b.echk.length;i++){
		if(b.echk[i].checked == true){
		a.editHidden.value=b.echk[i].value;
		a.submit();
		}
	}
	if(a.editHidden.value == ""){alert("You must tick a checkbox");return;}
	return;
}





