function submitPopupRefer()
{
    var refererForm = new VarienForm('referer-form');
    refererForm.submit();
}
function showRegisterForm()
{
    
	if($('register-user').style.display == 'none')
	{
		//$('login-title').hide();
		$('login-content').hide();
        $('register-user').show();
	}
	else
	{
		//$('login-title').show();
		$('login-content').show();
		$('register-user').hide();
	}
}

Register = Class.create();
Register.prototype = {
	    initialize: function(registerForm){
            this.varianFromObj = registerForm;
            this.submitBtn = $('customer-submit');
            Event.observe(this.submitBtn, 'click', this.registerUser.bind(this));
	        this.onSuccess = this.onRegisterSuccess.bindAsEventListener(this);
	    },
	    
	    registerUser: function(event){ 
            if(this.varianFromObj.validator.validate()){

	    	    var myAjax = new Ajax.Request(this.varianFromObj.form.action, {
        	        asynchronous: true,
					parameters : $('form-validate').serialize(),
                    onException: function (xhr, e)
                    {
                        alert('Exception : ' + e);
                    },
                    onComplete: function(transport){},
                    onSuccess: this.onSuccess
	    	    });
            }
            
            event.stop();
            return false;
	    },
	    
	    onRegisterSuccess: function(transport)
	    {
            var response = {};
	    	if (transport && transport.responseText){
                try{
                    response = eval('(' + transport.responseText + ')');
                }
                catch (e) {
                    response = {};
                }
            }
			if(response.redirectError)
			{
				$('success-register-message').update('<ul class="messages"><li class="success-msg"><ul><li>'+response.redirectError+'</li></ul></li></ul>') ;
			}
			else if(response.redirectSuccess)
			{
				$('success-register-message').update('<ul class="messages"><li class="error-msg"><ul><li>'+response.redirectSuccess+'</li></ul></li></ul>') ;
			}
	    }
}


Login = Class.create();
Login.prototype = {
	    initialize: function(loginForm){
            this.varianFromObj = loginForm;
            this.submitBtn = $('send2');
            Event.observe(this.submitBtn, 'click', this.loginUser.bind(this));
	        this.onSuccess = this.onLoginSuccess.bindAsEventListener(this);
	    },
	    
	    loginUser: function(event){
	    	//alert(this.varianFromObj.form.action);return false;
            //if(this.varianFromObj.validator.validate()){
	    	    var myAjax = new Ajax.Request(this.varianFromObj.form.action, {
        	        asynchronous: true,
					parameters : $('login-form').serialize(),
                    onException: function (xhr, e)
                    {
                        alert('Exception : ' + e);
                    },
                    onComplete: function(transport){},
                    onSuccess: this.onSuccess
	    	    });
            //}
            
            event.stop();
            return false;
	    },
	    onLoginSuccess: function(transport)
	    {
            var response = {};
	    	if (transport && transport.responseText){
                try{
                    response = eval('(' + transport.responseText + ')');
                }
                catch (e) {
                    response = {};
                }
            }
			if(response.redirectError)
			{
				$('login-message').update('<ul class="messages"><li class="success-msg"><ul><li>'+response.redirectError+'</li></ul></li></ul>') ;
				//window.location.href = 
			}
			else if(response.redirectSuccess)
			{
				$('login-message').update('<ul class="messages"><li class="error-msg"><ul><li>'+response.redirectSuccess+'</li></ul></li></ul>') ;
			}
	    }
}
function Calcage(secs, num1, num2)
  {
    s = ((Math.floor(secs/num1))%num2).toString();
    if (s.length < 2) 
    {    
      s = "0" + s;
    }
    return (s);
  }
  
  function CountBack(myDiv, secs)
  {
    /*var DisplayStr;
    var DisplayFormat = "%%D%% days - %%H%% hours - %%M%% mins - %%S%% sec";
    DisplayStr = DisplayFormat.replace(/%%D%%/g,    Calcage(secs,86400,100000));
    DisplayStr = DisplayStr.replace(/%%H%%/g,        Calcage(secs,3600,24));
    DisplayStr = DisplayStr.replace(/%%M%%/g,        Calcage(secs,60,60));
    DisplayStr = DisplayStr.replace(/%%S%%/g,        Calcage(secs,1,60));*/
    var DisplayStr;
    var DisplayFormat = "%%H%% hours - %%M%% mins - %%S%% sec";
    var day = Calcage(secs,86400,100000);
    var hours = (parseInt(day)*24)+ parseInt(Calcage(secs,3600,24));
    DisplayStr = DisplayFormat.replace(/%%H%%/g,        hours);
    DisplayStr = DisplayStr.replace(/%%M%%/g,        Calcage(secs,60,60));
    DisplayStr = DisplayStr.replace(/%%S%%/g,        Calcage(secs,1,60));
    if(secs > 0)
    {    
      document.getElementById(myDiv).innerHTML = DisplayStr;
      setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
      document.getElementById(myDiv).innerHTML = "";
    }
  }
  function signupPopup1(param)
  {        
    if(!param)
        param = 'vip';
    hs.htmlExpand(document.getElementById(param), { objectType: 'ajax', align: 'center', width:470, height: 400} );
    return false;    
  }
  function signupPopup()
  {
    hs.htmlExpand(document.getElementById('vip-footer-login'), { objectType: 'ajax', align: 'center', width:500, height: 400} );
    return false;    
  }
