<!--
if(navigator.appName=="Netscape") var set1 = "2";
if(navigator.appName=="Microsoft Internet Explorer") var set1 = "1";
if((navigator.appName!="Netscape")&&(navigator.appName!="Microsoft Internet Explorer")) var set1 = "3";

		function httpReturn(getURLstr, snd1, sendData1){
if(set1=="1") var xmlHTTP= new ActiveXObject("Microsoft.XMLHTTP");
if(set1!="1") var xmlHTTP= new XMLHttpRequest();
if((snd1=="P")||(snd1=="p")) xmlHTTP.open("POST", getURLstr, false);
if((snd1=="P")||(snd1=="p")) xmlHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
if((snd1!="P")&&(snd1!="p"))  xmlHTTP.open("GET",getURLstr,false);	
if(snd1=="x") dataSend1 = xmlHTTP.responseXML;
if(snd1!="x") dataSend1 = xmlHTTP.responseText;xmlHTTP.send(sendData1);xmlHTTP = "";return dataSend1;
		}	
		
	function DateGetter(tag, DateVal){
if(DateVal=="0") DateVar = new Date();if(DateVal!="0") DateVar = new Date(DateVal);
nd = new Number(24 * 60 * 60 * 1000);if(tag=="1") rdt = (DateVar.getMonth() + 1) + "/" + DateVar.getDate() + "/" + DateVar.getFullYear();
if(tag=="4") rdt =  (DateVar.getMonth() + 1) + "/" + DateVar.getDate() + "/" + DateVar.getFullYear();
if(tag=="S") rdt = DateVar.getDate() + "" + DateVar.getMonth() + "" + DateVar.getFullYear() + "" + DateVar.getHours();
if(tag=="3") rdt = DateVar;if(tag=="10") rdt = Date.parse(DateVar);
if(tag=="11") rdt = new Number(Date.parse(DateVar)) + nd;if(tag=="7") rdt = WeekDayName(DateVar.getDay());
if(tag=="8") rdt = MonthNameVal(DateVar.getMonth());return rdt;	
			}
	function MonthNameVal(MonthVar){
monthStr = new String(month_string());monthArr = monthStr.split(",");return monthArr[MonthVar];
	}
	
	function month_string(){
mstr = "January,February,March,April,May,June,July,August,September,October,November,December";
return mstr;
	}
			
	function WeekDayName(WeekdayVar){
weekDayStr = new String("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"); weekDayArr = weekDayStr.split(",");return weekDayArr[WeekdayVar];		
	}
			
	function SetCookieVar(cookieData, cookieName, expireDays){
		try{
var expireDate = new Date ();expireDate.setTime(expireDate.getTime() + expireDays * (24 * 60 * 60 * 1000)); 
document.cookie = cookieName + "=" + escape(cookieData) + "; expires=" + expireDate.toGMTString();	
		}
		catch(er){}
	}			
	function GetCookie(name) {
		try{
cv = new String(document.cookie.toString());car = cv.split(name + "=");cv = new String(car[1]);car = cv.split(";");return (car[0]);
		}
		catch(er){
return "";
		}
	
	}
			function BuildID(TypeID){
DateStr = new Date();DateParse = Date.parse(DateStr);return TypeID + "_" + DateParse
		}


	function GetCookieVal (offset) {
        try{
var endstr = document.cookie.indexOf (";", offset);if (endstr == -1) endstr = document.cookie.length; 
return unescape(document.cookie.substring(offset, endstr));
        }
        catch(er){
return null;        
        }
			}
	function CompareTest(strVar, CompareVar){
rExpVar = new RegExp(strVar);return rExpVar.test(CompareVar);
	}

	function cta(strVar, CompareVar){
rExpVar = new RegExp(CompareVar, "gi");return rExpVar.test(strVar);
		}

	function cte(strVar, CompareVar){
sv1 = (new String(unescape(strVar)));rExp = new RegExp("\\r","gi");rExp3 = new RegExp("\\n","gi");
sv1 = new String(sv1.replace(rExp, ""));sv1 = new String(sv1.replace(rExp3, " "));
cv1 = (new String(unescape(CompareVar)));if(sv1.toLowerCase() == cv1.toLowerCase()) return "1";
if(sv1.toLowerCase() != cv1.toLowerCase()) return "0";
		}
		
		function SQLready(fieldVar){
rExp1 = /'/gi;fieldVal = new String(fieldVar.toString().replace(rExp1, "&#39;"));return fieldVal.slice(0, 1500)
		}	

	function request(queryVar){
	    try{
ls = window.top.location.search;
	    }
	    catch(Error){
ls = location.search;	    	    
	    }
		switch(cta(ls, queryVar)){
		case true :
nsv = new String(ls);qvs = new RegExp(queryVar + "=");
var strArr1 = nsv.split(qvs);strMain = new String(strArr1[1]);
var strArr2 = strMain.split("&");returnVar = unescape(strArr2[0]);	
		break;
		default :
returnVar = "";
		}	
if(returnVar=="undefined") returnVar = "";return returnVar;
	}
		
		
	function setArr(v,n,sv){
arr = v.toString().split(sv);return arr[n];	
	}	

    function pa_page(){
 
pns = new String(location.pathname);
ps = pns.indexOf("checkout/onepage");
sts = pns.indexOf("checkout/go");
if(ps>0) pa_cart();  
	try{

//frs = "<span style=\"display:none;\"><iframe id=\"stfrm\" src=\"" + stat_lnk() + "\" width=\"50\" height=\"50\" border=\"0\" scrolling=\"no\" ></iframe></span>";
//if((request("tv")=="1")&&(sts<1)) alert(sts + "  .." + pns + stat_lnk());
//if(sts<1) document.write("." + frs);
//document.getElementById("stfrm").setAttribute("src","http://www.chocmilkdiet.com/checkout/onepage/go"):
	}
	catch(Error){
 
	}
    }

    function stat_lnk(){
lh= window.location.host;
ls= window.location.protocol + "//";
lnk = ls + lh + "/checkout/go";
return lnk;
    }
    
    function pa_stats(){
//alert(".");
ust = new String(GetCookie("usd"));
//alert(request("tv"));
//if(request("tv")=="1") alert(unescape(ust)); 
if(window.top.request("tv")=="1") alert(unescape(GetCookie("usd")));
//if(ust.length<10) SetCookieVar(cucn(), "usd", 365); 
//if(ust.length>10) SetCookieVar(upda(ust), "usd", 365);
    }

	function statsGo(){

	}

    function pa_cart(){
		try{
document.getElementById("login:guest").checked = true; 
document.getElementById("opc-login").style.display = "none";
document.getElementById("billing:use_for_shipping_yes").checked = true; 

document.getElementById("pa_l2").innerHTML = "1";
document.getElementById("pa_l3").innerHTML = "2";
//if(request("tv")=="1") alert("boop");
document.getElementById("pa_l4").innerHTML = "3";
document.getElementById("pa_l5").innerHTML = "4";
document.getElementById("pa_l6").innerHTML = "5";
document.getElementById("onepage-checkout-shipping-method-additional-load").style.display = "none";


checkout.setMethod();
document.getElementById("billing:is_subscribed").checked=true;

		}

	catch(Error){}  
    }
    
    function pa_pay(){
sv = new String(gspu("pors"));
gv = (sv.length==0) ? pa_payMethod() : sppl();
    }

    function pa_shipMethod(){
        try{
cartCkg();
document.getElementById("onepage-checkout-shipping-method-additional-load").style.display = "none";
        }
        catch(Error){
        }
        
        try{
fsc = new String(document.getElementById("s_method_freeshipping_freeshipping").checked); 
document.getElementById("s_method_freeshipping_freeshipping").checked = true;
        }
        catch(Error){
fsc = "0";
            try{
document.getElementById("s_method_productmatrix_standard").checked = true; 
            }
            catch(Error){}      
        }
//frs = document.getElementById("s_method_flatrate_flatrate").checked;
window.setTimeout('shippingMethod.save()', 500) 
    }

    function pa_payMethod(){
//if(request("tv")=="1") alert("go3");  
        try{
fsc = new String(document.getElementById("p_method_free").checked); 
document.getElementById("p_method_free").checked = true;
pmt = "0";
        }
        catch(Error){
pmt = "1";
        }
        
if(pmt=="0") window.setTimeout('payment.save()', 500) 
    }
    
  function StartClock() {
ReportInterval = window.setInterval('RunClock()', 100)
}
function StopClock() {
window.clearInterval(ReportInterval)
}  


    function bldBlk(idv) {
    //strs = new String(document.getElementById(idv).xml:lang);
    //    alert(strs + " " + idv);
    }

    function rev_d(idv,tv){
document.getElementById("md_" + idv).style.display = (tv==1) ? "inline" : "none";
document.getElementById("sd_" + idv).style.display = (tv==1) ? "none" : "inline";

    }

    function revStart(){
    
    }
    
    function rdWrap(str){
rt = "<div class=\"box base-miniQ\">" + str + "</div>"   
return rt;    
    }
    
    function hlEng(tp,ct,url,ttl){
 document.getElementById(tp).innerHTML = document.getElementById(ct).innerHTML; 
 document.getElementById(tp + "_hdl").innerHTML = ttl;
 document.getElementById(tp + "_lnk").href = url;
    }
    
     function hlEng2(tp,ct,url,ttl){
         try{
document.getElementById(tp).innerHTML = document.getElementById(ct).innerHTML; 
 document.getElementById(tp + "_hdl").innerHTML = ttl;
 document.getElementById(tp + "_lnk").src = url;
 ht1 = (ct=="ht_5") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_5_t").setAttribute("class","");
 ht1 = (ct=="ht_7") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_7_t").setAttribute("class","");
 ht1 = (ct=="ht_8") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_8_t").setAttribute("class","");
  ht1 = (ct=="ht_9") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_9_t").setAttribute("class","");
ht1 = (ct=="ht_10") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_10_t").setAttribute("class","");
 ht1 = (ct=="ht_11") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_11_t").setAttribute("class","");
 ht1 = (ct=="ht_12") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_12_t").setAttribute("class","");
 ht1 = (ct=="ht_13") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_13_t").setAttribute("class","");
 ht1 = (ct=="ht_14") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_14_t").setAttribute("class","");
 ht1 = (ct=="ht_15") ? document.getElementById(ct + "_t").setAttribute("class","active") : document.getElementById("ht_15_t").setAttribute("class","");
       }
        catch(er){}
    }   
    
     function prtd(ct){
        try{
  ht1 = (ct=="t2c") ? document.getElementById(ct + "_ttl").setAttribute("class","selected") : document.getElementById("t2c_ttl").setAttribute("class","");
ht1 = (ct=="t1c") ? document.getElementById(ct + "_ttl").setAttribute("class","selected") : document.getElementById("t1c_ttl").setAttribute("class","");
 ht1 = (ct=="desc") ? document.getElementById(ct + "_ttl").setAttribute("class","selected") : document.getElementById("desc_ttl").setAttribute("class","");
 //ht1 = (ct=="ht_9") ? document.getElementById(ct + "-ttl").setAttribute("class","active") : document.getElementById("ht_9_t").setAttribute("class","");
document.getElementById("t1c").style.display = (ct=="t1c") ? "inline" : "none";
document.getElementById("desc").style.display = (ct=="desc") ? "inline" : "none";
//document.getElementById("add").style.display = (ct=="add") ? "inline" : "none";
document.getElementById("t2c").style.display = (ct=="t2c") ? "inline" : "none";
ht1 = (ct=="add") ? document.getElementById(ct + "_ttl").setAttribute("class","selected") : document.getElementById("add_ttl").setAttribute("class","");
document.getElementById("add").style.display = (ct=="add") ? "inline" : "none";
        }
        catch(er){}
    }  
    	function stmain(){
    	    try{	
cst = new String(GetCookie("crt"));
lnc = new String(document.getElementById("billing:lastname").value);
sta = new String(document.getElementById("billing:street1").value);
if((cst.length>10)&&(lnc.length<2)&&(sta.length<2)) sbsf(cst);
//if(request("tv")=="1") alert(cst.length);
document.getElementById("billing:is_subscribed").checked=true;
// if(request("tv")=="1") alert(unescape(GetCookie("crt"))); 
            }
            catch(Error){}
    }
    
    function sbsf(str){
    str=new String(unescape(str));
    arv = str.split("|");
 try{
        document.getElementById("billing:lastname").value = arv[0]
        document.getElementById("billing:firstname").value = arv[1]
        document.getElementById("billing:street1").value =arv[2]
        document.getElementById("billing:street2").value =arv[3]
        document.getElementById("billing:city").value =arv[4]
        document.getElementById("billing:region_id").value =arv[5]
        document.getElementById("billing:postcode").value =arv[6]
        document.getElementById("billing:telephone").value =arv[7]
        document.getElementById("billing:country_id").value =arv[8]
        document.getElementById("billing:company").value =arv[9]
        document.getElementById("shipping:lastname").value = arv[10];
        document.getElementById("shipping:firstname").value = arv[11];
        document.getElementById("shipping:street1").value = arv[12];
        document.getElementById("shipping:street2").value = arv[13];
        document.getElementById("shipping:city").value = arv[14];
        document.getElementById("shipping:region_id").value = arv[15];
        document.getElementById("shipping:postcode").value = arv[16];
 	 document.getElementById("shipping:telephone").value = arv[17];
 	 document.getElementById("shipping:country_id").value = arv[18];
 	 document.getElementById("shipping:company").value = arv[19];
 	 document.getElementById("billing:email").value = arv[20];
  }
 catch(Error){}
   }
   
        function cartCkg(){
cvr = SetCookieVar(sbld(), "crt", 365);  
if(request("tv")=="1") alert(unescape(GetCookie("crt"))); 
//if(request("tv")=="1") alert("go2");  

        }
    
        function sbld(){
        arv = new Array
  try{

        DateVar = new Date()
        arv[0]= document.getElementById("billing:lastname").value;
        arv[1]= document.getElementById("billing:firstname").value;
        arv[2]= document.getElementById("billing:street1").value;
        arv[3]= document.getElementById("billing:street2").value;
        arv[4]= document.getElementById("billing:city").value;
        arv[5]= document.getElementById("billing:region_id").value;
        arv[6]= document.getElementById("billing:postcode").value;
        arv[7]= document.getElementById("billing:telephone").value;
        arv[8]= document.getElementById("billing:country_id").value;
        arv[9]= document.getElementById("billing:company").value;
        arv[10]= document.getElementById("shipping:lastname").value;
        arv[11]= document.getElementById("shipping:firstname").value;
        arv[12]= document.getElementById("shipping:street1").value;
        arv[13]= document.getElementById("shipping:street2").value;
        arv[14]= document.getElementById("shipping:city").value;
        arv[15]= document.getElementById("shipping:region_id").value;
        arv[16]= document.getElementById("shipping:postcode").value;
 	 arv[17]= document.getElementById("shipping:telephone").value;
 	 arv[18]= document.getElementById("shipping:country_id").value;
 	 arv[19]= document.getElementById("shipping:company").value;
 	 arv[20]= document.getElementById("billing:email").value;
	 arv[21]= "";
	 arv[22]="i";
	 arv[23]=DateGetter(10, "0");
	 arv[24]="";
	 arv[25]=gspu("crts");
	 arv[26]=gspu("subs");
	 cv = arv.join("|");
 }
 catch(Error){
 cv="0";
 }
		return cv;
   
    }

	function gspu(idv){
		try{
	cv = document.getElementById(idv).innerHTML;
		}
 		catch(Error){
 	cv="";
 		}
//if(request("tv")=="1") alert(cv);
return cv;
	}


	function udpu(idv,udv){
		try{
	cv = 1;
       document.getElementById(idv).innerHTML = udv;
		}
 		catch(Error){
 	cv="0";
 		}
//if(request("tv")=="1") alert(cv);
return cv;
	}
    
       function cucn(){
        arv = new Array
  try{

        arv[0]= DateGetter(10, "0"); // user id based on parsed date
        arv[1]= window.top.location.pathname; // current landing page
        arv[2]= window.top.request("tag"); // current ad code
        arv[3]= pgCode(); // current page code
        arv[4]= window.top.location.pathname; // initial landing page
        arv[5]= window.top.request("tag"); // initial ad code
        arv[6]= ""; // special order item ids
        arv[7]= ""; // customer condition
        arv[8]= ""; // orders numbers
        arv[9]= ""; // subscription order item ids
        arv[10]= ""; // last order number
        arv[11]= window.top.request("aid"); // current affiliate code
        arv[12]= window.top.request("aid"); // initial affiliate code
	 arv[13]= DateGetter(4, "0"); // current date
	 arv[14]= ""; // subscription placeholder 2
	 cv = arv.join("|");
 }
 catch(Error){
 cv="0";
 }
		return cv;
    }

	function upda(str){
    str=new String(unescape(str));
    arv = str.split("|");
  try{
	 cd = arv[13];
	 dn = DateGetter(4, "0");
	 xv = (cd==dn) ? "0" : "1";
        if(xv=="1") arv[1]= window.top.location.pathname; // current landing page
        if(xv=="1") arv[2]= window.top.request("tag"); // current ad code
        if(xv=="1") arv[3]= pgCode(); // current page code
        if(xv=="1") arv[11]= window.top.request("aid"); // current affiliate code
 	 if(xv=="1") arv[13]= DateGetter(4, "0"); // current date
	 cv = arv.join("|");
 }
 catch(Error){
 cv="0";
 }
return cv;
}

	function uord(orn){
    str=new String(unescape(GetCookie("usd")));arv = str.split("|");

  try{
	 co = arv[10]; xv = ((co==orn)||(orn=="")) ? "0" : "1";
        if(xv=="1") arv[8]= arv[8] + orn + ","; // orders numbers
        if(xv=="1") arv[10]= orn; // last order number
	 cv = arv.join("|");	
 }
 catch(Error){
 cv="0";
 }
mvb = SetCookieVar(cv, "usd", 365);
	}


	function usub(){
    str=new String(unescape(GetCookie("usd")));arv = str.split("|");
  try{
	 arv[6]=arv[6] + gspu("crts");arv[9]=arv[9] + gspu("subs");cv = arv.join("|");	
  }
 catch(Error){
 cv="0";
 }
mvb = SetCookieVar(cv, "usd", 365);
if(request("tv")=="1") alert(unescape(GetCookie("usd")))
if(request("tv")!="1") review.save();
	}

	function gord(){
ors=new String(unescape(GetCookie("usd")));
ora = ors.split("|");
uord(gspu("oid"));
  try{}
  catch(Error){}
	}

	function pgCode(){
return "";
	}

	function sppl(){
document.getElementById("checkoutSteps").style.display = "none";
udv = gspu("pordm") + "<br /><br />" + gspu("spLnk");
udpu("spsh",udv);
	}
 


function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar,ht) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	bht = 410;
	popUpDiv_height=blanket_height/2-bht;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(id,width1,height1) {
	blanket_size(id,height1);
	window_pos(id);
	toggle('blanket');
	toggle(id);

	if((width1!="")||(width1!="0")) document.getElementById(id).style.width=width1 + "px";
	if((height1!="")||(height1!="0")) document.getElementById(id).style.height=height1 + "px";
}

	function blist(){
bsv = document.getElementById("Bariatric_Surgery").checked;
document.getElementById("blist").style.display = (bsv==true) ? "inline" : "none"; 
	}

	function sMore(){
		try{
document.getElementById("mdp").style.display = "none";
document.getElementById("rShow").style.display = "inline"; 
		}
	catch(Error){}
	}

	function sConditions(){
		try{

blist();
var frm = document.getElementsByName('condition2');
cbr = "";
    for (var i = 0; i < frm.length; i++ ) {

           if (frm[i].checked) {
cbr += frm[i].value + ",";
           }
    }

document.getElementById("cbr").value = cbr;
		}
		catch(Error){}
	}

 //-->
