jQuery(function(jQuery){
    var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
    if (badBrowser) {
        if(jQuery('#linesupport')){
            jQuery('#linesupport').scrollFollow();
        }
    }
	check_user_login();
});
/*
function show_sub_menu(Obj){
    jQuery(".n1").each(function(){
        jQuery(this).removeClass("current");
        jQuery(this).children("#sub_menu_div").hide();
    });
    jQuery(Obj).children("span").addClass("cBlue");
    jQuery(Obj).parent().parent().addClass("current");
    jQuery(Obj).parent().parent().children('div').eq(0).show();
    jQuery(Obj).parent().next().show();
}

function hide_sub_menu(Obj){
    jQuery(Obj).parent().parent().mouseover(function(){
        console.log("over");
        jQuery(Obj).children("span").addClass("cBlue");
        jQuery(Obj).parent().parent().addClass("current");
        jQuery(Obj).parent().parent().children('div').eq(0).show();
        jQuery(Obj).parent().next().show();
    });
    jQuery(Obj).parent().parent().mouseout(function(){
        jQuery(Obj).parent().next().hide();
        jQuery(Obj).parent().parent().removeClass("current");
        jQuery(Obj).parent().parent().children('div').eq(0).hide();
        jQuery(Obj).children("span").removeClass("cBlue");
    });
}
*/
function hide_all_head_sub(Obj){
    jQuery(Obj).parent().children("li").each(function(){
        jQuery(this).children("a").children("span").hide();
        jQuery(this).children("div").hide();
    });
}
function show_sub_menu(Obj){
    jQuery(Obj).parent().children("li").each(function(){
        jQuery(this).children("a").children("span").hide();
        jQuery(this).children("div").hide();
    });
    jQuery(Obj).children("a").children("span").show();
    jQuery(Obj).children("div").show();
}

function hide_sub_menu(Obj){
    jQuery(Obj).children("div").mouseover(function(){
        jQuery(Obj).children("a").children("span").show();
        jQuery(Obj).children("div").show();
    });
    jQuery(Obj).children("div").mouseout(function(){
        jQuery(Obj).children("a").children("span").hide();
        jQuery(Obj).children("div").hide();
    });
}
function check_user_login(){
    jQuery.ajax({
        type: "post",
        url : "/login/check_user_login",
        dataType:'json',
        error: function(msg){
            jQuery("#head_user_div").html('<a href="/login/">Sign in</a> / <a href="/reg/">Register</a>');
            return false;
        },
        success: function(json){
            switch (json.flag) {
                case 1:
                    jQuery("#head_user_div").html('<a href="/login/">Sign in</a> / <a href="/reg/">Register</a>');
                    break;
                case 2:
                    jQuery("#head_user_div").html('<a href"/usercenter/userinfo>Hi ' + json.firstname + '</a> [<a href="/login/loginout">log out</a>]');
                    break;
                default:
                    jQuery("#head_user_div").html('<a href="/login/">Sign in</a> / <a href="/reg/">Register</a>');
                    break;
            }
        }
    });
}

function showNews(){
    jQuery("#NewsList").hide();
    jQuery("#NewsLoad").show();
    jQuery.ajax({
        type: "post",
        url : "/information/AjaxInfoList",
        dataType:'html',
        error: function(msg){
            return false;
        },
        success: function(json){
            jQuery("#NewsList").html(json);
            jQuery("#NewsLoad").hide();
            jQuery("#NewsList").show();
        }
    });
}
function showFeed(){
    jQuery("#FeedList").hide();
    jQuery("#FeedLoad").show();
    jQuery.ajax({
        type: "post",
        url : "/feedback/AjaxFeedList",
        dataType:'html',
        error: function(msg){
            return false;
        },
        success: function(json){
            jQuery("#FeedList").html(json);
            jQuery("#FeedLoad").hide();
            jQuery("#FeedList").show();
        }
    });
}

function check_search_form(){
    var form_search = jQuery.trim(jQuery("#search_value").val());
    if(form_search.length < 3){
        alert("Please input your searching content. For any question, feel free to contact us by LIVE CHAT.");
        return false;
    }
}


function show_livechat(Obj){
    if(jQuery(Obj).next().css("display") == "none"){
        jQuery(Obj).next().show();
        jQuery("#livechat_sub").show();
        jQuery("#livechat_add").hide();
    }else{
        jQuery(Obj).next().hide();
        jQuery("#livechat_sub").hide();
        jQuery("#livechat_add").show();
    }
}
