String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function CheckForm( theform )
{
	if( theform.naam.value.trim().length == 0 ){
		alert ("Naam is een verplicht veld");
		theform.naam.focus();
		return false;
	}
	if( theform.voornaam.value.trim().length == 0 ){
		alert ("Voornaam is een verplicht veld");
		theform.voornaam.focus();
		return false;
	}	
	

	if( theform.straat.value.trim().length == 0 ){
		alert ("Straat is een verplicht veld");
		theform.straat.focus();
		return false;
	}		

	if( theform.huisnummer.value.trim().length == 0 ){
		alert ("Huisnummer is een verplicht veld");
		theform.huisnummer.focus();
		return false;
	} else { 
		if(!isInteger(theform.huisnummer.value.trim())){
			alert ("Huisnummer moet een nummer zijn");
			theform.huisnummer.focus();
			return false; 
		}
			
	}

	if ((theform.emailaddress.value.trim().length > 0) && !evalidate(theform.emailaddress.value)) {
		alert('Verkeerde formaat');
		theform.emailaddress.focus();
		return false;
	} 
	
	if (!theform.afspraak.checked && !theform.offerte.checked) {
		alert ("'Wat wenst U' is een verplicht veld");
		theform.afspraak.focus();
           	return false;

	}
	return true;
}

// 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);
	if (s.charAt(0)!= '0') {
		return false;
	}	
	if (!isInteger(s)) {
		return false;
	}
	return true;
}

function evalidate(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) {
      return false;
   }
   return true;
}
function ShowMenu(num, menu, max)
        {
                //starting at one, loop through until the number chosen by the user
                for(i = 1; i <= num; i++){
                        //add number onto end of menu
                        var menu2 = menu + i;
                        //change visibility to block, or 'visible'
                        document.getElementById(menu2).style.display = 'block';
                }
                //make a number one more than the number inputed
                var num2 = num;
                num2++;
                //hide it if the viewer selects a number lower
                //this will hide every number between the selected number and the maximum
                //ex.  if 3 is selected, hide the <div> cells for 4, 5, and 6
                //loop until max is reached
                while(num2 <= max){
                        var menu3 = menu + num2;
                        //hide 
                        document.getElementById(menu3).style.display = 'none';
                        //add one to loop
                        num2=num2+1;
                }
        }

        
 

// Calculate four digit year.
function fourdigits(number)	{
	return (number < 1000) ? number + 1900 : number;
}

// Join it all together
function getToday(){
// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Minggu', 'Senin','Selasa','Rabu','Kamis','Jumat','Sabtu');

// Array list of months.
var months = new Array('Januari','Pebruari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','Nopember','Desember');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();	
	
	
today =   days[now.getDay()] + ", " + 
         date + " " +
 		 months[now.getMonth()] + " " +
         (fourdigits(now.getYear())) ;

// Print out the data.
return today;

}