
// *** Numeric validation ***
   function isNumericKey(e)
	{
	var k = document.all ? e.keyCode : e.which;
	return ((k > 47 && k < 58) || k == 8 || k == 0);
	}
	
// *** Float validation ***
function keyCheck(eventObj, obj)
{
var keyCode

// Check For Browser Type
if (document.all){ 
keyCode=eventObj.keyCode
}
else{
keyCode=eventObj.which
}

var str=obj.value

if(keyCode==46){ 
if (str.indexOf(".")>0){
return false
}
}

if((keyCode<48 || keyCode >58) && (keyCode != 46)){ // Allow only integers and decimal points 
return false
}
return true
}

	
//**************	
	
function validateTextbox(textbox, message) //make sure user enters a value
{
if (textbox.value=="") //if current field is empty
{
alert(message); //display an error message
textbox.select(); //select the current textbox
textbox.focus(); //and set the focus there
return false; //return error condition
}
else
return true;
}
// Checking the Type of image
function checkimagetype(ext) {
  if(!ext) return true;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  if((ext != 'jpg') && (ext != 'peg') && (ext != 'tif')) {
  document.frmstore.hdntxtmsg.value="Please select a .jpg, .jpeg, or .tif file only";
  document.frmstore.file.focus();
    return false; }
  else
    return true; 
}
// list box checking

function validateListbox(list, message) //make sure user selects an item
{
if (list.selectedIndex == 0) //first model is not valid
{
alert (message); //display an error message
list.focus(); //and set the focus there
return false; //return an error condition
}
else
return true;
}


// *** Email validation ***
	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || 
str.indexOf(at)==lstr){
		   alert("Invalid email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || 
str.indexOf(dot)==lstr){
		    alert("Invalid email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || 
str.substring(lat+1,lat+2)==dot){
		    alert("Invalid email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid email address")
		    return false
		 }

 		 return true					
	}
//*****************email validation end

// *** Email validation display in textbox ***
	function echecknew(str,frm) {
        dml=document.forms[frm];
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || 
str.indexOf(at)==lstr){
		   //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || 
str.indexOf(dot)==lstr){
		    //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || 
str.substring(lat+1,lat+2)==dot){
		   //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid email address")
		   dml.txtdisplay.value="Invalid email address..";
		    return false
		 }

 		 return true					
	}
//*****************email validation end


//################Friend email in the left hand side
function validfriendmail()
{
	 var emailID=document.frmmail.txtmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your friends Email address..")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
  document.frmmail.name="vary";
  document.frmmail.method="post";
  document.frmmail.action="contact-us-submit.php";
  document.frmmail.submit();
	return true;
}


function contactmail()
{
	 var emailID=document.frmcontact.txt_email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true;
}

 //*********************raminder mail checking
 function remaindemail()
{
	 var emailID=document.frmrem.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true;
}

//trim blankspace validation
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
 
