function closeBlock(id){
new Effect.Fade('block_'+id,{beforeStart:function(){new Effect.Appear('block_tab_'+id);} });
}

function blockslide(dir,id){
obj = 'block_tab_'+id;
 if(dir == 'out'){
  //new Effect.Move(obj,{ x: 100, y: 0, mode: 'relative' });
  $(obj).style.left=(0-10)+'px';
 }

 if(dir == 'in'){
  //new Effect.Move(obj,{ x: -100, y: 0, mode: 'relative'});
  $(obj).style.left=(0-180)+'px';
 }
}
function showBlock(id){
new Effect.Fade('block_tab_'+id,{beforeStart:function(t){renderBlock(id);}});
}
function renderBlock(id){
new Effect.Appear('block_'+id);
}
function checkText(el,mes){
	if (el.value == "") {
    alert( mes );
    el.focus(); 
    return false ;
  }
	return true;
}
function checkMail(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_email); // "vul uw email in"
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[a-z]+([.]?[a-z0-9_-]+)*[@]([a-z0-9_-]+[.])+([a-z]{2,4})$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_email); // "Het door uw ingevoerder e-mail adres is ongeldig.\n Gebruik van hoofdletters is niet toegestaan" );
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkPC(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_zip); // "Vul uw postcode in.\n (bv. 1111AA)" 
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[0-9]{4}[a-zA-z]{2}$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_zip); // "Het door uw ingevoerder postcode is ongeldig (bv. 1111AA)." 
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkNum(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_number ); // "Vul uw nummer in.\n(bv. 0206666666)"
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[0-9]{10}$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_phone ); // "Het door u ingevoerde nummer is ongeldig.\n Voer uw nummer als volgt zonder streepjes in: 0206666666"
	    el.focus();
	    return false;
	  }
	}
	return true;
}
function checkInt(el,force){
  var regex = el.value
  if(force || regex !=''){
	  if(force && regex == ''){
			alert( translation.reg_empty_number ); // "Vul uw nummer in.\n(bv. 10)"
			el.focus();
			return false ;
		}
	  var valid = new RegExp("^[0-9]*$").exec(regex);
		if(!valid) { 
	    alert( translation.reg_invalid_number); // "Het door u ingevoerde nummer is ongeldig.\n Voer uw nummer als volgt in: 10" 
	    el.focus();
	    return false;
	  }
	}
	return true;
}var prod_pop_container = 'prod_popover_container';
var prod_pop_holder = 'prod_popover';
var prod_pop_back = 'prod_popover_back';

function showproddetails(pid,catid,reffer){
  var url = "showProductDetails";
  new Ajax.Updater(prod_pop_holder,url,{parameters:'js=1&pid='+pid+'&catid='+catid+'&reffer='+reffer,onComplete:function(){showProdPopOver();}  } );
}
var product_container_height;
var product_container_width;

function orderSmallProducts(){
  //var plist = $('product_container').select('div.small_product_container');
  //alert(plist.length);
  if( getprod_go){
  height=$('product_container').getHeight()-40;
  product_container_height=height;
  width =$('product_container').getWidth()-40;
  product_container_width=width;
  var size = 210;
  var asize=200;
  xnum = parseInt(width/size);
  ynum = parseInt(height/size);
  margin = 5;

  try{
    //alert(width+'x'+height);
    //alert(xnum+'x'+ynum);
    xdiv = parseInt(((width-(xnum*asize))/xnum)/2);
    ydiv = parseInt(((height-(ynum*asize))/ynum)/2);
    //alert(xdiv+'x'+ydiv);
    if(xdiv > ydiv){
      margin = ydiv;
    }else{
      margin = xdiv;
    }
  }
  catch(e){}
  if(margin < 5){margin=5;}

  if($('catid')){catid=$('jsvals')['catid'].value; }else{catid=0;}
  if($('pcatid')){pcatid=$('pcatid').value;}else{pcatid=0;}
  if($('cppid')){cppid=$('cppid').value;}else{cppid=0;}
  if($('cfid')){cfid=$('cfid').value;}else{cfid=0;}
  if($('page')){page=$('page').value;}else{page=0;}
  new Ajax.Updater('product_holder','/getProducts',{parameters:'js=1&catid='+catid+'&pcatid='+pcatid+'&cppid='+cppid+'&cfid='+cfid+'&xnum='+xnum+'&ynum='+ynum+'&page='+page+'&margin='+margin+'&height='+height+'&width='+width});
  }
}

function resizeProdDetail(){
  if($(prod_pop_holder)){
    var sizes = getSize();
    var dimensions = $(prod_pop_holder).getDimensions();
    var dheight = 424;
    if( dimensions.height> 424){dheight=dimensions.height;};
    pwidth = (sizes[0]-dimensions.width)/2; //$(prod_pop_holder).offsetWidth)/2;
    pheight=(sizes[1]-dheight)/2; //$(prod_pop_holder).offsetHeight)/2;
    if(pwidth<0){pwidth=0;}
    if(pheight<0){pheight=0;}
    $(prod_pop_back).style.width=sizes[0]+'px';
    $(prod_pop_back).style.height=sizes[1]+'px';
    $(prod_pop_holder).style.top = pheight+'px';
    $(prod_pop_holder).style.left = pwidth+'px';
  }
}
function showProdPopOver(){
  if($(prod_pop_container)){
    if($(prod_pop_container).style.display=='none'){
      $(prod_pop_container).style.display='';
      resizeProdDetail();
      Effect.Appear(prod_pop_holder); //,{afterFinish:function(){resizeProdDetail();}});
    }
  }
}

function hideProdPopOver(){
  if($(prod_pop_container)){
    if($(prod_pop_container).style.display==''){
      //Effect.Fade(prod_pop_container);
      $(prod_pop_container).style.display='none';
    }
  }
}var shopcartTimer;
var shophide='0';
var shopcart_effect=false;
function addProd2Cart(pid,aantal,catid){
 //new Ajax.Request('/addCart',{parameters:'js=1&pid='+pid+'&aantal='+aantal+'&catid='+catid, onComplete:function(t){$('shopcart_holder').innerHTML=$('shopcart_holder').innerHTML+t.responseText;showShopCart();} });
 new Ajax.Updater('shopcart_holder','/addCart',{parameters:'js=1&pid='+pid+'&aantal='+aantal+'&catid='+catid, onComplete:function(){showShopCart();} });
}
function showShopCart(){
 $('shopcart_container').style.left = ($('head_cart').offsetLeft+20)+'px';
 $('shopcart_container').style.top = ($('head_cart').offsetTop+2)+'px';
 $('shopcart_container').style.display='';
 new Effect.Appear('shopcart_holder',{afterFinish:function(){hideShopCart();} ,queue:{position:'end',limit:2,scope: 'menushopcart'}});
}
function hideShopCart(){
 new Effect.Shrink('shopcart_holder',{direction:'top-left', delay:1.0,queue:{position:'end',limit:2,scope: 'menushopcart'} });
}
function removeProdFromCart(pid){
 new Ajax.Request('/delCart',{parameters:'js=1&pid='+pid,onComplete:function(t){if(t.responseText == 'True'){new Effect.Fade('prod_'+pid,{afterFinish:function(){$('prod_'+pid).remove();}});}} } );
}function checkContactForm(form){
  if(!checkText(form.firstname,translation.reg_empty_firstname)){return false;}
  if(!checkText(form.lastname,translation.reg_empty_lastname)){return false;}
  if(!checkMail(form.email,true)){return false;}
  if(!checkText(form.about,translation.contact_empty_subject)){return false;}
  if(!checkText(form.bericht,translation.contact_empty_message)){return false;}
  return true;
}
