// JavaScript Document
//plugin in show getid 20110401
var $bool = false;
function GetQueryString(name) {

    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");

    var r = window.location.search.substr(1).match(reg);

    if (r != null) return unescape(r[2]); return null;

}
$(function() {
    var cid = GetQueryString("CateId");
    if ($("#cssid" + cid).length > 0) {
        if ($("#cssid" + cid).siblings("ul").children("li").length > 0) {
            setTimeout(function() { $("#cssid" + cid).siblings("ul").slideDown().end().parent().addClass("hover").siblings().removeClass("hover").siblings("ul").hide() }, 500);
        }
    }

})
//show obj
$(function() {
    $("#selectbox").hover(function() {
        $(this).children("dt").siblings().show();

    }, function() {
        $(this).children("dt").siblings().fadeOut(500);
    })
})

//plugin in scroll20110419
$(document).ready(function() {
    var len2 = $(".vscrollc > li").length;
    var index2 = 0;
});

var sli = 655; //parseInt($(".vscrollc > li").innerWidth(true));
var scrollul = $(".vscrollc");
var slen_ = scrollul.find("li").length - 3;
var sw_ = 655;
var ssrc_ = scrollul.find("img").attr("src");
$(".goleft").click(function() {
    if (parseInt(scrollul.css("left")) < 0 && !scrollul.is(":animated"))
    { scrollul.animate({ left: "+=" + sli }, 350); }
});
$(".goright").click(function() {
    if (Math.abs(parseInt(scrollul.css("left"))) <= sw_ && !scrollul.is(":animated"))
    { scrollul.animate({ left: "-=" + sli }, 350); }
});
$(function() {
    $(".vcon1 a").click(function() {
        if ($(this).attr("rel") !== "")
        { $("#imginfo").html($(this).attr("rel")); }
        else { $("#imginfo").html("暂无内容详细说明...") }
        $(".v-con img").attr("src", $(this).children("img").attr("src"));
        return false;
    })
})

//plugin in tr:even color
$(function() {
    $(".dlist tr:even").addClass("even");
    $(".role_con_table tbody").children("tr:even").addClass("even");
});
//plugin in imgload
jQuery.fn.loadthumb = function(options) {
    options = $.extend({
        src: ""
    }, options);
    var _self = this;
    _self.hide();
    var img = new Image();
    $(img).load(function() {
        _self.attr("src", options.src);
        _self.fadeIn("slow");
    }).attr("src", options.src);
    return _self;
}
//plugin in slidebox
$(document).ready(function() {
    var len = $(".slide-btn dd a").length;
    var index = 0;
    var adTimer;
    $(".slide-btn dd a").mouseover(function() {
        index = $(".slide-btn dd a").index(this);
        showImg(index);
    }).eq(0).mouseover();
    $('.slide-con').hover(function() {
        clearInterval(adTimer);
    }, function() {
        adTimer = setInterval(function() {
            index++;
            if (index == len) { index = 0; }
            showImg(index);
        }, 5000);
    }).trigger("mouseleave");
});
//plugin in tab
$(function() {
    $.fn.extend({ "jxtab": function(c) {
        $(this).bind(c || "click", function() {
            var n = $(this).parent().children().index(this);
            $(this).addClass("hover").siblings().removeClass("hover");
            $(this).parent().siblings(".info-tab").children().hide().eq(n).show();
        });
    }
    });
})
/*
jxtab插件调用
*/
$(function() {
    $(".sidebar .title-tab a").jxtab("mouseover");
})
$(function() {
    $(".tab-nav a").jxtab("mouseover");
})
$(function(){
		   $(".search-txt").bind("click",function(){
												  if($(this).val()=='请输入关键字..'){$(this).val("");}
												  }).bind("blur",function(){
													  if($(this).val()==""){$(this).val("请输入关键字..");}
													  })
		   });
//onclick="if(this.value=='请输入关键字..'){this.value==''}" onblur="if(this.value==''){this.value='请输入关键字..'}" 
/*
下拉列表取值
*/
function sm() {
    return "\n\n\n\n使用说明：\n 把元素属性name命名为：class,产生的关键字就为：?class=你选择的值。keyword=关键字";
}
function geturl() {
    var n1 = $(".search dt span"),
	n2 = $(".search-txt");
    if (n2.val() == "" || n2.val() == "请输入关键字..") { alert("请输入您要搜索的关键字"); n2.val(""); n2.focus(); return false; }
    var cateval = n1.text();
    var tourl='';

    if (cateval == "寻资本") {
        tourl = "Capital.aspx?";
    }
    else if (cateval == "投项目")
    { tourl = "Project.aspx?"; }
    else if (cateval == "实时数据") {
    tourl = "IncidentNews.aspx?type=sc&";
    }
    else if (cateval == "交易产品") {
    tourl = "product.aspx?";
    }
    else if (cateval == "会议活动") {
    tourl = "MeetingSearchList.aspx?";
    }
    else
    {
    alert("请选择搜索的信息分类");
    return ;
    }
    $.get("/IAjax/ITopSearchkey.aspx?s=" + Math.random(), { action: "addkey", keyname: URLencode(n2.val()), tourl: tourl + "?topkey={0}" }, addend);
    window.location = tourl + n2.attr("name") + "=" + URLencode(n2.val());
}

function addend(msg) {}


function URLencode(sStr) {
    return escape(sStr).
             replace(/\+/g, '%2B').
                replace(/\"/g, '%22').
                   replace(/\'/g, '%27').
                     replace(/\//g, '%2F');
}

//show
$(function() {
    var $$n = 5; $$li = $(".slidenav li").length, $$h = $(".slidenav li").outerHeight(true), $$top = 0, $$height = $$li * $$h - $$n * $$h, $$top = $$i = 0;

    $(".slidenav li").bind("mouseover", function() {
        $(this).addClass("curr").siblings().removeClass("curr");
        var $$src = $(this).children().attr("rel"),$$href=$(this).children().attr("href");
        $(".slideshow img").attr("src", $$src);
        $(".slideshow a").attr("href",$$href);
    });
    $("#goup").bind("click", function() {
        if (Math.abs(parseInt($(".slidenav").css("top"))) < $$height) {
            $$top = parseInt($(".slidenav").css("top")) - $$h;
            $(".slidenav").animate({ "top": $$top });
            $$i++;
            $(".slidenav li").eq($$i).trigger("mouseover");
        }
    });
    $("#godown").bind("click", function() {
        if (Math.abs(parseInt($(".slidenav").css("top"))) > 0) {
            $$top = parseInt($(".slidenav").css("top")) + $$h;
            $(".slidenav").animate({ "top": $$top });
            $$i--;
            $(".slidenav li").eq($$i).trigger("mouseover");
        }
    });
});

//plugin in dllist20110511
$(function() {
    $(".dlbox dt").bind("click", function() {
        $(".dlbox dt").siblings().hide();
        if ($(this).siblings().is(":visible")) {
            $(this).siblings().fadeOut(500);
        } else {
            $(this).siblings().fadeIn(250);
            var w = $(this).siblings().children("p").outerWidth(true) + 16;
            $(this).siblings().css({ "height": "120", "width": w, "overflow-y": "scroll", "overflow-x": "hidden" });
            $bool = true;
            return false;
        }
    });
    $(".dlbox dd a").bind("click", function() {
        $(this).parent().parent().siblings("dt").children().text($(this).text());
        $(this).parent().parent().hide();
        return false;
    });
    $(document).bind("click", function() { if ($bool) $(".dlbox dd").fadeOut(); $bool = false; })
});
// search
$(function() {
    $("#ireset").bind("click", function() {
        $(".d-sinfo #ddate").val("");
        $(".d-sinfo dt span").html("");
    });
});
function resdata() {
    function cktxt(obj) {
        if (obj.html().indexOf("请选择") != -1 || obj.text() == "") { obj.wrapInner("<font color='red'></font>"); return true; }
    }
    if ($(".d-sinfo #ddate").val().indexOf("请选择") != -1 || $(".d-sinfo #ddate").val() == "") { alert("请选择时间"); $(".d-sinfo #ddate").click(); return false; }
    if (cktxt($(".d-sinfo dt span").eq(0))) { alert("请选择所在区域"); if ($(".d-sinfo dt span").eq(0).html() == "") { $(".d-sinfo dt").eq(0).siblings().show(); } return false; }
    if (cktxt($(".d-sinfo dt span").eq(1))) { alert("请选择所属行业"); if ($(".d-sinfo dt span").eq(1).html() == "") { $(".d-sinfo dt").eq(1).siblings().show(); } return false; }
    return window.location.href = "?date=" + $(".d-sinfo #ddate").val() + "&aeraid=" + $(".d-sinfo dt span").eq(0).html() + "&industryid=" + $(".d-sinfo dt span").eq(1).html();
};
//show menu tools
$(function() {
    $(".categories-con").find("li").hover(function() {
        $(this).addClass("curr").siblings().removeClass("curr");
    }, function() {
        $(this).removeClass("curr");
    });
});
//remove elm to first
$(function() {
    if ($(".t-con dl dt.curr").length > 0) {
        $(".t-con dl dt.curr").bind("click", function() {
            $(this).siblings("dd").prependTo($(this).parent("dl"));
            $(this).prependTo($(this).parent("dl"));
            $(this).siblings(".all").prependTo($(this).parent("dl"));
        }).trigger("click");
    }
});
//Comment
$(function() {
    $(".commentBox").bind("mouseover", function() {
        $(".tieOperations").css("visibility", "hidden");
        $(this).children(".tieOperations").css("visibility", "visible");
        return false;
    }).bind("mouseout",function(){
		$(".tieOperations").css("visibility", "hidden");
		});
})
