﻿function pfjs_signIn(valgroup){
    $(".feedback").queue([]).stop().css({backgroundColor:"#dedede", border:"1px solid #bebebe"}).html("Signing in...").show(function(){ 
        if(validategroup(valgroup)){
               sites_sspurplefishescom_login.SignIn($("input.txt_loginemail").val(),$("input.txt_loginpass").val(), function(response){
                    //When we get back
                    if (response.error != null){
                        alert('ERROR. Please refresh/reload this page by using the button on your browser or by pressing Ctrl + F5 to continue and try again.');
                        return;
                    }
                    if(response.value == "success"){
                       // $("#t4hl").attr("onmouseover", "").bind("click", function(e){
                           // return false;
                        //});
                        //$("#t4hl").html("<img src=\"/sites/streetshirts.com/template/images/t4_l_d.gif\" alt=\"\" width=\"5\" height=\"34\" id=\"t4i\" class=\"t_li\" />2. Sign in/up - Complete");
                        //selecttab('t5');
                        //pfjs_addressdef();
                        window.location = $.jqURL.get('ref');
                    }
                    else
                    {
                        pfjs_displayMessage('.feedback', 'success', response.value, true);  
                    }
               });
        }
        else
        {
            pfjs_displayMessage('.feedback', 'success', 'Error signing in. Please correct the errors shown below and try again.', true);  
            return false;
        }
    });
}

//Displays a success message
function pfjs_displayMessage(where, type, message, hide){
    $('html, body').animate({scrollTop: 0}, 400);
    $(where).html(message).animate( { backgroundColor: '#ffffff', borderBottomColor: '#bebebe', borderLeftColor: '#bebebe', borderRightColor: '#bebebe', borderTopColor: '#bebebe' }, 100, function(){
        $(this).animate({opacity: 1.0}, 2000, function(){
            $(this).animate( { backgroundColor: '#74d6fa', borderBottomColor: '#45c8f8', borderLeftColor: '#45c8f8', borderRightColor: '#45c8f8', borderTopColor: '#45c8f8' }, 2000, function(){
                    $(this).animate({opacity: 1.0}, 5000, function(){
                        if(hide) $(this).hide("fast");
                    });
                });
            });
        });
}