/*
Bepaald de onload, functie toevoegen aan body onload d.m.v.: window.onload.actions.push(function_naam);
*/
window.onload = function () {
	huidige_taal = ($('body').attr('lang'));
	if(window.alphaPNG) alphaPNG();
    MM_preloadImages('/images_' + huidige_taal + '/menu_over2.gif','/images_' + huidige_taal + '/menu_collectie2.gif','/images_' + huidige_taal + '/menu_winkelwagen2.gif','/images_' + huidige_taal + '/menu_faq2.gif','/images_' + huidige_taal + '/menu_contact2.gif','/images_' + huidige_taal + '/menu_home2.gif');
	MM_preloadImages('/images_' + huidige_taal + '/menu_home2.gif','/images_' + huidige_taal + '/menu_over2.gif','/images_' + huidige_taal + '/menu_collectie2.gif','/images_' + huidige_taal + '/menu_winkelwagen2.gif','/images_' + huidige_taal + '/menu_faq2.gif','/images_' + huidige_taal + '/menu_contact2.gif');
	for (var i=0;arguments.callee.actions.length>i;i++)
        arguments.callee.actions[i]();
};
window.onload.actions = [];

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function goToUrl(url) {
	document.location.href = url;
}

function sli(iurl,iw,ih) {
	huidige_taal = ($('body').attr('lang'));
	var ileft=(screen.width/2)-(iw/2);
	var itop=(screen.height/2)-(ih/2);
	var nurl = '/popup/popup.php?image='+iurl+'&huidige_taal=' + huidige_taal;
	var nwidth = 'width='+iw;
	var nheight = 'height='+ih;
	var nproperties = nwidth+','+nheight+',scrollbars=no,left='+ileft+',top='+itop;
	window.open(nurl,'Image',nproperties);
}

function change_image(org, dest, color, kleurnaam, geur, status, status_tekst) {
	image = document.getElementById('afb_'+org);
	link = document.getElementById('link_'+org);
	weergave = document.getElementById('code_weergave_'+org);

	bestel_link = new String(document.getElementById('bestel_link_org_'+org).href);

	kleur_label = document.getElementById('kleur_label_'+org);
	
	image.src = '/images/products/'+dest+'.jpg';

	groot_image=new Image;
	groot_image.src='/images/products/groot_'+dest+'.jpg';	
	
	iw = groot_image.width;
	ih = groot_image.height;
	
	if(iw == 0 && ih == 0){
		iw = 400;
		ih = 410;
	}

	link.href = "javascript:sli('"+dest+"','"+iw+"','"+ih+"');";

	weergave.innerHTML = '<span>Code:</span> '+dest+ (kleurnaam != null ? ' - '+kleurnaam : null);
	if(geur) {
	    geur_label = document.getElementById('geur_label_'+org);
		geur_label.innerHTML = '<span>Geur:</span> '+geur;
	}

	p = bestel_link.split('&');
	new_link = p[0]+'&kleur='+color;
	
// 	if(status == '0'){
// 		document.getElementById('bestel_link_'+org).href = new_link;
// 	}

	bestel_label = document.getElementById('bestel_html_'+org);

	if(status != 2){
		bestel_label.innerHTML = '<a class="bestel mandje_button" id="bestel_link_'+org+'" href="'+new_link+'"><span>'+status_tekst+'</span></a>';
	} else {
		bestel_label.innerHTML = '<span class="uitverkocht">'+status_tekst+'</span>';
	}
	
}

$(document).ready(function() {
	//$('.blink').blink(); // default is 500ms blink interval.
    $('.blink').blink({delay:1500}); // causes a 100ms blink interval.
});

Cufon.replace("#collection h2.category-name, h2.category-name, h1.home");


