function check_collapse(argv1)
{
	var my_element = document.getElementById(argv1);

	if ( my_element.style.display == "none" )
    {
		my_element.style.display = "";
	}
	else
	{
		my_element.style.display = "none";
	}
	
	if(argv1 == 'Shop by Category')
	{
		document.getElementById('Shop by Heel Size').style.display = "none";
	}
	else if(argv1 == 'Shop by Heel Size')
	{
		document.getElementById('Shop by Category').style.display = "none";
	}
	return false;
}

function check_newslatter()
{
	if(trim(document.getElementById('dhim_newslatter').value, " ") == '' || document.getElementById('dhim_newslatter').value == 'Enter your Email Address')										
	{
		alert('Please Enter e-Mail Address.');
		document.getElementById('dhim_newslatter').focus();
		return false;
	}
	else if(echeck(document.getElementById('dhim_newslatter').value) ==  'invalid')
	{
		alert('Please Enter Valid e-Mail Address.');
		document.getElementById('dhim_newslatter').focus();
		return false;
	}
	else
	{
		return true;
	}
}

function checknewslatter()
{
	if(document.getElementById('dhim_newslatter').value == 'Enter your Email Address')										
	{
		document.getElementById('dhim_newslatter').value = '';
	}
}

function getnewslatter()
{
	if(document.getElementById('dhim_newslatter').value == '')										
	{
		document.getElementById('dhim_newslatter').value = 'Enter your Email Address';
	}
}

function bookmarksite(title, url)
{
	if(document.all)											// ie
		window.external.AddFavorite(url, title);
	else
		alert("Press CTRL+D to bookmark this site.");
}

function tellafrnd()
{
	if(trim(document.tellafriend.sender_name.value, " ") == '')										
	{
		alert('Please Enter Your Name');
		document.tellafriend.sender_name.focus();
		return false;
	}
	else if(trim(document.tellafriend.sender_email.value, " ") == '')										
	{
		alert('Please Enter Your Email');
		document.tellafriend.sender_email.focus();
		return false;
	}
	else if(echeck(document.tellafriend.sender_email.value) ==  'invalid')
	{
		alert('Please Enter Valid Email');
		document.tellafriend.sender_email.focus();
		return false;
	}
	else if(trim(document.tellafriend.friendemail1.value, " ") == '')										
	{
		alert('Please Enter Your Email');
		document.tellafriend.friendemail1.focus();
		return false;
	}
	else if(echeck(document.tellafriend.friendemail1.value) ==  'invalid')
	{
		alert('Please Enter Valid Email');
		document.tellafriend.friendemail1.focus();
		return false;
	}
	else
	{
		return true;
	}
}

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){
		   return "invalid";
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return "invalid";
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return "invalid";
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return "invalid";
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return "invalid";
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return "invalid";
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return "invalid";
		 }

 		 return "valid";					
	}
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

