﻿function $(TID)
{
    return document.getElementById(TID);
}

function floatBox(){}
floatBox.prototype = {
	name:null,
	positionY:0,
	init:function(){
		$(this.name).style.top = document.documentElement.clientHeight - $(this.name).offsetHeight + "px";
		return parseInt($(this.name).style.top);
		},
	toScroll:function(){
		$(this.name).style.top = this.positionY + document.documentElement.scrollTop + "px";
		}
	}
var floatBox1 = new floatBox();
window.onload=function(){
	
	floatBox1.name = "floatBox";
	floatBox1.positionY = floatBox1.init();
window.onscroll=function(){
	floatBox1.toScroll();
	}
	}
function NarrowBox(){
var arrDD=$("floatBox").getElementsByTagName("dd");
var bDT=$("floatBox").getElementsByTagName("dt")[0];
bDT.style.height="15px";
for(var i=0;i<arrDD.length;i++){
arrDD[i].style.display="none";
$("floatBox").style.width="90px";
}
}
function EnlargeBox(){
var arrDD=$("floatBox").getElementsByTagName("dd");
var bDT=$("floatBox").getElementsByTagName("dt")[0];
bDT.style.height="30px";
for(var i=0;i<arrDD.length;i++){
arrDD[i].style.display="block";
$("floatBox").style.width="190px";

}

}
function CloseBox(){
$("floatBox").style.display="none";
}	

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="+encodeURI(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)
//{
//    var oldCookie = getCookie("InquireList")==null?"":getCookie("InquireList");
//    if(pid.replace(" ","") != "" && oldCookie.indexOf(pid+",")<0)
//    {
//        setCookie("InquireList",oldCookie+pid+",");
//    }
//    if(ask==true)
//    {
//        if(window.confirm("Inquiry for the product was submitted successfully. Shift to the page of products inquired ?"))
//        {
//            location.href="/aspx/InquiryBasket.aspx";
//        }
//    }
//}
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 != "")
    {
        if(window.confirm("Inquiry for the product was submitted successfully. Shift to the page of products inquired ?"))
        {
            location.href="/aspx/InquiryBasket.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="+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 addCookie(){　 // 加入收藏夹  
    if (document.all){   
        window.external.addFavorite(window.location.href, 'XiangBo');   
    }else if (window.sidebar){   
        window.sidebar.addPanel('XiangBo', window.location.href, "");   
    }   
}   
  
function setHomepage(){　 // 设为首页  
    if (document.all){   
        document.body.style.behavior = 'url(#default#homepage)';   
        document.body.setHomePage('域名地址');   
    }else if (window.sidebar){   
        if (window.netscape){   
            try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
            }catch (e) {   
                alert("該操作被瀏覽器拒絕，如果想啟用該功能，請在地址欄內輸入 about:config,然後將項 signed.applets.codebase_principal_support 值該為true");   
            }   
        }   
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);   
        prefs.setCharPref('browser.startup.homepage', '域名地址');   
    }   
}   




