// JavaScript Document
function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight)=='number') {
windowHeight=window.innerHeight;
}
else {
if (document.documentElement&&
document.documentElement.clientHeight) {
windowHeight=
document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight=document.body.clientHeight;
}
}
}
return windowHeight;
}


function getWindowWidth() {
var windowWidth=0;
if (typeof(window.innerWidth)=='number') {
windowWidth=window.innerWidth;
}
else {
if (document.documentElement&&
document.documentElement.clientWidth) {
windowWidth=
document.documentElement.clientWidth;
}
else {
if (document.body&&document.body.clientWidth) {
windowWidth=document.body.clientWidth;
}
}
}
return windowWidth;
}

var newwindow;
function poptastic(url,width,height)
{
	newwindow=window.open(url,'name','height='+height+',width='+width+',left='+((getWindowWidth()/2)-width/2)+',top='+((getWindowHeight()/2)-height/2)+',scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function validate()
{
try
         { 
           with( document.employer )
           {
           if( employer_username.value == "")
           {
              throw "Silakan isi username Anda";
           }
           if( employer_username.value.length < 6 )
           {
              throw "Username Anda harus mempunyai setidaknya 6 karakter.";
           }
           if( employer_password.value == "" )
           {
              throw "Silakan isi password Anda.";
           }
           if( employer_password.value.length < 6 )
           {
              throw "Password Anda harus mempunyai setidaknya 6 karakter.";
           }
		   
		   if( confirm_password.value != employer_password.value )
           {
              throw "Password Anda tidak sama.";
           }
		   if( employer_email.value == "" )
           {
              throw "Silakan isi email Anda.";
           }

			var str = employer_email.value;
			var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    	   if (!str.match(re)) {
               throw "Silakan periksa format email Anda.";
  		   }

		   if( company_name.value == ""  )
           {
              throw "Silakan isi nama perusahaan Anda.";
           }

			if( company_address.value == "" )
           {
              throw "Silakan isi alamat perusahaan Anda.";
           }

			if( company_city.value == "" )
           {
              throw "Silakan isi kota perusahaan Anda.";
           }
		   
			if( company_location.value == "" )
           {
              throw "Silakan isi lokasi perusahaan Anda.";
           }

			if( company_postalcode.value == "" )
           {
              throw "Silakan isi kode pos perusahaan Anda.";
           }

			if( contact_person.value == "" )
           {
              throw "Silakan isi contact person Anda.";
           }
			if( job_title.value == "" )
           {
              throw "Silakan isi jabatan contact person Anda.";
           }
			if( contact_phone.value == "" )
           {
              throw "Silakan isi nomor kontak contact person Anda.";
           }

//			if( company_phone.value == ""  ||
//               isNaN( company_phone.value ))
//           {
//              throw "Silakan isi nomor telepon perusahaan Anda. Nomor telepon hanya boleh angka, tidak boleh ada spasi dan tanda baca.";
//           }
			if( company_phone.value == "" )
           {
              throw "Silakan isi nomor telepon perusahaan Anda. ";
           }

			if( company_industry.value == "" )
           {
              throw "Silakan isi industri perusahaan Anda.";
           }
			if( company_type.value == "" )
           {
              throw "Silakan isi tipe perusahaan Anda.";
           }
			if( agree.checked != true )
           {
              throw "Silakan baca dan beri tanda checklist pada Privacy and Terms of Service Statement.";
           }

		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

function val_keyword()
{
try
         { 
           with( document.search )
           {
           if( keyword.value == "")
           {
              throw "Keyword tidak boleh kosong";
           }
           if( keyword.value.length < 3 )
           {
              throw "Keyword harus setidaknya 3 karakter.";
           }
		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

function val_pass()
{
try
         { 
           with( document.chg_pass )
           {
           if( old_password.value == "")
           {
              throw "Silakan masukkan password lama Anda!";
           }
           if( new_password.value.length < 6 )
           {
              throw "Password Anda harus mempunyai setidaknya karakter!";
           }
           if( new_password.value != confirm_password.value )
           {
              throw "Password baru dan Confirm Password tidak sama!";
           }
           if( new_password.value == old_password.value )
           {
              throw "Password baru dan lama Anda tidak sama! Silakan ulangi lagi!";
           }
		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}


function user_validate()
{
try
         { 
           with( document.register )
           {
/*           if( user_name.value == "")
           {
              throw "Silakan isi username Anda";
           }
           if( user_name.value.length < 6 )
           {
              throw "Username Anda harus mempunyai setidaknya 6 karakter.";
           }
           if( user_pass.value == "" )
           {
              throw "Silakan isi password Anda.";
           }
           if( user_pass.value.length < 6 )
           {
              throw "Password Anda harus mempunyai setidaknya 6 karakter.";
           }
		   
		   if( confirm_password.value != user_pass.value )
           {
              throw "Password Anda tidak sama.";
           }
		   if( user_email.value == "" )
           {
              throw "Silakan isi email Anda.";
           }
			var str = user_email.value;
			var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    	   if (!str.match(re)) {
               throw "Silakan periksa format email Anda.";
  		   }

			if( user_salutation.value == ""  )
           {
              throw "Silakan pilih sapaan untuk Anda.";
           }
		   if( user_fname.value == ""  )
           {
              throw "Silakan isi nama depan Anda.";
           }
		   if( user_lname.value == ""  )
           {
              throw "Silakan isi nama belakang Anda.";
           }

			if( user_address.value == "" )
           {
              throw "Please provide your address.";
           }
			if( user_city.value == "" )
           {
              throw "Please provide your city.";
           }
		   if( user_phone.value == ""  ||
               isNaN( user_phone.value ))
           {
              throw "Please provide your phone number.";
           }
			if( user_gender.value == "" )
           {
              throw "Silakan pilih jenis kelamin Anda.";
           }
			if( bdate.value == "" && bmonth.value == "" && byear.value == "")
           {
              throw "Silakan isi tanggal lahir Anda.";
           }

			if( agree.checked != true )
           {
              throw "Silakan baca dan beri tanda checklist pada Privacy and Terms of Service Statement.";
           }
/*			if( user_experience.value == "" )
           {
              throw "Please select your experience level.";
           }

			if( new_from_month.value == "" && new_from_month.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_from_year.value == "" && new_from_year.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_to_month.value == "" && new_to_month.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_to_year.value == "" && new_to_year.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_company.value == "" && new_company.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_position.value == "" && new_position.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_salary.value == "" && new_salary.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_job_careerlevel.value == "" && new_job_careerlevel.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_job_category.value == "" && new_job_category.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }

			if( new_job_industry.value == "" && new_job_industry.title =="required")
           {
              throw "Silakan isi pengalaman Anda.";
           }
*/

		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

function post_validate()
{
try
         { 
		 sbm = document.post.submit_btn;
	  	 sbm.disabled = true;
		 //alert (sbm.disabled);
           with( document.post )
           {
           if( job_position.value == "")
           {
              throw "Posisi pekerjaan tidak boleh kosong.";
           }
           if( job_careerlevel.value == "" )
           {
              throw "Silakan pilih level karir.";
           }
           if( job_category.value == "" )
           {
              throw "Silakan pilih kategori.";
           }
           if( job_location.value =="" )
           {
              throw "Silakan pilih lokasi.";
           }
		   
		   if( job_type.value == "" )
           {
              throw "Silakan pilih tipe pekerjaan.";
           }
		   if( job_salary1.value == "" && hide_salary.checked != true )
           {
              //alert(hide_salary.checked);
			  throw "Silakan masukkan gaji.";
           }

		   if( isNaN( job_salary1.value ))
           {
              throw "Hanya boleh angka.";
           }

			if( job_qualification.value == ""  )
           {
              throw "Silakan pilih kualifikasi.";
           }
		   if( job_experience.value == ""  )
           {
              throw "Silakan tulis pengalaman minimal.";
           }
		}
      }
      catch( error )
      {
        alert( error );
		sbm.disabled = false;
        return( false );

      }
      return( true ); 
}

function val_check()
{
try
         { 
           with( document.form )
           {
           if( applicant_check.value == "")
           {
              throw "Silakan pilih satu record atau lebih.";
           }
		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

function photo_validate()
{
try
         { 
           with( document.resume )
           {
           if( user_photo.value == "")
           {
              throw "Silakan upload foto Anda";
           }
		   
		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

function contact_validate()
{
try
         { 
           with( document.contact )
           {
           if( name.value == "" || name.value=="name")
           {
              throw "Silakan tulis nama Anda";
           }
           if( address.value == "" || address.value=="address")
           {
              throw "Silakan tulis alamat Anda";
           }
           if( email.value == "" || email.value=="email")
           {
              throw "Silakan tulis email Anda";
           }
           if( city.value == "" || city.value=="city")
           {
              throw "Silakan tulis kota Anda";
           }
           if( comment.value == ""   )
           {
              throw "Silakan tulis komentar Anda";
           }
		   
		}
      }
      catch( error )
      {
        alert( error );
        return( false );
      }
      return( true ); 
}

