function ipopPromo() {
 //$('icontent').style.width = 670 + 'px';
 //$('icontent').style.height = 383 + 'px';
 new Ajax.Updater('icontent', '/showDemoVideoIpop',{ evalScripts:true, onComplete: function() {  myIpop.doipop(); }   } );
}
function promoVideo() {
 new Ajax.Updater('homevids', '/showPromoVideo',{ evalScripts:true  } );
}
function ipopPromoClose() {
 new Ajax.Updater('homevids', '/showHomeVideoChoices',{ evalScripts:true  } );
}
function resetForm(formid) {
 form = $(formid);
 inputs = form.getElementsByTagName('input');
 selects = form.getElementsByTagName('select');
 i = 0;
 while (i < inputs.length) {
   t_input = inputs[i];
   tv = t_input.value;
   tn = t_input.name;
   tt = t_input.type;
   if (tt == 'radio' || tt == 'checkbox') {  t_input.checked == false ; }
   else if (tt == 'hidden') {}
   else { 
    if (t_input.className != 'submit') {    t_input.value = ''; }
   }
   i++;
 }
 i=0;
 while (i < selects.length) {
   t_input = selects[i];
   t_input.selectedIndex = 0;
   i++;
 }

}

function enableAdvancedSearch() {
 jQuery('#advanced_search_toggle').attr('value','1');
 $('advanced_search_options').style.display = 'block';
}
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


function checkStreetWithNum(name,mes,form){
 var el = form[name];
 var valid = new RegExp("^[a-zA-Z0-9\ ]+[ ]+[0-9]{1,}[a-zA-Z]{0,}").exec(el.value);
  if((!valid)){
   alert(mes);
   Fat.fade_element(name);
   el.focus();
   return false;
 }
 return true;
}
function checkZipcode(name,mes,form){
 var el = form[name];
 var valid = new RegExp("^[0-9]{4}[ ]{0,1}[a-zA-Z]{2}$").exec(el.value);
  if((!valid)){
   alert(mes);
   Fat.fade_element(name);
   el.focus();
   return false;
 }
 return true;
}
function checkPhone(name,form,force){
 var el = form[name];
 var valid = new RegExp("^([0-9]{3}[-]{0,1}[0-9]{7})|([0-9]{2}[-]{0,1}[0-9]{8})$").exec(el.value);
  if((!valid && el.value != '')||(!valid && force)){
   alert(translation.invalid_phone);
   Fat.fade_element(name);
   el.focus();
   return false;
 }
 return true;
}
function checkJSDate(form,name,force){
 var el = form[name];
 var valid = new RegExp("^^[0-3][0-9][-]([0][0-9]|[1][0-2])[-][0-9]{4}$").exec(el.value);
 if((!valid && el.value != '')||(!valid && force)){
   alert("Invalid date format. example: dd-mm-yyyy");
   Fat.fade_element(name);
   el.focus();
   return false;
 }else if(valid){
    day =parseInt(el.value.substr(0,2),10);
    month = parseInt(el.value.substr(3,2),10)-1;
    year = el.value.substr(6,4);
    dteDate=new Date(year,month,day);
    if(month != dteDate.getMonth() || day != dteDate.getDate() || year != dteDate.getFullYear()){
      alert("Entered None existing date" );
      Fat.fade_element(name);
      el.focus();
      return false;
    }
 }
 return true;
}
function checkRadio(name,mes,form){
  var el = form[name];
  var sel = false;
  for(var i=0;i<el.length;i++){
    if(el[i].checked){
      sel = el[i].checked;
    }
  }
  if(!sel){
    alert(translation.noselect_radio);
    el[0].focus();
  }
  return sel;
}
function checkSelect(form,name,title,invalid){
  var el = form[name];
  if(el[el.selectedIndex].value == invalid){
    alert(title+": invalid Selection.");
    Fat.fade_element(name);
    el.focus();
    return false;
  }
  return true;
}
function validateFloatCheck(el,pos){
 el.value = el.value.replace(/[a-zA-Z,]+/ig,'');
 var valid = new RegExp("^[0-9]+[.]{0,1}[0-9]{0,"+pos+"}$").exec(el.value);
 if(!valid || el.value == ''){
   return false;
 }
 return true;
}
function validateFloat(el,pos){
 el.value = el.value.replace(/[a-zA-Z,]+/ig,'');
 var valid = new RegExp("^[0-9]+[.]{0,1}[0-9]{0,"+pos+"}$").exec(el.value);
 if(!valid && el.value != ''){
   el.value = el.value.substr(0,el.value.length-1);
 }
calcSubjects();
}
function trim(value) {
  value = value.replace(/^\s+/,'');
  value = value.replace(/\s+$/,'');
  return value;
}
function isInt(val){
  value =  new RegExp("^[0-9]{1,}$").exec(val);
  return value;
}
function isFloat(val){
  value =  new RegExp("^[0-9]+[.]{0,1}[0-9]{0,4}$").exec(val);
  return value;
}

function genPopOver(holder){
  if(!$(holder)){
    var text = '<div id=\"'+holder+'\" class=\"popover_container\" style=\"display:none;\"><div class=\"ajax_loader\"><img class=\"ajax_loader\" src=\"\/loader.gif\" alt=\"loading\" \/><\/div><\/div>'; //style=\"display:none;\"
    $('body').insert({Bottom:text});
    showPopOver(holder);
  }
  genPopOverBack();
}
function genPopOverBack(){
  ssize = getSize();
  var divs = $('body').select('div.popover_container');
  var back = '<div id=\"popover_back\" style=\"width:'+ssize[2]+'px;height:'+ssize[3]+'px;\"></div>';
  removePopOverBack();
  if(divs.length > 0){
    divs[0].insert({Before:back});
  }else{
    $('body').insert({Bottom:back});
  }
  resizePopOverBack();
}
function resizePopOverBack(){
 ssize = getSize();
 if($('popover_back')){
  $('popover_back').style.width = ssize[2]+'px';
  $('popover_back').style.height = ssize[3]+'px';
 }
}
function removePopOverBack(){
  if($('popover_back')){
    $('popover_back').remove();
  }
}
function clearPopOvers(){
  var divs = $('body').select('div.popover_container');
  for(var i=0;i<divs.length;i++){
   divs[i].remove();
  }
  removePopOverBack();
}
function closePopOver(holder){
 new Effect.Fade(holder,{duration:0.5,afterFinish:function(){$(holder).remove();removePopOverBack();}});
}
function showPopOver(holder){
 var ssize = getSize(); //Array(myWidth,myHeight,maxW,maxH,mode);
 $(holder).style.display = '';
 var height = $(holder).offsetHeight;
 var width = $(holder).offsetWidth;
 $(holder).style.display = 'none';
 var left = parseInt((ssize[0]-width)/2);
 $(holder).style.left = left+'px';
 var scrolltop = f_scrollTop();
 var top = parseInt(scrolltop)+parseInt(parseInt(ssize[1]-height)/2);
 $(holder).style.top = top+'px'; 
 $(holder).style.display ='';
 new Effect.Appear(holder,{duration:0.5});
}
var defaultheight = 300;
function resizePopOverHeight(id){
  el = $(id);
  var diffspace = 22;
  if(el.scrollHeight <= defaultheight){
    return '';
  }
  else if((el.scrollHeight-diffspace) < el.getHeight()){
    //el.style.height = el.scrollHeight+"px";
    new Effect.Morph(el,{style:'height:'+defaultheight+'px',afterFinish:function(){resizePopOverBack();}});
  }else{
    //el.style.height = el.scrollHeight+"px";
    defaultheight = el.getHeight()-diffspace;
    new Effect.Morph(el,{style:'height:'+(el.scrollHeight-(diffspace-4))+'px',afterFinish:function(){resizePopOverBack();}});
  } 
}function renderSubCat(holder,id,n){

}function checkTerms(form) {
 vw = $('voorwaarden');
 if (vw.checked == false) { $('vw_warn').style.display='block'; return false; }
 return true;
}
function shoppingCartPrev(form){
 form['step'].value = parseInt(form['step'].value)-1;
 form.action = '/shoppingcart';
 form.submit();
}
function shoppingCartNext(form){
 form['step'].value = parseInt(form['step'].value)+1;
 form.action = '/shoppingcart';
 form.submit();
}var Ipop = Class.create();
Ipop.prototype = {
    imageArray: [],
    activeImage: undefined,
    
    // initialize()
    //
    initialize: function() {    

       $('overlay').hide().observe('click', (function() { this.end(); }).bind(this));
       $('ipop').hide().observe('click', (function(event) { if (event.element().id == 'ipop') this.end(); }).bind(this));

       var th = this;
      (function(){
            var ids = 'overlay ipop';   
            $w(ids).each(function(id){ th[id] = $(id); });
        }).defer();

    },

  doipop: function() {
  //   $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
  // stretch overlay to fill page and fade in
  var arrayPageSize = this.getPageSize();
  $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });

  // calculate top and left offset for the lightbox 
  var arrayPageScroll = document.viewport.getScrollOffsets();

  var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10); //+ (document.viewport.getHeight() / 10);

  var lightboxLeft = arrayPageScroll[0];
  this.ipop.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }); //.show();  //als je m meteen zichtbaar wil

  new Effect.Appear(this.overlay, { duration: 0.5, from: 0.0, to: 0.7   });
  
  onComplete: new Effect.Appear(this.ipop, { duration: 1.0, from: 0.0, to: 1.0 })
  } ,

    //
    //  end()
    //
    end: function() {
        //this.disableKeyboardNav();
        this.ipop.hide();
        new Effect.Fade(this.overlay, { duration: 0.5 });
        //$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
    },

    //
    //  getPageSize()
    //
    getPageSize: function() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;

	}

}

function initIpop() { myIpop = new Ipop(); }
document.observe('dom:loaded', function () { initIpop(); });
function activateTab(el){
  //'tabholder';
  tabcontainers = $('tabcontainer').select(".tabcontainer");
  for(t=0;t<tabcontainers.length;t++){
    tabcontainers[t].className = 'tabcontainer notactive';
  }
  $(el.id+"_container").className = 'tabcontainer active';

  tabholders = $('tabholder').select(".tab_holder");
  for(t=0;t<tabholders.length;t++){
    tabholders[t].className = 'tab_holder';
  }
  el.className = 'tab_holder active';

  if($('taboptionscontainer')){
    taboptionscontainers = $('taboptionscontainer').select(".taboptionitem_container");
    for(t=0;t<taboptionscontainers.length;t++){
      taboptionscontainers[t].className = 'taboptionitem_container notactive';
    }
    $(el.id+"_option").className = 'taboptionitem_container active';
  }
}
function saveTab(id,page){
  //ff uit;
  //new Ajax.Request('/admin/setSelTab',{parameters:'id='+id+'&page='+page});
}
function updateCategoryViewTab(id,container) {
}


function navTo(holder,url,qs){
  jQuery.ajax({ url:url, data:'js=1&'+qs, type:'POST', success: function(data){ jQuery('#'+holder).html(data); } });
  return false;
}
function navToGo(form,holder,url){
  qs = form.serialize();
  jQuery.ajax({ url:url, data:'js=1&'+qs,type:'POST', success: function(data){ jQuery('#'+holder).html(data); } });
  return false;
}
