var siteroot ="/";

var activeid = null;


function popUp(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=500,left = 10,top = 10');");
}

function popUpInformatie(URL) {
   day = new Date();
   id = day.getTime();
   
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 10,top = 10');");
}
function popPrint(URL) {
   day = new Date();
   id = day.getTime();
   
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=750,height=500,left = 10,top = 10');");
}


function popUpZwaarte(URL) {
   day = new Date();
   id = day.getTime();
   
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 10,top = 10');");
}

function popUpKaart(URL) {
   day = new Date();
   id = day.getTime();
   
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 10,top = 10');");
}

function ShowPhoto(URL) {
   day = new Date();
   id = day.getTime();
   ur=siteroot+"php/image.php?image="+URL+"&width=580&height=400";
   eval("page" + id + " = window.open(ur, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 10,top = 10');");
}

function ShowMeerInfoPop(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=450,left = 100,top = 100');");
}

function formatPhoneNumber(object) {
   str=object.value;
   str=str.replace('-','');
   str=str.replace('+','00');
   str=str.replace(str.substring( str.lastIndexOf('('),(str.lastIndexOf(')')+1)),'');
   str=str.replace('(','');
   str=str.replace(')','');
   str=str.replace(/ */g,"");
   x = str.length;
   formatted_str="";
   while(x > 0) {
      part = str.substring(x-3,x);
      if(formatted_str.length == 0)
       formatted_str=part;
      else
       formatted_str=part+" "+formatted_str;
      x=x-3;
   }
   object.value=formatted_str;
}



function SetAdvancedSelectBox(object,waarde) {
   for (i=0;i<object.length;i++) {
      if(object.options[i].value==waarde) {
         object.options[i].selected = true;
      }
   }
}


function GetSelectBoxValue(field){

	return field.options[field.selectedIndex].value;
}


function SetSelectBox(field,waarde) {
   for (i=0;i<document.searchform.elements[field].length;i++) {
      if(document.searchform.elements[field].options[i].value==waarde) {
         document.searchform.elements[field].options[i].selected = true;
      }
   }
}


function SetTextBox(field,waarde) {
   document.searchform.elements[field].value = waarde;
}


function SetRadio(field,waarde) {
   if(waarde=='') {
      waarde='all';
   }
   for (i=0;i<document.theform.elements[field].length;i++) {
      if(document.theform.elements[field][i].value==waarde) {
         document.theform.elements[field][i].checked= true;
      }
   }
}

function SetCheckbox(field,waarde) {
   if(waarde!='' || waarde=='0') {
      document.theform.elements[field].checked= true;
   }
}

function changeBlock(blockName){
  var newBlockName = document.getElementById(blockName);
   if(newBlockName.style.display == "block"){
      newBlockName.style.display = "none";

   }
   else{
      newBlockName.style.display = "block";

    }
}


function AddOption(obj_ID,value,field) {
   obj1 = document.getElementById(obj_ID);
   obj1.options[obj1.options.length] = new Option(field,value);		
}

function updateCountry(object) {
   document.getElementById('s-country').options.length = 0;
   AddOption('s-country',0,'- Geen voorkeur -');
   document.getElementById('s-country').value=0;
   if(parseInt(object.value)) {
      for (i=0;i<=countrys[parseInt(object.value)].length-1;i++) {
         AddOption('s-country',countrys[parseInt(object.value)][i]['value'],countrys[parseInt(object.value)][i]['field']);   
      }      
   }
}


<!--
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.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];}
}
//-->




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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' is geen geldig e-mail adres.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
  } if (errors) alert('Onderstaande velden zijn niet correct ingevuld :\n\n'+errors);
  document.MM_returnValue = (errors == '');
}



function TellAFriend(ID_reis) {
   result = true;
   name     = document.getElementById('inp_name').value;
   email      = document.getElementById('inp_email').value;
   if(!name) {
      alert('Vul een geldige naam in');
      result = false;
   }
   if(!email) {
      alert('Vul een geldige e-mailadres in');
      result = false;
   }
      
   var opt = {
      method: 'post',
      postBody: 'name='+name+'&email='+email+'&ID_reis='+ID_reis,
      
      onSuccess: function(t) {
        document.getElementById('tellafriend').innerHTML = t.responseText;
      },
      
      on404: function(t) {
        alert('Error 404: location "' + t.statusText + '" was not found.');
      },
      onFailure: function(t) {
        alert('Error ' + t.status + ' -- ' + t.statusText);
      }
   }
   if(result)
      new Ajax.Request(siteroot+'reis/tellafriend', opt);
}         



