var numb = '0123456789';
	var lwr = ' abcdefghijklmnopqrstuvwxyz';
	var upr = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var splchr = '!@#$%^&*_+-=<>/?:[]{}';
	var phone = '0123456789-';
	var date= '0123456789-/.';

	function isValid(parm,val) 
	{
	 for (i=0; i<parm.length; i++) 
		 {
			if (val.indexOf(parm.charAt(i),0) == -1)
				return false;
		 }
	  return true;
	}

function isAlphanum(parm)
	{  
		return isValid(parm,lwr+upr+numb);
	}

function popup(mylink, windowname)
{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
	  href=mylink.href;
	window.open(href, windowname, 'width=400,height=400,scrollbars=yes');
	return false;
}

 function LTrim( value ) 
{
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) 
{
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) 
{
	
	return LTrim(RTrim(value));
	
}
function checkNull(parm)
	{
		if(fn_Trim(parm.value) == "" || fn_Trim(parm.value) == null)
		{
			parm.value="";
			return true;
		}
		else
		{
			return false;
		}
	}

//************************************************************************************************************
//Funtion Name		:	chkLogin
//Arguments			:	thisform (Current form) 
//Return Value		:	Boolean
//Purpose			:	Validating the text fields in the form.
//Created by		:	Sarvesh Kulkarni
//Created date		:	7/10/2007
//************************************************************************************************************

function chkLogin(thisform)
{
	with(thisform)
	{
		if(txtUserName.value == "")
		{
			alert("Please enter your User ID");
			txtUserName.focus();
			return false;
		}
		if(txtPassword.value == "")
		{
			alert("Please enter your Password");
			txtPassword.focus();
			return false;
		}
	}
	return true;
}
function chkSearch1(thisform)
{
	with(thisform)
	{
		/*if(keyword.value == "")
		{
			alert("Please enter keyword");
			keyword.focus();
			return false;
		}*/
		if(selCategoty.value == "")
		{
			alert("Please select Category for Searching");
			selCategoty.focus();
			return false;
		}
	}
	return true;
}

function chkAdvSearch(thisform)
{
	with(thisform)
	{
		/*if(keyword.value == "")
		{
			alert("Please enter keyword");
			keyword.focus();
			return false;
		}*/
		if((selCategoty.value == "")&&(selCategoty1.value == ""))
		{
			alert("Please select Category for Searching");
			//selCategoty.focus();
			return false;
		}
	}
	return true;
	
		/*if((fieldName0.value == "")&&(fieldName1.value == "")&&(fieldName2.value == "")&&(fieldName3.value == "")&&(fieldName4.value == "")&&(fieldName5.value == ""))
		{
			alert("Please enter Value for Searching");
			fieldName0.focus();
			return false;
		}
*/

}

function chkBlock(thisform)
{
	with(thisform)
	{
		if(txtBlockName.value == "")
		{
			alert("Please enter Block Name");
			txtBlockName.focus();
			return false;
		}
		if(txtBlockWidth.value == "")
		{
			alert("Please enter Block Width");
			txtBlockWidth.focus();
			return false;
		}
		else if(isNaN(txtBlockWidth.value))
		{
			alert("Block Width must be numeric. Please enter valid Block Width");
			txtBlockWidth.value="";
			txtBlockWidth.focus();
			return false;
		}
		if(txtBlockHeight.value == "")
		{
			alert("Please enter Block Height");
			txtBlockHeight.focus();
			return false;
		}
		else if(isNaN(txtBlockHeight.value))
		{
			alert("Block Height must be numeric. Please enter valid Block Height");
			txtBlockHeight.value="";
			txtBlockHeight.focus();
			return false;
		}
		if(txtBlockBorder.value == "")
		{
			alert("Please enter Block Border");
			txtBlockBorder.focus();
			return false;
		}
		else if(isNaN(txtBlockBorder.value))
		{
			alert("Block Border must be numeric. Please enter valid Block Border");
			txtBlockBorder.value="";
			txtBlockBorder.focus();
			return false;
		}
	}
	return true;
}

function chkAdminLogin(thisform)
{
	//echo "dfsdfs";
	with(thisform)
	{
		if(txtLoginName.value == "")
		{
			alert("Login field left blank");
			txtLoginName.focus();
			return false;
		}
		if(txtPassword.value == "")
		{
			alert("Password field left blank");
			txtPassword.focus();
			return false;
		}
	}
	return true;
}

function fn_chkinvitefrnds(thisform,j)
{
	
	with(thisform)
	{  j--;
		thisform.hidD.value=j;
		for(k=1;k<=j;k++)
		{  
			
			
			if(document.getElementById("frndEmail"+k).value == "")
				{
				alert("Friend Email field left blank");
				document.getElementById("frndEmail"+k).focus();
				return false;
			}
			if(document.getElementById("frndEmail"+k).value.indexOf("@")< 1 || document.getElementById("frndEmail"+k).value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					document.getElementById("frndEmail"+k).value="";
					document.getElementById("frndEmail"+k).focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((document.getElementById("frndEmail"+k).value.lastIndexOf(".")-(document.getElementById("frndEmail"+k).value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					document.getElementById("frndEmail"+k).value="";
					document.getElementById("frndEmail"+k).focus();
					return false;
				}
			/*if(frndName.value == "")
			{
				alert("Friend Name field left blank");
				frndName.focus();
				return false;
			}
			if(frndEmail.value == "")
			{
				alert("Friend Email field left blank");
				frndEmail.focus();
				return false;
			}
			else
			 {
				//Check for '@' and '.' in Field Email
				if(frndEmail.value.indexOf("@")<1 || frndEmail.value.indexOf(".")<1)
				{	
					alert("Email Address is Invalid");
					frndEmail.value="";
					frndEmail.focus();
					return false;
				}
				//Check if index of '@' < '.' in Field Email
				if((frndEmail.value.lastIndexOf(".")-(frndEmail.value.indexOf("@")))<3)
				{
					alert("Email Address is Invalid");
					frndEmail.value="";
					frndEmail.focus();
					return false;
				}
			 }*/ 
		}
		return true;
	}
}

function fn_chksuggForm(thisform)
{
	with(thisform)
	{
		if(frndName.value == "")
		{
			alert("Friend Name field left blank");
			frndName.focus();
			return false;
		}
		if(frndEmail.value == "")
		{
			alert("Friend Email field left blank");
			frndEmail.focus();
			return false;
		}
		else
		 {
			//Check for '@' and '.' in Field Email
			if(frndEmail.value.indexOf("@")<1 || frndEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				frndEmail.value="";
				frndEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((frndEmail.value.lastIndexOf(".")-(frndEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				frndEmail.value="";
				frndEmail.focus();
				return false;
			}
		 }
		if(msg.value=="")
		{
			alert("Message field left blank.");
			msg.focus();
			return false;
		}
		
		return true;
	}
}

function chkChangeEmail(thisform)
{
	with(thisform)
	{
		if(txtEmail.value == "")
		{
			alert("Email field left blank");
			txtEmail.focus();
			return false;
		}
		else
		 {
			//Check for '@' and '.' in Field Email
			if(txtEmail.value.indexOf("@")<1 || txtEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((txtEmail.value.lastIndexOf(".")-(txtEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
		 }
	}
	return true;
}
function chkChangePassword(thisform)
{
	with(thisform)
	{
		if(txtOldPassword.value == "")
		{
			alert("Old Password field cannot be blank");
			txtOldPassword.focus();
			return false;
		}
		 if(txtOldPassword.value.length < 6)
		 {
			alert("Password should contain 6 or more characters");
			txtOldPassword.focus();
			 return false;
		 }
		 if(!isAlphanum(fn_Trim(txtOldPassword.value)))
		 {
			alert("Password cannot contain special characters");
			txtOldPassword.focus();
			 return false;
		 }
		if(txtNewPassword.value == "")
		{
			alert("New password field cannot be blank");
			txtNewPassword.focus();
			return false;
		}
		if(txtNewPassword.value.length < 6)
		 {
			alert("New Password should contain 6 or more characters");
			txtNewPassword.focus();
			 return false;
		 }
		 if(!isAlphanum(fn_Trim(txtNewPassword.value)))
		 {
			alert("Password cannot contain special characters");
			txtNewPassword.focus();
			 return false;
		 }
		if(txtRnewPassword.value == "")
		{
			alert("Confirm New Password field cannot be blank");
			txtRnewPassword.focus();
			return false;
		}
		 
		 if(txtNewPassword.value!=txtRnewPassword.value)
		 {
			 alert("Please Enter the same password");
		     txtRnewPassword.value="";
			 txtRnewPassword.focus();
			 return false;
		 }
	}
	return true;
}


function fn_chkforgotpass(thisform)
{
	with(thisform)
	{
		if(email.value == "")
		{
			alert("Email field cannot be blank");
			email.focus();
			return false;
		}
		else
		 {
			//Check for '@' and '.' in Field Email
			if(email.value.indexOf("@")<1 || email.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((email.value.lastIndexOf(".")-(email.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
		 }
		
		return true;
	}
}

function fn_chkbarterchoice(thisform)
{
	
	with(thisform)
	 {
		
		if(chooseBarter(choiceEx)== false)
		{
			alert("Choose a Product to Barter");
			return false;
		}
	 }
	 return true;
}
function fn_chkbarterchoice1(thisform)
{
	
	with(thisform)
	 {
		if(chooseBarter(choice)== false)
		{
			alert("Choose a Membership");
			return false;
		}
	 }
	 return true;
}
function chooseBarter(j)
{
	
	for (var i=0; i<j.length; i++) 
			{
				if (j[i].checked == false) 
				{
					
					continue;
				}
				else
				{
					return true;
					break;
				}
			}return false
}


//************************************************************************************************************
//Funtion Name		:	fn_chkAddUser
//Arguments			:	thisform (Current form) 
//Return Value		:	Boolean
//Purpose			:	Validating the text fields in the form.
//Created by		:	Sarvesh Kulkarni
//Created date		:	7/9/2007
//************************************************************************************************************
 function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
function fn_LTrim(value) 
	{
		// Set the pattern 
		var re = /\s*((\S+\s*)*)/;
		
		// Return the replaced value 
		return value.replace(re, "$1");
	}
	// Function fn_LTrim END 

	// fn_RTrim 
	// Function Description:	
	//		Removes ending whitespaces
	//
	function fn_RTrim(value) 
	{
		// Set the pattern 
		var re = /((\s*\S+)*)\s*/;
		
		// Return the replaced value 
		return value.replace(re, "$1");
	}
	// Function fn_RTrim END 



	// fn_Trim 
	// Function Description:	
	//		Removes leading and ending whitespaces
	//
	function fn_Trim(value) 
	{
		return fn_LTrim(fn_RTrim(value));
	}
	// Function fn_Trim END 

function isRequired(thisform)
{
	with(thisform)
	{
		
		if(email.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 email.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(email.value.indexOf("@")<1 || email.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((email.value.lastIndexOf(".")-(email.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
		 }
		 if(trim(query.value) == "")
		 {
			 alert("Comments field is empty. Please enter Comments");
			 query.focus();
			 return false;
		 }
	}
}
function formvalidation(thisform)
{
	
	with(thisform)
	{
		if(email.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 email.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(email.value.indexOf("@")<1 || email.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((email.value.lastIndexOf(".")-(email.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				email.value="";
				email.focus();
				return false;
			}
		 }
	}

}
function fn_chkAddUser(thisform)
 {
	
		with(thisform)
	 {
		 if(txtFirstName.value == "")
		 {
			 alert("First Name field is empty. Please enter First Name");
			 txtFirstName.focus();
			 return false;
		 }

		 if(txtLastName.value == "")
		 {
			 alert("Last Name field is empty. Please enter Last Name");
			 txtLastName.focus();
			 return false;
		 }

		  if(txtStreetAddress.value == "")
		 {
			 alert("Street Name field is empty. Please enter Street Name");
			 txtStreetAddress.focus();
			 return false;
		 }
		var selObj = document.getElementById('ddlCountry');
		var selIndex = selObj.selectedIndex;
		//alert(selIndex);	
		  if(selIndex == "0")
		 {
             
			 alert("Please select Country");
			document.getElementById('ddlCountry').focus();
			 return false;
		 }
		
		
		
		var stateObj = document.getElementById('ddState');
		var stIndex = stateObj.selectedIndex;
		if((stIndex == 0)&&(dd_State.value == ""))
		 {
			 alert("Please select State");
			  document.getElementById('ddState').focus();
				
			  return false;
		 }

		 var cityObj = document.getElementById('selCity');
		var cityIndex = cityObj.selectedIndex;

		if((cityIndex == 0)&&(sel_City.value == ""))
		 {
			 alert("Please select City");
			 document.getElementById('selCity').focus();
			
			  return false;
		 }
			
		 if(txtZipCode.value == "")
		 {
			 alert("Zipcode field is empty. Please enter Zipcode");
			 txtZipCode.focus();
			 return false;
		 }
		 /*else if(isNaN(txtZipCode.value))
		{
			alert("Zipcode must be numeric. Please enter valid Zipcode");
			txtZipCode.value="";
			txtZipCode.focus();
			return false;
		}*/
		if(txtPhone.value == "")
		 {
			 alert("Phone Number field is empty. Please enter Phone Number");
			 txtPhone.focus();
			 return false;
		 }
		 /*else if(isNaN(txtPhone.value))
		{
			alert("Phone Number must be numeric. Please enter valid Phone Number");
			txtPhone.value="";
			txtPhone.focus();
			return false;
		}*/else if(txtPhone.value.length < 10)
		 {
				alert("Please enter valid Phone Number");
			txtPhone.value="";
			txtPhone.focus();
			return false;
		 }
		 if(txtEmail.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 txtEmail.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(txtEmail.value.indexOf("@")<1 || txtEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((txtEmail.value.lastIndexOf(".")-(txtEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
		 }
		
		 if(txtconfirmEmail.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 txtconfirmEmail.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(txtconfirmEmail.value.indexOf("@")<1 || txtconfirmEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				txtconfirmEmail.value="";
				txtconfirmEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((txtconfirmEmail.value.lastIndexOf(".")-(txtconfirmEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				txtconfirmEmail.value="";
				txtconfirmEmail.focus();
				return false;
			}
		 }
		 if(txtEmail.value!=txtconfirmEmail.value)
		 {
			 alert("Please enter correct confirm email");
			 txtconfirmEmail.value= "";
			 txtconfirmEmail.focus();
			 return false;
		 }
		  if(emailentered.value!=""){
		if(txtEmail.value==emailentered.value)
		 {
			 txtEmail.value= "";
			 txtEmail.focus();
			 alert("Please enter another email ID");
			 return false;
		 }}
		if(txtlogin.value == "")
		 {
			 alert("Login ID field is empty. Please enter Login ID");
			 txtlogin.focus();
			 return false;
		 }
		 else
		 {
			if((txtlogin.value.length < 6)||(txtlogin.value.length > 18))
			 {
				alert("Please enter valid Login ID between 6 to 18 characters.");
				txtlogin.value="";
				txtlogin.focus();
				return false;
			 }
		 }
		
		
		 if(txtPassword.value == "")
		 {
			 alert("Password cannot be blank");
			 txtPassword.focus();
			 return false;
		 }
		   if(loginentered.value!=""){
		if(txtlogin.value==loginentered.value)
		 {
			txtlogin.value= "";
			 txtlogin.focus();
			 alert("Please enter loginID");
			 return false;
		 }}
		   if(txtPassword.value.length < 6)
		 {
			alert("Password should contain 6 or more characters");
			txtPassword.focus();
			 return false;
		 }
		 if(!isAlphanum(fn_Trim(txtPassword.value)))
		 {
			alert("Password cannot contain special characters");
			txtPassword.focus();
			 return false;
		 }
		
	
		if(txtconfirmPassword.value == "")
		 {
			 alert("Confirm Password field is empty. Please enter Confirm Password");
			 txtconfirmPassword.focus();
			 return false;
		 }
		 
		 if(txtPassword.value!=txtconfirmPassword.value)
		 {
			 alert("Please Enter the same password");
		     txtconfirmPassword.value="";
			 txtconfirmPassword.focus();
			 return false;
		 }
		 var selObj1 = document.getElementById('ddlsecretQ');
		var selIndex1 = selObj1.selectedIndex;
		//alert(selIndex1);	
		  if(selIndex1 == "0")
		 {
			 alert("Secret Answer field is empty. Please enter Secret Answer");
			 document.getElementById('ddlsecretQ').focus();
			 return false;
		 } 
		if(txtSecret.value == "")
		 {
			 alert("Secret Answer field is empty. Please enter Secret Answer");
			 txtSecret.focus();
			 return false;
		 }
		if(txtDOB.value == "")
		 {
			 alert("Date of Birth field is empty.Please select Date of Birth");
			 txtDOB.focus();
			 return false;
		 }
		 if(txtTerms.checked!=true)
		 {
			 alert("Please accept the terms and Conditions");
			 txtTerms.focus();
			 return false;
		 }
		/*  hash = hex_md5(code_check.value);
		 if(hash != Get_Cookie('vihash'))
		 {
			 alert("Security code does not match");
			 code_check.focus();
			 //var f = document.getElementById('iframe1');
			//f.src = f.src;
			 return false;
		 }*/
		 if(verificationNmaeNew.value == "")
		 {
			 alert("Enter Verification letter or number");
			 verificationNmaeNew.focus();
			 return false;
		 }
		 if(verificationNmaeNew.value != verificationSessionNew.value )
		 {
			  alert("Enter correct Verification letter or number");
			 verificationNmaeNew.focus();
			 return false;
		 }
	 }
	 return true;
 }

function fn_chkEditUser(thisform)
 {
	
		with(thisform)
	 {
		 if(txtFirstName.value == "")
		 {
			 alert("First Name field is empty. Please enter First Name");
			 txtFirstName.focus();
			 return false;
		 }

		 if(txtLastName.value == "")
		 {
			 alert("Last Name field is empty. Please enter Last Name");
			 txtLastName.focus();
			 return false;
		 }

		  if(txtStreetAddress.value == "")
		 {
			 alert("Street Name field is empty. Please enter Street Name");
			 txtStreetAddress.focus();
			 return false;
		 }
		var selObj = document.getElementById('ddlCountry');
		var selIndex = selObj.selectedIndex;
		//alert(selIndex);	
		  if(selIndex == "0")
		 {
             
			 alert("Please select Country");
			document.getElementById('ddlCountry').focus();
			 return false;
		 }
			
		
			
			
		 if(txtState.value == "")
		 {
			
			 alert("State Name field is empty.Please enter State Name");
			 txtState.focus();
			 return false;
		 }
	
		 if(txtCity.value == "")
		 {
			 alert("Please select City");
			 txtCity.focus();
			 return false;
		 }
		 if(txtZipCode.value == "")
		 {
			 alert("Zipcode field is empty. Please enter Zipcode");
			 txtZipCode.focus();
			 return false;
		 }
		 
		if(txtPhone.value == "")
		 {
			 alert("Phone Number field is empty. Please enter Phone Number");
			 txtPhone.focus();
			 return false;
		 }
		 else if(isNaN(txtPhone.value))
		{
			alert("Phone Number must be numeric. Please enter valid Phone Number");
			txtPhone.value="";
			txtPhone.focus();
			return false;
		}else if(txtPhone.value.length < 10)
		 {
				alert("Please enter valid Phone Number");
			txtPhone.value="";
			txtPhone.focus();
			return false;
		 }
		 if(txtEmail.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 txtEmail.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(txtEmail.value.indexOf("@")<1 || txtEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((txtEmail.value.lastIndexOf(".")-(txtEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
		 }

		
	 }
	 return true;
 }



//************************************************************************************************************
//Funtion Name		:	chk_EditUser
//Arguments			:	thisform (Current form) 
//Return Value		:	Boolean
//Purpose			:	Validating the text fields in the form.
//Created by		:	Sarvesh Kulkarni
//Created date		:	7/9/2007
//************************************************************************************************************
 
function chk_EditUser(thisform)
 {

	 with (thisform)
	 {
		 if(txtUserName.value == "")
		 {
			 alert("Username field is empty. Please enter Username");
			 txtUserName.focus();
			 return false;
		 }

		 if(txtPassword.value == "")
		 {
			 alert("Password field is empty. Please enter Password");
			 txtPassword.focus();
			 return false;
		 }

		
		 if(trim(txtNewPassword.value) != "")
		 {
			 if(trim(txtConfirmPassword.value) == "")
			 {
				 alert("Confirm Password field is empty. Please enter Confirm Password");
				 txtConfirmPassword.focus();
				 return false;
			 }
			  
			
		 }
		 
		 if(trim(txtConfirmPassword.value) != "")
		 {
			if(trim(txtNewPassword.value) == "")
			 {
				 alert("New Password field is empty. Please enter New Password");
				 txtNewPassword.focus();
				 return false;
			 }
		 }
		 
		if((trim(txtNewPassword.value) != "") && (trim(txtConfirmPassword.value) != ""))
		 {
			 if(txtNewPassword.value != txtConfirmPassword.value)
			 {
				alert("Confirmed password is incorrect\nPlease re-enter new password");
				txtNewPassword.value= "";
				txtConfirmPassword.value= "";
				txtNewPassword.focus();
				return false;
			 }
		 }
			 
		 if(txtName.value == "")
		 {
			 alert("Name field is empty. Please enter Name");
			 txtName.focus();
			 return false;
		 }
		 else
		{
			var chkChars = txtName.value
			var validChars = "0123456789!@#$%^&*_+-=<>/?:[]{}";
				for (i=0; i<chkChars.length; i++) 
				{
					var bool = 0;
					for (j=0; j<validChars.length; j++) 
					{
						if(chkChars.charAt(i) ==  validChars.charAt(j))
						{
							bool = 1;
							break;
						}	
					}
					if(bool == 1)
					{
						alert("Invalid Name\nName cannot contain (0-9) digits and special characters");
						txtName.value="";
						txtName.focus();
						return false
						break;
					}
				}
		}

		 if(txtCompanyName.value == "")
		 {
			 alert("Company Name field is empty. Please enter Company Name");
			 txtCompanyName.focus();
			 return false;
		 }

		 if(taAddress.value == "")
		 {
			 alert("Address field is empty. Please enter Address");
			 taAddress.focus();
			 return false;
		 }

		 if(txtZip.value == "")
		 {
			 alert("Zip field is empty. Please enter Zip");
			 txtZip.focus();
			 return false;
		 }
		 else if(isNaN(txtZip.value))
		{
			alert("Zip must be numeric. Please enter valid Zip");
			txtZip.value="";
			txtZip.focus();
			return false;
		}

		 if(txtState.value == "")
		 {
			 alert("State field is empty. Please enter State");
			 txtState.focus();
			 return false;
		 }
		 else
		{
			var chkChars = txtState.value
			var validChars = "0123456789!@#$%^&*_+-=<>/?:[]{}";
				for (i=0; i<chkChars.length; i++) 
				{
					var bool = 0;
					for (j=0; j<validChars.length; j++) 
					{
						if(chkChars.charAt(i) ==  validChars.charAt(j))
						{
							bool = 1;
							break;
						}	
					}
					if(bool == 1)
					{
						alert("Invalid State\nState cannot contain (0-9) digits and special characters");
						txtState.value="";
						txtState.focus();
						return false
						break;
					}
				}
		}

		 if(ddlCountry.value == "")
		 {
			 alert("Country is empty\nPlease mention Country");
			 ddlCountry.focus();
			 return false;
		 }

		 if(txtPhone.value == "")
		 {
			 alert("Phone field is empty. Please enter Phone");
			 txtPhone.focus();
			 return false;
		 }
		 else if(isNaN(txtPhone.value))
		 {
			alert("Phone must be numeric. Please enter valid Phone");
			txtPhone.value="";
			txtPhone.focus();
			return false;
		 }

		 if(txtFax.value == "")
		 {
			 alert("Fax field is empty. Please enter Fax");
			 txtFax.focus();
			 return false;
		 }
		 else if(isNaN(txtFax.value))
		 {
			alert("Fax must be numeric. Please enter valid Fax");
			txtFax.value="";
			txtFax.focus();
			return false;
		 }

		 if(txtEmail.value == "")
		 {
			 alert("Email field is empty. Please enter Email");
			 txtEmail.focus();
			 return false;
		 }
		else
		 {
			//Check for '@' and '.' in Field Email
			if(txtEmail.value.indexOf("@")<1 || txtEmail.value.indexOf(".")<1)
			{	
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
			//Check if index of '@' < '.' in Field Email
			if((txtEmail.value.lastIndexOf(".")-(txtEmail.value.indexOf("@")))<3)
			{
				alert("Email Address is Invalid");
				txtEmail.value="";
				txtEmail.focus();
				return false;
			}
		 }

		if(txtWebsite.value == "")
		{
			 alert("Website field is empty. Please enter Website");
			 txtWebsite.focus();
			 return false;
		}

		if(txtVerificationNumber.value == "")
		{
			 alert("Verification field is empty\nPlease enter Verification Number on the right");
			 txtVerificationNumber.focus();
			 return false;
		}
	 }
	 return true;
 }


//************************************************************************************************************
//Funtion Name		:	chkSearch
//Arguments			:	thisform (Current form) 
//Return Value		:	Boolean
//Purpose			:	Validating the search field in the form.
//Created by		:	Sarvesh Kulkarni
//Created date		:	7/25/2007
//************************************************************************************************************

function chkSearch(thisform)
{
	with(thisform)
	{
		if(txtSearch.value == "")
		{
			alert("Please type the keyword you are looking for");
			txtSearch.focus();
			return false;
		}
	}
	return true;
}

function addProduct(thisform)
{
	with(thisform)
	{
		if(ddlCategory.value == "")
		{
			alert("Please select category");
			ddlCategory.focus();
			return false;
		}
		
		if(hiddenCat.value!="")
		{
			for(i=0;i<hiddenCat.value;i++)
			{
				var f="fieldName";
				var fieldValue = f+i;
				var val = document.getElementById(fieldValue).value;
				if(val=="")
				{
					alert("Please Enter Additional Field Value");
					document.getElementById(fieldValue).focus();
					return false;
				}
			}
			
		}
		if(txtDesc.value == "")
		{
			alert("Features/decription cannot be blank");
			txtDesc.focus();
			return false;
		}
				
	}
	return true;
}

function editProduct(thisform)
{ 
		
	with(thisform)
	{
		
		if(txtDesc.value == "")
		{
			alert("Features/decription cannot be blank");
			txtDesc.focus();
			return false;
		}	

		if(hiddenOldCat.value!="")
		{
			for(i=0;i<hiddenOldCat.value;i++)
			{
				var f="oldfieldName";
				var fieldValue = f+i;
				var val = document.getElementById(fieldValue).value;
				if(val=="")
				{
					alert("Please Enter Additional Field Value");
					document.getElementById(fieldValue).focus();
					return false;
				}
			}
			
		}
	
		if(hiddenCat.value!="")
		{
			for(i=0;i<hiddenCat.value;i++)
			{
				var f="fieldName";
				var fieldValue = f+i;
				var val = document.getElementById(fieldValue).value;
				if(val=="")
				{
					alert("Please Enter Additional Field Value");
					document.getElementById(fieldValue).focus();
					return false;
				}
			}
			
		}
		
	}
	return true;
}

function addBanner(thisform)
{
	with(thisform)
	{
		if(txtstatus.value == "")
		{
			alert("Please select the status");
			txtstatus.focus();
			return false;
		}
		if(blockid.value == "")
		{
			alert("Please select Banner Block");
			blockid.focus();
			return false;
		}
		if(imagealt.value == "")
		{
			alert("Please enter Alternate message");
			imagealt.focus();
			return false;
		}
		if(imagetype.value == "")
		{
			alert("Please select Image Type");
			imagetype.focus();
			return false;
		}
		if(httpurl.value == "")
		{
			alert("Please enter url");
			httpurl.focus();
			return false;
		}
		if(date1.value == "")
		{
			alert("Please select Start Date");
			date1.focus();
			return false;
		}
		if(date2.value == "")
		{
			alert("Please select End Date");
			date2.focus();
			return false;
		}
		
		
	}
	return true;
}

function editBanner(thisform)
{
	with(thisform)
	{
		if(txtstatus.value == "")
		{
			alert("Please select the status");
			txtstatus.focus();
			return false;
		}
		if(blockid.value == "")
		{
			alert("Please select Banner Block");
			blockid.focus();
			return false;
		}
		if(imagealt.value == "")
		{
			alert("Please enter Alternate message");
			imagealt.focus();
			return false;
		}
		if(imagetype.value == "")
		{
			alert("Please select Image Type");
			imagetype.focus();
			return false;
		}
		if(httpurl.value == "")
		{
			alert("Please enter url");
			httpurl.focus();
			return false;
		}
		if(date1.value == "")
		{
			alert("Please select Start Date");
			date1.focus();
			return false;
		}
		if(date2.value == "")
		{
			alert("Please select End Date");
			date2.focus();
			return false;
		}
		
	}
	return true;
}

function addCategory(thisform)
{
	
	with(thisform)
	{
		
		if(txtCatName.value == "")
		{
			alert("Please enter Category Name");
			txtCatName.focus();
			return false;
		}
		if(txtareaCatDesc.value == "")
		{
			alert("Please enter Category Description");
			txtareaCatDesc.focus();
			return false;
		}
		if(selCatStatus.value == "")
		{
			alert("Please select Category Status");
			selCatStatus.focus();
			return false;
		}
		
	}
	return true;
}

function editCategory(thisform)
{
	with(thisform)
	{
		if(txtCatName.value == "")
		{
			alert("Please enter Category Name");
			txtCatName.focus();
			return false;
		}
		if(selParentCatg.value == "")
		{
			alert("Please select Parent Category");
			selParentCatg.focus();
			return false;
		}
		if(txtareaCatDesc.value == "")
		{
			alert("Please enter Category Description");
			txtareaCatDesc.focus();
			return false;
		}
		if(selCatStatus.value == "")
		{
			alert("Please select Category Status");
			selCatStatus.focus();
			return false;
		}
		
	}
	return true;
}

function addBrand(thisform)
{
	with(thisform)
	{
		if(txtBrandName.value == "")
		{
			alert("Please enter Brand Name");
			txtBrandName.focus();
			return false;
		}
		if(txtBrandDesc.value == "")
		{
			alert("Please enter Brand Description");
			txtBrandDesc.focus();
			return false;
		}
		if(ddlbrandStatus.value == "")
		{
			alert("Please select Brand Status");
			ddlbrandStatus.focus();
			return false;
		}
	}
	return true;
}

function editBrand(thisform)
{
	with(thisform)
	{
		if(txtBrandName.value == "")
		{
			alert("Please enter Brand Name");
			txtBrandName.focus();
			return false;
		}
		if(txtBrandDesc.value == "")
		{
			alert("Please enter Brand Description");
			txtBrandDesc.focus();
			return false;
		}
		
		if(ddlbrandStatus.value == "")
		{
			alert("Please select Brand Status");
			ddlbrandStatus.focus();
			return false;
		}
	}
	return true;
}
i=2;
function generateRow(i) {

//alert(i);
var d=document.getElementById("div");
d.innerHTML+="<table align='center' width='100%' cellspacing='2' cellpadding='2'><tr class='font_text2'><td align='right'><input type='text' name='frndEmail"+i+"' id='frndEmail"+i+"' value='Enter Email Id' class='flat' style='height:18px;width:300px'></td></tr></table>";
}

function getPage1()
{

	pageValue = document.getElementById("page").value;
	var objHidPage = document.getElementById("page1");
	objHidPage.value = pageValue;
	document.pageForm.submit();
}
function submitPage(pageNum) { 
	var objHidPage = document.getElementById("page1");
	if(objHidPage != ""){
		objHidPage.value = pageNum;
		
		var objForm = document.getElementById("pageForm");
		
		if(objForm != null){
			document.pageForm.submit();
		}
	}
}

function clear_default_text(){
	if (document.formSearch.keyword.value=="    -------- Enter Keyword --------   "){
		document.formSearch.keyword.value = "";
		return true;
	}
}