// JavaScript Document
var WinID 		= 0
var PriceLine0
var PriceLine1
var PriceLine2
var QMain			= 0
var QDiscount 		= 0
var	vDiscount		= 0
var vSubTotal		= 0
var vDisplayTotal 	= 0
var vChoiceName		= ''
var vColourName		= ''

function GetBrowser()
{ 
	if (navigator.appName == 'Microsoft Internet Explorer') 
	{return ("IE")}
	else
	{return ("NonIE")}
}

function OL(CatIn)
{
//	if (CatIn !=0){CatOver(CatIn)
CatOver(CatIn)
}

function CatOver(IDin)
{
	document.getElementById("Cella" + IDin).className = "MainMenuItemOver"
	document.getElementById("Cellb" + IDin).className = "MainMenuItemOver" 
	document.getElementById("Cellc" + IDin).className = "MainMenuItemOver"
	document.getElementById("Celld" + IDin).className = "MainMenuItemOver"
		if (vCurrentCat != IDin){
		document.getElementById("Arrow" + IDin).src = "Headings/BlackRightArrow.jpg";
		}
		else
		{
		document.getElementById("Arrow" + IDin).src = "Headings/BlackDownArrow.jpg"
		if (vCurrentSub != 0){SubOver(vCurrentSub)};
		}
}
function CatOut(IDin)
{
	if (vCurrentCat != IDin){
	document.getElementById("Cella" + IDin).className = "MainMenuItem"
	document.getElementById("Cellb" + IDin).className = "MainMenuItem" 
	document.getElementById("Cellc" + IDin).className = "MainMenuItem"
	document.getElementById("Celld" + IDin).className = "MainMenuItem"
	document.getElementById("Arrow" + IDin).src = "Headings/RightArrow.jpg"
	}
}

function SubOver(IDin)
{
document.getElementById("Suba" + IDin).className = "SubMenuItemOver"
document.getElementById("Subb" + IDin).className = "SubMenuItemOver"
}
function SubOut(IDin)
{
	if (vCurrentSub != IDin){
	document.getElementById("Suba" + IDin).className = "SubMenuItem"
	document.getElementById("Subb" + IDin).className = "SubMenuItem"
	}
}
function CatLeap(CatIn,PageIn)
{
window.location= PageIn + "?cat=" + CatIn
}
function SubLeap(CatIn,SubIn,PageIn)
{
window.location= PageIn + "?cat=" + CatIn  + "&sub=" + SubIn
}

function PopLinkCheck(PageIn,Win,Hin)
	{
	if (document.form1.dirty.value == 0)
		{
		newWindow = window.open(PageIn , "newWin","toolbar=no, width=" + Win + ", height=" + Hin + ", scrollbars=yes")
		}
		else
		{
		alert("Please save the details before continuing")
		}
	}
	
function PopLink(PageIn,Win,Hin)
	{
		var vPoint = PageIn.lastIndexOf(".")
		var PageString = PageIn.substr(0,vPoint)
		newWindow = window.open(PageIn , 'NewWin'  ,"toolbar=no, width=" + Win + ", height=" + Hin + ", scrollbars=yes, status=no")
	}
		
function SetDirty()
{
	document.form1.dirty.value = 1
} 

function DelConfirm(PageIn)
{
var answer = confirm ("Are you sure")

if (answer){window.location = PageIn}

}

function CalcDiscount()
{
	
if (OfferAMT > 0)
	{	
		//Do the money off discounts
		if (OfferType == 2) {vDiscount = ((vSubTotal/100) * OfferAMT).toFixed(2) } // % off
		
		if (OfferType == 3) {vDiscount = vSubTotal -  OfferAMT} // AMT off

		// do the Multibuy calc
		if (OfferType == 1) 
		{
		vMB = Math.floor(QtyIn/OfferAMT)
		if (vMB > 0 ){
			SetPriceLine(2,vMB,ProdRef,ProdName,'',OfferName,0,'')
			}
		}

	}
}

function SetPriceLine(N,Q,I,I1,I2,I3,P,F)
{
	if (N==1){
	document.form2.itemname.value = I
	document.form2.itemname2.value = I1
	document.form2.itemname3.value = I2
	document.form2.itemname4.value = I3
	document.form2.price.value = P
	document.form2.fixedquantity.value = "yes"
	document.form2.quantity.value = Q
	}

	if (N==2){
	document.form2.X1itemname.value = I
	document.form2.X1itemname2.value = I1
	document.form2.X1itemname3.value = I2
	document.form2.X1itemname4.value = I3
	document.form2.X1price.value = P
	document.form2.X1fixedquantity.value = "yes"
	document.form2.X1quantity.value = Q
	}
}

function BN()
{
		if (vDisplayTotal == 0) 
	{
		alert("We are unable to provide a quote for this\nPlease contact us with your requirements")
		}
	else
	{
	// if the product is a rolloer blind then fill in the relevant fields
	if (vRollerBlind == "Y") {DoRB()}
//	window.resizeTo(600,550)
	document.form2.submit();
	}
}
	
function ClearHidden()
{

	document.form2.itemname.value = ""
	document.form2.itemname2.value = ""
	document.form2.itemname3.value = ""
	document.form2.itemname4.value = ""
	document.form2.price.value = ""
	document.form2.fixedquantity.value = ""
	document.form2.quantity.value = ""

	document.form2.X1itemname.value = ""
	document.form2.X1itemname2.value = ""
	document.form2.X1itemname3.value = ""
	document.form2.X1itemname4.value = ""
	document.form2.X1price.value = ""
	document.form2.X1fixedquantity.value = ""
	document.form2.X1quantity.value = ""

	}
	
	function CW()
	{
	window.opener.location.reload(true);
	window.close();
		}
		
	function DoRB()
	{
	var	v4text = ""
	var vRollerBlindChoices 
	
	vRollerBlindChoices = document.form1.BlindControl.options[document.form1.BlindControl.selectedIndex].text 
	vRollerBlindChoices = vRollerBlindChoices + ", " + document.form1.InRecess.options[document.form1.InRecess.selectedIndex].text
	
	v4text = document.form2.itemname2.value
	
	if (v4text == "")
	{	
		document.form2.itemname2.value = vRollerBlindChoices
		}
		else
		{
			document.form2.itemname2.value = "" + v4text + ", " + vRollerBlindChoices
			}
	
	}