﻿function $(TID)
{
    return document.getElementById(TID);
}

function ShowSubMenu(show_id,hide_ids)
{
    if(hide_ids != "")
    {
        for(var i=0;i<hide_ids.split(",").length;i++)
        {
            try
            {
                $(hide_ids.split(",")[i]).style.display='none';
            }catch(e){}
        }
    }
    
    try
    {
        $(show_id).style.display='';
    }
    catch(e){}
}


function Search_Click()
{
    var str=$("SearchStr").value;
    if(str == "")
    {return;}
    location.href ="/aspx/Search.aspx?Key="+encodeURIComponent(str);
}


function showBgImage(index)
{
try
{
    $("mainnav").getElementsByTagName("li")[index].className="here";
}
catch(e){}
}

// JScript 文件
function getCookie (sCookieName)
{
    var sName=sCookieName+"=", ichSt, ichEnd;
    var sCookie=document.cookie;

    if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
    {
        if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
            ichEnd = sCookie.length;
        return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
    }
    
    return null;
}
   
function setCookie (sName, vValue)
{
    var argv = setCookie.arguments, argc = setCookie.arguments.length;
    var sExpDate = (argc > 2) ? "; expires="+argv[2].toGMTString() : "";
    var sPath = "; path=/";// (argc > 3) ? "; path="+argv[3] : "";
    var sDomain = (argc > 4) ? "; domain="+argv[4] : "";
    var sSecure = (argc > 5) && argv[5] ? "; secure" : "";
    document.cookie = sName + "=" + escape(vValue,0) + sExpDate + sPath + sDomain + sSecure + ";";
}
    
function deleteCookie (sName)
{
    document.cookie = sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
}

//------------------------------------

function setProductInqurie(pid,ask)
{
if(ask == true){
    setCookie("InquireList",pid+",");
    location.href="/aspx/Products_Feedback.aspx";
}else{
    var oldCookie = getCookie("InquireList")==null?"":getCookie("InquireList");
    if(pid.replace(" ","") != "" && oldCookie.indexOf(pid+",")<0)
    {
        setCookie("InquireList",oldCookie+pid+",");
    }
}
}

function selectAll()
{
    var cbs = document.getElementsByName("CheckBox_Prod");
    var check_ids = "";
    for(var i=0;i<cbs.length;i++)
    {
        if(cbs[i].checked == true)
        {
            check_ids += cbs[i].value+",";
            setProductInqurie(cbs[i].value,false);
        }
    }
    if(check_ids != "")
    {
            //location.href="/aspx/InquiryBasket.aspx";
            location.href="/aspx/Products_Feedback.aspx";
    }
    else
    {
        alert("Pls select products");
    }
    //
    //event.returnValue = false;
    return false;
}


function pcSearch()
{
    var maxtype= $("ProdClassSearch1_drtype");
    var _id = maxtype.options[maxtype.selectedIndex].value;
    //
    var key = document.getElementById("ProdClassSearch1_KeyText1").value;
    if( key=="" && _id == "")
    {return;}
    location.href = ("/aspx/Search.aspx?TypeID="+_id+"&key="+encodeURIComponent(key));
    
}
function pcSearch2()
{
    var maxtype= $("uc_search2_drtype2");
    var _id = maxtype.options[maxtype.selectedIndex].value;
    //
    var key = document.getElementById("uc_search2_SearchStr2").value;
    if( key=="" && _id == "")
    {return;}
    location.href = ("/aspx/Search.aspx?TypeID="+_id+"&key="+encodeURIComponent(key));
    
}
/*function pcSearch()
{
    var maxtype= $("uc_search_drtype");
    var _id = maxtype.options[maxtype.selectedIndex].value;
    //
    var key = document.getElementById("uc_search_KeyText1").value;
    if( _id != "")
    {
		if(key=="products search") key="";
	}
	else{
		if(key=="" || key=="products search") return false;
	}
	location.href = ("/aspx/Search.aspx?TypeID="+_id+"&key="+encodeURI(key));
    
}*/
function clickThisImg(Name)
{
    
    $("Img").src="/UserFiles/Image/"+Name;
}

function chgH3_Style(id)
{
    try
    {  
    $( id ).className="here";
    }catch(e){}
}

function chgH4_Style(id)
{
    try
    {  
    $( id ).className="here";
    }catch(e){}
}

function showContent(obj,a_id)
{
    var ps = "p_Description,p_Specification,p_Picture,p_Case";
    for(var i=0;i<ps.split(",").length;i++)
    {
        try
        {
            $(ps.split(",")[i]).style.display = "none";
        }
        catch(e){}
    }
    obj.style.display = "block";
    
    //
    var as="a_show_Description,a_show_Specification,a_show_Picture,a_show_Case,";//background:#EBF1F8; color:#2E3192;
    for(var i=0;i<as.split(",").length;i++)
    {
        try
        {
            $(as.split(",")[i]).style.background = "#7298CB";
            $(as.split(",")[i]).style.color = "#FFFFFF";
        }
        catch(e){}
    }
    $(a_id).style.backgroundColor = "#EBF1F8";
    $(a_id).style.color = "#2E3192";
    try{
    window.event.returnValue =false;
    }catch(e){}
    return false;
}
function AddClick( ID , TYPE )
{
    var url="<iframe width=0 height=0 style='display:none' src='/aspx/AddClick.aspx?TYPE="+TYPE;
    url+="&IDentityID=";
    url+=ID;
    url+="'></iframe>";
    document.write(url);
}
function AjaxGetPro_Next( ControlID , ObjectID , Type )
{
    var xmlhttp;
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                document.getElementById(ControlID).innerHTML=value;
            }
            else
            {
                return null;
            }
        }
    }
    xmlhttp.open( "post" , "/aspx/Ajax.aspx" , true );
    xmlhttp.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' );
    xmlhttp.send( "IdentityID=" + escape( ObjectID ) + "&Type=" + escape( Type ) );
}
function AjaxGetRemmProd( ControlID , ObjectID )
{
    var xmlhttp;
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                document.getElementById(ControlID).innerHTML=value;
            }
            else
            {
                return null;
            }
        }
    }
    xmlhttp.open( "post" , "/aspx/Ajax.aspx" , true );
    xmlhttp.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' );
    xmlhttp.send( "GetREMMPROD=" + escape( ObjectID ));
}

function AjaxPageClass( control,pars ){
var xmlhttp;
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                
                try
                {
                    document.getElementById(control).innerHTML=value;
                }catch(e){}
                
            }
            else
            {
                return null;
            }
        }
    }
    xmlhttp.open( "post" , "/aspx/AjaxGetPages.aspx" , true );
    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlhttp.send(pars);
}


// JavaScript Document
(function(){

//ADS命名空间
if(!window.ads){window['ads'] = {}}

//检查js是否能正确运行
function runCheck(other){
	if(other===false 
	   || !Array.prototype.push
	   || !Object.hasOwnProperty
	   || !document.createElement
	   || !document.getElementsByTagName
	   ){
		return false;
		}
	return true;
	}
window['ads']['runCheck'] = runCheck;

//根据ID获取元素，可同时获取多个
function $(){
	var elements = new Array();
	
	for(var i = 0; i<arguments.length; i++){
		var element=arguments[i];
		if(typeof arguments[i] == 'string'){
			element = document.getElementById(element);
			}
		if(arguments.length == 1){
			return element;
			}
		elements.push(element);		
		}
	return elements;
	}
window['ads']['$'] = $;

//根据Class获取元素
function $c(className,tag,parent){
	parent = parent || document;
	tag = tag || '*';
	if(!(parent = $(parent))){return false;}
	
	//查找匹配标签
	var allTags = (tag == "*" && parent.all) ? parent.all : parent.getElementsByTagName(tag);
	
	var elements = new Array();
	
	//正则表达式，判断className是否正确
	className = className.replace(/\-/g,"\\-");
	var regex = new RegExp("(^|\\s)" + className + "(\\s|$)");
	
	var element;
	for(var i=0;i<allTags.length;i++){
		element = allTags[i];
		if(regex.test(element.className)){
			elements.push(element);
			}
		}
	if(elements.length == 1) return elements[0];
	return elements;
	}
window['ads']['$c'] = $c;

//根据html标签获取元素
function $t(tag,parent){
	parent = parent || document;
	tag = tag || '*';
	if(!(parent = $(parent))){return false;}
	
	//查找匹配标签
	var allTags = (tag == "*" && parent.all) ? parent.all : parent.getElementsByTagName(tag);
	
	var elements = new Array();
	
	if(allTags.length == 1){return allTags[0]};
	
	for(var i=0;i<allTags.length;i++){
		elements.push(allTags[i]);
		}
	return elements;
	}
window['ads']['$t'] = $t;

//添加、移除事件
function addEvent(node,type,listener){
	if(!runCheck()){return false;}
	if(!(node = $(node))){return false;}
	
	//W3C添加事件方法
	if(node.addEventListener){
		node.addEventListener(type,listener,false);
		return true;
		}
	//MSIE添加事件方法
	else if(node.attachEvent){
		node['e'+type+listener] = listener;
		node[type+listener] = function(){
			node['e'+type+listener](window.event);
			}
		node.attachEvent('on'+type,node[type+listener]);
		return true;
		}
	return false;
	}
window['ads']['addEvent'] = addEvent;

function removeEvent(node,type,listener){
	if(!runCheck()){return false;}
	if(!(node = $(node))){return false;}
	
	//W3C添加事件方法
	if(node.removeEventListener){
		node.removeEventListener(type,listener,false);
		return true;
		}
	//MSIE添加事件方法
	else if(node.detachEvent){
		node.detachEvent('on'+type,node[type+listener]);
		node[type+listener] = null;	
		return true;
		}
	return false;
	}
window['ads']['removeEvent'] = removeEvent;

})();


//产品内容品的产品评论脚本
function Ajax_getLeave( ControlID , productID ,currentPage )
{
    var xmlhttp;
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                document.getElementById(ControlID).innerHTML=value;
            }
            else
            {
                return null;
            }
        }
    }
    xmlhttp.open( "post" , "/aspx/MsgAjax.aspx" , true );
    xmlhttp.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' );
    xmlhttp.send( "productID=" + escape( productID ) + "&currentPage=" + escape(currentPage));
}
function Ajax_setLeave(productID,name,email,content)
{

    var xmlhttp;
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;  
　　　　　　flag = pattern.test(email);  
　　　　　　if(!flag)  
　　　　　　{  
　　　　　　　alert("Your email address is not correct!");  
　　　　　　　closeAlert();
　　　　　　　return false;  
　　　　　　}
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {    
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                alert(value);
                closeAlert();
                //document.getElementById(ControlID).innerHTML=value;
            }
            else
            {
                alert("error");
            }
        }
    }
    xmlhttp.open( "post" , "/aspx/MsgAjax.aspx" , true );
    xmlhttp.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' );
    xmlhttp.send(  "insert=true&productID=" + escape( productID ) + "&name="+ name + "&email="+email + "&content="+content);
}




function showLayer2(objA,objB,cur){
	for(var i = 0;i<objB.length;i++){
		objB[i].style.display = "none";
		}
	if(cur){objB[cur].style.display = "block";}
	for(var i = 0;i<objA.length;i++){
		addListent(i);
		}
		
	function addListent(index){		
		ads.addEvent(objA[index],"mouseover",function(){			
			for(var j = 0;j<objB.length;j++){
				objB[j].style.display = "none";
				}
			for(var n = 0;n < objA.length;n++){
				objA[n].className = "tab tab"+(n+1);
				}
			this.className = "tab tab" + (index+1) + "_here";
			objB[index].style.display = "block";
			})		
		}
	}
	

ads.addEvent(window,"load",function(){
    var xmlhttp;
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch( e )
    {
        xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    }
    
    xmlhttp.onreadystatechange=function()
    {    
        if( 4 == xmlhttp.readyState )
        {
            if( 200 == xmlhttp.status )
            {
               
                var value=xmlhttp.responseText;
                var oElemt=document.createElement("div");
				oElemt.innerHTML=value;
				document.body.appendChild(oElemt);
				
				var oScript2=document.createElement("script");
				    oScript2.src="/js/ControlfloatBox.js";
				    document.body.appendChild(oScript2);
				
				
				//判断是否IE6
				var browser=navigator.appName 
                var b_version=navigator.appVersion 
                var version=b_version.split(";"); 
                var trim_Version=version[1].replace(/[ ]/g,""); 
                if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
                { 			
				    var oScript=document.createElement("script");
				    oScript.src="/js/floatBox.js";
				    document.body.appendChild(oScript);
				    document.getElementById("floatBox").style.position="absolute";
				}
                //alert(value);
                //document.getElementById(ControlID).innerHTML=value;
            }
            else
            {
                //alert("error");
            }
        }
    }
    xmlhttp.open( "get" , "/FloatBox.aspx?t="+(new Date()).getTime() , true );
    xmlhttp.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' );
    xmlhttp.send(null);

});
