var g_debug = true;			//是否显示调试信息
var _loading = false;

/*	所有页面的INPUT元素样式控制	*/
function inputStyle(fEvent,oInput){
	if (!oInput.style) return;
	var put=oInput.getAttribute("type").toLowerCase();

	switch (fEvent){
		case "focus" :
			oInput.isfocus = true;
			if(put=="text" || put=="password")
				oInput.className = "TEXTBOX_focus";	
			break;
		case "mouseover" :			
			if(put=="submit" || put=="button" || put=="reset")			
				oInput.className="BUTTON_over";
			else
				oInput.className = "TEXTBOX_focus";	
			break;
		case "blur" :
			oInput.isfocus = false;
			if(put=="text" || put=="password")
				oInput.className = "TEXTBOX";
			break;
		case "mouseout" :
			if(put=="submit" || put=="button" || put=="reset")
				oInput.className = "BUTTON";
		    else if(!oInput.isfocus)
				oInput.className = "TEXTBOX";
			break;
	}	
}

window.onload = function setDefaultSkin(){
	var oInput = document.getElementsByTagName("input");
	var onfocusStr = [];
	var onblurStr = [];
	for (var i=0; i<oInput.length; i++)
	{
		if (!oInput[i]||!oInput[i].getAttribute("type")) continue;
		var put=oInput[i].getAttribute("type").toLowerCase();
		if((put=="submit" || put=="button" || put=="reset") && oInput[i].className == "")
		{
			oInput[i].className="BUTTON";
		}
		if(put=="checkbox" || put=="radio")
		{
			oInput[i].className="CHECKBOX";
		}
		if ((put=="text" || put=="password" || put=="submit" || put=="button" || put=="reset"))
		{
			if((put=="text" || put=="password") && oInput[i].className != ""){
				continue;
			}else if((put=="submit" || put=="button" || put=="reset") && oInput[i].className != "BUTTON"){
				continue;
			}
			/*
			if (document.all)
			{
				oInput[i].attachEvent("onmouseover",oInput[i].onmouseover=function(){inputStyle("mouseover",this);});
				oInput[i].attachEvent("onmouseout",oInput[i].onmouseout=function(){inputStyle("mouseout",this);});
				oInput[i].attachEvent("onmouseout",oInput[i].onfocus=function(){inputStyle("focus",this);});
				oInput[i].attachEvent("onmouseout",oInput[i].onblur=function(){inputStyle("blur",this);});
			}
			else{
				oInput[i].addEventListener("onmouseover",oInput[i].onmouseover=function(){inputStyle("mouseover",this);},false);
				oInput[i].addEventListener("onmouseout",oInput[i].onmouseout=function(){inputStyle("mouseout",this);},false);						
				oInput[i].addEventListener("onmouseout",oInput[i].onfocus=function(){inputStyle("focus",this);},false);
				oInput[i].addEventListener("onmouseout",oInput[i].onblur=function(){inputStyle("blur",this);},false);
			}*/

			if (document.all)
			{
				oInput[i].attachEvent("onmouseover",oInput[i].onmouseover=function(){inputStyle("mouseover",this);});
				oInput[i].attachEvent("onmouseout",oInput[i].onmouseout=function(){inputStyle("mouseout",this);});
			}
			else{
				oInput[i].addEventListener("onmouseover",oInput[i].onmouseover=function(){inputStyle("mouseover",this);},false);
				oInput[i].addEventListener("onmouseout",oInput[i].onmouseout=function(){inputStyle("mouseout",this);},false);				
				//获取焦点
				if(oInput[i].getAttribute("onfocus")){
					oInput[i].addEventListener("onfocus",oInput[i].onblur=function(){eval(this.getAttribute("onfocus"));inputStyle("focus",this);},false);
				}else{
					oInput[i].addEventListener("onfocus",oInput[i].onfocus=function(){inputStyle("focus",this);},false);
				}
				//失去焦点
				if(oInput[i].getAttribute("onblur")){
					oInput[i].addEventListener("onblur",oInput[i].onblur=function(){eval(this.getAttribute("onblur"));inputStyle("blur",this);},false);
				}else{
					oInput[i].addEventListener("onblur",oInput[i].onblur=function(){inputStyle("blur",this);},false);
				}
			}
		}
	}
}



//得到指定TagName的对象
function gname(name){
	return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}

//不需要CTRL
function bbimg(o){
	var zoom = parseInt(o.style.zoom, 10) || 100;
	zoom -= event.wheelDelta / 12;
	if(zoom > 0) {
	o.style.zoom = zoom + '%';
	}
	return false;
}

/*--需要CTRL
function bbimg1(o){
	if(event.ctrlKey) {
	var zoom = parseInt(o.style.zoom, 10) || 100;
	zoom -= event.wheelDelta / 12;
	if(zoom > 0) {
	o.style.zoom = zoom + '%';
	}
	return false;
	} else {
	return true;
	}
}
--*/

//检查浏览器类型
function Browser(){
	var ua, s, i;
	this.isIE = false;
	this.isNS = false;
	this.isOP = false;
	this.isSF = false;
	this.version = null;

	ua = navigator.userAgent.toLowerCase();
	s = "opera";
	if ((i = ua.indexOf(s)) >= 0){
		this.isOP = true;return;
	}
	s = "msie";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length)); 
		return;
	}
	s = "gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
	s = "safari";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isSF = true;
		return;
	}
}

//选择所有/
function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.name != 'chkall')
		{
			e.checked = form.chkall.checked; 
		}
	}
}

//右上角loading提示控制
function showtoploading(){
    if($("toploading")){
        var divElement = $("toploading");
        Element.show('toploading');    
    }else{
	    var divElement = document.createElement("DIV");
	    divElement.id = "toploading";
    	document.body.appendChild(divElement);
	}
	divElement.innerHTML = "<img src='../images/toploading.gif'/><br/>请稍候...";
}
function closetoploading(){
	Element.hide('toploading');
}
//END

//o:要显示气泡的对象,msg:气泡中的文本,left:气泡向左偏移的像素
function showbleb(o,msg,left){
    //if(_loading) 
    //    return;

    var ele = document.createElement("SPAN");
    ele.id = "msgbleb_box";
    ele.style.cssText = "position:relative";
    o.parentNode.appendChild(ele);
    
    
    //var template = '<span id="msgbleb_box" style="position:relative">';
    var template = "";
    if(left != "")
        template += '<div id="msgbleb" style="left:'+ left +'px">';
    else
        template += '<div id="msgbleb">';
    template += '	<div style="height:60px; padding:5px 10px; border-top:#6AC2F4 1px solid;border-right:#6AC2F4 1px solid;border-left:#6AC2F4 1px solid; background:#EBF9FF; filter:alpha(opacity=80); -moz-opacity:0.8; opacity: 0.8; text-align:center;">';
    template += msg   	
    template += '    	<br/><a href="javascript:void(0)" onclick="closebleb(this)" id="closebleb">关闭</a>';
    template += '    </div>';
    template += '    <div style="background:url('+ templatepath +'images/msgblebbottom.gif) no-repeat; height:5px"></div>';
    template += '</div>';
    //template += '</span>';
    ele.innerHTML = template;
}
function closebleb(o){
    //o.parentNode.parentNode.parentNode.style.display = "none";
    var oo = o.parentNode.parentNode.parentNode;
    oo.removeChild(oo.childNodes[oo.childNodes.length-1]);
}

function showbox(o){
		//alert(o);
		$(o).style.display="";
	}
function closebox(o){
		//alert(o);
		$(o).style.display="none";
	}

function CloseajaxDiv(){
	Element.hide('ajax-div');
}
function ShowajaxDiv(url, width) {
		if($("ajax-div")) {
			var divElement = $("ajax-div");
		} else {
			var divElement = document.createElement("DIV");
			divElement.id = "ajax-div";
			divElement.className = "ajax-div";
			document.body.appendChild(divElement);
		}
		divElement.innerHTML = "loading...";
		divElement.style.cssText = "width:"+width+"px;";
		var userAgent = navigator.userAgent.toLowerCase();
		var is_opera = (userAgent.indexOf('opera') != -1);
		var clientHeight = scrollTop = 0; 
		if(is_opera) {
			clientHeight = document.body.clientHeight /2;
			scrollTop = document.body.scrollTop;
		} else {
			clientHeight = document.documentElement.clientHeight /2;
			scrollTop = document.documentElement.scrollTop;
		}
		divElement.style.left = (document.documentElement.clientWidth /2 +document.documentElement.scrollLeft - width/2)+"px";
		divElement.style.top = (clientHeight +　scrollTop - divElement.clientHeight/2)+"px";

		var pars = url.split("?")[1];
		url = url.split("?")[0];
		var myAjax = new Ajax.Request(
			url,
			{
			method: "post", 
			parameters: pars,
			onSuccess: function(t) {
				divElement.innerHTML = t.responseText;
			}
			});	
}
function ShowHideDiv(obj, width) {
    obj.className = "ajax-div";
	obj.style.cssText = "width:"+width+"px;";
	var userAgent = navigator.userAgent.toLowerCase();
	var is_opera = (userAgent.indexOf('opera') != -1);
	var clientHeight = scrollTop = 0; 
	if(is_opera) {
		clientHeight = document.body.clientHeight /2;
		scrollTop = document.body.scrollTop;
	} else {
		clientHeight = document.documentElement.clientHeight /2;
		scrollTop = document.documentElement.scrollTop;
	}
	obj.style.left = (document.documentElement.clientWidth /2 +document.documentElement.scrollLeft - width/2)+"px";
	obj.style.top = (clientHeight +　scrollTop - obj.clientHeight/2)+"px";
}
function CloseMsgDiv(obj) {
	try{
	Element.hide('ajax-bg');
	}catch(e){}
	try{
	Element.hide(obj);
	}catch(e){}


	var browser = new Browser();
	if(browser.isIE)
	{
		if(browser.version < 7)
		{
			var allselect = gname("select");
			for (var i=0; i<allselect.length; i++){
				allselect[i].style.visibility = "visible";
			}
		}
	}
}
function ShowMsgDiv(obj, objwidth) {
    if (document.readyState == "complete") {

        if (!objwidth) objwidth = 250;
        obj = $(obj);
        obj.style.display = "";
        var obj_MsgDiv = "ajax-bg";

        if ($(obj_MsgDiv)) {
            var divElement = $(obj_MsgDiv);
        } else {
            var divElement = document.createElement("DIV");
            divElement.id = obj_MsgDiv;
            divElement.className = obj_MsgDiv;
            document.body.appendChild(divElement);
        }
        divElement.style.display = '';
        divElement.style.height = GetBrowserDocument().scrollHeight + "px";

        var userAgent = navigator.userAgent.toLowerCase();
        var is_opera = (userAgent.indexOf('opera') != -1);
        var clientHeight = scrollTop = 0;
        if (is_opera) {
            clientHeight = document.body.clientHeight / 2;
            scrollTop = document.body.scrollTop;
        } else {
            clientHeight = document.documentElement.clientHeight / 2;
            scrollTop = document.documentElement.scrollTop;
        }

        obj.style.left = (document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft - objwidth / 2) + "px";

        var browser = new Browser();
        if (browser.isIE) {
            if (browser.version >= 7)
                obj.style.top = (clientHeight / 2 + scrollTop - obj.clientHeight / 3) + "px";
            else {
                obj.style.top = (clientHeight + scrollTop - obj.clientHeight / 2) + "px";
                var allselect = gname("select");
                for (var i = 0; i < allselect.length; i++) {
                    if (allselect[i].className != "RSVPELEMENT")
                        allselect[i].style.visibility = "hidden";
                }
            }
        }
        else
            obj.style.top = (clientHeight + scrollTop - obj.clientHeight / 2) + "px";
    } else {
    setTimeout('try{ShowMsgDiv("' + obj + '");}catch(e){self_debug(e.message);}', 500);
    }
}

function ShowAjaxMsg(msg, pic, objwidth) {
    if (!objwidth) objwidth = 300;
    if (!pic) pic = webpath + "images/succee.gif";
  
    if (document.readyState == "complete") {  
        
        var obj_MsgDiv = "ajax-bg";
        var obj = "divrsvp_ajax";
        
        if ($(obj_MsgDiv)) {
            var divElement = $(obj_MsgDiv);
        } else {
            try{
            var divElement = document.createElement("DIV");
            divElement.id = obj_MsgDiv;
            divElement.className = obj_MsgDiv;
            document.body.appendChild(divElement);
           
            }catch(e){
                self_debug(e.message);
            }
        }
        divElement.style.display = '';
        divElement.style.height = GetBrowserDocument().scrollHeight + "px";

        if ($(obj)) {
            obj = $(obj);
        }
        else {
            obj = document.createElement("DIV");
            obj.id = "divrsvp_ajax";
            obj.className = "divrsvp";
            obj.style.width = "300px";
            
            obj.appendChild(document.createElement("DL"));
            document.body.appendChild(obj);
        }
        
        var innerhtml = '';
        //innerhtml ='<div id="divrsvp_ajax" class="divrsvp"><dl>';
        innerhtml += '<dt class="mydrag" onMouseDown="divDrag.startMove(event,\'divrsvp_ajax\')"><a href="javascript:void(0)" onclick="CloseMsgDiv(\'divrsvp_ajax\')"><img class="closeMsgDiv" src="' + webpath + 'images/close.jpg"/></a>提示信息</dt>';
        innerhtml += '<dd style="padding:0;margin:0;height:80px">';
        innerhtml += '<img style="float:left;margin:10px 10px 0 0;" src="' + pic + '" />';
        innerhtml += '<div style="padding:0;margin:20px 0 10px 0;font-size:14px;">';
        innerhtml += msg;
        innerhtml += '</div>';
        innerhtml += '</dd>';
        //innerhtml += '</dl></div>';
        obj.innerHTML = innerhtml;

        try{
        var userAgent = navigator.userAgent.toLowerCase();
        var is_opera = (userAgent.indexOf('opera') != -1);
        var clientHeight = scrollTop = 0;
        if (is_opera) {
            clientHeight = document.body.clientHeight / 2;
            scrollTop = document.body.scrollTop;
        } else {
            clientHeight = document.documentElement.clientHeight / 2;
            scrollTop = document.documentElement.scrollTop;
        }

        obj.style.left = (document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft - objwidth / 2) + "px";

        var browser = new Browser();
        if (browser.isIE) {
            if (browser.version >= 7)
                obj.style.top = (clientHeight / 2 + scrollTop - obj.clientHeight / 3) + "px";
            else {
                obj.style.top = (clientHeight + scrollTop - obj.clientHeight / 2) + "px";
                var allselect = gname("select");
                for (var i = 0; i < allselect.length; i++) {
                    allselect[i].style.visibility = "hidden";
                }
            }
        }
        else
            obj.style.top = (clientHeight + scrollTop - obj.clientHeight / 2) + "px";
            
        }catch(e){
            self_debug("err2:"+ e.message);
        }
    } else {
    setTimeout('try{ShowAjaxMsg("' + msg + '","' + pic + '",' + objwidth + ');}catch(e){self_debug(e.message);}', 500);
    }
}


function GetBrowserDocument()
{
   var _dcw = document.documentElement.clientHeight;
   var _dow = document.documentElement.offsetHeight;
   var _bcw = document.body.clientHeight;
   var _bow = document.body.offsetHeight;
   
   if(_dcw == 0) return document.body;
   if(_dcw == _dow) return document.documentElement;
   
   if(_bcw == _bow && _dcw != 0) 
     return document.documentElement;
   else
     return document.body;
}


function ShowTabs(obj,F_TabNames,F_TabIds){
	if(typeof(obj) == "object"){
		var num;
		for (var i=0; i<F_TabNames.length; i++){
			if(F_TabNames[i] == obj.id){
				num = i;
				document.getElementById(F_TabNames[i]).className = "up";
				document.getElementById(F_TabIds[i]).style.display = "";
			}else{
				document.getElementById(F_TabNames[i]).className = "down";
				document.getElementById(F_TabIds[i]).style.display = "none";
			}
		}
		if(num > 0)document.getElementById(F_TabNames[num-1]).className = "down";
	}else{
		for (var i=0; i<F_TabNames.length; i++){
			if(i == obj){
				document.getElementById(F_TabNames[i]).className = "up";
				document.getElementById(F_TabIds[i]).style.display = "";
				if(i>0)document.getElementById(F_TabNames[i-1]).className = "down";
			}else{
				document.getElementById(F_TabNames[i]).className = "down";
				document.getElementById(F_TabIds[i]).style.display = "none";
			}
		}
	}
}


/*  图片缩放    */
function onloadAdjustImg(id,Owidth,Oheight){
	aa = eval(id);
	if(aa.width > aa.height){
		aa.style.width	=	Owidth;
	}
	else
	{
		aa.style.height	=	Oheight;
	}
}
function onloadAdjustImg_Big(id,Owidth,Oheight){
	aa = eval(id);
	if(aa.width < aa.height){
		aa.style.height	=	Oheight;
	}
	else
	{
		aa.style.width	=	Owidth;
	}
}
/*  图片缩放 END    */

//图片预览
function showpreview(Obj,ShowObj,w,h){
	sFromUrl =  Obj.value;
	if(typeof(ShowObj) != "object")
	    ShowObj = document.getElementById(ShowObj);
	
//	if(sFromUrl.toLowerCase().indexOf("http://") == -1){
//	    sFromUrl = webpath + sFromUrl.toLowerCase();
//    	sFromUrl = sFromUrl.replace("//","/");
//    }
	var temphtml="style:";
	if(!isNaN(w))
	    temphtml += "width:"+w+";";
    if(!isNaN(h))
	    temphtml += "height:"+w+";";
	
	var sHTML = '<a href="'+sFromUrl+'" target="_blank"><img src="'+sFromUrl+'" border="0" align=center style="'+ temphtml +'" onmousewheel="return bbimg(this)" onload="javascript:if(this.width>screen.width-800)this.style.width=screen.width-800;"';
	sHTML = sHTML+'/></a>';
	if (sFromUrl.length<10){sHTML='';}
	try{
	    ShowObj.innerHTML = sHTML;
	}catch(e){
	    self_debug(e.message);
	}
}


var _isIE=false;

//图片加载后调整图片大小
function DownImage(J,E,A,D,B){
	D=D||1;B=B||1;
	var C=new Image();
	C.src=J.src;
	if(_isIE){
		var I="<img src='"+J.src+"' style='position:absolute; visibility:hidden'/>";
		document.body.insertAdjacentHTML("afterBegin",I)
	}
	if(C.width>0&&C.height>0){
		var F=(E/C.width<A/C.height)?E/C.width:A/C.height;
		var L=0;var H=0;
		if(F<=1){
			L=J.width=C.width*F;
			H=J.height=C.height*F;
		}else{
			L=J.width=C.width;
			H=J.height=C.height;
		}
		if(D==1){
			var K=(E-L)/2;J.style.marginLeft=J.style.marginRight=K+"px";
		}
		if(B==1){
			var K=(A-H)/2;
			J.style.marginTop=J.style.marginBottom=K+"px";
		}
	}
}

//调整显示切换label菜单样式
//menuboxid,     盒子容器ID
//ismenustr,    当前页
function setMenu(menuboxid,ismenustr){
	filename = ismenustr;
	filename = filename +" ";
	filename = filename.toLowerCase();
	var childLength = document.getElementById(menuboxid).childNodes;
	for(i=0;i<childLength.length;i++){

		if(childLength[i].tagName == "H2"){
			childLength[i].className = "down";
		}
	
		if(filename.indexOf(childLength[i].name) >=0){
			childLength[i].className = "up";
		}
		
	}
}


//调整框架的高度
function dyniframesize(num,iframes,parentnum){
	if(iframes){
		var iframeids=iframes.split(",");
	}else{
		var iframeids=["ifrMainContent"];
	}
	if(num){
	}else num = 0;
	
	if(parentnum){
		parentnum++;
	}else parentnum = 1;
	

	var iframehide="no";				//页面不支持框架时,是否隐藏.yes:隐藏,no不隐藏
	var dyniframe;
	try{
		for (i=0; i<iframeids.length; i++){  
			if(document.getElementById){ 
				try{
				dyniframe = document.getElementById(iframeids[i]);		
				}catch(e){}
				if(!window.opera){
						try{
							document.getElementById(iframeids[i]).height = document.getElementById(iframeids[i]).contentDocument.body.offsetHeight;
						}catch(e){}
						try{
							parent.document.getElementById(iframeids[i]).height = parent.document.getElementById(iframeids[i]).contentDocument.body.offsetHeight;
						}catch(e){}
						try{
							document.getElementById(iframeids[i]).height = parseInt(document.getElementById(iframeids[i]).Document.body.scrollHeight);
						}catch(e){}
						try{
							parent.document.getElementById(iframeids[i]).height = parseInt(parent.document.getElementById(iframeids[i]).Document.body.scrollHeight);
						}catch(e){}
						try{
							parent.parent.document.getElementById(iframeids[i]).height = parseInt(parent.parent.document.getElementById(iframeids[i]).Document.body.scrollHeight);
						}catch(e){}
					//}
				}
			
			}
		}
	}catch(e){}
}


///调整页面中列表状态切换标签样式
function showpagetitletab(pagetitle){
  var url=window.location.search;
  var childLength = document.getElementById(pagetitle).childNodes;
  if(url.indexOf("?")!=-1){
    var str = url.substr(1) 
    strs = str.split("&");
    for(i=0;i<strs.length;i++){
      if(strs[i].split("=")[0] == "tab"){
        $(strs[i].split("=")[1]).className="up";
      }
    }
  }else{
      childLength[0].className = "up";
  }
  
}

//显示提示层
function wsug(e, str){ // http://www.hansir.cn
 var oThis = arguments.callee;
 if(!str) {
  oThis.sug.style.visibility = 'hidden';
  document.onmousemove = null;
  return;
 }  
 if(!oThis.sug){
  var div = document.createElement('div'), css = 'top:0; left:0; position:absolute; z-index:100; visibility:hidden';
   div.style.cssText = css;
   div.setAttribute('style',css);
  var sug = document.createElement('div'), css= 'font:normal 12px/16px "宋体"; white-space:nowrap; color:#666; padding:3px; position:absolute; left:0; top:0; z-index:10; background:#f9fdfd; border:1px solid #0aa';
   sug.style.cssText = css;
   sug.setAttribute('style',css);
  var dr = document.createElement('div'), css = 'position:absolute; top:3px; left:3px; background:#333; filter:alpha(opacity=50); opacity:0.5; z-index:9';
   dr.style.cssText = css;
   dr.setAttribute('style',css);
  var ifr = document.createElement('iframe'), css='position:absolute; left:0; top:0; z-index:8; filter:alpha(opacity=0); opacity:0';
   ifr.style.cssText = css;
   ifr.setAttribute('style',css);
  div.appendChild(ifr);
  div.appendChild(dr);
  div.appendChild(sug);
  div.sug = sug;
  document.body.appendChild(div);
  oThis.sug = div;
  oThis.dr = dr;
  oThis.ifr = ifr;
  div = dr = ifr = sug = null;
 }
 var e = e || window.event, obj = oThis.sug, dr = oThis.dr, ifr = oThis.ifr;
 obj.sug.innerHTML = str;
 
 var w = obj.sug.offsetWidth, h = obj.sug.offsetHeight, dw = document.documentElement.clientWidth||document.body.clientWidth; dh = document.documentElement.clientHeight || document.body.clientHeight;
 var st = document.documentElement.scrollTop || document.body.scrollTop, sl = document.documentElement.scrollLeft || document.body.scrollLeft;
 var left = e.clientX +sl +17 + w < dw + sl  &&  e.clientX + sl + 15 || e.clientX +sl-8 - w, top = e.clientY + st +17 + h < dh + st  &&  e.clientY + st + 17 || e.clientY + st - 5 - h;
 obj.style.left = left+ 10 + 'px';
 obj.style.top = top + 10 + 'px';
 dr.style.width = w + 'px';
 dr.style.height = h + 'px';
 ifr.style.width = w + 3 + 'px';
 ifr.style.height = h + 3 + 'px';
 obj.style.visibility = 'visible';
 document.onmousemove = function(e){
  var e = e || window.event, st = document.documentElement.scrollTop || document.body.scrollTop, sl = document.documentElement.scrollLeft || document.body.scrollLeft;
  var left = e.clientX +sl +17 + w < dw + sl  &&  e.clientX + sl + 15 || e.clientX +sl-8 - w, top = e.clientY + st +17 + h < dh + st  &&  e.clientY + st + 17 || e.clientY + st - 5 - h;
  obj.style.left = left + 'px';
  obj.style.top = top + 'px';
 }
}

/*菜单处理程序*/
function setmenu() {
    var scriptname = window.location.href.replace(window.location.search,"");
    if(window.location.port != "80" && window.location.port != "")
        scriptname = scriptname.replace("http://"+ document.domain +":"+ window.location.port+"/","");
    else{
        scriptname = scriptname.replace("http://"+ document.domain +"/","");
        scriptname = scriptname.replace("http://"+ document.domain ,"");
    }

    //alert(scriptname);       
    //alert($("mainMenu").childNodes[0].getElementsByTagName("LI").length);
    var menus = {
            "index.aspx":0,
            "index.html":0,
            "506.aspx":1,
            "movie/pack.aspx":2,
            "movie/topic.aspx":3,
            "ask/index.aspx":4,
        "movie/quest.aspx": 5
            };
    //alert(scriptname);
    if (scriptname.indexOf("-") != -1) {
        //        if(scriptname.split("-") == "index")
        //            scriptname = scriptname.replace("index-","");
        //        else{
        scriptname = scriptname.replace(scriptname.split("-")[0] + "-", "");
        
        if (scriptname.indexOf("-") != -1) {
            scriptname = scriptname.split("-")[0] + "." + scriptname.split(".")[1];
        }
       // alert(scriptname);
        //}
    }
    try {
        $("mainMenu").childNodes[0].getElementsByTagName("LI")[menus[scriptname]].className = "up";
    } catch (e) {
    //alert(e.message);
    }
}