var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)return data[i].identity;}else if(dataProp)return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};var wantitall_string="";
function urlencode(str){str=(str+'').toString();return encodeURIComponent(str).replace(/!/g,'%21').replace(/'/g,'%27').replace(/\(/g,'%28').replace(/\)/g,'%29').replace(/\*/g,'%2A').replace(/%20/g,'+').replace('%2F',' ');}
function c_s(o,b){o.style.background="#"+b;}
function getAds(){document.getElementById("showAd").innerHTML=document.getElementById("execAd").innerHTML;}
function cpo(myObj){var Value=myObj[myObj.selectedIndex].value;document.location=Value;}
function rp(Expression){var MatchString='page--';MatchString=MatchString.toLowerCase();var StartPos=Expression.toLowerCase().indexOf(MatchString);if(StartPos>-1){var BasePart1;var BasePart2='';var EndPos=Expression.indexOf('/',StartPos);if(EndPos==-1){EndPos=Expression.length;}BasePart1=Expression.substr(0,StartPos);if(EndPos>-1){BasePart2=Expression.substr(EndPos+1,Expression.length);}if(BasePart2=='/'){BasePart2='';}Expression=BasePart1+BasePart2;}return(Expression);}
function ajax_update_prices(id_string,decimals){if(!decimals){decimals=0;}path="/includes/wantitall_prices.php?decimals="+decimals+"&id_string="+escape(id_string);wantitall_string=id_string;load_wia(path);}
function load_wia(path){var uniqueid=new Date().getTime();var xmlhttp=createXMLHttp();xmlhttp.onreadystatechange=function(){wia_stateChanged(xmlhttp);};xmlhttp.open("GET",path,true);xmlhttp.send(null);}
function createXMLHttp(){var myobj;try{myobj=new ActiveXObject("Msxml2.XMLHTTP.4.0");}catch(ex){try{myobj=new ActiveXObject("Msxml2.XMLHTTP.3.0");}catch(ex){try{myobj=new ActiveXObject("Msxml2.XMLHTTP");}catch(ex){try{myobj=new ActiveXObject("Microsoft.XMLHTTP");}catch(ex){try{myobj=new XMLHttpRequest();}catch(ex){myobj=false;alert("Could not load XMLHTTP component");}}}}}return myobj;}
function wia_stateChanged(xmlhttp){if(xmlhttp.readyState!=4){return;}if(xmlhttp.readyState==4&&xmlhttp.status==200){var res=xmlhttp.responseText+"";if(res.length>0){arr=res.split("\n");for(x in arr){if(arr[x].indexOf("=")>-1){var id=arr[x].substring(0,arr[x].indexOf("="));var price=arr[x].substring(arr[x].indexOf("=")+1);obj=document.getElementById("price_"+id);if(obj){obj.innerHTML=price;}else{}}}}if(wantitall_string.length>0){arr=wantitall_string.split("~");for(x in arr){tt=arr[x].split("==");obj=document.getElementById("price_"+tt[0]);if(obj){if(obj.innerHTML.indexOf("price_loader")>-1){obj.innerHTML="";}}}}}}
function gscm(objname,pm_id,type){document.getElementById(objname).style.display="block";var path="/processing/share.php?product_master_id="+pm_id;lc2(path,objname,type,pm_id);}
function lc2(path,var_obj,type,product_id){var uniqueid=new Date().getTime();path=path+"&ts="+uniqueid;var xmlhttp2=createXMLHttp();xmlhttp2.onreadystatechange=function(){sc2(xmlhttp2,var_obj,type,product_id);};xmlhttp2.open("GET",path,true);xmlhttp2.send(null);}
function sc2(xmlhttp2,var_obj,type,item_id)
{if(xmlhttp2.readyState!=4)return;if(xmlhttp2.readyState==4&&xmlhttp2.status==200)
{obj=document.getElementById(var_obj);obj.innerHTML=xmlhttp2.responseText;if(var_obj=="elp_3")
{if(type==0){obj.className='ibal fr b';}
else
{obj.className='ibal fr b t_lgrey';}}
if(var_obj=="elp_2"){document.getElementById("elp_1").className='ibal fr b t_lgrey';document.getElementById("elp_1").innerHTML='<div id="el_1" class="sp ibhui iimg" onmouseover="iba(1,1,1);" onmouseout="iba(1,0,1);" onclick="sld(\'elp_1\','+item_id+',1);"><!----></div>Like';}
if(var_obj=="elp_1"){document.getElementById("elp_2").className='ibal fr b t_lgrey';document.getElementById("elp_2").innerHTML='<div id="el_2" class="sp ibhdi iimg" onmouseover="iba(2,1,1);" onmouseout="iba(2,0,1);" onclick="sld(\'elp_2\','+item_id+',-1);"><!----></div>Dislike';}
if(var_obj=="els_3"){obj.className='ibal fr b';}
if(var_obj=="els_2"){document.getElementById("els_1").className='ibal fr b t_lgrey';document.getElementById("els_1").innerHTML='<div id="el_1" class="sp ibhui iimg" onmouseover="iba(1,1,2);" onmouseout="iba(1,0,2);" onclick="stld(\'els_1\','+item_id+',1);"><!----></div>Like';}
if(var_obj=="els_1"){document.getElementById("els_2").className='ibal fr b t_lgrey';document.getElementById("els_2").innerHTML='<div id="el_2" class="sp ibhdi iimg" onmouseover="iba(2,1,2);" onmouseout="iba(2,0,2);" onclick="stld(\'els_2\','+item_id+',-1);"><!----></div>Dislike';}}}
function hscm(objname){document.getElementById(objname).style.display="none";}
function sscm(objname){document.getElementById(objname).style.display="block";}
function checkActionHash()
{switch(window.location.hash)
{case"#write_review":showProductReviewBox();break;case"#price_alert":sam('elp_3',document.getElementById("master_id").value,0);break;case"#like":sld('elp_1',document.getElementById("master_id").value,1);break;case"#dislike":sld('elp_2',document.getElementById("master_id").value,-1);break;case"#write_comment":document.getElementById("ctxt").focus();break;case"#slike":stld('els_1',document.getElementById("sID").value,1);break;case"#sdislike":stld('els_1',document.getElementById("sID").value,1);break;}}
function comdel(cid,ref,pg)
{if(pg==1){Path="/processing/compare_comments_process.php";}
if(pg==2){Path="/processing/store_comments_process.php";}
RequestData="cid="+cid+"&prID=2"+"&ref="+ref;var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);window.location=xmlhttp.responseText;}
function spa()
{if(document.getElementById("papub").style.display=="none")
{document.getElementById("paErr").innerHTML="";document.getElementById("papub").style.display="block";document.getElementById("eml4R5").focus();}
else
{document.getElementById("papub").style.display="none";}}
function pap(objname,product_master_id,type)
{if(document.getElementById("eml4R5").value!=""&&IsEmail(document.getElementById("eml4R5").value))
{sam(objname,product_master_id,type,document.getElementById("eml4R5").value);document.getElementById("papub").style.display="none";}
else
{document.getElementById("paErr").innerHTML="<span class='ml_10'>Invalid e-mail address</span>";document.getElementById("eml4R5").focus();}}
function sam(objname,product_master_id,type,eml)
{if(!eml){eml="";}
var path="/processing/set_alert_process.php?product_master_id="+product_master_id+"&type="+type+"&eml="+eml;lc2(path,objname,type,product_master_id);}
function sld(objname,product_master_id,type)
{var path="/processing/like_dislike_process.php?product_master_id="+product_master_id+"&type="+type;lc2(path,objname,type,product_master_id);}
function stld(objname,store_id,type)
{var path="/processing/store_like_dislike_process.php?sID="+store_id+"&type="+type;lc2(path,objname,type,store_id);}
function gsem(objname,product_master_id,type){document.getElementById(objname).style.display="none";var completeURL="/products/tell_a_friend.php?product_master_id="+product_master_id;var popupWidth=600;var popupHeight=260;var screenW=screen.width;var screenH=screen.height;var xpos=((screenW/2)-(popupWidth/2));var ypos=((screenH/2)-(popupHeight/2));x=window.open(completeURL,'email_window','left='+xpos+',top='+ypos+',width='+popupWidth+',height='+popupHeight+',toolbar=0,resizable=0,scrollbars=0');}
var current_offer_order = "f";
var showing_more_offers = 0;
function load_offers(product_master_id,order){

    if(showing_more_offers == 1){
        $("#addition_offers").hide();
        var path="/products/ajax_offers.php?all=1&product_master_id="+product_master_id+"&order="+order;
    }else{
        var path="/products/ajax_offers.php?product_master_id="+product_master_id+"&order="+order;
    }


    if(order == "f"){

        $("#sort_p").css("font-size", "12px");
        $("#sort_p").css("font-weight", "normal");
        
        $("#sort_f").css("font-size", "14px");
        $("#sort_f").css("font-weight", "bold");

    
    }else{
        $("#sort_p").css("font-size", "14px");
        $("#sort_p").css("font-weight", "bold");
        
        $("#sort_f").css("font-size", "12px");
        $("#sort_f").css("font-weight", "normal");
    }
    
    if(showing_more_offers == 0){
        $("#additional_offers_link").hide();
    }

    $("#loading_offers").show();
    //$("#o_c").hide();

    $.ajax({
	  type: "GET",
	  url: path,
	  cache: false,
	  success: function(html){
	    current_offer_order = order;
		$("#o_c").html(html);
        $("#loading_offers").hide();
        //$("#o_c").show();
        if(showing_more_offers == 0){
            $("#additional_offers_link").show();
        }
	  }
	});	

}

function load_more_offers(product_master_id){

    var path="/products/ajax_offers.php?more=1&product_master_id="+product_master_id+"&order="+current_offer_order;

    $("#additional_offers_link").hide();
    $("#loading_offers").show();

    $.ajax({
	  type: "GET",
	  url: path,
	  cache: false,
	  success: function(html){
	    showing_more_offers = 1;
	    
		$("#addition_offers").html(html);
        $("#loading_offers").hide();
	  }
	});	
    

}


function offers_changed(xmlhttp_offers){if(xmlhttp_offers.readyState!=4)return;if(xmlhttp_offers.readyState==4&&xmlhttp_offers.status==200){var offers=document.getElementById("o_c");offers.innerHTML=xmlhttp_offers.responseText;}}
function sR(starGroup,starNo,starType){document.getElementById("starRating_"+starGroup).value=starNo;rR(starGroup,document.getElementById("starRating_"+starGroup).value,starType);}
function rR(starGroup,starNo,starType){var x;var y;var clActive="";var clInActive="";if(starType==1){clActive="sp rv_sa fl";clInActive="sp rv_si fl";}if(starType==2){clActive="rsp rv_ta fl";clInActive="rsp rv_ti fl";}for(x=1;x<=starNo;x++){document.getElementById("s_"+starGroup+"_"+x).className=clActive;}for(y=5;y>starNo;y--){document.getElementById("s_"+starGroup+"_"+y).className=clInActive;}starNo=parseInt(starNo);switch(starNo){case 0:document.getElementById("rT_"+starGroup).innerHTML="";break;case 1:document.getElementById("rT_"+starGroup).innerHTML="Very bad";break;case 2:document.getElementById("rT_"+starGroup).innerHTML="Bad";break;case 3:document.getElementById("rT_"+starGroup).innerHTML="Good";break;case 4:document.getElementById("rT_"+starGroup).innerHTML="Very good";break;case 5:document.getElementById("rT_"+starGroup).innerHTML="Excellent";break;}}
function rRR(starGroup,starNo,starType){rR(starGroup,document.getElementById("starRating_"+starGroup).value,starType);}
function srb(signedIn,ease,avail,time,care,starType,varobj){if(!signedIn){varobj.href="/members/sign_in.php?ref=rate_store";}else{var boxstate=document.getElementById("divRating").style.display;if(boxstate=="none"){document.getElementById("divRating").style.display="block";sR(1,ease,starType);sR(2,avail,starType);sR(3,time,starType);sR(4,care,starType);}if(boxstate=="block"){document.getElementById("divRating").style.display="none";}}return false;}
function srv(){var radioValue="";for(i=0;i<document.frmReview.reviewRecommend.length;i++){if(document.frmReview.reviewRecommend[i].checked==true){radioValue=document.frmReview.reviewRecommend[i].value;}}var Score1=document.getElementById("starRating_1").value;var Score2=document.getElementById("starRating_2").value;var Score3=document.getElementById("starRating_3").value;var Score4=document.getElementById("starRating_4").value;if(radioValue!=""){var rURL=window.location.href;var hashLocation=0;hashLocation=rURL.indexOf('#');if(hashLocation>0){rURL=rURL.substring(0,hashLocation);}RequestData="StoreID="+document.getElementById("reviewStoreID").value+"&ease="+Score1+"&avail="+Score2+"&deliver="+Score3+"&care="+Score4+"&recomm="+radioValue;Path="/processing/save_review.php";var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);if(xmlhttp.responseText=="success"){alert("Thanks. Your review was successfully submitted.");window.location=rURL;}else{alert("An error occurred. Please retry submitting your review.")}}else{alert("Would you recommend this store?");}}
function checkStoreRateHash(signedIn,ease,avail,time,care,starType){switch(window.location.hash){case"#rate_store":srb(signedIn,ease,avail,time,care,starType,null);break;}}
function spr()
{if(document.getElementById("ctxt").value.length<2)
{document.getElementById("comerr").innerHTML="Comment too short.";}
else
{document.getElementById("btncmt").disabled=true;document.frmComment.submit();}}
function repo(mid,pid,ref,element)
{RequestData="mid="+mid+"&pid="+pid+"&ref="+ref;Path="/processing/offer_report_process.php";var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);if(xmlhttp.responseText=="success")
{document.getElementById("tooltext_2").innerHTML="Thank You";}
else
{if(xmlhttp.responseText.substr(0,4)=="http")
{window.location=xmlhttp.responseText;}
else
{alert("An error occurred. Please try again.");}}}
function repc(cid,ref,pg)
{if(pg==1){Path="/processing/compare_comments_process.php";}
if(pg==2){Path="/processing/store_comments_process.php";}
RequestData="cid="+cid+"&prID=3"+"&ref="+ref;var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);if(xmlhttp.responseText=="success"){document.getElementById("crep_"+cid).innerHTML="<span class='cred b'>Reported</span>";}else{alert("An error occurred. Please try again.");}}
function sfr(id){if(document.getElementById("show_review_option_"+id).innerHTML=="Read full review"){document.getElementById("show_review_option_"+id).innerHTML="Hide full review";document.getElementById("review_"+id).style.height="auto";}else{document.getElementById("show_review_option_"+id).innerHTML="Read full review";document.getElementById("review_"+id).style.height="45px";}}
function iml(MaxLen){if(document.getElementById("ctxt").value.length>=MaxLen){document.getElementById("comerr").innerHTML=MaxLen+" characters only.";document.getElementById("ctxt").value=document.getElementById("ctxt").value.substr(0,MaxLen+1);}}
function ChangePriceFilter(allowed_min,allowed_max){var min_price=document.frmPriceFilter.price_min.value;var max_price=document.frmPriceFilter.price_max.value;var Error=0;if(!IsNumber(min_price)){Error=2}else if(!IsNumber(max_price)){Error=3}else{if(min_price*1>=max_price*1){Error=4}if(min_price<allowed_min){if(max_price<allowed_min){Error=1;}}if(min_price>allowed_max){Error=1;}}if(Error==1){min_price=allowed_min;max_price=allowed_max;}if(Error>=2){ErrMsg="There was a problem with your Price Range filter\n\n";ErrMsg=ErrMsg+"Please make sure that you only enter numeric values\n";ErrMsg=ErrMsg+"and that the minimum value is less than the maximum value\n";alert(ErrMsg);}else{var BaseURL=document.location+'';var MatchString='pricerange--';MatchString=MatchString.toLowerCase();var StartPos=BaseURL.toLowerCase().indexOf(MatchString);if(StartPos>-1){var BasePart1;var BasePart2='';var EndPos=BaseURL.indexOf('/',StartPos);BasePart1=BaseURL.substr(0,StartPos);if(EndPos>-1){BasePart2=BaseURL.substr(EndPos+1,BaseURL.length)}if(BasePart2=='/'){BasePart2='';}BaseURL=BasePart1+BasePart2;}if(BaseURL.length-1!=BaseURL.lastIndexOf('/')){BaseURL=BaseURL+'/';}if(min_price<0){min_price=0;}BaseURL=BaseURL+'pricerange--'+Math.round(min_price)+'-'+Math.round(max_price)+'/';BaseURL=rp(BaseURL);BaseURL=BaseURL.replace("co.za/categories/","co.za/browse/");BaseURL=BaseURL.replace("co.za/search/","co.za/browse/search/");document.location=BaseURL;}return false;}function IsNumber(strField){var strValidChar=".)-(,+1234567890";var strChar;var BooleanResult=true;if(strField.length==0)return false;for(i=0;i<strField.length&&BooleanResult==true;i++){strChar=strField.charAt(i);if(strValidChar.indexOf(strChar)==-1){BooleanResult=false;}}return BooleanResult;}function reportReview(rid){var psrc=window.location.href;RequestData="rid="+rid+"&psrc="+psrc;Path="/products/report_review_process.php";var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);if(xmlhttp.responseText=="success"){alert("Thank you for reporting abuse.");}else{alert("An error occurred. Please retry reporting the review.");}}
function catsearch(varObj){if(varObj.qwe123.value==""&&varObj.asd123.value==""&&varObj.zxc123.value==""){return;}else{search_string="";if(varObj.qwe123.value!=""){search_string=search_string+varObj.qwe123.value;}if(varObj.asd123.value!=""){search_string=search_string+" "+varObj.asd123.value;}if(varObj.zxc123.value!=""){search_string=search_string+" "+varObj.zxc123.value;}varObj.q.value=search_string;zsubmit_search(varObj);}}
function signup(){if(document.getElementById("storeName1AbC").value!=""){if(document.getElementById("storeURL2CdE").value!=""&&document.getElementById("storeURL2CdE").value.indexOf('http://')!=-1&&document.getElementById("storeURL2CdE").value.length>10){if(document.getElementById("storeContact5LmN").value!=""){if(document.getElementById("storeContact7RsT").value!=""&&document.getElementById("storeContact7RsT").value.length>=7){if(document.getElementById("storeEmail8UvW").value!=""&&IsEmail(document.getElementById("storeEmail8UvW").value)){document.getElementById("signupButtonDv6000Q1").disabled=true;document.frmSignup.submit();}else{document.getElementById("errorMsgP3O4U7").innerHTML="Invalid Email Address.";document.getElementById("storeEmail8UvW").focus();}}else{document.getElementById("errorMsgP3O4U7").innerHTML="Invalid Phone Number.";document.getElementById("storeContact7RsT").focus();}}else{document.getElementById("errorMsgP3O4U7").innerHTML="Invalid Contact Person.";document.getElementById("storeContact5LmN").focus();}}else{document.getElementById("errorMsgP3O4U7").innerHTML="Invalid Website Address.";document.getElementById("storeURL2CdE").focus();}}else{document.getElementById("errorMsgP3O4U7").innerHTML="Invalid Store Name.";document.getElementById("storeName1AbC").focus();}}
function IsEmail(Expression){if(Expression==null)return(false);var supported=0;if(window.RegExp){var tempStr="a";var tempReg=new RegExp(tempStr);if(tempReg.test(tempStr))supported=1;}if(!supported)return(Expression.indexOf(".")>2)&&(Expression.indexOf("@")>0);var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");var r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,5}|[0-9]{1,3})(\\]?)$");return(!r1.test(Expression)&&r2.test(Expression));}
function copt(cOption){document.getElementById("cs_1").style.display="none";document.getElementById("cs_2").style.display="none";document.getElementById("cs_3").style.display="none";document.getElementById("cs_4").style.display="none";document.getElementById("csf").style.display="none";switch(cOption.value){case"0":break;case"1":document.getElementById("cs_1").style.display="block";document.getElementById("csf").style.display="block";break;case"2":document.getElementById("cs_2").style.display="block";document.getElementById("csf").style.display="block";break;case"3":document.getElementById("cs_3").style.display="block";document.getElementById("csf").style.display="block";break;case"4":document.getElementById("cs_4").style.display="block";break;default:document.getElementById("csf").style.display="block";break;}}
function cJump(){if(document.getElementById("nameqw12").value!=""){if(document.getElementById("emailer23").value!=""&&IsEmail(document.getElementById("emailer23").value)){if(document.getElementById("msgui45").value!="")
{Path="/general/contact-us-process.php";RequestData="nameqw12="+escape(document.getElementById("nameqw12").value)+"&emailer23="+escape(document.getElementById("emailer23").value)+"&telty34="+escape(document.getElementById("telty34").value)+"&msgui45="+document.getElementById("msgui45").value;var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);if(xmlhttp.responseText!="")
{document.getElementById("csf").innerHTML=xmlhttp.responseText;}}else{alert("Please supply your message.");}}else{alert("Please supply a valid e-mail address.");}}else{alert("Please supply your name.");}}
function ship(element,offset,ctent,inst,pos,sid)
{Path="/processing/store_shipping_process.php"
RequestData="sid="+sid;var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);stt(element,offset,xmlhttp.responseText,inst,pos);}
function stt(element,offset,ctent,inst,pos)
{var tooltext=document.getElementById("tooltext_"+inst);var tooltip=document.getElementById("ttip_"+inst);var content=document.getElementById("origtext_"+inst).value;if(element.height&&element.width)
{tooltip.style.top=element.offsetTop+element.height+offset+"px";tooltip.style.left=element.offsetLeft+(element.width/8)+"px";}
else
{tooltip.style.top=element.offsetTop+offset+"px";tooltip.style.left=element.offsetLeft+"px";}
var state=tooltip.style.display;if(state=='none'||state=='')
{switch(pos)
{case"pr":tooltext.innerHTML=ctent+content;break;case"po":tooltext.innerHTML=content+ctent;break;case"no":tooltext.innerHTML=content;break;default:tooltext.innerHTML=ctent;break;}
tooltip.style.display="table-cell";}
if(state=='table-cell'){tooltip.style.display="none";}}
function smb(obj_name,hobj,default_height){var obj=document.getElementById(obj_name);if(obj.style.height!="auto"){obj.style.height="auto";document.getElementById(hobj).innerHTML="Show Less";}else{obj.style.height=default_height+"px";document.getElementById(hobj).innerHTML="Show More";}}
function iba(el,state,page)
{if(state==1)
{switch(el)
{case 1:document.getElementById("el_"+el).className='sp ibhua iimg';break;case 2:document.getElementById("el_"+el).className='sp ibhda iimg';break;case 3:document.getElementById("el_"+el).className='sp ibca iimg';break;case 4:document.getElementById("el_"+el).className='sp ibsa iimg';break;}
if(page==1){document.getElementById("elp_"+el).className='ibal fr b';}
if(page==2){document.getElementById("els_"+el).className='ibal fr b';}}
if(state==0)
{switch(el)
{case 1:document.getElementById("el_"+el).className='sp ibhui iimg';break;case 2:document.getElementById("el_"+el).className='sp ibhdi iimg';break;case 3:document.getElementById("el_"+el).className='sp ibci iimg';break;case 4:document.getElementById("el_"+el).className='sp ibsi iimg';break;}
if(page==1){document.getElementById("elp_"+el).className='ibal fr b t_lgrey';}
if(page==2){document.getElementById("els_"+el).className='ibal fr b t_lgrey';}}}
function rib(ref)
{window.location="/members/sign_in.php?ref="+ref;}
function insu()
{var obj=document.getElementById("frm_insurance");var msg="";if(obj.title[obj.title.selectedIndex].value==""){msg=msg+"* Please select a title\n";}
if(obj.first_name.value.length<=3){msg=msg+"* Please enter a valid First Name\n";}
if(obj.last_name.value.length<=3){msg=msg+"* Please enter a valid Last Name\n";}
if(obj.id_number.value.length<13){msg=msg+"* Please enter a valid ID Number\n";}
if(obj.cell_number.value.length<10){msg=msg+"* Please enter a valid Cell Number\n";}
if(obj.email.value.length<3){msg=msg+"* Please enter a valid Email Address\n";}else{if(!IsEmail(obj.email.value)){msg=msg+"* Please enter a valid Email Address\n";}}
if(msg!=""){alert("There was a problem with your details:\n\n"+msg+"\nPlease correct the above mentioned fields and re-submit your form");}else{obj.quote_btn.value="Loading...";obj.quote_btn.disabled=true;Path="/processing/insurance_process.php"
RequestData="t="+obj.title[obj.title.selectedIndex].value+"&fn="+escape(obj.first_name.value)+"&ln="+escape(obj.last_name.value)+"&id="+escape(obj.id_number.value)+"&cn="+escape(obj.cell_number.value)+"&em="+escape(obj.email.value);var xmlhttp=createXMLHttp();xmlhttp.open("POST",Path,false);xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(RequestData);document.getElementById("inscon").innerHTML=xmlhttp.responseText;}}
function tellf(){var obj=document.getElementById("tellff");var url="/products/tell_a_friend_process.php?product_master_id="+escape(obj.product_master_id.value)+"&name="+escape(obj.name.value)+"&email="+escape(obj.email.value)+"&f_name="+escape(obj.f_name.value)+"&f_email="+escape(obj.f_email.value)+"&message="+escape(obj.message.value);var err="";if(!IsEmail(obj.email.value))
err+="* Invalid Email Address\n";if(obj.name.value.length<=2)
err+="* Invalid Name\n";if(!IsEmail(obj.f_email.value))
err+="* Invalid Friend's Email Address\n";if(obj.f_name.value.length<=2)
err+="* Invalid Friend's Name\n";if(err.length>0){alert("There was a problem processing your request:\n\n"+err);}else{window.location=url;}}
function store_search(varObj){var s="";var ss="";if(varObj.q){s=urlencode(varObj.q.value.toLowerCase().replace(/^\s+|\s+$/g,""));}else{location.href=location.href;}if(varObj.store){ss=urlencode(varObj.store.value.toLowerCase().replace(/^\s+|\s+$/g,""))}if(s.length<1){location.href="/";}search_string="/browse/search/"+s+"/"+"store--"+ss;location.href=search_string;return false;}

function jmp_clk(B){
    var C=Decode64(B);
    var W="";
    window.open(C,"",W)
}

function Decode64(A){
    var D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var K,I,G,J,H,F,E;
    var B="";
    var C=0;
    A=A.replace(/-/g,"+").replace(/_/g,"=").replace(/\./g,"/");
    if(A.match("/[^A-Za-z0-9+\\/=]/")){
        return""
    }
    do{
        J=D.indexOf(A.charAt(C++));
        H=D.indexOf(A.charAt(C++));
        F=D.indexOf(A.charAt(C++));
        E=D.indexOf(A.charAt(C++));
        K=(J<<2)|(H>>4);
        I=((H&15)<<4)|(F>>2);
        G=((F&3)<<6)|E;
        B+=String.fromCharCode(K);
        if(F!=64){
            B+=String.fromCharCode(I)
        }
        if(E!=64){
            B+=String.fromCharCode(G)
        }
        K=I=G=J=H=F=E=""
    }while(C<A.length);
    
    return B;
}
function cat_suggest(){
	$.ajax({
	  type: "GET",
	  url: "/processing/pm_get_last_categories.php?match_id=0",
	  cache: false,
	  success: function(html){
		var mySplitResult = html.split("|");
		$('.cat_suggestions').each(
			function(){
				var match_id = $(this).attr("id");
				var jquery_to_execute_on_completion = $(this).attr("jquery_to_execute_on_completion");
				var str = "";
				for(i = 0; i < mySplitResult.length; i++){
					if(mySplitResult[i].length > 0){
						str = str + '<a href=\'javascript:match_by_suggestion('+ match_id.replace("cat_suggest_", "") +','+ i +', "'+ escape(jquery_to_execute_on_completion) +'");\' id=\'link_'+ i +'_'+ match_id.replace('cat_suggest_', '') +'\' class=\'suggested_category\'>'+ mySplitResult[i] +'</a>, ';
					}
				}
				$('#' + match_id).html(str);
			}
		);
	  }
	});
}

function match_by_suggestion(match_id, link_id, jquery_to_execute_on_completion){

//alert(match_id);

	$.ajax({
		url: '/processing/pm_remap_category.php?value=' + escape($("#link_" + link_id + "_" + match_id).html()) + "&match_id=" + match_id,
		error: function(XMLHttpRequest, textStatus, errorThrown){
		alert(XMLHttpRequest.responseText);
		},
		success: function(html){
		    //alert(html);
			$("#re_map_cat_" + match_id).hide();
			//$("#ele" + element_to_hide).hide();
			eval(jquery_to_execute_on_completion);
			cat_suggest();
		}
	});	
}

$('#show_cat').click(function(){$('#all_categories').toggle('fast')});$('#close_cat').click(function(){$('#all_categories').hide('fast')});
