document.write("<style type=\"text/css\">"); 
document.write("ul.list1 li div p{*position:absolute;top:50%; left:0; display:table-cell; vertical-align:middle;width:100%;}");
document.write(".content_in,li.nopadding p,.productall p{text-justify: inter-ideograph; text-align: justify;}");
document.write("</style>"); 

$(function(){

//		document.body.onmouseup=function(){document.selection.empty();}
		document.body.oncontextmenu=function(){return false;}
//		document.body.onmousemove=function(){document.selection.empty();}
		document.body.oncopy=function(){document.selection.empty();}
		document.body.onselect=function(){document.selection.empty();}


	var options1 = {format: '%Y年%B%d日 %A %H:%M:%S' };$('#time').jclock(options1);
	$("#logo").append("<span id=\"sresult\"><img src=\"images/lightbox-ico-loading.gif\" width=\"24\" height=\"24\" alt=\"正在传送数据...\" /></span>");
	$("#sresult").css("opacity","0.95");
	$("#frmsearch").submit(function(){searchinput();return false;});
	$("#searchGo").click(function(){searchinput();return false;});
	$("#searchArea").click(function(){
		if ($("input[name='keywords']").val() == "关键词"){
		$("input[name='keywords']").val("");
		}
	});

	if ($("div.pjh").length > 0) {showrequest("para.aspx","para",false);}
	$("#pjsubmit").click(function(){pjse()});
	$("#pjsarea").keydown(function(e){if (e.keyCode == 13){pjse()}});

	var navigatorLI = $("div.navigator li,#homeh1_0_1 li,#protree li");
	for (var i = navigatorLI.length; i > 0; i--){
		var childA = navigatorLI.eq(i-1).children("a");
		if(childA.attr("href").indexOf(":") > 0) {
			childA.attr("href", $("li:eq(0)>a", childA.next()).attr("href"));
		}

		if (navigatorLI.eq(i-1).children("ol").length >0 && navigatorLI.eq(i-1).children("ol").children("li").length > 1){
			navigatorLI.eq(i-1).children("a").eq(0).addClass("hasul");
		}
	}

	$("#protree a.ac").parents("li").children("a").addClass("ac");
	$("div.navigator > ul > li > ol li:first-child").addClass("first");
	$("div.navigator > ul > li:has(ol)").hover(function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").show();$(this).children("a").eq(0).children("span").eq(0).addClass("ac")}
		},function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").hide();$(this).children("a").eq(0).children("span").eq(0).removeClass("ac")}
		});

	$("#homeh1_0_1 li:has(ol),#protree li:has(ol)").hover(function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").show();$(this).children("a").eq(0).addClass("ac")}
		},function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").hide();$(this).children("a").eq(0).removeClass("ac")}
		});

	var navigatorOL = $("#homeh1_0_1 ol");
	for (var i = navigatorOL.length; i > 0; i--){
		if (navigatorOL.eq(i-1).children("li").length >4 ){
			navigatorOL.eq(i-1).addClass("four");
		}
	}
	$("#homeh1_0_1 > ul > li > ol").append("<li class=\"bottom\"></li>");
	$("#homeh1_0_1 > ul > li:lt(13)").show();

	$("ul.list0 li:even").addClass("even");
	if ($("ul.list1").length > 0) {	$("ul.list1 li a.thumb").lightBox();}
	if ($("ul.list2").length > 0) {	$("ul.list2 li a.thumb").lightBox();}
	if ($("ul.list01").length > 0) {$("ul.list01 li a.thumb").lightBox();}
	if($("body").attr("id") == "P03" ) {
		$("#h0_0 > dd").eq(0).append("<div id=\"window\"></div>");
//		$("li a.thumb").lightBox();
	    $("#marquee_container").kxbdMarquee(true,0,'left',1,10);
	}

	if($("body").attr("id") == "P00" ) {
		//roller.init('homeh1_0_1','v',0,-22,60,15);
		$("#homeh0_0").html(fplay("images/media.swf","267","233","transparent"));
		$("#homeh0_1").html(fplay("images/home.swf","723","233","transparent"));
		$("#flashSlider").html(fplay("images/img.swf","263","320","transparent",flashSlider));
		}
		else{
		$("#flash").html(fplay("images/homein.swf","991","150","transparent"));
		}

		
//
	 $("#homeh1_1_0 ul>li").each(function(){
						$(this).hover(function(){
						$("#homeh1_1_0 ol.ac").removeClass("ac");$("#homeh1_1_0 li.ac").removeClass("ac");$(this ).addClass("ac");
						$(this ).children("ol").addClass("ac");
						})
	 });

	$("#homeh1_1_0 ol,#homeh1_1_0 h2 a").hover(function(){
		$("#homeh1_1_0 a.ac").removeClass("ac");
		$(this).parent("li").children("h2").children("a").addClass("ac");
	});

  /* ---------------media--------------------- */
    if ($("#media")) {
        var ml = 0;                                             //当前 marginLeft 是 0；

        var win = $("#win");
        win.before("<img class='left' src='images/turn_left.gif'>");
        win.after("<img class='right' src='images/turn_right.gif'>");
        var winli = $("li", win);
        
/*0701*/if(winli.length > 4) {
            win.next().css("visibility", "visible");
        }

        var img_btn = $("#media").find(".slide_pl").find("img").not(".point").not(".min_scr");

        var rec = 1;
        img_btn.click(function() {
            var tar_ul = $(this).parent().children("#win").children("ul");
            if (this.className == "left") {
                if (rec > 1) {
                    ml = ml + 98;
                    tar_ul.animate({marginLeft: ml}, 800);

                    if (rec == 2) {
                        win.prev().css("visibility", "hidden");
                    }
                    win.next().css("visibility", "visible");    
                    rec--;
                }
            } else {
                if (rec <= tar_ul.children("li").length - 4) {
                    ml = ml - 98;
                    tar_ul.animate({marginLeft: ml}, 800);

                    win.prev().css("visibility", "visible");
                    if (rec == tar_ul.children("li").length - 4) {
                        win.next().css("visibility", "hidden");   
                    }
                    rec++;
                }
            }
        });

        var img_scr = $("#media").find(".min_scr");
        var img_pt = $("#media").find(".point");
        var title = $("#media > .avi_txt > .title");
        var txt = title.next();

        title.text(img_scr.eq(0).next().next().text());
        txt.text(img_scr.eq(0).next().next().next().text());

        img_scr.click(function() {
            var cur = $(this);
//[0701]
            var rel = $("img", cur).attr("rel"); 
            var adr = "images/v.swf?media="+rel;
            cur.parent().append(img_pt);

            var cur_title = cur.nextAll(".title").text();
            var cur_txt = cur.nextAll(".txt").text();
            title.text(cur_title);
            txt.text(cur_txt);

            document.getElementById("flashcontent").innerHTML = fplay(adr,"481","386","full");
        });
        
        //初始化指向。
        winli.eq(0).append(img_pt);

        //页面加载自动播放。
        var adr_rel = $("img", winli.eq(0)).attr("rel");        //获取第一个视频的 rel。
        var adr = "images/v.swf?media="+adr_rel;
        $("#flashcontent").html(fplay(adr,"481","386","full"));  //不需要 #P10 判断了。
    }
    
/* ========================================== */

//resp
			$(".theme1").hover(
				function(){
			$(".p1").show("slow")},
					function(){
			$(".p1").slideUp("slow")})

			$(".theme2").hover(
				function(){
			$(".p2").show("slow")},
				function(){
			$(".p2").slideUp("slow")})

			$(".theme3").hover(
				function(){
			$(".p3").show("slow")},
				function(){
			$(".p3").slideUp("slow");});

/**/

    var map = $("#chinamap");
    var map_a = $(">div>a", map);
    map_a.each(function() {
        if($(this).attr("href").indexOf("#") > -1) {
            $(this).addClass("ok");
        }
    });
    map_a.hover(function() {
        $(this).addClass("over");
    }, function() {
        $(this).removeClass("over");
    });
    var prov_data = $("#map>dl.provdata");
    var viewb = $("#map>dl.desc");
    var bef = $("<div>");

    map_a.click(function() {
        bef.removeClass("ac");
        $(this).addClass("ac");
        bef = $(this);

        var href = $(this).attr("href");
        var st = href.indexOf("#");
        var myProv = prov_data.children("dt").filter("." + href.slice(st+1));

/*0608*/var dd = myProv.next("dd");
        var dd_br = dd.children("br");

        viewb.fadeOut("fast", function() {
            viewb.html("");
            viewb.append(myProv.clone()).append(myProv.next("dd").clone());

/*0608*/    if (dd_br.length > 15) {
                var t_pages = Math.ceil(dd_br.length/15);
                
                var temp_node = document.createDocumentFragment();

                var temp1 = $("<a class='up' href='javascript:void(null)'></a>")[0];
                var temp2 = $("<a class='down' href='javascript:void(null)'></a>")[0];
                var temp3 = $("<p class='c_page'>1</p>")[0];
                var temp5 = $("<p class='t_pages'>" + t_pages + "</p>")[0];

                temp_node.appendChild(temp1);
                temp_node.appendChild(temp2);
                temp_node.appendChild(temp3);
                temp_node.appendChild(temp5);

                viewb.append(temp_node);                    //fragment dom;

                var v_dd = $(">dd", viewb);
                v_dd.contents().wrapAll("<div>");                 //contents() method is very useful.

                /**/
                var up = $("a.up", viewb);
                var down = $("a.down", viewb);
                var step = 225;                             // 225 px / 15 lineheight =  15 lines;
                var cur_mg = 0;
                var page = 1;
                var wrap_div = $(">dd>div", viewb);
                var v_sp = $(">p.c_page", viewb);

                down.click(down_c = function() {
                    page += 1;
                    v_sp.text(page);
                    wrap_div.css("marginTop", cur_mg -= step);
                    if (page > 1) {
                        up.bind("click", up_c).removeClass("dis");
                    }
                    if (page >= t_pages) {
                        down.unbind("click", down_c).addClass("dis");
                    }
                });
                up.click(up_c = function() {
                    page -= 1;
                    v_sp.text(page);
                    wrap_div.css("marginTop", cur_mg += step);
                    if(page < t_pages) {
                        down.bind("click", down_c).removeClass("dis");
                    }
                    if (page <= 1) {
                        up.unbind("click", up_c).addClass("dis");
                    }
                });
                up.addClass("dis").unbind("click", up_c);    //first sight, up button must be disabled;
            }

            
            viewb.slideDown("fast");
        });

    });
/*map*/

});

//***

function searchinput(){
	if ($("input[name='keywords']").attr("value") == "" || $("input[name='keywords']").attr("value") == "关键词"){
		alert("请输入关键词\n\n支持多个关键词，请用空格分开");
		$("input[name='keywords']").val("");
	    $("input[name='keywords']").focus();
		return false;
    }else{
		$("input[name='keywords']").attr("value",trim($("input[name='keywords']").attr("value")));
		$("#sresult").css("display","block");
		$("#sresult").html("<img src=\"images/lightbox-ico-loading.gif\" width=\"24\" height=\"24\" alt=\"正在传送数据...\" />");

		showrequest("search_ajax.aspx?keywords=" + encodeURIComponent(escape($("input[name='keywords']").attr("value"))),"sresult",false);
		cls_button();
	}
}

function trim(a_strVarContent) {
var pos1, pos2, newstring;pos1 = 0;pos2 = 0;newstring = "";
	if ( a_strVarContent.length > 0 ) {
		for( i=0; i<=a_strVarContent.length; i++) { 
			if ( a_strVarContent.charAt(i) == " " ) pos1 = pos1 + 1;
			else break;
		} 
		for( i=a_strVarContent.length; i>=0 ; i--) {
			if ( a_strVarContent.charAt(i) == " " ) pos2 = pos2 + 1;
			else break;
		}
		newstring = a_strVarContent.substring(pos1, a_strVarContent.length-pos2) 
	} 
	return newstring; 
} 

function searchp(keywords,r,p,ttype){
	showrequest("search_ajax.aspx?keywords=" + keywords + "&r=" + r + "&p=" + p + "&type=" + ttype,"sresult",false);cls_button();
	return false;
}

function cls_button(){
	nCol = $("#sresult > A");
	for (i=0;i<nCol.length;i++){
		if (nCol[i].className == "cls"){
			nCol[i].onclick = function(){
				this.parentNode.style.display = "none";
			}
		}
	}
}

var http_request = false;
function showrequest(url,element,asyn) {
	var isFFCLS = true;
	http_request = false;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {alert('Giving up :( Cannot create an XMLHTTP instance');return false;}
    http_request.onreadystatechange = sub_showrequest;
    http_request.open('GET', url, asyn);
    http_request.send(null);
	if ((!asyn) && (isFFCLS)) sub_showrequest();
	function sub_showrequest(){
	    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
			isFFCLS = false;
			document.getElementById(element).innerHTML = http_request.responseText;
        } else {alert('There was a problem with the request.');}
		}	
	}
}

$.fn.kxbdMarquee = function(options){
    var opts = $.extend({},$.fn.kxbdMarquee.defaults,options);
    
    return this.each(function(){
        var $marquee = $(this);//滚动元素容器
        var _scrollObj = $marquee.get(0);//滚动元素容器DOM
        var scrollW = $marquee.width();//滚动元素容器的宽度
        var scrollH = $marquee.height();//滚动元素容器的高度
        var $element = $marquee.children(); //滚动元素
        var $kids = $element.children();//滚动子元素
        var scrollSize=0;//滚动元素尺寸
        var _type = (opts.direction == 'left' || opts.direction == 'right') ? 1:0;//滚动类型，1左右，0上下
        
        //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度
        $element.css(_type?'width':'height',10000);
        //获取滚动元素的尺寸
        if (opts.isEqual) {
            scrollSize = $kids[_type?'outerWidth':'outerHeight']() * $kids.length;
        }else{
            $kids.each(function(){
                scrollSize += $(this)[_type?'outerWidth':'outerHeight']();
            });
        }
        //滚动元素总尺寸小于容器尺寸，不滚动
        if (scrollSize<(_type?scrollW:scrollH)) return; 
        //克隆滚动子元素将其插入到滚动元素后，并设定滚动元素宽度
        $element.append($kids.clone()).css(_type?'width':'height',scrollSize*2);
        
        var numMoved = 0;
        function scrollFunc(){
            var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollLeft':'scrollTop';
            if (opts.loop > 0) {
                numMoved+=opts.scrollAmount;
                if(numMoved>scrollSize*opts.loop){
                    _scrollObj[_dir] = 0;
                    return clearInterval(moveId);
                } 
            }
            if(opts.direction == 'left' || opts.direction == 'up'){
                _scrollObj[_dir] +=opts.scrollAmount;
                if(_scrollObj[_dir]>=scrollSize){
                    _scrollObj[_dir] = 0;
                }
            }else{
                _scrollObj[_dir] -=opts.scrollAmount;
                if(_scrollObj[_dir]<=0){
                    _scrollObj[_dir] = scrollSize;
                }
            }
        }
        //滚动开始
        var moveId = setInterval(scrollFunc, opts.scrollDelay);
        //鼠标划过停止滚动
        $marquee.hover(
            function(){
                clearInterval(moveId);
            },
            function(){
                clearInterval(moveId);
                moveId = setInterval(scrollFunc, opts.scrollDelay);
            }
        );
        
    });
};
$.fn.kxbdMarquee.defaults = {
    isEqual:true,//所有滚动的元素长宽是否相等,true,false
    loop: 0,//循环滚动次数，0时无限
    direction: 'left',//滚动方向，'left','right','up','down'
    scrollAmount:1,//步长
    scrollDelay:10//时长

};
$.fn.kxbdMarquee.setDefaults = function(settings) {
    $.extend( $.fn.kxbdMarquee.defaults, settings );
};

var roller=function(){
	return{
		init:function(el,ty,sx,ex,d,st){
			e= document.getElementById(el);if(!e){return;}a=$("#homeh1_0_1 > ul > li >a");//e.getElementsByTagName("a");
			for(i=0;i<a.length;i++){
				if(!a[i].id){a[i].id=el.id+i;}
				a[i].n=a[i].o=sx;a[i].en=ex; a[i].ty=ty;				
				if(a[i].ty=='v'){a[i].style.backgroundPosition = '8px '+a[i].n+'px';}
				else if(a[i].ty=='h'){a[i].style.backgroundPosition = a[i].n+'px -22px';}
				else{return;}
				a[i].onmouseover=roller.o;a[i].onmouseout=roller.o;
				a[i].st=Math.abs(Math.abs(ex-sx)/st);a[i].t=d/st;
			}
		},
		o:function(e){
			e=e||window.event;c=e.target!=null?e.target:e.srcElement;
			if(c.nodeName=='A' && e.type=="mouseover"){c.w=c.en;roller.s(c);}
			else if(c.nodeName=='A'){c.w=c.o;roller.s(c);}
		},
		s:function(e){
			if(e.ti){clearTimeout(e.ti);}
			if(Math.abs(e.n-e.w)<e.st){e.n=e.w;}
			else if(e.n<e.w){e.n=e.n+e.st;}
			else if(e.n>e.w){e.n=e.n-e.st;}			
			if(e.ty=='v'){e.style.backgroundPosition = '8px '+e.n+'px';}
			else{e.style.backgroundPosition = e.n+'px -22px';}
			if(e.n==e.w){clearTimeout(e.ti);return;}
			e.ti=setTimeout(function(){roller.s(e)}, e.t);
		}
	}
}();

function para(p,keywords){
	showrequest("para.aspx?keywords=" + keywords + "&p=" + p,"para",false);
	return false;
}

function pjse(){
	if ($("input[id='pjsarea']").attr("value") == ""){
		alert("输入关键词");
		$("input[id='pjsarea']").focus();
	}else{
		para(1,encodeURIComponent(escape($("input[id='pjsarea']").attr("value"))))
	}
}

function fplay(swf, swfwidth, swfheight,full,FlashVars) { 
    if (navigator.userAgent.indexOf('Firefox') > - 1) {
		if (FlashVars){
	        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="' + full + '" allowFullScreen="true" allowScriptAccess="always" FlashVars="' + FlashVars + '"></embed>');
		}else{
        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="' + full + '"></embed>');}
    } else {
		if (FlashVars){
			return('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + swfwidth + '" height="' + swfheight + '"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="' + full + '" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="wmode" value="' + full + '" /><param name="FlashVars" value="' + FlashVars + '" /></object>');
		}else{
        return('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + swfwidth + '" height="' + swfheight + '"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="' + full + '" /></object>');}
    }
}
