function position_glasses(vent,windowid,ventpatterns)
{
//var pt_x=parseInt(getXY(document.getElementById('wgs'))[0],10);
	//var pt_y=parseInt(getXY(document.getElementById('wgs'))[1],10);
	var d; var sh=0;
	
	if(document.getElementById("hinge_"+windowid))
	{ 
	
	if(vent[0]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_'+windowid).clientHeight}
   	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_'+windowid))[1],10)-d;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_'+windowid).style.left="-10px";
	 document.getElementById('img_hinge_'+windowid).style.top="-10px";
	 document.getElementById('img_hinge_'+windowid).src=ventpatterns[0];
	 document.getElementById('p_hinge_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_'+windowid).clientHeight)+2*d+1)+"px";
	 document.getElementById('p_hinge_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_'+windowid).clientWidth)+2*d+1)+"px";
	  document.getElementById('hinge_'+windowid).style.height=(parseInt(document.getElementById('hinge_'+windowid).clientHeight)+2*d+1)+"px";
	 document.getElementById('hinge_'+windowid).style.width=(parseInt(document.getElementById('hinge_'+windowid).clientWidth)+2*d+1)+"px";
	  }
	
    if(document.getElementById("hinge_left_"+windowid))
	{ if(vent[3]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_left_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_left_'+windowid))[1],10)-d-2;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_left_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_left_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_left_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_left_'+windowid).style.left="-10px";
	 document.getElementById('img_hinge_left_'+windowid).style.top="-10px";
	 document.getElementById('img_hinge_left_'+windowid).src=ventpatterns[3];
	 document.getElementById('p_hinge_left_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_left_'+windowid).clientHeight)+2*d+5)+"px";
	 document.getElementById('p_hinge_left_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_left_'+windowid).clientWidth)+2*d+3)+"px";
	  document.getElementById('hinge_left_'+windowid).style.height=(parseInt(document.getElementById('hinge_left_'+windowid).clientHeight)+2*d+5)+"px";
	 document.getElementById('hinge_left_'+windowid).style.width=(parseInt(document.getElementById('hinge_left_'+windowid).clientWidth)+2*d+3)+"px";
	  }
	 if(document.getElementById("hinge_right_"+windowid))
	{
	 if(vent[4]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_right_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_right_'+windowid))[1],10)-d-2;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_right_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_right_'+windowid).style.left=(vent_left-1)+"px";
	 document.getElementById('p_hinge_right_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_right_'+windowid).style.left="-300px";
	 document.getElementById('img_hinge_right_'+windowid).style.top="-10px";
	 document.getElementById('img_hinge_right_'+windowid).src=ventpatterns[4];
	 document.getElementById('p_hinge_right_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_right_'+windowid).clientHeight)+2*d+5)+"px";
	 document.getElementById('p_hinge_right_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_right_'+windowid).clientWidth)+2*d+3)+"px";
	 document.getElementById('hinge_right_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_right_'+windowid).clientHeight)+2*d+5)+"px";
	 document.getElementById('hinge_right_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_right_'+windowid).clientWidth)+2*d+3)+"px";
	  }
	  if(document.getElementById("hinge_top_"+windowid))
	{ 
	  if(vent[1]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_top_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_top_'+windowid))[1],10)-d-1;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_top_'+windowid))[0],10)-d;
	 
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_top_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_top_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_top_'+windowid).style.left="-10px";
	 document.getElementById('img_hinge_top_'+windowid).style.top="-10px";
	 document.getElementById('img_hinge_top_'+windowid).src=ventpatterns[1];
	 document.getElementById('p_hinge_top_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_top_'+windowid).clientHeight)+2*d+3)+"px";
	 document.getElementById('p_hinge_top_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_top_'+windowid).clientWidth)+2*d+2)+"px";
	  document.getElementById('hinge_top_'+windowid).style.height=(parseInt(document.getElementById('hinge_top_'+windowid).clientHeight)+2*d+3)+"px";
	 document.getElementById('hinge_top_'+windowid).style.width=(parseInt(document.getElementById('hinge_top_'+windowid).clientWidth)+2*d+2)+"px";
	  }
	  if(document.getElementById("hinge_bot_"+windowid))
	{ if(vent[2]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_bot_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_bot_'+windowid))[1],10)-d-1;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_bot_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_bot_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_bot_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_bot_'+windowid).style.left="-10px";
	 document.getElementById('img_hinge_bot_'+windowid).style.top="-100px";
	 document.getElementById('img_hinge_bot_'+windowid).src=ventpatterns[2];
	 document.getElementById('p_hinge_bot_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_bot_'+windowid).clientHeight)+2*d+3)+"px";
	 document.getElementById('p_hinge_bot_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_bot_'+windowid).clientWidth)+2*d+1)+"px";
	  document.getElementById('hinge_bot_'+windowid).style.height=(parseInt(document.getElementById('hinge_bot_'+windowid).clientHeight)+2*d+3)+"px";
	 document.getElementById('hinge_bot_'+windowid).style.width=(parseInt(document.getElementById('hinge_bot_'+windowid).clientWidth)+2*d+1)+"px";
	  }
	  
	  if(document.getElementById("hinge_left_bot_"+windowid))
	{ if(vent[5]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_left_bot_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_left_bot_'+windowid))[1],10)-d;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_left_bot_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_left_bot_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_left_bot_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_left_bot_'+windowid).style.left="-10px";
	 document.getElementById('img_hinge_left_bot_'+windowid).style.top="-100px";
	 document.getElementById('img_hinge_left_bot_'+windowid).src=ventpatterns[5];
	 document.getElementById('p_hinge_left_bot_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_left_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('p_hinge_left_bot_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_left_bot_'+windowid).clientWidth)+2*d+2)+"px";
	  document.getElementById('hinge_left_bot_'+windowid).style.height=(parseInt(document.getElementById('hinge_left_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('hinge_left_bot_'+windowid).style.width=(parseInt(document.getElementById('hinge_left_bot_'+windowid).clientWidth)+2*d+2)+"px";
	  }
	  
	  if(document.getElementById("hinge_right_bot_"+windowid))
	{ if(vent[6]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_right_bot_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_right_bot_'+windowid))[1],10)-d;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_right_bot_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_right_bot_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_right_bot_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_right_bot_'+windowid).style.left="-300px";
	 document.getElementById('img_hinge_right_bot_'+windowid).style.top="-100px";
	 document.getElementById('img_hinge_right_bot_'+windowid).src=ventpatterns[6];
	 document.getElementById('p_hinge_right_bot_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_right_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('p_hinge_right_bot_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_right_bot_'+windowid).clientWidth)+2*d+1)+"px";
	  document.getElementById('hinge_right_bot_'+windowid).style.height=(parseInt(document.getElementById('hinge_right_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('hinge_right_bot_'+windowid).style.width=(parseInt(document.getElementById('hinge_right_bot_'+windowid).clientWidth)+2*d+1)+"px";
	  }
	  
	  if(document.getElementById("hinge_mid_top_"+windowid))
	{ if(vent[7]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_mid_top_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_mid_top_'+windowid))[1],10)-d;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_mid_top_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_mid_top_'+windowid).style.left=vent_left+"px";
	 document.getElementById('p_hinge_mid_top_'+windowid).style.top=vent_top+"px";
	 document.getElementById('img_hinge_mid_top_'+windowid).style.left="-150px";
	 document.getElementById('img_hinge_mid_top_'+windowid).style.top="-10px";
	 document.getElementById('img_hinge_mid_top_'+windowid).src=ventpatterns[7];
	 document.getElementById('p_hinge_mid_top_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_mid_top_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('p_hinge_mid_top_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_mid_top_'+windowid).clientWidth)+2*d+3)+"px";
	  document.getElementById('hinge_mid_top_'+windowid).style.height=(parseInt(document.getElementById('hinge_mid_top_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('hinge_mid_top_'+windowid).style.width=(parseInt(document.getElementById('hinge_mid_top_'+windowid).clientWidth)+2*d+3)+"px";
	  }
	  
	  if(document.getElementById("hinge_mid_bot_"+windowid))
	{ if(vent[8]=="novent")
	  {
	   d=8;
	   } else {
	   d=0;
	   }
	   if( isSafari ){ sh=document.getElementById('p_hinge_mid_bot_'+windowid).clientHeight}
	 var vent_top=parseInt(getXY(document.getElementById('td_hinge_mid_bot_'+windowid))[1],10)-d;
	 var vent_left=parseInt(getXY(document.getElementById('td_hinge_mid_bot_'+windowid))[0],10)-d;
	 vent_top-=sh/2;
	 document.getElementById('p_hinge_mid_bot_'+windowid).style.left=(vent_left-1)+"px";
	 document.getElementById('p_hinge_mid_bot_'+windowid).style.top=(vent_top-1)+"px";
	 document.getElementById('img_hinge_mid_bot_'+windowid).style.left="-150px";
	 document.getElementById('img_hinge_mid_bot_'+windowid).style.top="-100px";
	 document.getElementById('img_hinge_mid_bot_'+windowid).src=ventpatterns[8];
	 document.getElementById('p_hinge_mid_bot_'+windowid).style.height=(parseInt(document.getElementById('p_hinge_mid_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('p_hinge_mid_bot_'+windowid).style.width=(parseInt(document.getElementById('p_hinge_mid_bot_'+windowid).clientWidth)+2*d+3)+"px";
	  document.getElementById('hinge_mid_bot_'+windowid).style.height=(parseInt(document.getElementById('hinge_mid_bot_'+windowid).clientHeight)+2*d+2)+"px";
	 document.getElementById('hinge_mid_bot_'+windowid).style.width=(parseInt(document.getElementById('hinge_mid_bot_'+windowid).clientWidth)+2*d+3)+"px";
	  }
	  
	  
}


function draw_toughenened(windowid,hinge)
{
var newDiv = document.createElement("div");
newDiv.setAttribute("id","div_"+hinge+"_"+windowid);
var x = parseInt(getXY(document.getElementById(hinge+'_'+windowid))[0],10);
var y = parseInt(getXY(document.getElementById(hinge+'_'+windowid))[1],10);
x=0;y=0;
var height = parseInt(document.getElementById(hinge+'_'+windowid).clientHeight,10);
var width = parseInt(document.getElementById(hinge+'_'+windowid).clientWidth,10);
x=x+parseInt(width/2)+15;
y=y+parseInt(height/2)-15;
newDiv.innerHTML = "<div  style='position:absolute;left:"+x+"px;top:"+y+"px;'><img src='images/though_left_transparent.gif'></div>";
if(document.getElementById(hinge+'_toughened'))
  {
	if(document.getElementById(hinge+'_toughened').value!="1")
	{
		  if(document.getElementById('div_'+hinge+'_'+windowid))
		  {
		  document.getElementById(hinge+'_'+windowid).removeChild(document.getElementById('div_'+hinge+'_'+windowid));
		  }
		} else{
		    if(document.getElementById('div_'+hinge+'_'+windowid))
			    {} else{
					    document.getElementById(hinge+'_'+windowid).appendChild(newDiv);
					   }
		   }
   } else {
	      if(document.getElementById(hinge+'_'+windowid))
		  {
	        document.getElementById(hinge+'_'+windowid).appendChild(newDiv);
		  }
	
   }
}


function get_glass_pattern(ratio)
{
var i=document.getElementById("window_glass_pattern_id").selectedIndex;
var window_style=document.getElementById("window_glass_pattern_id").options[i].text;
/*var j=document.getElementById("window_glass_style_id").selectedIndex;
var window_glass_style=document.getElementById("window_glass_style_id").options[j].text;
var k=document.getElementById("window_glass_type_id").selectedIndex;
var window_glass_type=document.getElementById("window_glass_type_id").options[k].text;*/
var image;
var size;
var width;
if(ratio>3.2){ 
         width=ratio*300;
        size="&image_width="+width; 
        }else {
	    size="&image_height=300";
	   }
	   
	
window_style=$.trim(window_style);

if(window_style=="Digital™"){
image="assets/windows/glass_interior/glass01.jpg";
}else if(window_style=="Sycamore™"){
image="assets/windows/glass_interior/glass02.jpg";
}else if(window_style=="Charcoal Sticks™"){
image="assets/windows/glass_interior/glass03.jpg";
}else if(window_style=="Contora™"){
image="assets/windows/glass_interior/glass04.jpg";
}else if(window_style=="Autumn™"){
image="assets/windows/glass_interior/glass05.jpg";
}else if(window_style=="Florielle™"){
image="assets/windows/glass_interior/glass06.jpg";
}else if(window_style=="Taffeta™"){
image="assets/windows/glass_interior/glass07.jpg";
}else if(window_style=="Arctic™"){
image="assets/windows/glass_interior/glass08.jpg";
}else if(window_style=="Everglade™"){
image="assets/windows/glass_interior/glass09.jpg";
}else if(window_style=="Chantilly™"){
image="assets/windows/glass_interior/glass10.jpg";
}else if(window_style=="Cotswold™"){
image="assets/windows/glass_interior/glass11.jpg";
}else if(window_style=="Minster™"){
image="assets/windows/glass_interior/glass12.jpg";
}else if(window_style=="May Flower™"){
image="assets/windows/glass_interior/glass13.jpg";
}else if(window_style=="Pelerine™"){
image="assets/windows/glass_interior/glass14.jpg";
}else if(window_style=="Oak™"){
image="assets/windows/glass_interior/glass15.jpg";
}else if(window_style=="Stippolyte™"){
image="assets/windows/glass_interior/glass16.jpg";
}else if(window_style=="Flemish™"){
image="assets/windows/glass_interior/glass17.jpg";
}else{
	alert("Please select a pattern");
return image;
}
return image;
}


function place_toughened(windowid,venttoughens)
{

	
	if(document.getElementById("hinge_"+windowid))
	{ if(venttoughens[0]=="1")
	  {
	   draw_toughenened(windowid,"hinge");
	   } else {
	   d=0;
	   }
	  
	 
	  }
	
    if(document.getElementById("hinge_left_"+windowid))
	{ if(venttoughens[3]=="1")
	  {
	   draw_toughenened(windowid,"hinge_left");
	   } else {
	   d=0;
	   }
	   
	 }
	 if(document.getElementById("hinge_right_"+windowid))
	{
	 if(venttoughens[4]=="1")
	  {
	   draw_toughenened(windowid,"hinge_right");
	   } else {
	   d=0;
	   }
	  
	  }
	  if(document.getElementById("hinge_top_"+windowid))
	{ if(venttoughens[1]=="1")
	  {
	   draw_toughenened(windowid,"hinge_top");
	   } else {
	   d=0;
	   }

	  }
	  if(document.getElementById("hinge_bot_"+windowid))
	{ if(venttoughens[2]=="1")
	  {
	   draw_toughenened(windowid,"hinge_bot");
	   } else {
	   d=0;
	   }
	  }
	  
	  if(document.getElementById("hinge_left_bot_"+windowid))
	  { 
	    if(venttoughens[5]=="1"){
		   draw_toughenened(windowid,"hinge_left_bot");
		   } else {
		   d=0;
		   }
	  
	  }
	  
	  if(document.getElementById("hinge_right_bot_"+windowid))
	  { if(venttoughens[6]=="1")
		  {
		   draw_toughenened(windowid,"hinge_right_bot");
		   } else {
		   d=0;
		   }
	  }
	  
	  if(document.getElementById("hinge_mid_top_"+windowid))
	  { if(venttoughens[7]=="1")
	   {
	    draw_toughenened(windowid,"hinge_mid_top");
	    } else {
	    d=0;
	    }
	   }
	  
	  if(document.getElementById("hinge_mid_bot_"+windowid))
	  { if(venttoughens[8]=="1")
	  {
	   draw_toughenened(windowid,"hinge_mid_bot");
	   } else {
	   d=0;
	   }
	   
	  }
	  
	  
}

function set_toughened_values(venttoughened)
{
	var id = "";
	for	(var i=0;i<9;i++){
	 switch(i){
			case 0:
				 id = "hinge";
			break;
			case 1:
				 id = "hinge_top";
			break;
			case 2:
				 id = "hinge_bot";
			break;
			case 3:
				 id = "hinge_left";
			break;
			case 4:
				 id = "hinge_right";
			break;
			case 5:
				 id = "hinge_left_bot";
			break;
			case 6:
				 id = "hinge_right_bot";
			break;
			case 7:
				 id = "hinge_mid_top";
			break;
			case 8:
				 id = "hinge_mid_bot";
			break;
		}
		if(venttoughened[i]=="1")document.getElementById(id+"_toughened").value=venttoughened[i];
	}
}

function draw_finish_image(finish,id,window_finish_id)
{
var image="";
 
	switch(finish)
	{
	 case "2":gbar_draw(id,window_finish_id);
	 break;
	 case "3":sleading_draw(id);
	 break;
	 case "4":
	 document.getElementById(id).style.backgroundImage="url(images/windowpatrns/diamonlead.gif)";
	 
	 break;
	}
	
}

function place_glass_finish(windowid,ventfinish,window_finish_id)
{
	if(document.getElementById("hinge_"+windowid))
	{
	   draw_finish_image(ventfinish[0],"hinge_"+windowid,window_finish_id);
	  
	  }
	
    if(document.getElementById("hinge_left_"+windowid))
	{
		draw_finish_image(ventfinish[3],"hinge_left_"+windowid,window_finish_id);
	 }
	 if(document.getElementById("hinge_right_"+windowid))
	{
	 draw_finish_image(ventfinish[4],"hinge_right_"+windowid,window_finish_id);
	  }
	  if(document.getElementById("hinge_top_"+windowid))
	   {
		draw_finish_image(ventfinish[1],"hinge_top_"+windowid,window_finish_id);

	   }
	  if(document.getElementById("hinge_bot_"+windowid))
	   {
		draw_finish_image(ventfinish[2],"hinge_bot_"+windowid,window_finish_id);

	   }
	  if(document.getElementById("hinge_left_bot_"+windowid))
	   {
		draw_finish_image(ventfinish[5],"hinge_left_bot_"+windowid,window_finish_id);

	   }
	  
	  if(document.getElementById("hinge_right_bot_"+windowid))
	   {
		draw_finish_image(ventfinish[6],"hinge_right_bot_"+windowid,window_finish_id);

	   }
	  
	  if(document.getElementById("hinge_mid_top_"+windowid))
	   {
		draw_finish_image(ventfinish[7],"hinge_mid_top_"+windowid,window_finish_id);

	   }
	  
	  if(document.getElementById("hinge_mid_bot_"+windowid))
	   {
		draw_finish_image(ventfinish[8],"hinge_mid_bot_"+windowid,window_finish_id);

	   }
}

function position_door_glasses(doorid,doorventpatterns)
{
   if(document.getElementById("door_"+doorid))
		{	
			document.getElementById('td_door_'+doorid).style.backgroundImage="url("+doorventpatterns[1]+")";
		}
   if(document.getElementById("door_bot_"+doorid))
		{	
			document.getElementById('td_door_bot_'+doorid).style.backgroundImage="url("+doorventpatterns[2]+")";
		}
   if(document.getElementById("left_opening_"+doorid))
		{	
			document.getElementById('td_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[3]+")";
		}
   if(document.getElementById("bot_left_opening_"+doorid))
		{	
			document.getElementById('td_bot_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[4]+")";
		}
   if(document.getElementById("top_left_opening_"+doorid))
		{	
			document.getElementById('td_top_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[5]+")";
		}
   if(document.getElementById("right_opening_"+doorid))
		{	
			document.getElementById('td_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[6]+")";
		}
   if(document.getElementById("bot_right_opening_"+doorid))
		{	
			document.getElementById('td_bot_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[7]+")";
		}
   if(document.getElementById("top_right_opening_"+doorid))
		{	
			document.getElementById('td_top_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[8]+")";
		}
   if(document.getElementById("top_opening_"+doorid))
		{	
			document.getElementById('td_top_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[9]+")";
		}
	
}

function place_door_glass_finish(doorid,doorventfinish,door_finish_id)
{
  	if(document.getElementById("door_"+doorid))
	{
	   draw_finish_image(doorventfinish[1],"door_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("door_bot_"+doorid))
	{
	   draw_finish_image(doorventfinish[2],"door_bot_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("left_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[3],"left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("bot_left_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[4],"bot_left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("top_left_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[5],"top_left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("right_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[6],"right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("bot_right_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[7],"bot_right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("top_right_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[8],"top_right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("top_opening_"+doorid))
	{
	   draw_finish_image(doorventfinish[9],"top_opening_"+doorid,door_finish_id);
	  
	  }
	 	
}
function change_pane(panel,door_frame_id,door_id,door_finish_id,door_style_id){
	var panel=parseInt(panel);
	if(door_finish_id=="1")
	{
		finish="white";
	}else if(door_finish_id=="2")
	{
		finish="wood1";
	}else if(door_finish_id=="3")
	{
		finish="wood2";
	}else if(door_finish_id=="4")
	{
		finish="wood2";
	}
	switch (panel){
		case 0://plain
		      if	(door_frame_id=='128'|| door_frame_id=='129' || door_frame_id=='132' || door_frame_id=='133' || door_frame_id=='142' || door_frame_id=='143' || door_frame_id=='144' || door_frame_id=='145' || door_frame_id=='223' || door_frame_id=='224' || door_frame_id=='225' || door_frame_id=='226' || door_style_id>'2'){
					document.getElementById('td_door_bot_'+door_id).style.backgroundImage="";
					document.getElementById('td_door_bot_'+door_id).className="win_glass_plain";
					document.getElementById('td_door_bot_'+door_id).innerHTML="";
				}
		break;
		case 1://plain
		      if	(door_frame_id=='128'|| door_frame_id=='129' || door_frame_id=='132' || door_frame_id=='133' || door_frame_id=='142' || door_frame_id=='143' || door_frame_id=='144' || door_frame_id=='145' || door_frame_id=='223' || door_frame_id=='224' || door_frame_id=='225' || door_frame_id=='226' || door_style_id>'2'){
					document.getElementById('td_door_bot_'+door_id).style.backgroundImage="";
					document.getElementById('td_door_bot_'+door_id).className="";
					document.getElementById('td_door_bot_'+door_id).innerHTML="";
				}
		break;
		case 2://full
				//document.getElementById('td_door_'+door_id).style.backgroundImage="";
				//document.getElementById('td_door_'+door_id).className="";
				if	(door_frame_id=='128'|| door_frame_id=='129' || door_frame_id=='132' || door_frame_id=='133' || door_frame_id=='142' || door_frame_id=='143' || door_frame_id=='144' || door_frame_id=='145' || door_frame_id=='223' || door_frame_id=='224' || door_frame_id=='225' || door_frame_id=='226' || door_style_id>'2'){
					document.getElementById('td_door_bot_'+door_id).style.backgroundImage="";
					document.getElementById('td_door_bot_'+door_id).className="";
					document.getElementById('td_door_bot_'+door_id).innerHTML="<img src='images/doors/"+finish+"/panel_full.gif' alt='' width='84' height'73' />";
				}
		break;
		case 3://halves
		if	(door_frame_id=='128'|| door_frame_id=='129' || door_frame_id=='132' || door_frame_id=='133' || door_frame_id=='142' || door_frame_id=='143' || door_frame_id=='144' || door_frame_id=='145' || door_frame_id=='223' || door_frame_id=='224' || door_frame_id=='225' || door_frame_id=='226' || door_style_id>'2'){
					document.getElementById('td_door_bot_'+door_id).style.backgroundImage="";
					document.getElementById('td_door_bot_'+door_id).className="";
					document.getElementById('td_door_bot_'+door_id).innerHTML="<img src='images/doors/"+finish+"/panel_halves.gif' alt='' width='84' height'73' />";
		}
		break;
	}
}

function place_french_door_glass_finish(doorid,doorventfinish,door_finish_id)
{ 
  	if(document.getElementById("d_door_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[1],"d_door_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_door_bot_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[2],"d_door_bot_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_left_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[3],"d_left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_bot_left_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[4],"d_bot_left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_top_left_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[5],"d_top_left_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_right_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[6],"d_right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_bot_right_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[7],"d_bot_right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_top_right_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[8],"d_top_right_opening_"+doorid,door_finish_id);
	  
	  }
  	if(document.getElementById("d_top_opening_"+doorid))
	{
	   draw_finish_image_french_door(doorventfinish[9],"d_top_opening_"+doorid,door_finish_id);
	  
	  }
	 	
}

function draw_finish_image_french_door(finish,id,window_finish_id)
{
var image="";
 
	switch(finish)
	{
	 case "2":gbar_draw_door(id,window_finish_id);
	 break;
	 case "3":sleading_draw_door(id);
	 break;
	 case "4":
	 document.getElementById(id).style.backgroundImage="url(images/windowpatrns/diamonlead.gif)";
	 
	 break;
	}
	
}

function position_french_door_handles(doorid)
{
//var pt_x=parseInt(getXY(document.getElementById('wgs'))[0],10);
	//var pt_y=parseInt(getXY(document.getElementById('wgs'))[1],10);
	var d; var sh=0;
	
	if(document.getElementById("td_handle_right_"+doorid))
	{ 
	
	 //if( isSafari ){ sh=document.getElementById('p_top_opening_'+doorid).clientHeight-20;}
	   
	 var handle_top=parseInt(getXY(document.getElementById('td_handle_right_'+doorid))[1],10);
	 var handle_left=parseInt(getXY(document.getElementById('td_handle_right_'+doorid))[0],10);
	// vent_top-=sh/2;
	 document.getElementById('d_handle_right_'+doorid).style.left=(handle_left-20)+"px";
	 document.getElementById('d_handle_right_'+doorid).style.top=(handle_top-10)+"px";
	 
	
	  }
	  
	  if(document.getElementById("td_handle_left_"+doorid))
	{ 
	
	 //if( isSafari ){ sh=document.getElementById('p_top_opening_'+doorid).clientHeight-20;}
	   
	 var handle_top=parseInt(getXY(document.getElementById('td_handle_left_'+doorid))[1],10);
	 var handle_left=parseInt(getXY(document.getElementById('td_handle_left_'+doorid))[0],10);
	// vent_top-=sh/2;
	 document.getElementById('d_handle_left_'+doorid).style.left=(handle_left-2)+"px";
	 document.getElementById('d_handle_left_'+doorid).style.top=(handle_top-10)+"px";
	 
	
	  }
	  
	  
}
//luke
function position_french_door_handles_luke(doorid)
{
	var path = "images/doors/handles/";
}
//luke
function position_french_door_glasses(doorid,doorventpatterns)
{
//var pt_x=parseInt(getXY(document.getElementById('wgs'))[0],10);
	//var pt_y=parseInt(getXY(document.getElementById('wgs'))[1],10);
	var d; var sh=0;
	
	if(document.getElementById("td_top_opening_"+doorid))
	{ 
	
	 if( isSafari ){ sh=document.getElementById('p_top_opening_'+doorid).clientHeight-20;}
	   
	 var vent_top=parseInt(getXY(document.getElementById('td_top_opening_'+doorid))[1],10)-10;
	 var vent_left=parseInt(getXY(document.getElementById('td_top_opening_'+doorid))[0],10)-10;
	 vent_top-=sh/2;
	 document.getElementById('p_top_opening_'+doorid).style.left=vent_left+"px";
	 document.getElementById('p_top_opening_'+doorid).style.top=vent_top+"px";
	 document.getElementById('img_top_opening_'+doorid).style.left="-10px";
	 document.getElementById('img_top_opening_'+doorid).style.top="-10px";
	 document.getElementById('d_top_opening_'+doorid).style.left="-10px";
	 document.getElementById('d_top_opening_'+doorid).style.top="-10px";
	 //document.getElementById('img_top_opening_'+doorid).src=ventpatterns[0];
	 document.getElementById('p_top_opening_'+doorid).style.height=(parseInt(document.getElementById('p_top_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('p_top_opening_'+doorid).style.width=(parseInt(document.getElementById('p_top_opening_'+doorid).clientWidth))+"px";
	  document.getElementById('d_top_opening_'+doorid).style.height=(parseInt(document.getElementById('d_top_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('d_top_opening_'+doorid).style.width=(parseInt(document.getElementById('d_top_opening_'+doorid).clientWidth))+"px";
	  }

  if(document.getElementById("td_top_left_opening_"+doorid))
	{ 
	
	 if( isSafari ){ sh=document.getElementById('p_top_left_opening_'+doorid).clientHeight-20;}
	   
	 var vent_top=parseInt(getXY(document.getElementById('td_top_left_opening_'+doorid))[1],10)-10;
	 var vent_left=parseInt(getXY(document.getElementById('td_top_left_opening_'+doorid))[0],10)-8;
	 vent_top-=sh/2;
	 document.getElementById('p_top_left_opening_'+doorid).style.left=vent_left+"px";
	 document.getElementById('p_top_left_opening_'+doorid).style.top=vent_top+"px";
	 document.getElementById('img_top_left_opening_'+doorid).style.left="-8px";
	 document.getElementById('img_top_left_opening_'+doorid).style.top="-10px";
	 document.getElementById('d_top_left_opening_'+doorid).style.left="-8px";
	 document.getElementById('d_top_left_opening_'+doorid).style.top="-10px";
	 //document.getElementById('img_top_left_opening_'+doorid).src=ventpatterns[0];
	document.getElementById('p_top_left_opening_'+doorid).style.height=(parseInt(document.getElementById('p_top_left_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('p_top_left_opening_'+doorid).style.width=(parseInt(document.getElementById('p_top_left_opening_'+doorid).clientWidth)-10)+"px";
	  document.getElementById('d_top_left_opening_'+doorid).style.height=(parseInt(document.getElementById('d_top_left_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('d_top_left_opening_'+doorid).style.width=(parseInt(document.getElementById('d_top_left_opening_'+doorid).clientWidth)-10)+"px";
	  }
	  
	  
	  if(document.getElementById("td_top_right_opening_"+doorid))
	{ 
	
	 if( isSafari ){ sh=document.getElementById('p_top_right_opening_'+doorid).clientHeight-20;}
	   
	 var vent_top=parseInt(getXY(document.getElementById('td_top_right_opening_'+doorid))[1],10)-10;
	 var vent_left=parseInt(getXY(document.getElementById('td_top_right_opening_'+doorid))[0],10)-6;
	 vent_top-=sh/2;
	 document.getElementById('p_top_right_opening_'+doorid).style.left=vent_left+"px";
	 document.getElementById('p_top_right_opening_'+doorid).style.top=vent_top+"px";
	 document.getElementById('img_top_right_opening_'+doorid).style.left="-6px";
	 document.getElementById('img_top_right_opening_'+doorid).style.top="-10px";
	 document.getElementById('d_top_right_opening_'+doorid).style.left="-6px";
	 document.getElementById('d_top_right_opening_'+doorid).style.top="-10px";
	 //document.getElementById('img_top_right_opening_'+doorid).src=ventpatterns[0];
	 document.getElementById('p_top_right_opening_'+doorid).style.height=(parseInt(document.getElementById('p_top_right_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('p_top_right_opening_'+doorid).style.width=(parseInt(document.getElementById('p_top_right_opening_'+doorid).clientWidth)-10)+"px";
	  document.getElementById('d_top_right_opening_'+doorid).style.height=(parseInt(document.getElementById('d_top_right_opening_'+doorid).clientHeight))+"px";
	 document.getElementById('d_top_right_opening_'+doorid).style.width=(parseInt(document.getElementById('d_top_right_opening_'+doorid).clientWidth)-10)+"px";
	  }
	  
	  if(document.getElementById("p_left_opening_"+doorid))
		{	
			document.getElementById('p_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[3]+")";
		}
	  if(document.getElementById("p_right_opening_"+doorid))
		{	
			document.getElementById('p_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[6]+")";
		}
		if(document.getElementById("p_bot_left_opening_"+doorid))
		{	
			document.getElementById('p_bot_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[4]+")";
		}
		if(document.getElementById("p_bot_right_opening_"+doorid))
		{	
			document.getElementById('p_bot_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[7]+")";
		}
		if(document.getElementById("p_top_opening_"+doorid))
		{	
			document.getElementById('p_top_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[9]+")";
		}
		if(document.getElementById("p_top_left_opening_"+doorid))
		{	
			document.getElementById('p_top_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[5]+")";
		}
		if(document.getElementById("p_top_right_opening_"+doorid))
		{	
			document.getElementById('p_top_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[8]+")";
		}
	  if(document.getElementById("p_slide_opening_"+doorid))
		{	
			document.getElementById('p_slide_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[10]+")";
		}
		if(document.getElementById("p_slide_left_opening_"+doorid))
		{	
			document.getElementById('p_slide_left_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[11]+")";
		}
		if(document.getElementById("p_slide_right_opening_"+doorid))
		{	
			document.getElementById('p_slide_right_opening_'+doorid).style.backgroundImage="url("+doorventpatterns[12]+")";
		}
	  
}
