window.onerror=null;
function bF(src, w, h) {

src="http://files.naturalgoodlife.com/print.php?url=" + src;
//alert(src)

  var winParam = 'scrollbars=yes, width=' + w + ', height=' + h + ', location=no, toolbar=no, directories=no, status=no ,menubar=no, resizable=no, screenX=0,screenY=0, top=0, left=0';    
   var wer = Math.random();
  wer = wer*10000;
  wer = Math.round(wer); 
  
  var name = 'nm' + wer;
  subs=window.open(src, name, winParam);

		  }  

function show_product_reviews(id){
	obj = Layer(id);
	if(obj.style.visibility=='hidden'){
		obj.style.visibility='visible';
		obj.style.position='static';
	}
	else{
		obj.style.visibility='hidden';
		obj.style.position='absolute';
		left:0;
		top:0;
	}
}

function show_c_layer(num){
		for(i=1;i<=4;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';
			}
			else{
				document.getElementById('hat' + i).className = 't26a1';
				document.getElementById('cont' + i).style.display='none';
			}
		}
		}
}

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

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

var Currtop='<div class=t6a1><b>Currently viewed items</b></div><table cellpadding=0 cellspacing=0 border=0 class=t7a1><tr>';

var Currbot='</tr></table>';

var CurrItema='<td><b>';
var CurrItemb='</b><br></td>';

var Currdiv='</tr><tr>';

var CurrItembc='<td><table align=center cellpadding=0 cellspacing=0 border=0 width=80><tr><th height=80>';
var CurrItembd='<br></th></tr></table><span class=col3>';
var CurrItembe='</span> &nbsp; &nbsp; &nbsp;';
var CurrIteme='<br><img width=1 height=5><br></td>';

    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('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('-||-');
            document.write(CurrItema);
            document.write(tempvall[0]);
            document.write(CurrItemb);
            }
        }
		document.write(Currdiv);
		for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            tempvall=GetCookie(ccc).split('-||-');
            document.write(CurrItembc);
            document.write(tempvall[1]);
			document.write(CurrItembd);
			document.write(tempvall[2]);
            document.write(CurrItembe);
			document.write(tempvall[3]);
            document.write(CurrIteme);
            }
        }
        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 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 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 (i=1;i<len;i++) {
optcheck=eval("optionvalue"+num+"[i]");
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;
            }
    }
}
return eval(optval);
}


function chprice(pr,num) {
if (Layer('pricetxt'+num)) {
		obj=Layer('pricetxt'+num);
		//obj2=eval("document.forms.multiorder.toppricetxt"+num)
		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.innerHTML='$'+pr;
		//obj2.value='$'+pr;
		}
}


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

