﻿// JavaScript Document
/*firefox window.event*/
function __firefox(){
    HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
    window.constructor.prototype.__defineGetter__("event", __window_event);
    Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style(){return this.style;}
function __window_event(){return __window_event_constructor();}
function __event_srcElement(){return this.target;}
function __window_event_constructor(){
    if(document.all){return window.event;}
    var _caller = __window_event_constructor.caller;
    while(_caller!=null){
        var _argument = _caller.arguments[0];
        if(_argument){
            var _temp = _argument.constructor;
            if(_temp.toString().indexOf("Event")!=-1){return _argument;}
        }
        _caller = _caller.caller;
    }
    return null;
}
if(window.addEventListener){__firefox();}
/*end firefox.event*/
//通用ID获取对象
function $(id){return document.getElementById(id);}
//通用NAME获取对象
function $N(Name){return document.getElementsByName(Name);}
//设为首页
function $HomePage(obj,Url){
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage(Url);
	return false
}
//加入收藏夹
function $Favorite(Url,Title){
	switch($GetIE()){
		case "IE": window.external.addFavorite(Url,Title);break;
		case "Firefox": window.sidebar.addPanel(Title, Url, "");break;
		case "Opera":
			var Opera = document.createElement('a');Opera.setAttribute('rel','sidebar');
			Opera.setAttribute('href',Url);Opera.setAttribute('title',Title);Opera.click();break;
	}
}
//判断浏览器
function $GetIE(){ 
   if(navigator.userAgent.indexOf("MSIE")>=0) return "IE"; 
   if(navigator.userAgent.indexOf("Firefox")>=0) return "Firefox"; 
   if(navigator.userAgent.indexOf("Opera")>=0) return "Opera"; 
   return "No"; 
}
//通用标签选择
function ShowTag(Name,Max,Num,nav){
	for(var i=1;i<=Max;i++){
		$(Name+i).className='';
		$(Name+"_"+i).style.display='none';
	}
	$(Name+Num).className=nav;
	$(Name+"_"+Num).style.display='block';
}
//通用标签选择
function ShowDiv(Name,Max,Num,nav){
	for(var i=1;i<=Max;i++){
		$(Name+i).style.display='none';
		$(Name+"_"+i).className='';
	}
	$(Name+Num).style.display='block';
	$(Name+"_"+Num).className=nav;
}
//通用标签选择
function HiddenDaig(Name){$(Name).style.display='none';}
function ShowDaig(Name,Obj){
	var e=window.event.srcElement;
	if (arguments.length == 0 ){
		Obj = e;
    }else{
		if(typeof(arguments[0])=='object'){
			Obj=arguments[0];
		}else{
        	Obj = document.getElementById(arguments[0]);
		}
    }
	var t = e.offsetTop,  h = e.clientHeight, l = e.offsetLeft,p = e.type;//控件的信息
	while (e = e.offsetParent){t += e.offsetTop; l += e.offsetLeft;}
	
	var cw = $(Name).clientWidth, ch = $(Name).clientHeight;
    var dw = document.body.clientWidth, dl = document.body.scrollLeft, dh = document.body.clientHeight,dt = document.body.scrollTop;
	if (document.body.clientHeight + dt - t - h >= ch) {
        $(Name).style.top = ((p=="image")? t + h : t + h + 3)+'px';
    }else {
        $(Name).style.top  = ((t - dt < ch) ? ((p=="image")? t + h : t + h + 3) : t - ch)+'px';
    }
    if (dw + dl - l >= cw){
        $(Name).style.left = l+'px'; 
    }else{ 
        $(Name).style.left = ((dw >= cw) ? dw - cw + dl : dl)-4+'px';
    }
	
	//$(Name).style.display='none';
	if($(Name).style.display=='block'){
		$(Name).style.display='none';
	}else{
		$(Name).style.display='block';
	}
}
function SetTime(N){
	N=N+1
	if (N>5)N=1
	ShowDiv('h',5,N,"dnav")
	hTimer = setTimeout('eval("SetTime('+N+')")', 3000);
}
function CheckCode(url){$("CheckCodeImg").src = url+"?"+Math.random()}
function HSearch(id,url){$(id).action=url+"search.asp"}
//LoadPic
function $UpFile(Url,Width,Height,scrollbars){
	window.open(""+Url,"","Width="+Width+",Height="+Height+",top=100,left=100,status=no,scrollbars="+scrollbars)
}
//返回上一页
function Back(){window.history.go(-1);	}
function CheckSelect(Name,Str){
	var SelectStr=$(Name)
	if(SelectStr!=null){
		for(i=0;i<SelectStr.length;i++){
			if(Str == SelectStr.options[i].text || Str == SelectStr.options[i].value) SelectStr.selectedIndex = i;
		}	
	}
}
function CheckRadio(Name,Str){
    var RadioStr=$N(Name);
    if(RadioStr!=null){
        for(i=0;i<RadioStr.length;i++){
            if(RadioStr[i].value==Str){return RadioStr[i].checked="checked"; }
        }
    }
    return null;
}

function uDaig(Url,Form,Par){
	if (CheckForm($(Form))!=false){
		var Pars=AjaxMake(Form,Par,true)
		new Ajax(Url,0,Pars,"get",uDaigAlert)
	}
}
function uDaigAlert(obj){
	alert(obj)
	if(obj.indexOf("成功")!=-1) HiddenDaig("diagbox");
	$("uName").value="";$("uMail").value="";$("uText").value="";
}
function flash(url,width,height){
document.write("<DIV>\r\
<OBJECT codeBase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" height=\""+height+"\" width=\""+width+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">\r\
<PARAM NAME=\"Movie\" VALUE=\""+url+"\">\r\
<PARAM NAME=\"Src\" VALUE=\""+url+"\">\r\
<PARAM NAME=\"WMode\" VALUE=\"Transparent\">\r\
<embed src=\""+url+"\" quality=\"high\" allowscriptaccess=\"always\" wmode=\"Transparent\" type=\"application/x-shockwave-flash\"  pluginspage=\"http://www.macromedia.com/go/getflashplayer\" height=\""+height+"\" width=\""+width+"\">\r\
</OBJECT>\r\
</DIV>")
}
