
function samePwd(p1,p2){
	if(p1.value!=p2.value){
		alert("Password Error");
		p2.focus();
		return false;
	}
		return true;
}

function onlyDigit()
{
  if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))
         || (window.event.keyCode == 13) || (window.event.keyCode == 46)
         || (window.event.keyCode == 45)))
  {
    window.event.keyCode = 0 ;
  }
}



function trim(inputString) {
  var retValue = inputString;
  var ch = retValue.substring(0, 1);
  while (ch == " ") {
    retValue = retValue.substring(1, retValue.length);
    ch = retValue.substring(0, 1);
  }
  ch = retValue.substring(retValue.length-1, retValue.length);
  while (ch == " ") {
    retValue = retValue.substring(0, retValue.length-1);
    ch = retValue.substring(retValue.length-1, retValue.length);
  }
  while (retValue.indexOf("  ") != -1) {
    retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
  }
  return retValue;
}

function checkForm(check_form_etem)
  {
	  if(check_form_etem!=null&&check_form_etem.tagName=='FORM')
	  {
		 for(var i=0;i<check_form_etem.length;i++)
		  {
			  var temp_boolean=true;
			  var temp_comp=check_form_etem.elements[i];
			  var temp_type= temp_comp.type;
			  if(temp_comp!=null&&temp_comp.msg!=null)
			  {
                if(temp_type=='textarea'||temp_type=='text' || temp_type=='file'||temp_type=='password')
                 {
                   temp_boolean=temp_boolean && trim(temp_comp.value)!='';
                   //жǷisemail
                   if(temp_boolean && temp_comp.isemail!=null){
                     		temp_boolean = temp_boolean && ValidataEmail(temp_comp.value);
                   }
				   //жǷisdigit
                   if(temp_boolean && temp_comp.isdigit!=null){
							temp_boolean = temp_boolean && parseInt(temp_comp.value);
                   }
				   //жǷisfloat
                   if(temp_boolean && temp_comp.isfloat!=null){
							temp_boolean = temp_boolean && parseFloat(temp_comp.value);
                   }
				 }
				 if(temp_type=='select-one')
				 {
					temp_boolean=temp_boolean && temp_comp.value!='0' && temp_comp.value!='';
				 }
				 if(!temp_boolean)
				 {
					alert(temp_comp.msg);
					return false;
				 }
			  }
		  }

	  }
	  else
	  {
		alert('javaScript')
	  }
	  return true;
  }

function ValidataEmail(str)
{
	var ret = false;
	if (typeof(str) != "undefined")
	{
		if (/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(str)){
		ret = true;}
	}
	return ret;
}

