function addLoadEvent(func) {    
    var oldonload = window.onload;    
    if (typeof window.onload != 'function') {    
        window.onload = func;    
    } else {    
        window.onload = function() {    
            if (oldonload) {    
     oldonload();    
            }    
            func();    
        }    
    }    
}    



//菜单修补
function menuFix() {
	var sfEls = document.getElementById("Nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {this.className+=(this.className.length>0? " ": "") + "sfhover";}
		sfEls[i].onMouseDown=function() {this.className+=(this.className.length>0? " ": "") + "sfhover";}
		sfEls[i].onMouseUp=function()   {this.className+=(this.className.length>0? " ": "") + "sfhover";}
		sfEls[i].onmouseout=function()  {this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");}
	}
	if (document.getElementById("mn_0100000000"))
	{ 
		var obj = document.getElementById("mn_0100000000").getElementsByTagName("ul");
		//alert('hj');
		for (var i=0; i<obj.length; i++) {
			obj[i].style.left = "50%";
		}
	}
}
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 

function PageFix() { 
	if (!document.getElementsByTagName) return; 

	var obj = document.getElementById("prdctTypes");
	if (obj){
		var obj2 = obj.getElementsByTagName("ul"); 
		if (obj2.length==0) obj.style.display="none";
	}
	var BasePath = document.location.pathname.toLowerCase();
	var s = BasePath.split('/') ;
	if (s.length>=2)
	{
		if (s[1]=="product")
		{
			obj = document.getElementById("crltvPrdcts");
			if (obj) obj.insertAdjacentHTML("afterEnd","<a href='/Buy/WebSales/index.htm' id='WebShop'><img src='/img/01/WebShop.gif' style='margin-left:10px;' /></a>");
		}

		if (s.length>=4)
		{
			if ((s[2]=="controlit")&&(s[3]=="mouse"))
			{
				obj = document.getElementById("WebShop");
				if (obj) obj.insertAdjacentHTML("afterEnd",'<div id="QA" style="padding:5px 2px; margin:5px 8px 0 5px; font-size:14px; border:1px solid #f3c"><img src="/img/at.gif" align=left><a href="/Support/FAQs/200946045717_092188.htm" title="答：不必为使用不习惯而惊奇，由于过去使用的传统鼠标的体积与形状，造成了我们使用鼠标的习惯。第一次接触肯辛通的超便携鼠标，会有少部分人感到不适。据美国媒体统计：74.8%的用户在2天内能够适应人体工学设计的肯辛通鼠标，很少一部分人则需要一到二周时间调整鼠标握法后，才能适应超便携鼠标。"><strong style="color:#906">为何个别用户对超便携鼠标感到使用不习惯？</strong></a></div>');
			}
		}

		if (s.length>=3)
		{
			if ((s[2]=="secureit"))
			{
				obj = document.getElementById("WebShop");
				if (obj) obj.insertAdjacentHTML("afterEnd",'<div id="QA" style="padding:5px 2px; margin:5px 8px 0 5px; font-size:14px; border:1px solid #f3c"><img src="/img/at.gif" align=left><a href="/Support/FAQs/200946045623_065949.htm" title="答：您所需要做的：联系肯辛通厂家或购买经销商，上报锁头的编号,从而配制钥匙，所需时间为7-10天(不包含物流时间)。"><strong style="color:#906">电脑锁的钥匙丢了怎么办？</strong></a></div>');
			}
		}
	}
}


addLoadEvent(function(){
	menuFix();
	PageFix();
});
//window.onload= function(){menuFix();PageFix()};

function FixMarkPrice()
{
	var obj = document.getElementById("MarkPrice");
	if (obj)
	{
		
		var obj1 = document.getElementById("Price");
		if (obj1.innerHTML=='') obj.parentNode.removeChild(obj);
	}

}

function ShowJS (pJSPath) {	
	var t= new Date;
	var p = pJSPath;
	if (p.indexOf('?')>0)
	{
		p = p + '&t=' + t.getTime();
	}
	else
	{
		p = p + '?t=' + t.getTime();
	}

	document.write('<script language="JavaScript" type="text/javascript" src="' + p + '"><\/script>');	
}

//修补FireFox
if (/Mozilla\/5\.0/.test(navigator.userAgent)){
	
if(window.Event){// 修正Event的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    event                        yes        yes            yes            yes                    yes
    event.returnValue            yes        yes            no            no                    no
    event.cancelBubble            yes        yes            no            no                    no
    event.srcElement            yes        yes            no            no                    no
    event.fromElement            yes        yes            no            no                    no
    
    */
    Event.prototype.__defineSetter__("returnValue",function(b){// 
        if(!b)this.preventDefault();
        return b;
        });
    Event.prototype.__defineSetter__("cancelBubble",function(b){// 设置或者检索当前事件句柄的层次冒泡
        if(b)this.stopPropagation();
        return b;
        });
    Event.prototype.__defineGetter__("srcElement",function(){
        var node=this.target;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("fromElement",function(){// 返回鼠标移出的源节点
        var node;
        if(this.type=="mouseover")
            node=this.relatedTarget;
        else if(this.type=="mouseout")
            node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("toElement",function(){// 返回鼠标移入的源节点
        var node;
        if(this.type=="mouseout")
            node=this.relatedTarget;
        else if(this.type=="mouseover")
            node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("offsetX",function(){
        return this.layerX;
        });
    Event.prototype.__defineGetter__("offsetY",function(){
        return this.layerY;
        });
    }
if(window.Document){// 修正Document的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    document.documentElement    yes        yes            yes            yes                    no
    document.activeElement        yes        null        no            no                    no
    
    */
    }
if(window.Node){// 修正Node的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    Node.contains                yes        yes            no            no                    yes
    Node.replaceNode            yes        no            no            no                    no
    Node.removeNode                yes        no            no            no                    no
    Node.children                yes        yes            no            no                    no
    Node.hasChildNodes            yes        yes            yes            yes                    no
    Node.childNodes                yes        yes            yes            yes                    no
    Node.swapNode                yes        no            no            no                    no
    Node.currentStyle            yes        yes            no            no                    no
    
    */
    Node.prototype.replaceNode=function(Node){// 替换指定节点
        this.parentNode.replaceChild(Node,this);
        }
    Node.prototype.removeNode=function(removeChildren){// 删除指定节点
        if(removeChildren)
            return this.parentNode.removeChild(this);
        else{
            var range=document.createRange();
            range.selectNodeContents(this);
            return this.parentNode.replaceChild(range.extractContents(),this);
            }
        }
    Node.prototype.swapNode=function(Node){// 交换节点
        var nextSibling=this.nextSibling;
        var parentNode=this.parentNode;
        node.parentNode.replaceChild(this,Node);
        parentNode.insertBefore(node,nextSibling);
        }
    }
if(window.HTMLElement){
    HTMLElement.prototype.__defineGetter__("all",function(){
        var a=this.getElementsByTagName("*");
        var node=this;
        a.tags=function(sTagName){
            return node.getElementsByTagName(sTagName);
            }
        return a;
        });
    HTMLElement.prototype.__defineGetter__("parentElement",function(){
        if(this.parentNode==this.ownerDocument)return null;
        return this.parentNode;
        });
    HTMLElement.prototype.__defineGetter__("children",function(){
        var tmp=[];
        var j=0;
        var n;
        for(var i=0;i<this.childNodes.length;i++){
            n=this.childNodes[i];
            if(n.nodeType==1){
                tmp[j++]=n;
                if(n.name){
                    if(!tmp[n.name])
                        tmp[n.name]=[];
                    tmp[n.name][tmp[n.name].length]=n;
                    }
                if(n.id)
                    tmp[n.id]=n;
                }
            }
        return tmp;
        });
    HTMLElement.prototype.__defineGetter__("currentStyle", function(){
        return this.ownerDocument.defaultView.getComputedStyle(this,null);
        });
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });
    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
        var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName;
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName+">";
        });
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
        switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
            case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
                return false;
            }
        return true;
        });

    HTMLElement.prototype.__defineSetter__("innerText",function(sText){
        var parsedText=document.createTextNode(sText);
        this.innerHTML=parsedText;
        return parsedText;
        });
    HTMLElement.prototype.__defineGetter__("innerText",function(){
        var r=this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
        });
    HTMLElement.prototype.__defineSetter__("outerText",function(sText){
        var parsedText=document.createTextNode(sText);
        this.outerHTML=parsedText;
        return parsedText;
        });
    HTMLElement.prototype.__defineGetter__("outerText",function(){
        var r=this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
        });
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
            window.event=e;
            return fHandler();
            }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
            this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
            this.removeEventListener(shortTypeName,fHandler,true);
        }
    HTMLElement.prototype.contains=function(Node){// 是否包含某节点
        do if(Node==this)return true;
        while(Node=Node.parentNode);
        return false;
        }
    HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
        switch(where){
            case "beforeBegin":
                this.parentNode.insertBefore(parsedNode,this);
                break;
            case "afterBegin":
                this.insertBefore(parsedNode,this.firstChild);
                break;
            case "beforeEnd":
                this.appendChild(parsedNode);
                break;
            case "afterEnd":
                if(this.nextSibling)
                    this.parentNode.insertBefore(parsedNode,this.nextSibling);
                else
                    this.parentNode.appendChild(parsedNode);
                break;
            }
        }
    HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML=r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where,parsedHTML);
        }
    HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
        var parsedText=document.createTextNode(txtStr);
        this.insertAdjacentElement(where,parsedText);
        }
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
            window.event=e;
            return fHandler();
            }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
            this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
            this.removeEventListener(shortTypeName,fHandler,true);
        }
    }
}

