/* All Rights Resevered © 2011 Digital Revolution BV */
var floaterShow = 3;
var popupAjaxData = null;
var formSubmitted = false;
var isIE7 = (window.navigator.appName == "Microsoft Internet Explorer" && (!document.documentMode || document.documentMode < 8));

function getEl(el){return $("#"+el).get(0);}
function getkey(e){if(window.event){return window.event.keyCode;}else if(e){return e.which;}else{return null;}}
function getsrc(e){if(window.event){return window.event.srcElement;}else if(e){return e.target;}else{return null;}}
function getElPos(id){var p=(typeof id=="string")?$("#"+id).position():$(id).position();return{left:p.left,top:p.top};}
function goodchars(e,g,n){var k=getkey(e);if(k==null)return true;var h=String.fromCharCode(k).toLowerCase();g=g.toLowerCase();if(g.indexOf(h) != -1){return true;}return(k==0||k==8||k==9||k==13||k==27);}
function checkDefVal(i,b){if(typeof i=="string")i=getEl(i);if(i.className)i.className=i.className.replace(/(^ error)|( error$)/g,"");if(i.title&&i.tagName!="SELECT"){var s=i.title.replace(/(^\s*)|(\s*$)/g,"");if(i.value==s){i.value="";}else if(b&&i.value==""){i.value=s;}}i=null;delete i;}
function setInputVal(i,v){try{if(typeof i=="string"){getEl(i).value=v;}else{i.value=v;}}catch(err){}}
function clearDefaults(formID,s){var formObj;var inputObj;if(typeof(formID)==='string')formObj=$('#'+formID);if(typeof(formObj)==='object'){inputObj=formObj.find(':input[type$="text"]');inputObj.each(function(){if($(this).val()!==''){if($.trim($(this).attr('title'))===$(this).val()){$(this).val('');}}});if(!formSubmitted&&s){formObj.submit();}}}
function setActionAndSubmit(el,inputID,v,formID){if(!formSubmitted){if(typeof(inputID)==='string'){inpObj=$('#'+inputID);inpObj.val(v);}if(typeof(formID)==='string'){formObj=$('#'+formID);formObj.submit();formSubmitted=true;$(el).prop('disabled',true);}}}
function submitPaymentForm(el){if(!formSubmitted){if(typeof(el)==='string'){formObj=$('#'+el);formObj.submit();formSubmitted=true;}}}
function formSubmitCheck(b,t,e,m){if(formSubmitted){return false;}else{if(t){if((!e&&getEl(t).title==" "+getEl(t).value+" ")||(e&&getEl(t).value=="")){if(m){alert(m);}getEl(t).focus();return false;}}if(b){getEl(b).disabled=true;getEl(b).className+=" dis";}formSubmitted=true;return true;}}
function formEnterCheck(f,e,k){if(!formSubmitted&&getkey(e)==13){var el=getsrc(e);if(el.tagName=="TEXTAREA"||(el.type&&(el.type=="button"||el.type=="submit"))){el=null;delete el;return true;}var arr = f.getElementsByTagName("*");var b = c = false;for(var i=0;i<arr.length;i++){if(!arr[i].disabled&&(arr[i].tagName=="SELECT"|| arr[i].tagName == "TEXTAREA"||(arr[i].tagName=="INPUT"&&arr[i].type!="hidden"))){if(el==arr[i]){c=true;}else if(c){if(arr[i].type&&arr[i].type=="submit"||(k&&arr[i].id&&arr[i].id==k)){b=false;break;}else{try{if(arr[i].scrollWidth>0){arr[i].focus();b=true;break;}}catch(m){}}}}}el=null;delete el;arr=null;delete arr;if(!b){if(f.id&&f.id=="bestelform"){clearDefaults(f,true);}else{formSubmitted=true;f.submit();}}return false;}}function showCompanyForm(s){getEl("divCompanyForm").style.display=(s)?"block":"none";getEl("bedrijf").value=(s)?"1":"0";}
function showDeliveryForm(){getEl("divDeliveryForm").style.display=(getEl("chkDelivery").checked)?"block":"none";}
function showFloater(id){if(id){if(typeof id=="string"){getEl("overlayFloater").style.top=(getElPos(id).top+20)+"px";}else{getEl("overlayFloater").className+=" cart";}try{floaterShow=parseInt(getEl("counterFloater").innerHTML);}catch(e){floaterShow=3;}if(isNaN(floaterShow)||floaterShow<1||floaterShow>10){floaterShow=3;}getEl("counterFloater").innerHTML=floaterShow;getEl("overlayFloater").style.display="block";setTimeout("showFloater()",1000);}else{floaterShow--;if(floaterShow>0){getEl("counterFloater").innerHTML=floaterShow;setTimeout("showFloater()", 1000);}else{getEl("overlayFloater").style.display="none";}}}
function refresh(){window.location.reload();}
function changeCursor(e,c){try{if(!c) c="default";if(typeof e=="string"){getEl(e).style.cursor=c;}else{e.style.cursor=c;}}catch(r){}}
function setInputsDis(){if(isIE7){var a=getEl("layout_panel_mid").getElementsByTagName("INPUT");for(var i=0;i<a.length;i++){if(a[i].disabled&&(a[i].type=="button"||a[i].type=="submit"||a[i].type=="text")){if(a[i].className){a[i].className+=" dis";}else{a[i].className="dis";}}}a=null;delete a;}}
function disableAndSubmit(el){if(!formSubmitted){if(typeof(el)==='object'){var frm=$(el).closest('form');frm.find(':input[type$="submit"]').prop('disabled',true);$(el).prop('disabled',false);formSubmitted=true;}}}

jQuery.popup={
box:"overlayContainer",div:"overlayContainerContent",hdr:"overlayContainerHeader",fadeIn:300,fadeOut:200,fadeMax:0.8,speed:300,ease:"easeinout",
content:null,contentWidth:800,contentHeight:400,contentAction:null,loading:null,loadingWidth:300,loadingHeight:90,loadingAction:null,
show:function(act,w,h,cb){if(typeof act=="string"){this.content=act;if(w)this.contentWidth=w;if(h) this.contentHeight=h;this.contentAction=(cb)?cb:null;this.loadingAction=null;}else{this.loadingAction=act;}if(typeof this.box=="string"){this.box=$("#"+this.box).get(0);this.div=$("#"+this.div).get(0);this.hdr=$("#"+this.hdr).get(0);if(!this.loading)this.loading=this.div.innerHTML;if(this.div.style.width)this.loadingWidth=parseInt(this.div.style.width);if(this.div.style.height)this.loadingHeight=parseInt(this.div.style.height);}if(this.box.style.display!="block"){$(this.hdr).css({'visibility':'hidden','width':'0px'});this.div.innerHTML="";$(this.div).css({"display":"block","visibility":"hidden","width":"0px","height":"0px","display":"none"});if(window.ActiveXObject){this.box.style.filter="alpha(opacity=0)";}else{this.box.style.opacity=0;}$("#printCSS").get(0).media="print";this.box.style.display ="block";$(this.box).fadeTo(this.fadeIn,this.fadeMax,this.ease,this.showCB);}else{if(isIE7)$(this.hdr).css({'visibility':'hidden','width':'0px'});if(this.contentAction){this.contentAction();}else if(this.loadingAction){this.loadingAction();}}},
showCB:function(){$($.popup.div).css({"display":"block","visibility":"visible"});if(window.ActiveXObject){this.style.removeAttribute('filter');}this.style.opacity="";if($.popup.loadingAction){$($.popup.div).animate({width:$.popup.loadingWidth+"px",height:$.popup.loadingHeight+"px"},$.popup.speed,$.popup.ease,$.popup.loadCB);}else{$.popup.checkViewport();$($.popup.div).animate({width:$.popup.contentWidth+"px",height:$.popup.contentHeight+"px"},$.popup.speed,$.popup.ease,$.popup.setContentCB);}},
loadCB:function(){if($.popup.loadingAction){this.innerHTML=$.popup.loading;$.popup.loadingAction();}else{$.popup.hide();}},
setContent:function(str,w,h){$.popup.div.innerHTML="";if(str)$.popup.content=str;if(w)$.popup.contentWidth=w;if(h)$.popup.contentHeight=h;$.popup.checkViewport();$($.popup.div).animate({width:$.popup.contentWidth+"px",height:$.popup.contentHeight+"px"},$.popup.speed,$.popup.ease,$.popup.setContentCB);},
setContentCB:function(){$($.popup.hdr).css({"width":"auto","visibility":"visible"});this.innerHTML=$.popup.content;$.popup.content=null;$.popup.checkIE7();if(popupAjaxData){var a=popupAjaxData.split("hash=");if(a.length>1)popupJump(a[1]);popupAjaxData=null;}},
changeContent: function(str){$.popup.div.innerHTML=str;$($.popup.hdr).css({"width": "auto", "visibility": "visible"});$.popup.checkIE7();},
hide:function(){this.div.innerHTML="";$(this.hdr).css({'visibility':'hidden','width':'0px'});$(this.div).css({"width":"0px","height":"0px","visibility":"hidden","display":"none"});$(this.box).fadeTo(this.fadeOut,0,this.ease,this.hideCB);},
hideCB:function(){this.style.display="none";$("#printCSS").get(0).media="embossed";},
resize:function(w,h){this.content=this.div.innerHTML;this.div.innerHTML="";$(this.div).animate({width:w+"px",height:h+"px"},this.speed,this.ease,this.resizeCB);},
resizeCB:function(){this.innerHTML=$.popup.content;$.popup.content="";$.popup.checkIE7();},
checkIE7:function(){if(isIE7)this.hdr.style.width=this.hdr.parentNode.offsetWidth+"px";},
checkViewport:function(){var w=this.box.scrollWidth-50;var h=this.box.scrollHeight-75;if($.popup.contentWidth>w){$.popup.contentWidth=(w>300)?w:300;}if($.popup.contentHeight>h){$.popup.contentHeight=(h>120)?h :120;}}
};

jQuery.extend({easing:{easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var ts=t-d/2;return -2*c*ts*ts/(d*d)+2*c*ts/d+c/2+b;}}});

function popupImage(imgid,ttl,w,h,pttl){popupAjaxData="ajax=image&iid="+imgid+"&ttl="+ttl;if(w)popupAjaxData+="&width="+w;if(h)popupAjaxData+="&height="+h;if(pttl)popupAjaxData+="&pttl="+pttl;$.popup.show(popupAjaxCallback);return false;}
function popupNews(id,w,h,pttl){popupAjaxData="ajax=news&sid="+id;if(w)popupAjaxData+="&width="+w;if(h)popupAjaxData+="&height="+h;if(pttl)popupAjaxData+="&pttl="+pttl;$.popup.show(popupAjaxCallback);return false;}
function popupPage(p,w,h,pttl){popupAjaxData="ajax=page";if(w)popupAjaxData+="&width="+w;if(h)popupAjaxData+="&height="+h;if(pttl)popupAjaxData+="&pttl="+pttl;var a=p.split("#");popupAjaxData+="&page="+a[0];if(a.length==2)popupAjaxData+="&hash="+a[1];$.popup.show(popupAjaxCallback);return false;}
function popupPrintOrder(){getEl("overlayContainerTitle").innerHTML=langPrintOrder;var s=getEl("printHeaderContainer").innerHTML+getEl("printOrderContainer").innerHTML;$.popup.show(s,680,600);}
function popupShipment(a,b,c,d){popupAjaxData="ajax=shipment&shid="+b+"&shname="+a+"&wid="+c+"&kid="+d;$.popup.show(popupAjaxCallback);}
function popupAjaxCallback(){$.ajax({type:"POST",url:globSiteDomain+"/shop/main.php?chk="+globSessionID,data:popupAjaxData,dataType:"xml",cache:false,timeout:5000,
success: function(s){var ttl=$(s).find("popup").attr("title");var txt=$(s).find("popup").text();if(ttl.length>0&&txt.length>10){getEl("overlayContainerTitle").innerHTML=ttl;$.popup.setContent(txt,parseInt($(s).find("popup").attr("width")),parseInt($(s).find("popup").attr("height")));}else{getEl("overlayContainerTitle").innerHTML="&nbsp;";$.popup.changeContent(getEl("ajaxContentError").innerHTML);}},
error: function(x,s,e){var b=true;if(!s){var st=x.responseText;st=st.substring(st.indexOf("<?xml"),st.lastIndexOf("</popup>")+8);if(st.length>40){if(window.ActiveXObject){var x=new ActiveXObject("Microsoft.XMLDOM");x.async="false";x.loadXML(st);b=(x.parseError.errorCode!=0);}else{var p=new DOMParser();var x=p.parseFromString(st,"text/xml");b=(x.documentElement.nodeName=="parsererror");}if(!b)this.success(x);}}if(b){getEl("overlayContainerTitle").innerHTML="&nbsp;";$.popup.changeContent(getEl("ajaxContentError").innerHTML);}}});}
function popupClose(){$.popup.hide();}
function popupOutside(e,t){try{el=getsrc(e);while(el!=t&&el.tagName!="BODY"){if(el.id&&(el.id=="overlayContainerContent"||el.id=="overlayContainerHeader")){return true;}el=el.parentNode;}popupClose();return false;}catch(err){}}
function popupJump(jumpto){var y=0;if(jumpto&&jumpto!="top"){var arr=getEl("overlayContainerContent").getElementsByTagName("A");for(var i=0;i<arr.length;i++){if(arr[i].name&&arr[i].name==jumpto){y=$(arr[i]).position().top;if(browserType=="FF"&&arr[i].scrollHeight==0)y-=12;y-=$("#overlayContainerContent").position().top+6;y+=getEl("overlayContainerContent").scrollTop;break;}}arr=null;delete arr;}$("#overlayContainerContent").animate({scrollTop: y},0);}
function popupQuestion(page,cid,qid,obj){if(typeof(page)==='string'){popupAjaxData='ajax=question&page='+page;if(typeof(cid)==='number'&&cid>0){popupAjaxData+='&categoryid='+cid;if(typeof(qid)==='number'&&qid>0){popupAjaxData+='&questionid='+qid;}}if(typeof(obj)==='object'){for(var name in obj){popupAjaxData+='&'+name+'='+obj[name];}}$.popup.show(popupAjaxCallback);}return false;}
