<!--
function GetRBselection(group)
{
  for ( var i=0; i<group.length; i++ )
  {
     if ( group[i].checked == true )
     {
        return( group[i].value );
     }
  }
  return("");
}

function getSelectedItems(oSel) {
    var selectedItems = new Array();
    for (var i = 0; i < oSel.length; i++)
		{
        if (oSel.options[i].selected)
            selectedItems[selectedItems.length] = oSel.options[i].value;
		}
    	return selectedItems;
}

var qsParm = new Array();
qsParm['w'] = null;
qsParm['d'] = null;
qsParm['q'] = null;
qsParm['t'] = null;
qsParm['c'] = null;
qsParm['VG'] = null;

qs();

function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf('=');
   if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      qsParm[key] = val;
      }
   }
}

qs();

var qsWidth,qsDepth,qsQuantity,qsColours,qsCut,qsVG;
qsWidth=qsParm['w'];
qsDepth=qsParm['d'];
qsQuantity=qsParm['q'];
qsColours=qsParm['col'];
qsCut=qsParm['c'];
qsVG=qsParm['VG'];

if (qsCut==null){
	qsCut="false"
}else{
	qsCut="true"
}

if (qsVG=="Estimate_Now")
{
	document.form1.A1_Width.value=qsWidth;
	document.form1.A2_Depth.value=qsDepth;
	document.form1.A3_Quantity.value=qsQuantity;
	document.form1.A4_Colours.selectedIndex=qsColours;
	if (qsCut=="true"){
		document.form1.Contour.checked = true;
	}
	calcGraphics();
}

function calcGraphics() {
	var iWidth,iDepth,iQuantity,iMeters,iColours;
	var GerberRate=0,DigitalRate=0,FlatRate=0;
	var GerberPrice=0,DigitalPrice=0,FlatPrice=0;
	var ColourValue;
	iWidth=document.form1.A1_Width.value;
	iDepth=document.form1.A2_Depth.value;
	iQuantity=document.form1.A3_Quantity.value;

	//0=NA, 1=1 colours, 2=2 colours, 3=3 colour, 4=Full;
	iColours = document.form1.A4_Colours.selectedIndex;
	ColourValue = document.form1.A4_Colours.options[iColours].value;

	iMeters=Math.round((Math.abs(iWidth/1000)*(iDepth/1000)*(iQuantity))*100)/100;

	if ((iMeters==NaN)||(iMeters==0)||(iColours==0))
	{
	alert("You must enter valid width, depth, quantity and select number of colours required.");
	GerberRate=0;
	DigitalRate=0;
	FlatRate=0;
	return false;
	}

	if (iColours==1)
	{
		GerberRate=52.83;
		FlatRate=1;
	}
	if (iColours==2)
	{
		GerberRate=52.83;
		FlatRate=1.85;
	}
	if (iColours==3)
	{
		GerberRate=52.83;
		FlatRate=2.6;
	}
	if (iColours==4)
	{
		GerberRate=52.83;
		FlatRate=3.25;
	}
	
	if ((iMeters>0.00)&&(iMeters<=1.00))
	{
	GerberRate=GerberRate*1.09;
	DigitalRate=39.92;
	FlatRate=FlatRate*52;
	}
	if ((iMeters>1.00)&&(iMeters<=2.00))
	{
	GerberRate=GerberRate*1.06;
	DigitalRate=39.27;
	FlatRate=FlatRate*51;
	}	
	if ((iMeters>2.00)&&(iMeters<=5.00))
	{
	GerberRate=GerberRate*1.03;
	DigitalRate=38.30;
	FlatRate=FlatRate*50;
	}	
	if ((iMeters>5.00)&&(iMeters<=10.00))
	{
	GerberRate=GerberRate*0.94;
	DigitalRate=35.40;
	FlatRate=FlatRate*48;
	}	
	if ((iMeters>10.00)&&(iMeters<=25.00))
	{
	GerberRate=GerberRate*0.91;
	DigitalRate=34.34;
	FlatRate=FlatRate*47;
	}
	if ((iMeters>26.00)&&(iMeters<=40.00))
	{
	GerberRate=GerberRate*0.88;
	DigitalRate=33.47;
	FlatRate=FlatRate*42;
	}
	if ((iMeters>40.00)&&(iMeters<=65.00))
	{
	GerberRate=GerberRate*0.85;
	DigitalRate=31.85;
	FlatRate=FlatRate*39;
	}
	if ((iMeters>65.00)&&(iMeters<=100.00))
	{
	GerberRate=GerberRate*0.79;
	DigitalRate=29.60;
	FlatRate=FlatRate*36;
	}
	if ((iMeters>100.00)&&(iMeters<=250.00))
	{
	GerberRate=GerberRate*0.75;
	DigitalRate=28.63;
	FlatRate=FlatRate*34;
	}
	if (iMeters>250)
	{
	GerberRate=GerberRate*0.72;
	DigitalRate=28.31;
	FlatRate=FlatRate*31.5;
	}

	document.form1.A5_Meters.value=iMeters+"";

	GerberPrice=Math.round((Math.abs(GerberRate)*(iMeters))*100)/100;
	DigitalPrice=Math.round((Math.abs(DigitalRate)*(iMeters))*100)/100;
	FlatPrice=Math.round((Math.abs(FlatRate)*(iMeters))*100)/100;
	
	if (document.form1.Contour.checked){
		DigitalPrice=Math.round((Math.abs(DigitalPrice)*(1.177))*100)/100;
		GerberPrice=Math.round((Math.abs(GerberPrice)*(1.075))*100)/100;
	}
	
	document.form1.C1_Digital_Description.value = iQuantity+" of "+iWidth+" x "+iDepth+"mm 1400 dpi solvent printed "+ ColourValue +" vinyl graphic";
	
	if ((iDepth>1200)&&(iWidth>1200))
	{
		document.form1.B1_Gerber_Description.value = "Not applicable can only laminate up to max depth of 1200mm";
		GerberPrice="NA";
	}else{
		document.form1.B1_Gerber_Description.value = iQuantity+" of "+iWidth+" x "+iDepth+"mm 1400 dpi vinyl printed in "+ ColourValue +" overlaminated ";
	}
	
	if ((iDepth>600)&&(iWidth>600))
	{
		document.form1.D1_Flat_Description.value = "Not applicable to flat vinyl cut graphics - Max depth is 600mm";
		FlatPrice="NA";
	}else{
		if (iColours==4)
		{
			ColourValue="4 colour";
		}
		document.form1.D1_Flat_Description.value = iQuantity+" of "+iWidth+" x "+iDepth+"mm solid flat colour vinyl graphic cut using "+ ColourValue +"s of vinyl";
	}

	document.form1.B2_Gerber_Price.value=GerberPrice+"";
	document.form1.C2_Digital_Price.value=DigitalPrice+"";
	document.form1.D2_Flat_Price.value=FlatPrice+"";

}

function calculateCost() {
	var setUp;
	var setUpCost, graphicCost,iMeters,IKit,IWeed,ITape,iVAT,setUpRate;
	var graphicSel;
	var IKit=0;
	var IWeed=0;
	var ITape=0;

	calcGraphics();
	
	setUpRate=12.99;
	iShipping=12.00;

	//graphicSel=document.form1.E1_Graphic_Selection.value;
	graphicSel=GetRBselection(document.form1.E1_Graphic_Selection);

	//if ((graphicSel!="Gerber")||(graphicSel!="Digital")||(graphicSel!="Flat"))
	if (graphicSel=="")
	{
		alert("You must select your desired graphic format for an accurate quote.");
		return false;
	}
	if (graphicSel=="Gerber")
	{
		graphicCost=document.form1.B2_Gerber_Price.value;
	}
	if (graphicSel=="Digital")
	{
		graphicCost=document.form1.C2_Digital_Price.value;
	}
	if (graphicSel=="Flat Vinyl")
	{
		graphicCost=document.form1.D2_Flat_Price.value;
	}

	setUp=GetRBselection(document.form1.F1_Artwork);
	if (setUp=="")
	{
		alert("You must select your desired set up and artwork option.");
		return false;
	}
	if (graphicCost>50.0)
	{
		setUpRate=17.60;
		iShipping=18.85;
	}
	
	if (setUp=="Sending")
	{
	setUpCost=setUpRate;
	}
	if (setUp=="Capture")
	{
	setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.10))*100)/100;
	}
	if (setUp=="Produce")
	{
		if ((graphicCost>0.0)&&(graphicCost<=50.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.70))*100)/100;
		}
		if ((graphicCost>50.0)&&(graphicCost<=100.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.60))*100)/100;
		}
		if ((graphicCost>100.0)&&(graphicCost<=200.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.50))*100)/100;
		}
		if ((graphicCost>200.0)&&(graphicCost<=300.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.40))*100)/100;
		}		
		if ((graphicCost>300.0)&&(graphicCost<=500.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.30))*100)/100;
		}
		if ((graphicCost>500.0)&&(graphicCost<=1000.0))
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.25))*100)/100;
		}
		if (graphicCost>1000.0)
		{
			setUpCost=Math.round(Math.abs(setUpRate+(graphicCost*0.20))*100)/100;
		}
	}

	if (document.form1.Kit.checked){
		IKit=9.99;
	}
	if (document.form1.Weed.checked){
		IWeed=Math.round(Math.abs(graphicCost*0.21)*100)/100;
	}
	if (document.form1.Tape.checked){
		ITape=Math.round(Math.abs(graphicCost*0.21)*100)/100;
	}

	document.form1.PSelected_Price.value= graphicCost+"";
	document.form1.PSetUp.value= setUpCost+"";
    document.form1.PKit.value=IKit+"";
	document.form1.PWeed.value=IWeed+"";
	document.form1.PTape.value=ITape+"";
    document.form1.PShipping.value=iShipping+"";

    subTotal=Math.round(Math.abs((graphicCost*1)+(setUpCost*1)+(IKit*1)+(IWeed*1)+(ITape*1)+(iShipping*1))*100)/100;
    document.form1.PSubTotal.value=subTotal+"";

    iVAT=Math.round((Math.abs(subTotal))*0.175*100)/100;
    document.form1.PVAT.value=iVAT+"";

    TotalCost=Math.round((Math.abs(iVAT+subTotal))*100)/100;
    document.form1.PTotal_Cost.value=TotalCost+"";
}

function bannerwarning()
{
var answer=confirm("This will clear ALL information on page including banner information - continue?");
if (answer)
	document.form1.reset();
else
	return false;
}
//-->