function ValidateSearchForm(thisObj)
{
	
	if (thisObj.strProfileName.value == '' && thisObj.strZip.value == '' && thisObj.strCity.value == '' && thisObj.strState.selectedIndex == 0 ) 
	{
		alert("Please enter atleast one search criteria.");
		thisObj.strProfileName.focus();
		return(false);
	}
	
	if (thisObj.strZip.value != '' )
	{
		if ( isNaN(thisObj.strZip.value))
		{
			alert("Please enter only numbers in the zip code field.");
			thisObj.strZip.focus();
			return(false);
		}
		if ( thisObj.strZip.value.length != 5 ) 
		{
			alert("Please enter a 5 digit zip code.");
			thisObj.strZip.focus();
			return(false);
		}
		
	}	
	return(true);
}

function ValidateSearchFormSub(thisObj)
{
	
	if (thisObj.strProfileName.value == '' && thisObj.strZip.value == '' ) 
	{
		alert("Please enter atleast one search criteria.");
		thisObj.strProfileName.focus();
		return(false);
	}
	
	if ((thisObj.strProfileName.value == 'salon name' ) && ( thisObj.strZip.value == '' || thisObj.strZip.value == 'zip') ) 
	{
		alert("Please enter atleast one search criteria.");
		thisObj.strProfileName.focus();
		return(false);
	}
	
	if ((thisObj.strZip.value == 'zip') && ( thisObj.strProfileName.value == '' || thisObj.strProfileName.value == 'salon name') ) 
	{
		alert("Please enter atleast one search criteria.");
		thisObj.strProfileName.focus();
		return(false);
	}
	
	if (thisObj.strZip.value != '' )
	{
		if ( isNaN(thisObj.strZip.value))
		{
			alert("Please enter only numbers in the zip code field.");
			thisObj.strZip.focus();
			return(false);
		}
		if ( thisObj.strZip.value.length != 5 ) 
		{
			alert("Please enter a 5 digit zip code.");
			thisObj.strZip.focus();
			return(false);
		}
		
	}	
	return(true);
}

// Validator Used on ChooseUser.asp
function Username_Validator(theForm)
{

  if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
  /*var checkStr = theForm.username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }*/

  if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  
  var checkStr = theForm.password.value;
  var allValid = true;

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }


  if (theForm.confirmpass.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value != theForm.password.value )
    {
      alert("Please re-enter your password correctly.");
      theForm.confirmpass.focus();
      return (false);
  }

  
  var checkStr = theForm.confirmpass.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

	  return (true);
}

// Email Validator
function Validate_Email(theForm)
{


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
  var checkStr = theForm.email.value;
  var allValid = true;
  var bDotPresent = false;
  var bRatePresent = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      	break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

    if (j == checkOK.length - 1  )
	    {
	    	bDotPresent = true;

	    }

	    if (j == checkOK.length -2 )
	    {
	    	bRatePresent = true;
	    }

  }

  if (!allValid)
  {
    alert("Please enter only letter, digit and \"-_@.\" characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if ((!bDotPresent) || (!bRatePresent) )

    {
    	alert ("Please enter a valid email address");
    	theForm.email.focus();
    	return(false);
    }

	  return (true);
}

// Open PopUp Window
function openPopUp (winURL, winName, winFeatures){
	newWindow = window.open(winURL,winName,winFeatures);
	newWindow.focus();
}

// New Gallery Window
function newGalleryWindow(galleryURL, galleryWinName, galleryFeatures){
	window.open(galleryURL, galleryWinName, galleryFeatures);
}

// Display WIndow
function displayWindow (url, width, height){
		var Win = window.open (url,"displayWindow",'width=' + width + ',height=' +
		height + ',resizable=0,scrollbars=no,menubar=no,status=yes');
		Win.focus();
}

// Form Validator
function validateIt(theForm)
 {
  if(theForm.categoryid.value != '')
	{
	theForm.submit()
	}
  else
     	{
     	return false
     	}
 }

// Clear Text
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
	  theText.value = ""
	}
}

// Change Password (I think)
function password(){
	self.name = "Parent_Window"; 
	window.open('/portal/user/send_pass.asp','EmailLoginInfo','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=350,height=260');
}

function confirmCancelMembership()
{
	var conf;	
	conf = confirm("Warning! You are about to cancel your auto renewal for your membership! Are you sure you want to do this?")	
	if (conf)
		return true;
	else
		return false;
}


function isFilled(field) {
  if (field.value.length < 1 || field.value == field.defaultValue) {
    return false;
  } else {
    return true;
  }
}

function isEmail(field) {
  if (field.value.indexOf("@") == -1 || field.value.indexOf(".") == -1) {
    return false;
  } else {
    return true;
  }
}



function RateReview_Validate(objForm)
{
	//alert("test")
	var blnOutReturnVal;
	var blnInReturnVal;	
	blnOutReturnVal = RateReview_TextCheck(objForm.strRateDesc, "Comments");
	//alert(blnOutReturnVal);
	if (blnOutReturnVal)
	{		
		
		blnInReturnVal = RateReview_RadioCheck(objForm, "rating");
		//alert("Radio exists: " + blnInReturnVal)
			if (blnInReturnVal)	
			{
				//alert ("blnInReturnVal is true for RadioCheck")
				return true;
			}
			else
			{
				//alert ("blnInReturnVal is False for RadioCheck")
				return false;		
			}
	}
	else
	{
		//alert ("blnOutReturnVal is False for TextCheck")
		return false;
	}
}
	

function RateReview_TextCheck(objTextBox, objName)
{
	if (objTextBox.value == "")
	{
		alert("Please Ensure that you have Entered data under " + objName )
		return false;
	}  
	else
	{
		//alert("TextCheck is Done and textbox do have contents....!")
		return true;
	}
}
	
	
function RateReview_RadioCheck(objForm, objName)
{	
	
	var i=0;
	var obj;
	var intCheckCount=0;
	
	for (i=0;i<objForm.elements.length;i++)
	{
		obj = objForm.elements[i];
		//alert("inside for")
		//alert(obj.checked)
		//if ((obj.type == "radio") && (obj.checked == true))
		if ((obj.type == "radio") && (obj.checked))
		{
			intCheckCount++;
			//alert("intCheckCount is " +intCheckCount);	
		}		
		//alert(intCheckCount)
		
	}
	
	if (intCheckCount>0)
	{
		//alert("Thank You for your Ratings...!");
		return true;
	}
	else
	{
		alert("Please ensure you have selected " + objName + ".");
		return false;
	}	
}

function ValidateReViewApprove()
{
	//alert("test");
	var intCheckCount = 0 ;
	var intCheckNoCount = 0 ;
	var strDeleteIds = "";
	var strUpdateIds = "";
	//var Radiobutton = document.frmReviewApprove.chkApprove;	
	//alert(Radiobutton);
	for (i=0;i<document.frmReviewApprove.elements.length;i++)
	{
		
		obj = document.frmReviewApprove.elements[i];
		//alert(obj);
		//alert(document.getElementById("strUser_id_" + i));
		if ((obj.type == "radio") && (obj.checked))
		{
			if (obj.value == 2)
			{
				intCheckNoCount++;
				
			}
			else
			{
				intCheckCount++;
				
				
			}
		}
	}
	
	
	if (intCheckNoCount > 0)
	{
		var blnConfirm = confirm("Selecting delete will delete the reviews permanantly.Are you sure you want to delete the selected reviews?")
	}
	else
	{
		var blnConfirm = confirm("Are you sure you want to update the selected reviews?")
		
	}	
	if (blnConfirm)
	{
		return true;
	}
	else 
	{
		return false;
	}
}


function openInviteAFriend(winname, wintitle)
{					
	var win = window.open(winname,wintitle,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=740,height=380');
	//win.focus();
}

function Validate_SuggestASalon(thisObj)
 {
	
	
	if ( thisObj.elements['item Stylists First Name:'].value  == '' ) 
		{
			alert ("Please enter the stylists first name.")
			thisObj.elements['item Stylists First Name:'].focus();
			return false;
		}
	
	if ( thisObj.elements['item Stylists Last Name:'].value == '' ) 
		{
			alert ("Please enter the stylists last name.")
			thisObj.elements['item Stylists Last Name:'].focus();
			return false;
		}

	if ( thisObj.elements['item Stylists Title:'].value == '' ) 
		{
			alert ("Please enter the stylists title.")
			thisObj.elements['item Stylists Title:'].focus();
			return false;
		}

	if ( thisObj.elements['item Name of Salon:'].value == '' ) 
		{
			alert ("Please enter the name of the salon.")
			thisObj.elements['item Name of Salon:'].focus();
			return false;
		}

	if ( thisObj.elements['item Address:'].value == '' ) 
		{
			alert ("Please enter the address of the salon.")
			thisObj.elements['item Address:'].focus();
			return false;
		}
	if ( thisObj.elements['item City:'].value == '' ) 
		{
			alert ("Please enter the city of the salon.")
			thisObj.elements['item City:'].focus();
			return false;
		}
	if ( thisObj.elements['item State:'].value == '' ) 
		{
			alert ("Please enter the state of the salon.")
			thisObj.elements['item State:'].focus();
			return false;
		}
	if ( thisObj.elements['item Zip:'].value == '' ) 
		{
			alert ("Please enter the zip code of the salon.")
			thisObj.elements['item Zip:'].focus();
			return false;
		}
	if ( thisObj.elements['item Phone Number:'].value == '' ) 
		{
			alert ("Please enter the phone number of the salon.")
			thisObj.elements['item Phone Number:'].focus();
			return false;
		}

	if ( thisObj.elements['item Email:'].value == '' ) 
		{
			alert ("Please enter the email address of the salon.")
			thisObj.elements['item Email:'].focus();
			return false;
		}
	if ( thisObj.elements['item Email:'].value != '' ) 
	{
		//alert ("Please enter the email address of the salon.")
		if (! isEmail( thisObj.elements['item Email:']))
		{
			alert ("Please enter valid email address of the salon.")
			thisObj.elements['item Email:'].focus();
			return false;
		}		
		
		
	}
	if ( thisObj.elements['Confirm Email:'].value == '' ) 
		{
			alert ("Please enter the confirm email address of the salon.")
			thisObj.elements['Confirm Email:'].focus();
			return false;
		}
	if ( thisObj.elements['Confirm Email:'].value != '' ) 
		{
			if (! isEmail( thisObj.elements['Confirm Email:']))
			{
				alert ("Please enter valid confirm email address of the salon.")
				thisObj.elements['Confirm Email:'].focus();
				return false;
			}
			
		}
	if ( thisObj.elements['item Email:'].value != thisObj.elements['Confirm Email:'].value ) 
		{
			alert ("Confirm email should be same as your email.Please re-enter your confirm email correctly.")
			thisObj.elements['Confirm Email:'].focus();
			return false;
		}
	

	return true;
}		