document.write("<style type=\"text/css\">"); 
document.write(".content_in{text-justify: inter-ideograph; text-align: justify;}");
document.write(".navigator ul li ol li a{filter:Alpha(Opacity=90);}");
document.write("</style>"); 

$(function(){
	$(".page_wrapper").eq(0).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("");
		}
	});

	var navigatorLI = $("div.navigator li,div.sub_navigator 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");
		}
	}

	$("div.navigator > ul > li > ol li:first-child").addClass("first");

	$("div.navigator li:has(ol)").hover(function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").slideDown();$(this).children("a").eq(0).children("span").eq(0).addClass("ac")}
		},function(){
			if ($(this).children("ol").children("li").length > 1){$(this).children("ol").slideUp("fast");$(this).children("a").eq(0).children("span").eq(0).removeClass("ac")}
		});

	$("div.procate > ul > li > ol > li > a.ac").parent("li").parent("ol").prev().addClass("ac");$("div.procate > ul > li > ol > li > a.ac").parent("li").parent("ol").show();

	$("div.procate li:has(ol)").click(function(){
		if ($(this).children("ol").children("li").length > 1){
			if ($(this).children("ol").hide()){
				$("div.procate > ul > li >ol").hide();$("div.procate > ul > li > a").removeClass("ac");$(this).children("ol").show();$(this).children("a").eq(0).addClass("ac")
			}else{
				$(this).children("ol").hide();$(this).children("a").eq(0).removeClass("ac");
			}
		}
	});
    $("div.procate li:has(ol),#P01 div.procatein > ul > li:first-child > h3 a").focus(function(){$(this).blur();});


	$("#P01 div.procatein > ul > li:first-child > h3 a").addClass("ac");$("#P01 div.procate_detail").eq(0).show();
	$("#P01 div.procatein > ul > li > h3 a").click(function(){
		$("#P01 div.procatein > ul > li > h3 a").removeClass("ac");
		$(this).addClass("ac");
		$("div.procate_detail").hide();
		$("div.procate_detail").eq($("#P01 div.procatein > ul > li > h3 a").index(this)).show();
		if ($(this).attr("id") == "apara"){
			$.post('para.aspx?proid=' + $(this).attr("rel"),function(data){
				$('#para').html(data);
			});
		}
	});


	$("#P00_h2 a.h200").hover(function(){
			$("#P00_h2 > ul > li").removeClass("ac");
			$(this).parent("li").addClass("ac");
		});

	if($("body").attr("id") == "P00" ) {
		$(".flash").eq(0).html(fplay("images/home.swf","995","241"));
		}else{
		$(".flash").eq(0).html(fplay("images/page.swf","995","179"));
		$(".about").eq(0).html(fplay("images/about_cn.swf","995","428"));
	}

	$("ul.list0 li:even").addClass("even");
	if ($("a.thumb").length > 0){$("a.thumb").lightBox();}
	roller.init('sbnav','v',0,-60,60,15);
});

//***
var roller=function(){
	return{
		init:function(el,ty,sx,ex,d,st){
			e=document.getElementById(el);if(!e){return;}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 = '0px '+a[i].n+'px';}
				else if(a[i].ty=='h'){a[i].style.backgroundPosition = a[i].n+'px -30px';}
				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 = '0px '+e.n+'px';}
			else{e.style.backgroundPosition = e.n+'px -30px';}
			if(e.n==e.w){clearTimeout(e.ti);return;}
			e.ti=setTimeout(function(){roller.s(e)}, e.t);
		}
	}
}();

function fplay(swf, swfwidth, swfheight,full) {
    if (navigator.userAgent.indexOf('Firefox') > - 1) {
		if (full == "full"){
	        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="window" allowFullScreen="true" allowScriptAccess="always"></embed>');
		}else{
        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="transparent"></embed>');}
    } else {
		if (full == "full"){
			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="window" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></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="transparent" /></object>');}
    }
}

function searchinput(){
	if ($("input[name='keywords']").attr("value") == "" || $("input[name='keywords']").attr("value") == "关键词"){
		alert("请输入关键词");
		$("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.');}
		}	
	}
}


function para(p_c_id,p){
//	if ($("#lBuy").style.visibility == 'visible') {	ClsBuyPara(document.buyFrm.paraid.value,"add");	}
	var ptd = $("#para");
	showrequest('para.aspx?proid=' + p_c_id + '&page=' + p,'para',false);
	var para_tbody = $("#para").children("tbody").eq(0);
	nCol = $("#para > tbody > tr");
	for (var i=0; i<nCol.length; i++){
		nCol[i].title = lan_str[10];
		nCol[i].onmouseover = function(){
			this.style.backgroundColor = '#ffc';
			this.style.color = '#ff6a00';
			window.status=lan_str[10];
		}
		nCol[i].onmouseout = function(){
			this.style.backgroundColor = '';
			this.style.color = '#333';
			window.status='';
		}
		nCol[i].onclick = function(){
			BuyPara(p_c_id,this.id.toString().match(/t(\d+)/)[1]);
		}
	}
//	buy_base();
}

