
var Currtop = '<div class="rec-ttl"><span>RECENTLY VIEWED ITEMS</span></div><table class="rv"><!--line--><tr class=line1>';
var CurrItema = '<td><div class="tbg"><div class="p1" style="background-image: url(';
var CurrItemab = ')">';
var CurrItemb = '</div><div class="marg">';
var CurrItemc = '</div></div></td>';
var Currbot = '</tr></table>';

   function pasteRelated() {
	var items_count=6;
    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(ccc));
    if (Rell) {
        document.write(Currtop);
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            tempvall=GetCookie(ccc).split('-||-');
            document.write(CurrItema);
            document.write(tempvall[0]);
            document.write(CurrItemab);
            document.write(tempvall[1]);
            document.write(CurrItemb);
	        document.write(tempvall[2]);
            document.write(CurrItemc);
            }
        }
        document.write(Currbot);
        }
    } 


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){
//alert(num + "   " + activeLayer);
		for(i=1;i<=10;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';
			}
		}
		
}
}

var activeLayer = 1;

function over_c_layer(num){
		if(activeLayer != num){
			//document.getElementById('hat' + num).style.background = 'url(/i/t1e2.gif)';
		}
}

function out_c_layer(num){
			if(activeLayer != num){
				//document.getElementById('hat' + num).style.background = 'url(/i/t2e2.gif)';
			}
}


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

/*

    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]);
					}
				}
			}	
		}
	}
}	


/*function makeavailable(num,state) {
    obj=eval("document.forms.multiorder.vwquantity"+num)
    obj.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))
}*/
function chprice(pr,num) {
if (document.forms['multiorder'].pricetxt){	
obj=eval("document.forms.multiorder.pricetxt");
}

		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';
			}
if (document.forms['multiorder'].pricetxt){	
obj.value='$'+pr;
}
		
		
				if (document.forms['email-send']){	
			document.forms['email-send'].elements['totalPrice'].value = pr;
			}	
		
}
function calcoptions(num) {
var optval=0;
len=eval("optionvalue"+num+".length");
for (i=1;i<len;i++) {
optcheck=eval("optionvalue"+num+"[i]");
if (optcheck.indexOf('(+')!=-1) {
	tmp=optcheck.split('(+')[1].split(')')[0];
	(tmp.indexOf('$')!=-1)?tmp=tmp.split('$')[1]:'';
    optval=optval+eval(tmp);
    }
    else {
        if (optcheck.indexOf('(-')!=-1) {
			tmp=optcheck.split('(-')[1].split(')')[0];
			(tmp.indexOf('$')!=-1)?tmp=tmp.split('$')[1]:'';
            optval=optval+eval('-'+tmp);
			
            }
            else {
            optval=optval+0;
            }
    }
}
return eval(optval);
}
function updateall(num) {
var totalprice;
calcq(num);
((eval("optionvalue"+num).length>0)?(totalprice=eval("qtyvalue"+num)*(eval("ipr"+num)+calcoptions(num))):(totalprice=eval("qtyvalue"+num)*eval("ipr"+num)));
chprice(totalprice,num);
}
function calcq(num) {
obj=eval("ranges"+num);
for (var i=0;i<obj.length;i++) {
    q=eval("qtyvalue"+num);
    ((obj[i]['q']<=q)?(eval("ipr"+num+"=obj[i]['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 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);



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();

}