﻿// JScript 文件
/*
<style type="text/css">
<!--
.objectShowNavMain{

}
.objectShowNavItem{
    font-size:12px;
	background-color:#000000;
}
.objectShowNavItemOver{
    font-size:12px;
	background-color:#cccccc;
}
.objectShowNavItemSpan{
	width:0;
	height:100%;
	display:inline-block;
	vertical-align:middle;
}
-->
</style>
*/
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));
    function objectNavShow(object, inner, left, top){
		this.inper = 150;
		this.inner = inner;
		this.arrDiv = new Array();
		var othis = this;
		this.closetime = true;
        this.div = document.createElement("div");
        this.div.style.position = "absolute";
        this.left = left;
        this.top = top;
        this.div.style.left = this.left + "px";
        this.div.style.top = this.top + "px";

        this.div.style.display = "none";
        this.div.style.zIndex = 10000;
        this.object = object;
        this.object.onmouseover = function(){
            othis.closetime = false;
            setTimeout(function(){
				othis.div.style.display = "";
				if (!ie && object != inner){
				    othis.div.style.left = (othis.left - document.documentElement.scrollLeft) + "px";
                    othis.div.style.top = (othis.top - document.documentElement.scrollTop) + "px";
				}
				othis.onOverOther();
			}, othis.inper);
        }
        this.object.onmouseout = function(){
            othis.closetime = true;
            setTimeout(function(){
				if (othis.closetime){
					othis.div.style.display = "none";
					othis.onOutOther();
				}
			}, othis.inper);
        }
		var myspan = document.createElement("span");
		if (ie){
			myspan.style.position = "relative";
		}else{
			myspan.style.position = "fixed";
		}
		myspan.appendChild(this.div);
		if (inner.childNodes.length > 0){
			inner.insertBefore(myspan, inner.childNodes[0]);
		}else{
			inner.appendChild(myspan);
		}
		this.overClass = "objectShowNavItemOver";
		this.outClass = "objectShowNavItem";
    }
    objectNavShow.prototype.createDiv = function(content, width, height, url, target, name){
		//this.div.className = this.outClass;
		var othis = this;
        var div = document.createElement("div");
        div.setAttribute("divname", name);
        this.arrDiv.push(div);
        div.style.width = width + "px";
        div.style.height = height + "px";
		div.className = this.outClass;
		div.innerHTML = "<span class=\"objectShowNavItemSpan\"></span>";
		div.innerHTML += "<span style=\"width:100%;\">" + content + "</span>";
        this.div.appendChild(div);
        div.style.cursor = "pointer";
		this.div.onmouseover = function(){
			othis.closetime = false;
			setTimeout(function(){
				othis.div.style.display = "";
				othis.onOverOther();
			}, othis.inper);
        }
        this.div.onmouseout = function(){
			othis.closetime = true;
			setTimeout(function(){
				if (othis.closetime){
					othis.div.style.display = "none";
					othis.onOutOther();
				}
			}, othis.inper);
        }
        div.onmouseover = function(){
			this.className = othis.overClass;
			//othis.oSecondNav = new objectNavShow(this, othis.inner, othis.left + 200, 0);
        }
        div.onmouseout = function(){
			this.className = othis.outClass;
        }
        div.onclick = function(){
            if (url != ""){
                if (target == "blank"){
                    window.open(url);
                }else{
                    location.href = url;
                }
            }
        }
    }
	objectNavShow.prototype.onOverOther = function(){
		
	}
	objectNavShow.prototype.onOutOther = function(){
		
	}
	objectNavShow.prototype.getDiv = function(name){
		for (var i=0; i<this.arrDiv.length; i++){
		    if (this.arrDiv[i].getAttribute("divname") == name){
		        //alert(this.arrDiv[i].getAttribute("divname"));
		        return this.arrDiv[i];
		    }
		}
		return null;
	}
    //var oNavShow1 = new objectNavShow(document.getElementById("aa"),document.getElementById("bb"), 100, 0);
    //oNavShow1.createDiv("新闻联播", 80, 20);