	//The following functions are for  login features
	
	function loginReady(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			//document.getElementById("voteResults").style.height = '265px';
			if(xmlHttp.responseText=="LOGIN SUCCESSFUL"){
				location.reload();
			}else{
				document.getElementById("info").innerHTML = xmlHttp.responseText;	
				if(xmlHttp.responseText=="Please enter your password"){
					document.getElementById("sign_me_in_password").focus();
				}else{
					document.getElementById("sign_me_in_email").focus();
				}
			}
		} 
	}
	
	function passwordResetReady(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			//alert(xmlHttp.responseText);
			if(xmlHttp.responseText=="SUCCESS"){
			
				var reset_results = '<div id="wrong_email" align="left" style="width:359px; padding-left:20px;';				
				reset_results += 'float:left; padding-top:60px; padding-bottom:60px; color:#000000;';
				reset_results += 'line-height:120%;">';				
				reset_results += 'An e-mail with instructions';
				reset_results += ' has been sent to the e-mail address you provided.';
				reset_results += ' Please check your inbox for further instructions.';
				reset_results += '</div>';				
				var instructions = '<span style=" text-transform:uppercase; font-weight:bold; font-size:14px;">';
				instructions += 'Instructions successfully sent.';
				instructions += '</span>';				
				document.getElementById("reset_instructions").innerHTML = instructions;	
				document.getElementById("reset_mypassword_success").innerHTML = reset_results;	
			}else{
				document.getElementById("wrong_email").innerHTML = xmlHttp.responseText;	
				document.getElementById("forgot_password_email").focus();
			}
		} 
	}
	
	function passwordReset(){
		var baseurl = document.getElementById("siteroot").value;//Website base url
		var email = document.getElementById("forgot_password_email").value;
		if(email == ""){
			alert("Please enter your e-mail address to reset your password!");
			document.getElementById("forgot_password_email").focus();
			return false;
		}
		var password = document.getElementById("sign_me_in_password").value;
		var message_info = '<span style="color:#0072bf; font-size:14px; font-weight:bold;">';
		message_info += 'Please wait.....';
		message_info += '</span>';		
		document.getElementById("wrong_email").innerHTML = message_info;
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request");
			return;
		}	
		var url = baseurl+'/login/password_reset.php';
	
		url+="?email="+email;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=passwordResetReady;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

	function signMeIn(){ 
		var baseurl = document.getElementById("siteroot").value;//Website base url
		var email = document.getElementById("sign_me_in_email").value;
		var password = document.getElementById("sign_me_in_password").value;
		var message_info = '<span style="color:#0072bf; font-size:14px; font-weight:bold;">';
		message_info += 'Please wait.....';
		message_info += '</span>';		
		document.getElementById("info").innerHTML = message_info;
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request");

			return;
		}	
		var url = baseurl+'/login/login.php';	
		url+="?email="+email+"&password="+password;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=loginReady;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	function signOut(){
		var baseurl = document.getElementById("siteroot").value;//Website base url
		var signOutUrl = baseurl+'/login/logout.php';
		location.href = signOutUrl;
	}
	
	
	function getLoginForm(){
        $.blockUI({ message: $('#loginForm') }); 
	}
	function closeBlock(){
		document.getElementById("forgot_password").style.display = 'none';
		document.getElementById("sign_me_in").style.display = 'block';
		document.getElementById("show_join").style.display = 'block';
		document.getElementById("show_alert").style.display = 'none';
		document.getElementById("info").innerHTML = '&nbsp;';
		document.getElementById("sign_me_in_password").value = "";
		document.getElementById("sign_me_in_email").value = "";
		$.unblockUI({ message: $('#loginForm') }); 
	}
	function forgotPassword(){//show forgot password features if the user has forgotten a password
		document.getElementById("sign_me_in").style.display = 'none';
		document.getElementById("forgot_password").style.display = 'block';
		//$('#sign_me_in').fadeOut();
		//$('#forgot_password').fadeIn('slow');
	}
	
//Common javscript functions
//Goto to url
function goTo(url){
	location.href=url;
}

//Registration functions
function shopperRegister(){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(document.getElementById("regEmail").value==""){
		alert('Please enter your e-mail address');
		document.getElementById("regEmail").focus();
		return false;
	}
	if (!filter.test(document.getElementById("regEmail").value)) {
		alert('Please provide a valid email address.');
		document.getElementById("regEmail").focus();
		return false;		
	}
	var email = document.getElementById("regEmail").value;
	email = email.replace('@','AT');
	goTo('http://www.livedress.com/connectlive/register/shopper/'+email);
}





//The following function is to activate the enter key
	
	function alertkey(e){
		if( document.captureEvents && Event.KEYUP ) {
			//remove this part if you do not need Netscape 4 to work
			document.captureEvents( Event.KEYUP );
		}
		/* this next line tells the browser to detect a keyup
		event over the whole document and when it detects it,
		it should run the event handler function 'alertkey' */
		//now create the event handler function to process the event
		if( !e ){
			//if the browser did not pass the event information to the
			//function, we will have to obtain it from the event register
			if( window.event ){
				//Internet Explorer
				e = window.event;
			}else{
				//total failure, we have no way of referencing the event
				return;
			}
		}
		if( typeof( e.keyCode ) == 'number'  ){
			//DOM
			e = e.keyCode;
		}else if( typeof( e.which ) == 'number' ){
			//NS 4 compatible
			e = e.which;
		} else if( typeof( e.charCode ) == 'number' ){
			//also NS 6+, Mozilla 0.9+
			e = e.charCode;
		} else{
			//total failure, we have no way of obtaining the key code
			return;
		}
		// window.alert('The key pressed has keycode ' + e +
		//' and is key ' + String.fromCharCode( e ) );
		if(e==13){	
			if(document.getElementById("loginForm").style.display=='block' || document.getElementById("loginForm").style.display==''){			
				if(document.getElementById("sign_me_in").style.display=='block' || document.getElementById("sign_me_in").style.display==''){
					signMeIn();			
				}else if(document.getElementById("forgot_password").style.display=='block' || document.getElementById("forgot_password").style.display==''){
					passwordReset();
				}
			}
		}	
	}
	document.onkeydown = alertkey; 
	
	
	
	
	
	

