
/******Validation for Registration Form for shops****14-Aug-09*********/

function shopRegistartion()
{
	alert("hello");
		if(document.getElementById('reg_o_password').value == document.getElementById('reg_o_confirm').value)	
		{
			return true;
		}
		else
			{
				document.getElementById('match_div').style.visibility = 'visible';
				document.getElementById('match_div').style.position = 'static';	
			return false;
			}
}
function shopReg()
{
		if(check_fields("reg_o_name","reg_o_name_div"))
			var o_name		=	true;
		else
			var o_name		=	false;
			
		if(check_fields("reg_o_address","reg_o_address_div"))
			var o_address	=	true;
		else
			var o_address	=	false;
		
		if(check_fields("reg_o_phone","reg_o_phone_div"))
			var o_phone		=	true;
		else
			var o_phone		=	false;
		
		if(check_fields("reg_o_password","reg_o_password_div"))
			var password	=	true;
		else
			var password	=	false;
			
		if(check_fields("reg_o_email","reg_o_email_div"))
		   var	o_email = true;
		else
		   var o_email = false;
		  
		 if(o_email == true)
		 {
			var email = checkmail("reg_o_email","reg_o_email_div");
			o_email = email;
			if(document.getElementById('reg_o_email').value == document.getElementById('reg_o_Conemail').value)
			{
				document.getElementById('reg_o_Conemail_div').style.visibility = 'hidden';
				document.getElementById('reg_o_Conemail_div').style.position = 'absolute';	
				var	o_Conemail = true;	
			}else{
				document.getElementById('reg_o_Conemail_div').style.visibility = 'visible';
				document.getElementById('reg_o_Conemail_div').style.position = 'static';	
				var o_Conemail = false;
			}
		 } 
		
		if(document.getElementById('reg_o_password').value == document.getElementById('reg_o_Conpassword').value)	
		 {
			document.getElementById('reg_o_Conpassword_div').style.visibility = 'hidden';
			document.getElementById('reg_o_Conpassword_div').style.position = 'absolute';	
			var	o_password = true;
		 }	
		 else
		 {
			document.getElementById('reg_o_Conpassword_div').style.visibility = 'visible';
			document.getElementById('reg_o_Conpassword_div').style.position = 'static';	
			var o_password = false;
		 }  
		 
		 if(check_fields("reg_e_name","reg_e_name_div"))
			var e_name	=	true;
		else
			var e_name	=	false;
			
		if((o_name==true) &&(o_address==true)&&(o_phone==true)&&(password==true)&&(o_email==true)&&(o_password==true)&&(e_name==true) )
			return true;
		else
		{
			document.getElementById('reg_o_name').focus();
			return false;
		}
}







function loginform()
{	
	
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;  
	var returnval=emailfilter.test(document.getElementById("txtemail").value);
	
if(document.getElementById("txtemail").value.length != 0 && document.getElementById("txtpswd").value.length!= 0)
	{
		if (returnval==false)  
		{ 
			document.getElementById("email_frm_div").style.visibility = 'visible';  
			document.getElementById("email_frm_div").style.position = 'static';  
			return false;  
		}  
		else
		{
			document.getElementById("email_frm_div").style.visibility = 'hidden';  
			document.getElementById("email_frm_div").style.position = 'absolute';  
			return true;  
		}
	}else{
			
			if(document.getElementById("log_alert").style.visibility == 'visible')
			{
				document.getElementById("log_alert").style.visibility = 'hidden';
				document.getElementById("log_alert").style.position = 'absolute';
		    }else{
			document.getElementById("log_alert").style.visibility = 'visible'
			document.getElementById("log_alert").style.position = 'static';
			}
			 
			return false;
		 }
}

function forgetPass()
{
	if(check_fields("useremail","userM_div"))
	   var	em = true;
	else
	  var em = false;
	 if(em==true)
	  	return true;
	else
		return false;
	  
	
}

 //*******************************
// Feedback
//******************************

function validateFeedBack()
{
	
	 if(check_fields("msg","msg_div"))
	  return true;
	 else
	 return false; 

}

//*******************************
// Forgot Password
//******************************

function fpass()
{
	
	if(check_fields("email","email_div"))
	   var	em = true;
	else
	  var em = false;	
	 
	if(em)
	 {
		var emv = checkmail("email","email_div");
		em = emv;
	 } 
	 
	if(em==true)
	
		return true;
   else
   		
		return false; 
}
//*******************************
// Contact Us 
//******************************

function validateContactUs()
{
	
 	 if(check_fields("name","name_div"))
	   var nm = true;
	 else
	   var nm = false;
	 if(check_fields("email","email_div"))
	   var	em = true;
	else
	  var em = false;	
	 
	if(em)
	 {
		var emv = checkmail("email","email_div");
		em = emv;
	 } 
	 
	if(check_fields("contactNo","contactNo_div"))
	   var cn = true;
	 else
	   var cn = false;
	
	if(cn){
		if(!isNaN(document.getElementById('contactNo').value))
		{
			document.getElementById("contactNo_div").style.visibility = 'hidden';
			document.getElementById("contactNo_div").style.position = 'absolute';	
			
			var cn = true;
		}else{
			document.getElementById("contactNo_div").style.visibility = 'visible';
			document.getElementById("contactNo_div").style.position = 'static';
			
			var cn = false;
		}
	}
	 
	if(check_fields("address","address_div"))
	   var add = true;
	 else
	   var add = false;
	
	if(check_fields("msg","msg_div"))
	   var msg = true;
	 else
	   var msg = false; 
	   
	 if( (nm) &&  (em) && (cd) && (add) && (msg))
		return true;
   else
		return false;  
	  
}
//*******************************
// Employee Menagment : Add Employee
//******************************



function addUser()
{
		if((check_fields('name','name_div')) && (check_fields('desg','desg_div')) && (checkmail('email')) && (check_fields('password','password_div')))
	 	{
			if(document.getElementById('password').value == document.getElementById('confirm').value)	
			{
			return true;
			}
			else
			{
			document.getElementById('match_div').style.visibility = 'visible';
			document.getElementById('match_div').style.position = 'static';	
			return false;
			}
			if(checkmail('email'))
			{
			return true;	
			}
		}
		
		else
		{
			return false;
		}
}
//*******************************
//testimonial email validation
//*******************************


function vTestimonialForm()
{
	
 	 if(check_fields("name","name_div"))
	   var nm = true;
	 else
	   var nm = false;
	   
	  if(check_fields("comment","comment_div"))
	   var cd = true;
	 else
	   var cd = false;
	 
	 if(check_fields("email","email_div"))
	   var	em = true;
	else
	   var em = false;
	  
	 if(em == true)
	 {
		var emv = checkmail("email","email_div");
		em = emv;
	 } 
	  
	 if( (nm == true) && (cd == true) &&  (em == true) )
		return true;
   else
		return false;  
	  
}
//*******************************
//hide div
//*******************************

function hidealldiv()
{
	
	document.getElementById("textfieldName_div").style.visibility = 'hidden';
	document.getElementById("textfieldLastName_div").style.visibility = 'hidden';
	document.getElementById("email_id_div").style.visibility = 'hidden';
	document.getElementById("txtpswd_div").style.visibility = 'hidden';
	document.getElementById("txtconpswd_div").style.visibility = 'hidden';
	//document.getElementById("radGender").style.visibility = 'hidden';
	document.getElementById("txtEcpswd_div").style.visibility = 'hidden';
	document.getElementById("txtDOB_div").style.visibility = 'hidden';
	
}


//**************************************
// Employee Management >> Edit Employee
//**************************************

function applyCarjob()
{
	 var a = check_fields("textfieldName","textfieldName_div");
	 var b = check_fields("textfieldLastName","textfieldLastName_div");	
	 var c = check_fields("txtDOB","txtDOB_div");	 	   
	 var d = check_fields("txtPrstLoc","txtPrstLoc_div");	 	   
	 var e = check_mail("email_id","email_id_div");	
	 var f = check_fields("contNo","contNo_div");
	if(a && b && c && d && e && f){
		return true;
	}
	 else{
		return false;
	 }
}

function contactUsqq()
{
 	 if(check_fields("textfieldName","textfieldName_div"))
		var	a = true;
	 else
	   var a = false;
	   
	if(check_mail("email_id","email_id_div"))
	 	var b = true;
	else
	   var b = false;
	  
	 if(check_fields("txtComProfile","txtComProfile_div"))
	 
		var	c = true;
	 else
	   var c = false; 	
	   
	 if(check_fields("txtAddress","txtAddress_div"))
		var	d = true;
	 else
	   var d = false; 
	   
	 if(check_fields("txtDiscription","txtDiscription_div"))
		var	e = true;
	 else
	   var e = false;	
	   
	if((a == true) && (b == true) && (c == true) && (d == true) && (e == true))
		return true;
	 else
		return false;
}


function loginChk()
{
		
		if((checkmail('email')) && (check_fields('password','password_div')))
	 	{
			if(document.getElementById('password').value == document.getElementById('confirm').value)	
			{
				return true;
			}
			else
			{
				
			document.getElementById('match_div').style.visibility = 'visible';
			document.getElementById('match_div').style.position = 'static';	
			return false;
			}
		}
		else
		{
			return false;
		}
		
}

function loginChk1()
{
		
		if((check_fields("textfieldUser","textfieldUser_div")) && (document.getElementById('textfieldPass').value.length != 0))
	 	{
			return true;
		}
		else
		{
			document.getElementById('textfieldUser_div').style.visibility = 'visible';
			document.getElementById('textfieldUser_div').style.position = 'static';	
			return false;
		}
		
}

//**************************************
// Member Profile Edit
//**************************************

function profileChk()
{
		if((check_fields("memName","memName_div")) && (checkmail("email")) && (check_fields("memDesg","memDesg_div"))  )
	 	{
			if(checkmail('email'))
			{
			return true;	
			}
		}
		else
		{
			return false;
		}
}

//**************************************
// Memeber's Profile > ChangePass
//**************************************

function ChangePass()
{
	
		if((check_fields("memName","memName_div")) && (checkmail("email")) && (check_fields("memDesg","memDesg_div"))  )
	 	{
			if(checkmail('email'))
			{
			return true;	
			}
		}
		else
		{
			return false;
		}
}

//**************************************
//Product's >> Download Form
//**************************************

function downloadForm()
{
						
 	 if(check_fields("textfieldName","textfieldName_div"))
		var	a = true;
	 else
	   var a = false;
	   
	 if(check_fields("textfieldLastName","textfieldLastName_div"))
		var	b = true;
	 else
	   var b = false; 	
	   
	 if(check_fields("txtDOB","txtDOB_div"))
		var	c = true;
	 else
	   var c = false; 
	   
	if(checkmail("email_id"))
	 	var d = true;
	else
	   var d = false;
	   
	if(check_fields("txtps","txtpswd_div"))
		var	e = true;
	 else
	   var e = false;
	   
	   if(check_fields("txtcps","txtEcpswd_div"))
		var	f = true;
	 else
	   var f = false; 
	
	   
	   if(document.getElementById('txtps').value == document.getElementById('txtcps').value)
			{
				//alert(document.getElementById('txtcps').value);
				var	g = true;
			}
			else
			{
			document.getElementById('txtconpswd_div').style.visibility = 'visible';
			document.getElementById('txtconpswd_div').style.position = 'static';	
			var	g = false;
			}	
			
	
	   	   
	if((a == true) && (b == true) && (c == true) && (d == true) &&(e == true) &&(f == true) &&(g == true))
		return true;
	 else
		return false;
}

//**************************************
//Product's >> Download Form
//**************************************

function downloadFormAjax()
{
 	if(check_fields("textfieldName","textfieldName_div"))
		var	a = true;
	 else
	   var a = false;
	   
	 if(check_fields("textfieldLastName","textfieldLastName_div"))
		var	b = true;
	 else
	   var b = false; 	
	   
	 if(check_fields("txtDOB","txtDOB_div"))
		var	c = true;
	 else
	   var c = false; 
	   
	if(checkmail("email_id"))
	 	var d = true;
	else
	   var d = false;
	   
	if(check_fields("txtps","txtpswd_div"))
		var	e = true;
	 else
	   var e = false;
	   
	   if(check_fields("txtcps","txtEcpswd_div"))
		var	f = true;
	 else
	   var f = false; 
	
	   
	   if(document.getElementById('txtps').value == document.getElementById('txtcps').value)
			{
				//alert(document.getElementById('txtcps').value);
				var	g = true;
			}
			else
			{
			document.getElementById('txtconpswd_div').style.visibility = 'visible';
			document.getElementById('txtconpswd_div').style.position = 'static';	
			var	g = false;
			}	
			
	
	   	   
	if((a == true) && (b == true) && (c == true) && (d == true) &&(e == true) &&(f == true) &&(g == true))
		return true;
	 else
		return false;
}






function check_admin_account1()
{
		if((checkmail('email')) && (check_fields('password','password_div')))
	 	{
			if(document.getElementById('password').value == document.getElementById('confirm').value)	
			{
				return true;
			}
			else
			{
			document.getElementById('match_div').style.visibility = 'visible';
			document.getElementById('match_div').style.position = 'static';	
			return false;
			}
		}
		else
		{
			return false;
		}
		
}
function check_admin_account()
{
		if((checkmail('email')) && (check_fields('password','password_div')))
	 	{
			if(document.getElementById('password').value == document.getElementById('confirm').value)	
			{
				return true;
			}
			else
			{
			document.getElementById('match_div').style.visibility = 'visible';
			document.getElementById('match_div').style.position = 'static';	
			return false;
			}
		}
		else
		{
			return false;
		}
		
}


/* Updated 2-March-08 - Samir */
function check_admin()
{
		if((check_fields('name','name_div')) && (checkmail('email')) && (check_fields('login','login_div')) && (check_fields('password','password_div')))
	 	{
			if(document.getElementById('password').value == document.getElementById('confirm').value)	
			{
			return true;
			}
			else
			{
			document.getElementById('match_div').style.visibility = 'visible';
			document.getElementById('match_div').style.position = 'static';	
			return false;
			}
			if(checkmail('email'))
			{
			return true;	
			}
		}
		
		else
		{
			return false;
		}
}

/* function check_image(field_id,span_name) */
function check_image(field_id)
{
	if (document.getElementById(field_id).value.length != 0)
	{
		var ext = document.getElementById(field_id).value;
		ext = ext.substring(ext.length-3,ext.length);
 		ext = ext.toLowerCase();
		if((ext != 'jpg') && (ext != 'gif') && (ext != 'png') )
		 {
/**
 * 			document.getElementById(span_name).style.visibility = 'visible';
			document.getElementById(span_name).style.position = 'static';
 */
			return false;
   		 }
 		 else
		 {
/**
 * 				document.getElementById(span_name).style.visibility = 'hidden';
				document.getElementById(span_name).style.position = 'absolute';
				document.getElementById('photo_ext').value = ext;
 */
				return true;	
		 }
	}
	else
	{
/**
 * 		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';

		return false;
		 */
		return true;
	}
}


function check_fields(field_id,span_name)
{	
	if (document.getElementById(field_id).value.length != 0)
	  {
		document.getElementById(span_name).style.visibility = 'hidden';
		document.getElementById(span_name).style.position = 'absolute';	
		return true;
	  }
	  else
	  {
		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';
		return false;
	  }
}


function check_dropdownfields(field_id,span_name)
{
  if (document.getElementById(field_id).value != 0)
  {
	document.getElementById(span_name).style.visibility = 'hidden';
	document.getElementById(span_name).style.position = 'absolute';
	return true;
  }
  else
  {
	document.getElementById(span_name).style.visibility = 'visible';
	document.getElementById(span_name).style.position = 'static';
	return false;
  }
}

/* Added 2nd March 08 - samir */
function checkmail(email_field)  
{  
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i  
	var returnval=emailfilter.test(document.getElementById(email_field).value)  
	if (returnval==false)  
	{  
		document.getElementById(email_field+"_div").style.visibility = 'visible';  
		document.getElementById(email_field+"_div").style.position = 'static';  
		return false;  
	}  
	else
	{
		document.getElementById(email_field+"_div").style.visibility = 'hidden';  
		document.getElementById(email_field+"_div").style.position = 'absolute';  
		return true;  
	}
} 

function getschdval()
{
	 if(document.getElementById("schd").value != '0')
	 {  
		document.getElementById("schdval").value = document.getElementById("schd").value;
		return true;
	 }
	 else
	 {
	 	document.getElementById("schd_div").style.visibility = 'visible';  
		document.getElementById("schd_div").style.position = 'static';  
		return false;  
	 }
}

function check_mail(email_field,span_name)  
{  
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i  
	var returnval=emailfilter.test(document.getElementById(email_field).value)  
	
	if (returnval==false)  
	{  
		document.getElementById(span_name).style.visibility = 'visible';  
		document.getElementById(span_name).style.position = 'static';  
		return false;  
	}  
	else
	{
		document.getElementById(span_name).style.visibility = 'hidden';  
		document.getElementById(span_name).style.position = 'absolute';  
		return true;  
	}
} 


function isNan(field_id,span_name)
{	
	  if (!isNaN(document.getElementById(field_id).value))
	  {
		document.getElementById(span_name).style.visibility = 'hidden';
		document.getElementById(span_name).style.position = 'absolute';	
		return true;
	  }
	  else
	  {
		document.getElementById(span_name).style.visibility = 'visible';
		document.getElementById(span_name).style.position = 'static';
		return false;
	  }
}
