window.addEvent('domready',function() {
  if($('slideshow-container')) {
    var slideshow = new SimpleSlideshow('slideshow-container','#slideshow-container img');
    slideshow.start();
  }

	new Tips('a.paymentinfo');

	// show tooltips with payment information
	$$('a.paymentinfo').each(function(info) {
		//info.store('tip:title', 'custom title for tip 1');
		if (info.getNext('p.paymentinfo')) {
			info.store('tip:text', info.getNext('p.paymentinfo').get('html'));
		}

		//info.addEvent('click', function(e) {
		//	e.stop();
		//});
	});
});

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}

/* Pop-up */
function showURL(url) {
window.open(url,'Applyscreen','width=650,height=545,scrollbars=yes,resizable=yes').focus();
}

var currentObj;

function swap(obj, state) {
  if (state != "") {
    if (state == 2) {
      obj.src = "images/buttons/" + obj.name + "_o.gif";
    } else if (state == 1) {
      obj.src = "images/buttons/" + obj.name + ".gif";
    }
    if (currentObj != null) {
      currentObj.src = "images/buttons/" + currentObj.name + "_o.gif";
    }
  }
}

var detect = navigator.userAgent.toLowerCase();
	function checkIt(string)
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}

function runSlideShow() {
  var oDiv = document.getElementById("productImg");
  if (Pic[0] == "") {
    oDiv.src = "/images/fotos/1.jpg";	
    stopSlide();
  } else {
    if (checkIt('msie')) {
      oDiv.style.filter = "blendTrans(Duration=0.5)"
      oDiv.filters.blendTrans.apply();
      oDiv.src = preLoad[j].src;
      //alert(j);
      oDiv.filters.blendTrans.play();
    } else {
      oDiv.src = preLoad[j].src;
    }
    j++;
    if (j >= p) j=0;
  }	   
}
  
function doSlide() {

  if (sliding == false) {	
	runSlideShow();
	slider = setInterval('runSlideShow()', 3000); 
    sliding = true;
  }
}
 
function stopSlide() {
  clearInterval(slider);
  sliding = false;
}

function popUp(target,width,height) {
  win = window.open(target,'Sportus','width=' + width + ',height=' + height+',location=0,menubar=0,status=0,resizable=0,resizeable=no,scrollbars=yes');
	if (!win.opener) win.opener = self;
	if (win.focus) win.focus();
}
window.pup = popUp;

// -----------------------------------------------------------------------------
function checkPrijsvraagForm() {
  var f = document.frmPrijsvraag;

  if ((f.antwoord[0].checked == false) && (f.antwoord[1].checked == false) && (f.antwoord[2].checked == false)) {
    alert('Selecteer alsjeblieft het antwoord op de prijsvraag!');
    return false;
  }

  /*if (f.maat.value == '') {
    f.maat.focus();
    alert('Geef alsjeblieft je maat op!');
    return false
  }*/

  if (f.vnaam.value == '') {
    f.vnaam.focus();
    alert('Vul alsjeblieft je voornaam in!');
    return false
  }

  if (f.anaam.value == '') {
    f.anaam.focus();
    alert('Vul alsjeblieft je achternaam in!');
    return false
  }

  if (f.adres.value == '') {
    f.adres.focus();
    alert('Vul alsjeblieft je adres in!');
    return false
  }

  if (f.postcode.value == '') {
    f.postcode.focus();
    alert('Vul alsjeblieft je postcode in!');
    return false
  } else {
    if (!isPostcode(f.postcode.value)) {
      alert('Vul alsjeblieft een geldige postcode in!');
      return false
    }
  }

  if (f.woonplaats.value == '') {
    f.woonplaats.focus();
    alert('Vul alsjeblieft je woonplaats in!');
    return false
  }

  if (f.telefoonnummer.value == '') {
    f.telefoonnummer.focus();
    alert('Vul alsjeblieft je telefoonnummer in!');
    return false
  } else {
    if (!isTelNumber(f.telefoonnummer.value)) {
      f.telefoonnummer.focus();
      f.telefoonnummer.select();
      alert('Vul alsjeblieft een geldig telefoonnummer in!');
      return false
    }
  }

  if (f.emailadres.value == '') {
    f.emailadres.focus();
    alert('Vul alsjeblieft je e-mailadres in!');
    return false
  } else {
    if (!isEmail(f.emailadres.value)) {
      f.emailadres.focus();
      f.emailadres.select();
      alert('Vul alsjeblieft een geldig e-mailadres in!');
      return false
    }
  }

  return true;
}

// -----------------------------------------------------------------------------
function changePageOnBrandSwap(listID) {
  var dd = document.getElementById(listID);
  var val = dd[dd.selectedIndex].value;
  document.location.href = val;
}

// -----------------------------------------------------------------------------

// controleren of de maat is geselecteerd
var addItem = function() {
	if (document.getElementById('frmAddItem').idOption1) {
		var el = document.getElementById('frmAddItem').idOption1;
		var test = el.options[0].innerHTML;
		if (test == 'Select variations' || test == 'Maatkeuze' || test == 'Größe' || test == 'Seleccione las variaciones')	{
			if (el.options[el.selectedIndex].value != '') {
				return true;
			} else {
				switch (test) {
					case 'Select variations' :
						alert('Please complete the missing information.');
						break;
					case 'Maatkeuze' :
						alert('Kies eerst een maat.');
						break;
					case 'Größe' :
						alert('Sie haben keine Größe angegeben.');
						break;
					default :
						alert('Kies eerst een maat.');
						break;
				}
				return false;
			}
		}
	}
}