String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function CheckForm( theform )
{
	
if( theform.noanggota.value.trim().length == 0 ){
		alert ("Nomer Anggota wajib di isi, untuk ynag belum meiliki isi dengan 000 ");
		theform.noanggota.focus();
		return false;
	}

if( theform.naam.value.trim().length == 0 ){
		alert ("Nama depan wajib di isi");
		theform.naam.focus();
		return false;
	}

if( theform.nama.value.trim().length == 0 ){
		alert ("Nama Pemohon  wajib di isi");
		theform.nama.focus();
		return false;
	}


if( theform.agama.value.trim().length == 0 ){
		alert ("Agama wajib di isi");
		theform.agama.focus();
		return false;
	}

if( theform.pendidikan.value.trim().length == 0 ){
		alert ("Pendidikan Akademik wajib di isi");
		theform.pendidikan.focus();
		return false;
	}


if( theform.fakultas.value.trim().length == 0 ){
		alert ("Nama Fakultas Kedokteran Gigi (drg) di isi");
		theform.fakultas.focus();
		return false;
	}


if( theform.lulus.value.trim().length == 0 ){
		alert ("Tahun Kelulusan sesuai ijazah drg wajib di isi");
		theform.lulus.focus();
		return false;
	}
if( theform.profesi.value.trim().length == 0 ){
		alert ("Pilihan pendidikan Profesi wajib di isi");
		theform.profesi.focus();
		return false;
	}
if( theform.unit.value.trim().length == 0 ){
		alert ("Pilihan Unit Kerja wajib di isi");
		theform.unit.focus();
		return false;
	}

if( theform.status.value.trim().length == 0 ){
		alert ("Status Praktek wajib di isi");
		theform.status.focus();
		return false;
	}
	
	if( theform.tmplahir.value.trim().length == 0 ){
		alert ("Tempat lahir wajib di isi");
		theform.tmplahir.focus();
		return false;
	}	
	
	if( theform.alamat.value.trim().length == 0 ){
		alert ("alamat wajib di isi");
		theform.alamat.focus();
		return false;
	}
if( theform.namaid.value.trim().length == 0 ){
		alert ("nama ID wajib di isi");
		theform.namaid.focus();
		return false;
	}

	
	if( theform.pwd1.value.trim().length == 0 ){
		alert ("Password wajib di isi");
		theform.pwd1.focus();
		return false;
	}	

	if( theform.pwd2.value.trim().length == 0 ){
		alert ("Re type Password wajib di isi");
		theform.pwd2.focus();
		return false;
	}	
if( theform.copy.value.trim().length == 0 ){
		alert ("Ada harus yakin, ingin memiliki account email di PDGI Cabang Sragen");
		theform.copy.focus();
		return false;
	}

		if ((theform.emailaddress.value.trim().length > 0) && !evalidate(theform.emailaddress.value)) {
		alert('Email Address tidak benar');
		theform.emailaddress.focus();
		return false;
	} 
	
	
		theform.orderdate.value = getToday();
	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;

}
