// 兼容firefox 的浮动提示 tooltip
// overDescLib.js
// modified by 飞鸟 shenpengfei@gmail.com
////////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////

// 主背景色（大区域）
// 通常使用明快的颜色（浅黄色等...）
	if (typeof fcolor == 'undefined') { var fcolor = "#FFFFCC";}
	
// Border的颜色和标题栏的颜色；
// 通常的颜色深（褐色，黑色等。）
	//if (typeof backcolor == 'undefined') { var backcolor = "#CDCDCD";}
	
if (typeof backcolor == 'undefined') { var backcolor = "#CDCDCD";}
	
	
// 文字的颜色
// 通常是比较深的颜色；
    if (typeof textcolor == 'undefined') { var textcolor = "#663300";}
// 标题的颜色
// 通常是明快的颜色；
	if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
	
// "Close"的颜色
// 通常是明快的颜色；
	if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}
	
	
// 弹出的窗口的宽度；
// 100-300 pixels 合适
	if (typeof width == 'undefined') { var width = "300";}
	
// 边缘的宽度，象素。
// 1-3 pixels 合适
	if (typeof border == 'undefined') { var border = "1";}
	
	
// 弹出窗口位于鼠标左侧或者右侧的距离，象素。
// 3-12合适
	if (typeof offsetx == 'undefined') { var offsetx = 10;}
	
// 弹出窗口位于鼠标下方的距离；
// 3-12 合适
	if (typeof offsety == 'undefined') { var offsety = 10;}
	
document.write("<style>.DEK {fONT-SIZE:6px; POSITION:absolute;VISIBILITY:hidden;background-color : transparent;layer-background-color : transparent;Z-INDEX:200;LINE-HEIGHT:2px;}");
document.write("td.DEK  {fONT-SIZE:6px;}.input {  font-size: 12px; border: #666666; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}</style>");
	
////////////////////////////////////////////////////////////////////////////////////
// 设置结束
////////////////////////////////////////////////////////////////////////////////////
var agt=navigator.userAgent.toLowerCase();
var is_firefox = (agt.indexOf('firefox') != -1);
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

// Microsoft Stupidity Check.
if (ie4) {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	} else if ((navigator.userAgent.indexOf('MSIE 6')>0)||(navigator.userAgent.indexOf('MSIE 7')>0))
	{
		ie5 = true;
	}
	else
	{
		ie5 = false; }
} else {
	ie5 = false;
}

var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_Ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_ie7    = (is_ie && (is_major == 4) && (agt.indexOf("msie 7")!=-1) );
var is_ie7up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5 && !is_ie6);

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);


var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr=1;
var ovDevDiv=document.getElementById("overDiv")
//alert(ovDevDiv.innerHTML)
var overDesc  
if ( (ns4) || (ie4) || is_firefox) {
	if (ns4) over = document.overDiv
	if (ie4||is_firefox) over = overDiv.style
	document.onmousemove = mouseMove
	if (ns4) document.captureEvents(Event.MOUSEMOVE)
}

//以下是附件显示
Xoffset=-10;
Yoffset=20;
var nav,old=false,iex=(document.all),yyy=-1000;
if(navigator.appName=="Netscape"&& !is_firefox){(document.layers)?nav=true:old=true;}
if (is_firefox) old=false;
if(!old){
var skn=(nav)?document.dek:document.getElementById("dek").style;
}
// 以下是页面中使用的公共函数；

// Simple popup right
function drs(text) {
	if (text == '')
		return
	
	dts(1,text);
}


// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4) ||is_firefox) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// 非公共函数，被其它的函数调用；

// Simple popup
function dts(d,text) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=1 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD CLASS=P1><FONT FACE=\"宋体\" COLOR=\""+textcolor+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}



// Common calls
function disp() {
	if ( (ns4) || (ie4) ||is_firefox ) {
		if (snow == 0) 	{
			if (dir == 2) { // Center
				moveTo(over,x+offsetx-(width/2),y+offsety);
			}
			if (dir == 1) { // Right
				moveTo(over,x+offsetx,y+offsety);
			}
			if (dir == 0) { // Left
				moveTo(over,x-offsetx-width,y+offsety);
			}
			showObject(over);
			snow = 1;
		}
	}
// Here you can make the text goto the statusbar.
}

// Moves the layer
function mouseMove(e) {
	if (ns4) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
	if (is_firefox){
	  x=e.pageX; y=e.pageY; 
	 }
	if (is_ie5up||is_opera5up) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (snow) {
		if (dir == 2) { // Center
			moveTo(over,x+offsetx-(width/2),y+offsety);
		}
		if (dir == 1) { // Right
			moveTo(over,x+offsetx,y+offsety);
		}
		if (dir == 0) { // Left
			moveTo(over,x-offsetx-width,y+offsety);
		}
	}
	// 附件显示
	
	
	var x1=x;//=(nav)?e.pageX:event.x+document.body.scrollLeft;
	var y1=y;//=(nav)?e.pageY:event.y+document.body.scrollTop;
	/*if (is_firefox) {y1=y;x1=x}
	else{
		if (nav){
			
		}
		else{
		}
	}*/
	skn.left=x+Xoffset;
	skn.top=y+yyy
}

// The Close onMouseOver function for Sticky
function cClick() {
	hideObject(over);
	sw=0;
}

// Writes to a layer
function layerWrite(txt) {
        if (ns4) {
                var lyr = document.overDiv.document
                lyr.write(txt)
                lyr.close()
        }
        else if (ie4||is_firefox) {
  //alert(document.getElementById["overDescDiv"])
  //document.getElementById["overDescDiv"].innerHTML = txt
  ovDevDiv.innerHTML=txt
 }
 		if (tr) {  }
}

// Make an object visible
function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4||is_firefox) obj.visibility = "visible"
}

// Hides an object
function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4||is_firefox) obj.visibility = "hidden"
}

// Move a layer
function moveTo(obj,xL,yL) {
        obj.left = xL
        obj.top = yL
}


// 附件显示的函数
	var foto1,largh,altez;
	
function kill(){
		if(!old){yyy=-1000;skn.visibility="hidden";}
	}
	
	//主函数
	function popup(img){
	  if ((img.substr(img.length-3,3)).toLowerCase()=='jpg')
	  {
	  	var p=img.lastIndexOf("/")
	  	var img2=img.substr(0,p)+"/s" + img.substr(p,img.length-p+1) 
		foto1= new Image();
		foto1.src=(img2);
		Controlla2(img2 )
	  }
	  else
	  {
	  foto1= new Image();
	  foto1.src=(img);	  
	  Controlla(img);
	  }
	}
	//
	function Controlla2(img){		
	  if((foto1.width!=0)&&(foto1.height!=0)){
	    largh=foto1.width+2;
	    altez=foto1.height+2;
	    viewFoto3(img);
	  }
	  else{
	    largh=200;
	    altez=100;
	    viewFoto2();
	  }
	}
		
	function Controlla(img){
		
	  if((foto1.width!=0)&&(foto1.height!=0)){
		if (foto1.width<=100 && foto1.height<=100){		
			largh=foto1.width+2;
			altez=foto1.height+2;
	    }
	    else{
			largh=100+2;
			altez=100/foto1.width*foto1.height+2;
	    }
	    viewFoto(img);
	  }
	  else{
	    largh=200;
	    altez=100;
	    viewFoto2();
	  }
	}
	function viewFoto(img){
	  var content="<table border=0 style='border:1px solid #000000;position:relative;left:-20;z-index:20;" + 
					"visibility:visible;top:"+(0-altez-50)+"' width="+largh+" height="+altez+" cellspacing=0 cellpadding=0><TR><TD align=center bgcolor=#ffffff><img src="+img+" width="+ (largh) + " height="+(altez)+"></TD></TR></TABLE>";
	if(old){return;}
	else{yyy=Yoffset;
	 if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
	 if(iex||is_firefox){document.getElementById("dek").innerHTML=content;skn.visibility="visible"}
	}
	}
	function viewFoto2(){
	  var content="";
	if(old){return;}
	else{yyy=Yoffset;
	 if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
	 if(iex||is_firefox){document.getElementById("dek").innerHTML=content;skn.visibility="visible"}
	}
	}
	
	function viewFoto3(img){
	  //window.status=img + ' small pic w:' + largh +  ' h:' + altez
	  var content="<table border=0 style='border:1px solid #000000;position:relative;left:-20;z-index:20;visibility:visible;top:"+(0-altez-50)+"' width="+largh+" height="+altez+" cellspacing=0 cellpadding=0><TR><TD align=center bgcolor=#ffffff><img src="+img+"></TD></TR></TABLE>";
		if(old){return;}
		else{
		 yyy=Yoffset;
		 if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
		 if(iex||is_firefox){document.getElementById("dek").innerHTML=content;skn.visibility="visible"}
		 }
	}