// DS: script to open the "speelboek type" popups
function openFlashPopup(type) {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 395;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=790, height=580, top=" + aTop + ", left=" + aLeft;
  var aWindow = window.open(eval(type + "Path"), "speelBoek2004", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}


// DS: script to open the "dagaanbiedingen" popup
function openPopop() {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 250;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=550, height=550, top=" + aTop + ", left=" + aLeft;
  var aWindow = window.open("http://www.intertoys.nl/dagPopup.html", "dagaanbiedingen", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}



// DS: script to open the "speelboek" popup
function openSpeelboek() {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 395;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=790, height=480, top=" + aTop + ", left=" + aLeft;
  var aWindow = window.open("http://www.intertoys.nl/sbFlash.cfm", "speelBoek2005", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}

// DS: script to open the "speelboek" popup
function openSpeelboekDE() {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 395;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=790, height=480, top=" + aTop + ", left=" + aLeft;
  var aWindow = window.open("http://www.intertoys.nl/sbFlashDE.cfm", "speelBoek2005", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}

// DS: script to open the "speelboek" popup
function openFolderDE() {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 395;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=790, height=480, top=" + aTop + ", left=" + aLeft;
  var aWindow = window.open("http://www.intertoys.nl/folder/de/wk472006/folderFlash.cfm", "Prospect", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}


// DS: script to open a banner popup
function openBannerPopup(url, id, width, height, scroll) {
	aTop = screen.height/2 - 240;
	aLeft = screen.width/2 - 395;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=" + scroll + ", resizable=0, width=" + width + ", height=" + height + ", top=" + aTop + ", left=" + aLeft;
  var bWindow = window.open(url, id, optionString);
  if (bWindow) {
    bWindow.focus();
    return true;
  } else {
    return false;
  }
}

// ds: preLoad( img1, img2, img3, etc)
//     used to preload images
function preLoad() {
 if (document.images) {
  if (typeof document.pics == 'undefined'){
   document.pics = new Object();
  }
  document.pics.loadedImages = new Array();
  var argLength = preLoad.arguments.length;
  for(arg=0;arg<argLength;arg++) {
   document.pics.loadedImages[arg] = new Image();
   document.pics.loadedImages[arg].src = preLoad.arguments[arg];
  }
 }
}

//     SwapImage
function MM_findObj(n, d) { //v3.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); 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 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];}}
}

// openWindow()
// MM rip om een window te openen met een nieuwe URL
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
// end openWindow()


/*************************************************************************************************
* Open a popup window to the specified uri
* - url The location to open to popup.
* - type The type of popupwindow(1(default))
* - name The name of the window(_blank is default)
**************************************************************************************************/
var popupTypes = {
  type1: new PopupType(424, 600),
  type2: new PopupType(790, 480)
}

function PopupType(width, height) {
  this.width = width;
  this.height = height;
}

function openPopup(aUrl, aType, aName) {
  var aWidth, aHeight;
  if (typeof aType == 'undefined' || !(aType.width && aType.height)) {
    aType = popupTypes.type1;
  }
  aWidth = aType.width;
  aHeight = aType.height;
  var optionString = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0, width=" + aWidth + ", height=" + aHeight
  var aWindow = window.open(aUrl, (aName) ? aName : "_blank", optionString);
  if (aWindow) {
    aWindow.focus();
    return true;
  } else {
    return false;
  }
}
/* Opens a popup using the href and target attributes from the a tag
 * - src the ancor tag(this)
 * - aType a popup type for the width and height(default = popupTypes.type1)
 * ------------------------------------------ */
function linkPopup(src, aType) {
  return openPopup(src.getAttribute('href'), aType || popupTypes.type1,(src.getAttribute('target') || '_blank'));
}



//MR: email validation function
function isEmail(str){
	re = new RegExp ('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$');
	return re.test(str);
}	  


// MR: this function is used to validate the Zoop form
function validateZoopForm(formname) {
    var bSuccess = true
    
    if (document.forms[formname].surname_prefix.value == '' && bSuccess) {
      alert('Het veld "Voornaam" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].surname_prefix.focus();
      bSuccess = false;
    }
    else if (document.forms[formname].surname.value == '' && bSuccess) {
      alert('Het veld "Achternaam" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].surname.focus();
      bSuccess = false;
    }
    else if (document.forms[formname].email.value == '' && bSuccess) {
      alert('Het veld "E-mailadres" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].email.focus();
      bSuccess = false;
    }
    else if (!isEmail(document.forms[formname].email.value) && bSuccess) {
      alert('Het veld "E-mailadres" is niet een geldig e-mailadres.');
      document.forms[formname].email.focus();
      bSuccess = false;
    }    
    else if (document.forms[formname].answer.value == '' && bSuccess) {
      alert('Het veld "Antwoord" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].answer.focus();
      bSuccess = false;
    }
    else if (!document.forms[formname].subscriptionI.checked && !document.forms[formname].subscriptionII.checked && bSuccess) {
      alert('Kies een van de twee beschikbare opties.');
      document.forms[formname].subscriptionI.focus();
      bSuccess = false;
    }      

    return bSuccess;

}

// MR: this function is used to validate the subscribe for newsletter form
function validateNewsletterForm(formname) {
    var bSuccess = true
    
    if (document.forms[formname].label.value == '' && bSuccess) {
      alert('Het veld "Naam" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].label.focus();
      bSuccess = false;
    }

    else if (document.forms[formname].email.value == '' && bSuccess) {
      alert('Het veld "E-mailadres" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].email.focus();
      bSuccess = false;
    }
    else if (!isEmail(document.forms[formname].email.value) && bSuccess) {
      alert('Het veld "E-mailadres" is niet een geldig e-mailadres.');
      document.forms[formname].email.focus();
      bSuccess = false;
    }    

    
    return bSuccess;

}


// SB: this function is used to validate the e-cards form
function validateECardForm(formname) {
    var bSuccess = true
    
    if (document.forms[formname].message.value == '' && bSuccess) {
      alert('Het veld "Boodschap" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].message.focus();
      bSuccess = false;
    }
		
    if (document.forms[formname].from_name.value == '' && bSuccess) {
      alert('Het veld "Van Naam" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].from_name.focus();
      bSuccess = false;
    }
		
    if (document.forms[formname].to_name.value == '' && bSuccess) {
      alert('Het veld "Naar Naam" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].to_name.focus();
      bSuccess = false;
    }

    else if (document.forms[formname].from_email.value == '' && bSuccess) {
      alert('Het veld "Van E-mailadres" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].from_email.focus();
      bSuccess = false;
    }

    else if (document.forms[formname].to_email.value == '' && bSuccess) {
      alert('Het veld "Naar E-mailadres" is een verplicht veld en mag niet leeg zijn.');
      document.forms[formname].to_email.focus();
      bSuccess = false;
    }
		
    else if (!isEmail(document.forms[formname].from_email.value) && bSuccess) {
      alert('Het veld "Van E-mailadres" is niet een geldig e-mailadres.');
      document.forms[formname].from_email.focus();
      bSuccess = false;
    }
		
    else if (!isEmail(document.forms[formname].to_email.value) && bSuccess) {
      alert('Het veld "Naar E-mailadres" is niet een geldig e-mailadres.');
      document.forms[formname].to_email.focus();
      bSuccess = false;
    }    

    
    return bSuccess;

}