	
	// Get object on form
	function getObj(name)
	{
	  if (document.getElementById)
	  {
	    return document.getElementById(name);
	  }
	  else if (document.all)
	  {
	    return document.all[name];
	  }
	  else if (document.layers)
	  {
	    return document.layers[name];
	  }
	  else return false;
	}
	
	function chk_rad(t, n, msg) {
		for (var i=0; i<n; i++) {
			if (t[i].checked!="0") return true;
		}
		alert(msg);
		return false;
	}
   
	function chk_text(t, msg) {
		if (t.value != '') return true;
		alert(msg);
		t.focus();
		return false;
	}
	
	function chk_select(t, msg) {
		if (t.selectedIndex != 0) return true;
       	alert(msg);
		t.focus();
		return false;
	}
	
	function chk_text_email(t, msg) {
      if (t.value != '') {
        var at = t.value.indexOf('@', 0);
        if (at > 1 && t.value.lastIndexOf('.') > at && t.value.lastIndexOf('.') < (t.value.length-2)) {
           return true;
        }
       }
       alert(msg);
       t.focus();
       t.select();
       return false;
   }
   
   function chk_textPassword(t, s, msg) {
		if(s.value == t.value) return true;
		alert(msg);
		s.focus();
		return false;
	}
	
	function chk_number(t, msg){
		var valid = "0123456789";
		var tt = t.value;
		for (var i=0; i < tt.length; i++) {
			temp = "" + tt.substring(i, i+1);
			if (valid.indexOf(temp) == "-1"){
				alert(msg);
				t.focus();
				return false;	
			}
		}	
		return true;
	}
	
	function chk_NumofChar(t, msg, num){
		if(t.value.length > num) return true;
		alert(msg);
		t.focus();
		return false;
	}
	
	function OnKeyPressForTest(){
  		// to allow 0-9 numeric digit in the input field
  		if( event.keyCode < 48 || event.keyCode > 57 ) event.returnValue = false;
	}
	
	function validate_audio(file) {
		
		if (file=="") return true;
		extArray = new Array(".mp3");
		allowSubmit = false;
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) { 
				allowSubmit = true; 
				break; 
			}
		}
		if (allowSubmit) return true; //form.submit();
		alert('Format Audio Invalide.');
	
	}
	
	function validate_video(file) {
		
		if (file=="") return true;
		extArray = new Array(".flv");
		allowSubmit = false;
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) { 
				allowSubmit = true; 
				break; 
			}
		}
		if (allowSubmit) return true; //form.submit();
		//else
		alert('Format Video Invalide.');
	}
	
	function validate_image(file) {
		
		if (file=="") return true;
		extArray = new Array(".gif", ".jpg", ".png");
		allowSubmit = false;
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) { 
				allowSubmit = true; 
				break; 
			}
		}
		if (allowSubmit) return true; //form.submit();
		//else
		alert('Format Photo Invalide.');
	}
	
	function validate_flash(file) {
		
		if (file=="") return true;
		extArray = new Array(".swf");
		allowSubmit = false;
		while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < extArray.length; i++) {
			if (extArray[i] == ext) { 
				allowSubmit = true; 
				break; 
			}
		}
		if (allowSubmit) return true; //form.submit();
		//else
		alert('Format Flash Invalide.');
	}
	
