String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function CheckForm( theform )
{
	if( theform.naam.value.trim().length < 3 ){
		alert ("Naam is een verplichte veld.");
		theform.naam.focus();
		return false;
	}

	if( theform.straat.value.trim().length < 3) {
		alert ("Straat is een verplichte veld.");
		theform.straat.focus();
		return false;
	}

        if( theform.woonplaats.value.trim().length < 3) {
		alert ("Woonplaats is een verplichte veld.");
		theform.woonplaats.focus();
		return false;
	}

	var btn = valButton(theform.land);
	if (btn == null)
	{
		alert("Land is een verplichte veld.");
            return false;
	}
	if (theform.email.value.trim().length < 1){
		alert("Email adres is een verplicte veld.");
		theform.email.focus();
		return false;
	}
        var mailval = theform.email.value.trim();
        var isvalid = evalidate(mailval);
        if(!isvalid) {
          alert("Geen valide email adres.");
          return false;
        }
	return true;
}

function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
// 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;

}
