
/*** click only once for forms ***/
function oneclick(theform){
if (document.all||document.getElementById){
  for (i=0;i<theform.length;i++){
  var tempobj=theform.elements[i]
    if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
    tempobj.disabled=true
  }
} else
return false
}

/*** broadcast message ***/
/*** did cause object expected error with doctype turned on before new copy from web ***/
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}

/*** Display icons ***/ 
/*** By On March 2006 ***/ 

function showimage() 
{ 
if (!document.images) 
return 
document.images.icons.src= 
document.myfishy.icon.options[document.myfishy.icon.selectedIndex].value 
} 

////Paint Calculator Code - Begins//////
function calculate() 
{ 
wall1_width = window.document.form1.wall1w.value; 
wall1_height = window.document.form1.wall1h.value; 
wall2_width = window.document.form1.wall2w.value; 
wall2_height = window.document.form1.wall2h.value; 
wall3_width = window.document.form1.wall3w.value; 
wall3_height = window.document.form1.wall3h.value; 
wall4_width = window.document.form1.wall4w.value; 
wall4_height = window.document.form1.wall4h.value; 

door1_width = window.document.form1.door1w.value; 
door1_height = window.document.form1.door1h.value; 
door2_width = window.document.form1.door2w.value; 
door2_height = window.document.form1.door2h.value; 

window1_width = window.document.form1.window1w.value; 
window1_height = window.document.form1.window1h.value; 
window2_width = window.document.form1.window2w.value; 
window2_height = window.document.form1.window2h.value; 

cans = window.document.form1.askcans.value; 

wall1_area = wall1_width * wall1_height; 
window.document.form1.wall1area.value = wall1_area; 
wall2_area = wall2_width * wall2_height; 
window.document.form1.wall2area.value = wall2_area; 
wall3_area = wall3_width * wall3_height; 
window.document.form1.wall3area.value = wall3_area; 
wall4_area = wall4_width * wall4_height; 
window.document.form1.wall4area.value = wall4_area; 

total1_area = wall1_area + wall2_area + wall3_area + wall4_area; 
window.document.form1.total1.value = total1_area; 

door1_area = door1_width * door1_height; 
door2_area = door2_width * door2_height; 
total_door_area = door1_area + door2_area; 

window1_area = window1_width * window1_height; 
window2_area = window2_width * window2_height; 
total_window_area = window1_area + window2_area; 

total_space = total_door_area + total_window_area; 

total2_area = total1_area - total_space; 
window.document.form1.total2.value = total2_area; 

give_cans = total2_area / cans; 
window.document.form1.givecans.value = give_cans; 
} 
////Paint Calculator Code - Ends//////
