// JavaScript Document

function display(selection) {}

function calcDoors () {
var style = document.doorpricer.glass.value
var width = document.doorpricer.width.value
var height = document.doorpricer.height.value

//Size Validation

if (width < 600)
   {
   alert("Minumum Width 600mm");
   }
   
if (width > 900)
   {
   alert("Maximum Width 900mm");
   }
   
   
	
if (height < 1500)
   {
   alert("Minimum Height 1500mm");
   }

if (height > 2500)
   {
   alert("Maximum Height 2500mm");
   }

//------- CLEAR GLASS PRICING----------- //

if (style =='Clear')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value=378 }
  
else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 394 }
 
else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 410 }

 // 763 - 838
 
else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 390 }
  
else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 407 }
 
else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 423 }

 // 839 - 900
 //up to here
else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 398 }
  
else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 417 }
 
else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 434 }
 
}

//------- SATIN GLASS PRICING----------- //

if (style == 'Satin')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 454 }
  
else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 480 }
 
else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 506 }

 // 763 - 838
 
else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 474 }
  
else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 501 }
 
else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 529 }

 // 839 - 900
 
else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 489 }
  
else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 518 }
 
else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 547 }
 
}
//------- CHINCHILLA GLASS PRICING----------- //

if (style == 'Chinchilla')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000)
 {document.doorpricer.finalprice.value= 477 }

else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250)
 {document.doorpricer.finalprice.value= 505 }

else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500)
 {document.doorpricer.finalprice.value= 534 }

 // 763 - 838

else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000)
 {document.doorpricer.finalprice.value= 498 }

else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250)
 {document.doorpricer.finalprice.value= 529 }

else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500)
 {document.doorpricer.finalprice.value= 559 }

 // 839 - 900

else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000)
 {document.doorpricer.finalprice.value= 515 }

else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250)
 {document.doorpricer.finalprice.value= 548 }

else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500)
 {document.doorpricer.finalprice.value= 580 }

}

//------- BRONZE/GREEN/GREY GLASS PRICING----------- //

if (style == 'Bronze' || style == 'Green' || style == 'Grey')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 405 }
  
else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 424 }
 
else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 444 }

 // 763 - 838
 
else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 420 }
  
else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 440 }
 
else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 461 }

 // 839 - 900
 
else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 431 }
  
else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 453 }
 
else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 474 }
 
}


//------- CHINCHILLA_BRONZE GLASS PRICING----------- //

if (style == 'Chinchilla_Bronze')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 526 }
  
else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 560 }
 
else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 596 }

 // 763 - 838
 
else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 553 }
  
else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 590 }
 
else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 628 }

 // 839 - 900
 
else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 573 }
  
else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 614 }
 
else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 653 }
 
}


//------- BLUE GLASS PRICING----------- //

if (style == 'Blue')

{

if (width >= 600 && width <= 762 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 430 }
  
else if (width >= 600 && width <= 762 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 452 }
 
else if (width >= 600 && width <= 762 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 475 }

 // 763 - 838
 
else if (width >= 763 && width <= 838 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 447 }
  
else if (width >= 763 && width <= 838 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 471 }
 
else if (width >= 763 && width <= 838 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 495 }

 // 839 - 900
 
else if (width >= 839 && width <= 900 && height >= 1500 && height <= 2000) 
 {document.doorpricer.finalprice.value= 460 }
  
else if (width >= 839 && width <= 900 && height >= 2001 && height <= 2250) 
 {document.doorpricer.finalprice.value= 486 }
 
else if (width >= 839 && width <= 900 && height >= 2251 && height <= 2500) 
 {document.doorpricer.finalprice.value= 511 }
 
}

 if (style == '-'){
alert("Please Select A Glass Style");
}


}


function extras () {
 // Brilliant Star Design Check Box
if (document.doorpricer.starcut.checked) {
document.doorpricer.brill.value=99
		}
		
if (document.doorpricer.starcut.checked == false) {
document.doorpricer.brill.value=0
		}
 
// Hardware Radio Buttons
if (document.doorpricer.hardware.checked) {
document.doorpricer.h1.value=0
		}
		
// if (document.doorpricer.hardware[1].checked) {
//		document.doorpricer.h1.value=149
//	}
	
// if (document.doorpricer.hardware[2].checked) {
//		document.doorpricer.h1.value=149
//	} 
// Locking Radio Buttons
if (document.doorpricer.lock[0].checked) {
		document.doorpricer.lk.value=0
	} 
	
if (document.doorpricer.lock[1].checked) {
		document.doorpricer.lk.value=25
	} 
	
if (document.doorpricer.lock[2].checked) {
		document.doorpricer.lk.value=25
	} 
	
// Delivery Radio Buttons
if (document.doorpricer.del[0].checked) {
		document.doorpricer.deliv.value=0
	} 
	
if (document.doorpricer.del[1].checked) {
		document.doorpricer.deliv.value=30
	} 
	}



function calcPrice() {
var pricex = document.doorpricer.finalprice.value
pricex = Number(pricex)
var hardware = document.doorpricer.h1.value
hardware = Number(hardware)
var cutstar = document.doorpricer.brill.value
cutstar = Number(cutstar)
var locking = document.doorpricer.lk.value
locking = Number(locking)
var delivery = document.doorpricer.deliv.value
delivery = Number(delivery)

document.doorpricer.cost.value = pricex 

var total = (pricex + hardware + cutstar + locking + delivery)

document.doorpricer.totalcost.value = total * 2

document.doorpricer.half.value = total

// VAT

var vats = total * 0.2

//round up vat to two decimals
	var vatresult=Math.round(vats*100)/100
	//
vatresult = Number(vatresult)

document.doorpricer.vatprice.value = vatresult

document.doorpricer.wpvat.value = vatresult + total

document.doorpricer.youpay.value = total


}





