// checks the message textbox to determine if it has exceeded the maximum length
function CheckTextLength(textArea, maxLength)
{		
	if (maxLength == 0)
		maxLength = 150;

	if(textArea.value.length > maxLength )
	{
		alert("Please shorten your message to a maximum length of " + maxLength + " characters or about 15 - 20 words.");		
		//Commented by Sudeshna
		/*textArea.value = "";*/
		textArea.focus();
	}			
}		

/*
 * Prevents user from entering more than specific number of characters in a textbox/textarea
 */
function LimitTextLength(textArea, maxLength)
{		
	if (maxLength == 0)
		maxLength = 150;

	if(textArea.value.length > maxLength )
	{		
		textArea.value = textArea.value.substring(0, maxLength);
		textArea.focus();
	}			
}		

function Sethiddenloginvalue(val)
{
	var _f = document.forms[0];
	for (i=0;i<_f.elements.length;i++)
	{
		if (_f.elements[i].id.indexOf('hidden_login') != -1)
			_f.elements[i].value=val;

	}
}

//Sudeshna--JavaScript to validate zipcode: Zip should have 5 numeric characters
function ValidateZip()
{	
	document.all.divZipError.style.display = "none";
		
	var mf = GetMainFormName();				
	var zipTextboxRef =  GetElementName("address_zip", mf);
	var zipTextbox = document.forms[mf].elements[zipTextboxRef];
	
	//Check if zip code length is 5
	if(zipTextbox.value.length != 5)
	{
		document.all.tblcellZip.style.color = "#ED950A";
		document.all.divZipError.style.display = "block";
		return false;
	}				
	else			
	{
		//If zipcode length is 5, only allow 0-9 to be entered as the characters
		var checkOK = "0123456789";
		var allValid = true;
		for (var i=0; i < zipTextbox.value.length; i++) 
		{ 
			ch = zipTextbox.value.charAt(i);
			
			for (var j = 0;  j < checkOK.length;  j++)
			{							
				if (ch == checkOK.charAt(j))
					break;							
			}
			
			if (j == checkOK.length)
			{							
				allValid = false;
				break;
			}
		}
		if (!allValid) 
		{
			document.all.tblcellZip.style.color = "#ED950A";
			document.all.divZipError.style.display = "block";
			return false;
		}	
		else
			return true;						
	}
}

function showOrHideCopy(FieldName)
{
	var showElement = document.all[FieldName];
	if(showElement.style.display=="none")
		showElement.style.display="inline";
	else
		showElement.style.display="none";
}
			
function showCopy(FieldName)
{
	var showElement = document.all[FieldName];
	showElement.style.display="inline";
}
function hideCopy(FieldName)
{
	var showElement = document.all[FieldName];
	showElement.style.display="none";
}
			
function gosearch(FieldName)
{	
	var mf = GetMainFormName();		
	if (mf==null) return;
	var searchVal = document.forms[mf].elements[FieldName].value;
	searchVal = searchVal.toLowerCase();
	document.forms[mf].action="results.aspx?SearchKeywords=" + searchVal;
	if(searchVal.replace(/^\s*|\s*$/g,"").length>0)
		document.forms[mf].submit();
}	

function isEnter(e,FieldName)
{
	if (e.keyCode == 13)
		gosearch(FieldName);
	return true;
}

function search_GoToURL(url)
{
	if (url!="") document.location.href= url;
}

function openPopup(url, name, popupWidth, popupHeight) {
	var winl = (screen.width - popupWidth) / 2;
	var wint = (screen.height - popupHeight) / 2;
	var name2 = name.replace(' ','');
	name2=name2.replace('-','');
		
	newWindow = open(url, name2, ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
	newWindow.focus();
}

function changeOpenerURL(thisWindow,url) {
	thisWindow.opener.location.href=url;
	thisWindow.focus();
	
}

function register() {
	openPopup('../popup/mailinglist.aspx','register', 480,400)
}

var SalonURL="";
function AddWebSiteURL(url,className,urlName){
	SalonURL = "<a href='" + url + "' target='_blank' class='" + className + "'>" + urlName + "</a>";  
}