

//=======================================================================

//	DATA VALIDATION

//=======================================================================



// with Message box

	function isEmpty(obj) {

		

		var len = obj.value.length;

		var fl_empty = true;

		

		for(i = 0; i < len; i++) {

			if (obj.value.substring(i,i + 1) != " ")

				fl_empty = false;

			if (!fl_empty)

				break;

		}

		

		if (fl_empty) {

			obj.focus();

			obj.select();

			alert("Field can't be empty!");

			return true;

		}



		return false;



	}



//--------------------------------------------------------------------



// without Message box

	function isEmpty1(obj) {

		var len = obj.value.length;

		var fl_empty = true;

		

		for(i=0;i<len;i++) {

			if ( obj.value.substring(i,i + 1) != " " ) 

				fl_empty = false;

			if ( !fl_empty )

				break;

		}

		

		if ( fl_empty )

			return true;

	

		return false;



	}



//--------------------------------------------------------------------



	function isSelected(obj) {

		if ( obj.value == "None" || obj.selectedIndex == 0 ) {

			

			alert("Please, select an item in the list!");

                                       obj.focus();

			return false;

		}

		else

			return true;

	}



//-----------------------------------------------------------------



	function isChecked(obj) {



		var ok = false;

			if ( obj.checked )

				return true;

			else {

				alert("The field must be selected!");

				//obj.focus();

				return false;

			}

	}



//--------------------------------------------------------------------



	function isPhone(obj) {

	

		var len = obj.value.length;

		var str = "`~!@=$%^&*_|\\}{[]:;\"'<,>?/";

		var char_tmp ="";

		

		for(i=0;i<len;i++) {

			char_tmp = obj.value.substring(i,i + 1);  

			if ( str.indexOf(char_tmp) != -1 )   {

				obj.focus();

				obj.select();

				alert("Symbol: " + char_tmp + " is not permitted for phone number!");

				return false;

			}

		}

		

		return true;



	}



//--------------------------------------------------------------------



	function isEmail(obj) {

		

		var len = obj.value.length;

		var str = " ~!#='`/$^&*()+\\|?><:;,\"{}[]";

		var char_tmp ="";

		

		for(i=0;i<len;i++) {

			char_tmp = obj.value.substring(i,i + 1);  

			if ( str.indexOf(char_tmp) != -1 )   {

				obj.focus();

				obj.select();

				alert("Symbol: " + char_tmp + " is not permitted for e-mail address!");

				return false;

			}

		}

		

			if ((obj.value.indexOf("@", 0)>=0) && (obj.value.indexOf(".", 0)>=0))

	 			return true;

			else {

				obj.focus();

				obj.select();

				alert("Entry must contain @ and . symbol as a part of valid e-mail address!");

				return false;

			}









		return true;

			

	}



//-------------------------------------------------------------------



	function isURL(obj) {



		var len = obj.value.length;

		var str = " !$%^*()\\|><;,\"{}[]";

		var char_tmp ="";

		

		for(i=0;i<len;i++) {

			char_tmp = obj.value.substring(i,i + 1);  

			if ( str.indexOf(char_tmp) != -1 )   {

				obj.focus();

				obj.select();

				alert("Symbol: " + char_tmp + " is not permitted for URL address!");

				return false;

			}

		}



		if (obj.value.indexOf("://", 0)>=0)

 			return true;

		else {

			obj.focus();

			obj.select();

			alert("Entry must contain :// symbols as a part of valid URL address!");

			return false;

		}

		

		return true;

	}



//-----------------------------------------------------------------



	function isRadioEmpty(obj) {



		var ok = false;

		var len = obj.length;

		for (i = 0; i < len; i++) {

			if (obj[i].checked) 

				{ ok= true; }	

		}

		if (!ok) {

			obj[0].focus();

			alert("One option must be selected in the group!");

			return true;

		}

		return false;



	}



//-----------------------------------------------------------------



	function isNumber(obj) {

	

		var len = obj.value.length;

		var str = "0123456789-/";

		var char_tmp ="";

		var count=0;

	

		for(i=0;i<len;i++) {

			char_tmp = obj.value.substring(i,i + 1);  

			if ( str.indexOf(char_tmp) != -1 )   

				count++;

		}

		

		if ( count == len )

			return true;

		else {

			obj.focus();

			obj.select();

			alert("Field must be numeric!");

			return false;

		}

	}



//-----------------------------------------------------------------



	function isNumberAndDot(obj) {

	

		var len = obj.value.length;

		var str = "0123456789.";

		var char_tmp ="";

		var count=0;

	

		for(i=0;i<len;i++) {

			char_tmp = obj.value.substring(i,i + 1);  

			if ( str.indexOf(char_tmp) != -1 )   

				count++;

		}

		

		if ( count == len )

			return true;

		else {

			obj.focus();

			obj.select();

			alert("Field must be numeric!");

			return false;

		}

	}



//=======================================================================

//	FIELD ENABLING/DISABLING

//=======================================================================



	var actColor = "#ffffff";

	var inactColor = "#cccccc";

	

	function disableText(obj) {

		obj.value = "";

		obj.disabled = true;

		obj.className = "controlgrey";

		return true;

	}



	function enableText(obj) {

		obj.disabled = false;

		obj.className = "control";

		return true;

	}



	function disableRadio(obj) {

		obj[0].disabled = true;

		obj[1].disabled = true;

		obj[0].className = "controlgrey";

		obj[1].className = "controlgrey";

		return true;

	}



	function enableRadio(obj) {

		obj[0].disabled = false;

		obj[1].disabled = false;

		obj[0].className = "control";

		obj[1].className = "control";

		return true;

	}



//-----------------------------------------------------------------



function chk_pass()

 {



   if ((document.cp.password.value) !=  (document.cp.repassword.value))

      {

        document.cp.password.select();

        alert("password not same in confirm password box");

        return true;

      

       }else

          {               

               return false;

           }



}







function chk_pin()

 {



   if ((document.cp.pin.value) !=  (document.cp.repin.value))

      {

        document.cp.pin.select();

        alert("pin not same in confirm pin box");

        return true;

      

       }else

          {               

               return false;

           }



}



































