
function resizeF(){
	if(document.getElementById('layers_div') && document.getElementById('cont7')){
			if(document.getElementById('cont7').style.display='block'){
				set_pos();
		}
	}
}

function set_pos(){
	obj = document.getElementById('cont7');
	obj1 = document.getElementById('layers_div');
			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj1.offsetLeft;
		objTop    = obj1.offsetTop;
		objParent = obj1.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		obj.style.top = objTop+4;
		//alert(obj.style.top)
		obj.style.left = objLeft;
}

function show_c_layer(num){
if(num!=7 || num==7 && document.getElementById('cont7')){
		for(i=1;i<=7;i++){
		if(document.getElementById('hat' + i) && document.getElementById('cont' + i)){

		//alert(url2)
			if(i==num){
				document.getElementById('hat' + i).className = 't26a2';
				document.getElementById('cont' + i).style.display='block';
				activeLayer = num;
			}
			else{
				document.getElementById('hat' + i).className = 't26a1';
				document.getElementById('cont' + i).style.display='none';
			}
		}
		
	
		}
			if(num==7){
				set_pos();
			}
}
}

var activeLayer = 1;

function over_c_layer(num){
			
		if(document.getElementById('hat' + num)){
			if(document.getElementById('hat' + num).className == 't26a2'){
				activeLayer = num;
			}
			document.getElementById('hat' + num).className = 't26a3';
		}
}

function out_c_layer(){
		for(i=1;i<=6;i++){
		if(document.getElementById('hat' + i) && document.getElementById('cont' + i)){
		//alert(url2)
			if(i==activeLayer){
				document.getElementById('hat' + i).className = 't26a2';
			}
			else{
				document.getElementById('hat' + i).className = 't26a1';
			}
		}
		}
}

function first_layer_ini1(){
	for(i=1;i<=6;i++){
	if(document.getElementById('hat' + i) && document.getElementById('cont' + i)){
 		document.getElementById('hat' + i).className = 't26a2';
		document.getElementById('cont' + i).style.display='block'
		break;
		}
	}    
}

var Currtop = '<div class="t3a4th"><div><div>Recently Viewed Items</div></div></div><div style="border-bottom:1px solid #c9d6bc;margin-top:5px;width:804px;"><div style="border-top:1px solid #c9d6bc;"><table><tr valign=top>';
var separ1  = '<td width=160>';
var separ2  = '<td width=160 class=t2d8>';
var CurrItema = '<table width=99 class="t1d3" align="center" style="margin-top:8px"><tr><td height=99>';
var CurrItemb = '<br></td></tr></table><div class="marg3 fs11">';
var CurrItemc = '</div></td>';
var Currbot = '</tr></table></div></div><br>';

    function pasteRelated() {
	var items_count=5;
    var asd=0;
    var Rell=false;
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            Rell=true;
            asd=asd+1;
            }
        }
//  alert(GetCookie('rel_5'));
    if (Rell) {
		document.write(Currtop);
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            tempvall=GetCookie(ccc).split('-||-');
            if (i==1) document.write(separ1);
            else document.write(separ2);
            document.write(CurrItema);
            document.write(tempvall[0]);
            document.write(CurrItemb);
	    document.write(tempvall[1]);
            document.write(CurrItemc);
            }
        }
        document.write(Currbot);
        }
    } 


function addtorel() {
	var items_count=6;
    related[CurrItemId]=CurrItem;
	rel_itms = new Array();
	inarr = false;
    for (i=1;i<=items_count;i++) {
    	cc='rel_'+i;
		if (!GetCookie(cc)) {
    	    SetCookie(cc, related[CurrItemId]);
        	break;
		} else {
			 if (GetCookie(cc)==related[CurrItemId]){
				 break;
			} else {
				for (i=0;i<items_count;i++) {
					ncc='rel_'+(i+1);
					if (GetCookie(ncc)==related[CurrItemId]) inarr=true;
					if (GetCookie(ncc))	rel_itms[i] = GetCookie(ncc);
				}
				if (!inarr){
					if (rel_itms.length == items_count) {
						rel_itms.splice(items_count-1,1);
					}
					rel_itms.unshift(related[CurrItemId]);
					for (i=1;i<=items_count;i++) {
						scc='rel_'+i;
						if (rel_itms[i-1]) SetCookie(scc, rel_itms[i-1]);
					}
				}
			}	
		}
	}
}	


var savingArray = false;

function updateall(num) {
num=0;
var totalprice=0;
calcq(num);
qvSaving = 0;
((eval("optionvalue"+num).length>0)?(totalprice=eval("qtyvalue"+num)*(eval("ipr"+num)+calcoptions(num))):(totalprice=eval("qtyvalue"+num)*eval("ipr"+num)));
  if(savingArray){
	if(eval("qtyvalue"+num) < savingArray.length){
		qvSaving = savingArray[eval("qtyvalue"+num)]*eval("qtyvalue"+num)
	}
	else{
		qvSaving = savingArray[(savingArray.length - 1)]*eval("qtyvalue"+num)
	}
    totalprice = totalprice - qvSaving;
  }

chprice(totalprice,0); 
}


function calcq(num) {
obj=eval("ranges"+num);
for (var i in obj) {
    q=eval("qtyvalue"+num);
    ((obj[i]['q']<=q)?(eval("ipr"+num+"=obj[i]['pr']")):(''))
    }
} 



function calcoptions(num) {
var optval=0;
len=eval("optionvalue"+num+".length");
for (j=1;j<len;j++) {
optcheck=eval("optionvalue"+num+"["+j+"]");
if (optcheck.indexOf('+$')!=-1) {
    optval=optval+eval(optcheck.split('(+$')[1].split(')')[0]);
 }
 else {
        if (optcheck.indexOf('-$')!=-1) {
            optval=optval+eval('-'+optcheck.split('(-$')[1].split(')')[0]);
        }
        else {
            optval=optval+0;
        }
 }
//alert("optionvalue"+num+"["+i+"]"+optcheck+"optval="+optval); 
}
return eval(optval);
}


function chprice(pr,num) {

		//obj2=Layer('pricetxt0');
		pr=Math.round(pr*100)/100;
		if (pr.toString().indexOf('.')!=-1) {
			pr=pr.toString().substring(0,pr.toString().indexOf('.')+3);
			if (pr.toString().split('.')[1].length==1) pr=pr+'0';
			}else{
			pr=pr+'.00';
			}
			obj=document.forms.multiorder.pricetxt;
			obj.value='$'+pr;


		if (document.forms['email-send']){	

			document.forms['email-send'].elements['totalPrice'].value = pr;
			}			
			
}


function openDelivery() {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open('delivery-est.html', 'EnlargePicture','width=1000,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}


function makeavailable(num,state) {
    obj=eval("document.forms.multiorder.vwquantity"+num)
    obj.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))
    obj2=eval("document.forms.multiorder.vwitem"+num)
    obj2.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))

for(i=0;i<document.forms.multiorder.elements.length; i++){
obj3 = document.forms.multiorder.elements[i];

	if(obj3.name.indexOf('vwattr'+num)!=-1){
		    obj3.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))
	}

}
	
	//alert(document.forms.multiorder.elements.length)
	
}



function insertMore() {
if (moretxtvalue!='') {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo2 = new Object();
    MoreInfo2 = window.open('more_info.html', 'EnlargePicture2','HEIGHT=450,WIDTH=790,scrollbars=yes,resizable=yes,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
    MoreInfo2.document.write('<html><head><title>Devine Medical - Product more info</title></title><link href="http://site.factorydirectmarket.com/css/main.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff" marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" link="#003399" vlink="#003399" alink="#003399"><table width="769" align="center" style="border-left:1px solid #a8a8a8;border-right:1px solid #a8a8a8"><tr><td class="t1a1 fs15 bd co1" height="74"><img src="http://site.factorydirectmarket.com/i/emaillogo.jpg" width="769" height="80"><br></td></tr></table><table width="769" align="center" style="border:1px solid #255B97"><tr valign="top"><td><table border="0" cellpadding="0" cellspacing="0" width="769" bgcolor="#255B97"><tr><td height="30"><div class="al1 bd co1 fs15"><img src="http://site.factorydirectmarket.com/i/ar5.gif" width="11" height="6" alt="" border="0" hspace="8">'+moretxttitle+'<img src="http://site.factorydirectmarket.com/i/ar5.gif" width="11" height="6" alt="" border="0" hspace="8"></div></td></tr></table>	<table width="100%"><tr> <td height="248" valign="top"><table width="95%" align="center"><tr>   <td><br>'+moretxtvalue+'<br><br></td>    </tr>    </table>		</td>	    </tr>    </table></td></tr></table>');
    }
else {
    alert('Your browser settings not allow to run scripts or version of your browser is old.');
    }
}


function getEmailQuote() {
formObj = document.forms.multiorder;
sFormObj = document.forms['email-send'];
    sFormObj.elements['mailOptions'].value='';
	for(i=0;i<formObj.elements.length;i++){
		if (formObj.elements[i].checked){
		sValue = formObj.elements[i].value + "";
		sValue = sValue.replace(" ","_nbsp_");
		sValue = sValue.replace("“","_quot1_");
		sName = formObj.elements[i].name + "";
		sName = sName.replace(" ","_nbsp_");
		sFormObj.elements['mailOptions'].value += '&' + sName + '=' + sValue;
		
		}
	}
	
	sFormObj.elements['mailQty'].value = formObj.vwquantity0.value;
	updateall('0');

	
}

function submitEQ(dlocat) {
	formObj = document.forms.multiorder;
	formObj.vwquantity0.value = dlocat.substring(dlocat.indexOf('?')+5,dlocat.indexOf('&'));
	dlocat = dlocat.substring(dlocat.indexOf('&')+1,dlocat.length);

//http://divine.amerika/dop3.html?itq=2&vwattr0_Seat_nbsp_Width=14_quot1_&vwattr0_Seat_nbsp_Depth=13_quot1_&

while(dlocat.indexOf('vwattr0')!=-1){
	sName = dlocat.substring(dlocat.indexOf('vwattr0'),dlocat.indexOf('='));
	sName = sName.replace("_nbsp_"," ");

	sValue = dlocat.substring(dlocat.indexOf('=')+1,dlocat.indexOf('&'));
	sValue = sValue.replace("_nbsp_"," ");
	sValue = sValue.replace("_quot1_","“");
	for(i=0;i<formObj.elements.length;i++){

		if (formObj.elements[i].name + "" == sName && formObj.elements[i].value + "" ==  sValue){
				formObj.elements[i].checked=true;
		}
	}
		
	dlocat = dlocat.substring(dlocat.indexOf('vwattr0')+1,dlocat.length);
	dlocat = dlocat.substring(dlocat.indexOf('vwattr0'),dlocat.length);
}

formObj.submit();

}