
function checkOrderValues(theForm)
{	

	for(var i=0; i < theForm.length; i++)
	{	
		switch(theForm[i].name)
		{	case "form_firstname"			:	if(theForm[i].value.length < 1) { alert('Voer uw voorletter(s) in.'); return false; } break;
			case "form_lastname"			:	if(theForm[i].value.length < 1) { alert('Voer uw achternaam in.'); return false; } break;
			case "form_email"				:	if(echeck(theForm[i].value) == false){ alert("Voer een correct email adres in.\n bijv: someone@somewhere.com."); return false; }break;
			case "form_phone"				:	if(theForm[i].value.length < 1) { alert('Voer uw achternaam in.'); return false; } break;
			case "form_address"				:	if(theForm[i].value.length < 1) { alert('Voer uw adres in.'); return false; } break;
			case "form_postal"				:	if(theForm[i].value.length < 1) { alert('Voer uw postcode in.'); return false; } break;
			case "form_city"				:	if(theForm[i].value.length < 1) { alert('Voer uw plaats in.'); return false; } break;
			case "checklock"				:	if(theForm[i].checked == false)	{ alert("Algemene voorwaarden gelezen?"); return false; } break;
			
		}
	}
return true; // -> return true if switch/case completes.
}



function checkContactValues(theForm)
{	

	for(var i=0; i < theForm.length; i++)
	{	
		switch(theForm[i].name)
		{	case "form_firstname"			:	if(theForm[i].value.length < 1) { alert('Voer uw voornaam in.'); return false; } break;
			case "form_lastname"			:	if(theForm[i].value.length < 1) { alert('Voer uw achternaam in.'); return false; } break;
			case "form_email"				:	if(echeck(theForm[i].value) == false){ alert("Voer een geldig email adres in.\n bijv: someone@somewhere.com."); return false; }break;
			case "form_message"				:	if(theForm[i].value.length < 1) { alert('Voer uw bericht in.'); return false; } break;
		}
	}
return true; // -> return true if switch/case completes.
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidatePhone(form){
	var Phone=form
	
	if ((Phone==null)||(Phone=="")){
		//alert("Voer uw telefoon nummer in.\n bijv: 06-12345678.")
		//Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone)==false){
		//alert("Voer uw telefoon nummer in.\n bijv: 06-12345678.")
		Phone=""
	//	Phone.focus()
		return false
	}
	return true
 }

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Voer uw email adres in.\n bijv: someone@somewhere.com.")
		    return false
		 }

 		 return true					
	}


function removeAll(theName){
	for (var i=(theName.options.length-1); i>=0; i--) { 
		theName.options[i] = null; 
	} 
	theName.selectedIndex = -1; 
} 

function addItem(theName, theVisible, theValue){
   theName[theName.length] = new Option(theVisible,theValue);
}

function getInfo() {
	with(document.form_order){
		if (form_product_type[0].selected==true) {
			removeAll(form_offer)
			addItem(form_offer,"Kies eerst product","0")
		}
		if (form_product_type[1].selected==true) {
			removeAll(form_offer)
			addItem(form_offer,"Eenmalig bundel voor 89,-","1")
		}
		if (form_product_type[2].selected==true || form_product_type[3].selected==true) {
			removeAll(form_offer)
			addItem(form_offer,"Gratis 1 extra maand Bulkpan","2")
			addItem(form_offer,"Gratis 500 extra SMS credits","3")
		}
	}
}



function toggleFrame( state , frame ) {
			
				divEl = document.getElementById(frame);
				if ( divEl && state ) {
					if ( state == 'off' ) {
						divEl.style.display = 'none';
						divEl.style.visibility = 'hidden';
					} else {
						divEl.style.display = 'block';
						divEl.style.visibility = 'visible';
					}
				}
			}

function popupform(myform, windowname)
{
	if (! window.focus)return true;
	window.open('', windowname, 'height=800,width=700,scrollbars=yes');
	myform.target=windowname;
	return true;
}
function popUp(URL , WDT, HGT ) {
	if (navigator.appName == 'Microsoft Internet Explorer' && HGT != '768')
	{
		WDT += 20;
		HGT += 23;
	}
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, 'popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width= "+ WDT +" ,height= "+ HGT +",left = 100,top = 0');");
}
function setbackground(page){

	var colors = new Array()
	colors["home"]		= "#04E500" 
	colors["bulkboy"]	= "#00DDE5" 	
	colors["topic"]		= "#E50C00" 
	colors["premium"]	= "#E5E100" 
	colors["bestellen"] = "#CB00E5" 
	colors["contact"]	= "#E58200" 
	colors["links"]		= "#E50076" 
	
	document.getElementById("head_ad").style.backgroundImage ='URL(\'images/ad/'+image[page]+'.jpg\')'; 
	document.getElementById("content").style.backgroundImage ='URL(\'images/content/'+image[page]+'_bg.jpg\')'; 
}
function click_radio( radiobutton ){

document.send_email.template[radiobutton].checked=true
}


function gebdate( form ){
	if ( form == "contact_insert" )
	{
		var menuValue = document.contact_insert.form_gebdate.checked
		if( menuValue == true ){
			document.contact_insert.form_birthdate_year.disabled=false
			document.contact_insert.form_birthdate_month.disabled=false
			document.contact_insert.form_birthdate_day.disabled=false
		} else {
			document.contact_insert.form_birthdate_year.disabled=true
			document.contact_insert.form_birthdate_month.disabled=true
			document.contact_insert.form_birthdate_day.disabled=true
		}
	}else{
		var menuValue = document.contact_update.form_gebdate.checked
		if( menuValue == true ){
			document.contact_update.form_birthdate_year.disabled=false
			document.contact_update.form_birthdate_month.disabled=false
			document.contact_update.form_birthdate_day.disabled=false
		} else {
			document.contact_update.form_birthdate_year.disabled=true
			document.contact_update.form_birthdate_month.disabled=true
			document.contact_update.form_birthdate_day.disabled=true
		}
	}
	
}


var checkflag = "false";
function check(field) {
	if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true;
		}
		checkflag = "true";
		return "Uncheck All";
	} else {
		for (i = 0; i < field.length; i++) {
			field[i].checked = false;
		}
		checkflag = "false";
		return "Check All";
	}
}

function setTemplate(){

	document.send_email.form_content.value = 
				document.send_email.form_template.options[document.send_email.form_template.selectedIndex].value;

}


// toggle menu navigation
function toggleMenu( NAME ) {

	var frame_array = NAME;
	var frame_array = frame_array.split(":");

	for (i=0;i<=frame_array.length-1;i++)
	{
		divEL = document.getElementById(frame_array[i]);
		if( divEL.style.display == 'block' ){
			divEL.style.display = 'none';
			divEL.style.visibility = 'hidden';
		}else{
			divEL.style.display = 'block';
			divEL.style.visibility = 'visible';
		}
	}

}
