﻿// JScript 文件
$(document).ready(function(){
        //If need login 
        if(gLoggedIn){
            $("#changeTheme").click(function(){
                $(this).parents().children('.wbox').slideToggle(100); $(this).toggleClass('tact');
            });
            
            $("#ulThemeList>li").click(function(){
                $("body").css('background-color', $(this).find('span').attr('bcolor'));
                $(this).siblings().removeClass('act');
                $(this).addClass('act');
                $.post("/handler/UpdateUserThemeColor.ashx", { "color" : $(this).find('span').attr('bcolor') });
            });
            //Init background-color
            $("body").css('background-color', preferColor);
            $("#ulThemeList>li>span[bcolor='" + preferColor + "']").parent().addClass('act');
        }else{
            $.harborkWatermark($("#txtLoginName,#txtLoginPass"));
            $.gtAutoSubmit($("#txtLoginName,#txtLoginPass"),$("#btnLogin"));        
            $("#btnLogin").click(function(){
                    if($("#txtLoginName").val().length == 0 || $("#txtLoginPass").val().length == 0){
                        alert("Please input your username/password.");
                        return false;
                    }
                    $.post("/handler/logincheck.ashx",{username: $("#txtLoginName").val(),password: hex_md5($("#txtLoginPass").val())},function(data){
                        eval("ret = " + data);                
                        if(ret.ret == 0){
                               window.location.href = "/backend/" + $.trim($("#txtLoginName").val()) + "/home.html";
                               return;
                        }else{
                            alert(ret.msg);
                            $("#txtLoginName")[0].focus();
                        }
                        
                    });
                return false;
            });
        }
        $(".loginwithfb").hover(
		    function(){$(this).children("li").show(0);},
		    function(){$(this).children("li.second,li.third").slideUp(200);}					 
	     );
	     
	     
	    
	    	    
});
