//********************************************
//Author：AIONG 2009.10.19
//E-mail:Cloudflyang@163.com 
//V-20091123
//********************************************
//fun.ChkSelect:全选,反选,全部选
//fun.SearchProduct:查找产品
//fun.SetBlurOrFocus:设置搜索框提示文字
//funHome.ChangeLink:友情链接打开新页面
//funHome.HomePage:设为首页//<a href="#" onclick="funHome.HomePage(this,'http://www.tyh1993.com');">设为首页</a>
//funHome.AddFavorite 加入收藏 //<a href="#" onclick="funHome.AddFavorite('http://www.tyh1993.com','太阳红化妆品');">加入收藏</a>
//funShowHide.ShowHide(obj) 显示或者隐藏目标 eg: funShowHide.ShowHide('div1')
//funShowHide.ShowHide(ShowObj,HideObj,ShowMethod)  eg: funShowHide.ShowHide('div1','div2','slide'),funShowHide.ShowHide('div1','','slide') 
//funShowHide.ShowsHides(ShowObjs,HideObjs)     eg: funShowHide.ShowsHides('div1,div2','div3,div4')
//funShowHide.Slide(obj,ShowOrHide) eg: funShowHide.Slide('div1'),funShowHide.Slide('div1','show'),funShowHide.Slide('div1','hide')
//funShowHide.Fade(obj,ShowOrHide)
//funShowHide.Show(obj,ShowOrHide)
/*********************************************/
jQuery.noConflict();
var fun = {
    /******/
    /****** 全选,反选,全不选 *******/
    ChkSelect: function(sender, obj) {
        var objChkBox = jQuery("#" + obj).find("tr").find("td:first input");
        switch (jQuery(sender).val()) {
            case "全选":
                objChkBox.attr("checked", true);
                jQuery(sender).val("全不选");
                break;
            case "全不选":
                objChkBox.attr("checked", false);
                jQuery(sender).val("全选");
                break;
            default:
                objChkBox.each(function() {
                    jQuery(this).attr("checked", !jQuery(this).attr("checked"));
                });
                break;
        }
    },
    /**全选/反选**/
    ChkPurviewSelect: function(sender) {
        var _id = jQuery(sender).attr("id");
        var checked = jQuery(sender).attr("checked");
        var tips = checked ? "确定全选该列？" : "确定全部取消选中？";
        if (confirm(tips)) {
            jQuery("input[id$='" + _id + "']").attr("checked", checked);
        } else {
            jQuery(sender).attr("checked", !checked);
        }
    },
    /****** 设置搜索框提示文字 *******/
    SetBlurOrFocus: function(obj, msg) {
        msg = (null == msg || "" == msg) ? "请输入搜索关键字" : msg;
        if ("" == jQuery(obj).val() || null == jQuery(obj).val()) {
            jQuery(obj).val(msg).css("color", "#808080");
        }
        else if (msg == jQuery(obj).val()) {
            jQuery(obj).val("").css("color", "#000");
        }
    },
    /****** 查找产品 *******/
    SearchProduct: function() {
        var tips = "请输入项目名称";
        var kw = jQuery("#txtKeyWord").val();
        if (null == kw || "" == kw || tips == kw) {
            alert("请输入要搜索的关键字");
            document.getElementById("txtKeyWord").value = "";
            document.getElementById("txtKeyWord").focus();
            return false;
        } else {
            window.location.href = "CaseList.aspx?kw=" + encodeURI(kw); //escape(kw);
        }
    },
    /****************/
    MenuShowHide: function(obj) {
        var _ext = obj.substring(0, obj.lastIndexOf('_') + 1);
        jQuery("div[id^='" + _ext + "']").slideUp("quick");
        fun.Slide(obj);
    },
    ShowOrHideTr: function(obj) {
        var _ext = jQuery(obj).attr("id");
        jQuery("tr[id^='" + _ext + "," + "']").toggle();
    },
    ShowHide: function(obj) {
        //alert(obj);
        jQuery("#" + obj).toggle();
    },
    ShowHide: function(ShowObj, HideObj, ShowMethod) {
        switch (ShowMethod) {
            case "slide": fun.Slide(ShowObj, "show"); break;
            case "fade": fun.Fade(ShowObj, "show"); break;
            case "show": fun.Show(ShowObj, "show"); break;
            default: jQuery("#" + ShowObj).show(); break;
        }
        switch (ShowMethod) {
            case "slide": fun.Slide(HideObj, "hide"); break;
            case "fade": fun.Fade(HideObj, "hide"); break;
            case "show": fun.Show(HideObj, "hide"); break;
            default: jQuery("#" + HideObj).hide(); break;
        }
    },
    ShowsHides: function(ShowObjs, HideObjs) {
        var shows = ShowObjs.split(',');
        var hides = HideObjs.split(',');
        for (var i = 0; i < shows.length; i++) {
            jQuery("#" + shows[i]).show();
        }
        for (var i = 0; i < hides.length; i++) {
            jQuery("#" + hides[i]).hide();
        }
    },
    Slide: function(obj, ShowOrHide) {
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if (dis) jQuery("#" + obj).slideDown("quick");
        else jQuery("#" + obj).slideUp("quick");
    },
    Fade: function(obj, ShowOrHide) {
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if (dis) jQuery("#" + obj).fadeIn("quick");
        else jQuery("#" + obj).fadeOut("quick");
    },
    Show: function(obj, ShowOrHide) {
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if (dis) jQuery("#" + obj).show("quick");
        else jQuery("#" + obj).hide("quick");
    },
    /********************/
    /** 友情链接打开新页面 **/
    ChangeLink: function(sender) {
        var win = window.open(jQuery(sender).val());
        if (null == win) {
            alert('新窗口看起来是被一个弹出窗口拦截程序所阻挡。 如果想打开新窗口，我们建议您将本站点加入到这个拦截程序设定的允许弹出名单中。有的弹出窗口拦截程序允许在长按Ctrl键时可以打开新窗口。');
        }
    },
    /*** 设为首页 ****/
    HomePage: function(sender, targetUrl) {
        targetUrl = (null == targetUrl) ? location.href : targetUrl;
        sender.style.behavior = 'url(#default#homepage)';
        sender.sethomepage(targetUrl);
    },
    /*** 加入收藏 ***/
    AddFavorite: function(targetUrl, targetName) {
        targetUrl = (null == targetUrl) ? location.href : targetUrl;
        window.external.addFavorite(targetUrl, targetName);
    }

};

var funHome = {
    /** 友情链接打开新页面 **/
    ChangeLink : function(sender){
        var win = window.open(jQuery(sender).val());
        if(null == win){
          alert('新窗口看起来是被一个弹出窗口拦截程序所阻挡。 如果想打开新窗口，我们建议您将本站点加入到这个拦截程序设定的允许弹出名单中。有的弹出窗口拦截程序允许在长按Ctrl键时可以打开新窗口。');
        } 
    },
    /*** 设为首页 ****/
    HomePage : function(sender,targetUrl){
         targetUrl = (null == targetUrl) ? location.href : targetUrl;
         sender.style.behavior = 'url(#default#homepage)';
         sender.sethomepage(targetUrl);   
    },
    /*** 加入收藏 ***/
    AddFavorite : function(targetUrl,targetName){
        targetUrl = (null == targetUrl) ? location.href : targetUrl;
        window.external.addFavorite(targetUrl,targetName);
    }
};

var funShowHide = {
    ShowHide : function(obj){
        jQuery("#" + obj).toggle();
    },
    ShowHide: function(ShowObj,HideObj,ShowMethod){
        switch(ShowMethod){
            case "slide" : funShowHide.Slide(ShowObj,"show");break;
            case "fade" : funShowHide.Fade(ShowObj,"show");break;
            case "show" : funShowHide.Show(ShowObj,"show");break;
            default : jQuery("#"+ShowObj).show();break;
        }
        switch(ShowMethod){
            case "slide" : funShowHide.Slide(HideObj,"hide");break;
            case "fade" : funShowHide.Fade(HideObj,"hide");break;
            case "show" : funShowHide.Show(HideObj,"hide");break;
            default : jQuery("#"+HideObj).hide();break;
        }
    },
    ShowsHides : function(ShowObjs,HideObjs){
        var shows = ShowObjs.split(',');
        var hides = HideObjs.split(',');
        for(var i=0;i < shows.length;i++){
            jQuery("#" + shows[i]).show();
        }
        for(var i=0;i < hides.length;i++){
            jQuery("#" + hides[i]).hide();
        }
    },
    Slide : function(obj,ShowOrHide){
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if(dis) jQuery("#"+obj).slideDown("quick");
        else jQuery("#"+obj).slideUp("quick"); 
    },
    Fade : function(obj,ShowOrHide){
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if(dis) jQuery("#"+obj).fadeIn("quick");
        else jQuery("#"+obj).fadeOut("quick");
    },
    Show : function(obj,ShowOrHide){
        var dis = (null != ShowOrHide) ? ("show" == ShowOrHide) : ("none" == jQuery("#" + obj).css("display"));
        if(dis) jQuery("#"+obj).show("quick");
        else jQuery("#"+obj).hide("quick");
    }
}

/***********************************************
HELP:
fun.ChkSelect使用示例:
<input type="button" value="全选" onclick="chkSelected(this,'<%= this.GridView1.ClientID %>');" />
<input type="button" value="全不选" onclick="chkSelected(this,'<%= this.GridView1.ClientID %>');" />
<input type="button" value="反选" onclick="chkSelected(this,'<%= this.GridView1.ClientID %>');" />

jQuery(document).ready(function(){
    jQuery(".iframeBody #divListTitle ul li").mouseover(function(){
        if(!jQuery(this).hasClass("active"))
            jQuery(this).addClass("active2");
    });
    jQuery(".iframeBody #divListTitle ul li").mouseout(function(){
        jQuery(".iframeBody #divListTitle ul li").each(function(){
            jQuery(this).removeClass("active2");
        });
    });
    jQuery(".iframeBody #txtMsgKeyword").blur(function(){
        Sec.SetBlurOrFocus(this);
    });
    jQuery(".iframeBody #txtMsgKeyword").click(function(){
        Sec.SetBlurOrFocus(this);
    });
    
});
***********************************************/