function Is_Exit(){
	if(confirm("您确定要退出登录状态吗？")){
		top.location.href = '../Logout.asp?RetUrl=' + escape(window.location.href);
	}
}
//获取ID
function $id(id){
	return document.getElementById(id);
}
	
//获取tagname
function $tag(tanme){
	return document.getElementsByTagName(tanme);
}

//投票
function Hit(srcid){
	var iddiv_obj = $id('Src_ID' + srcid);
	var hitdiv_obj = $id('Src_HitNum' + srcid);
	var RetCode,RetDes;
	
	var xmldocumento = GetXMLContent('js/DoAjax.asp?action=hit&src_id='+srcid);
	RetCode = xmldocumento.selectSingleNode('//ReturnStr/RetCode/text()').nodeValue;
	RetDes = xmldocumento.selectSingleNode('//ReturnStr/RetDes/text()').nodeValue;
  	switch(RetCode){
  		case '0000' :
				hitdiv_obj.innerHTML = (Math.round(hitdiv_obj.innerHTML)+1).toString();
				iddiv_obj.innerHTML = '已投票';
				alert('投票成功！');
				break;
  		case '0001' :
  	  		alert(RetDes);
  	   		break;
  		case '0002' :
				hitdiv_obj.innerHTML = (Math.round(hitdiv_obj.innerHTML)+1).toString();
				iddiv_obj.innerHTML = '已投票';
				alert(RetDes);
				break;
  		case '0003' :
				hitdiv_obj.innerHTML = (Math.round(hitdiv_obj.innerHTML)+1).toString();
				iddiv_obj.innerHTML = '已投票';
				alert(RetDes);
				break;
  	}
}

//创建事件
function CtreateEvent(obj,eventname,func){
	if(navigator.userAgent.indexOf("MSIE")>=0){
		var f =new Function("event",func);
		obj.attachEvent(eventname,f);
		}
		else{
			obj.setAttribute(eventname,func);
			}
	}

//用于获得一个页面的RSS链接
function getRssUrl(){
	var theurl = '';
	theurl = document.getElementsByTagName('link')[3].href
	return theurl;
}

function isDate(str)   
{
	var r=str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);     
	if(r==null)return false;
	var d=new Date(r[1], r[3]-1, r[4]);     
	return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);   
}


// JavaScript Document
//滚动内容，oTarget为父窗口，iDelayTime为停顿延时，iSpeedTime为滚动速度默认为10ms
var rollChild = function(oTarget,iDelayTime,iSpeedTime,iStep,sDir,iConWidth,iConHeight)
{
	alert(oTarget.childNodes.length);
	if(oTarget.childNodes.length > 1)
	{
		var isStop = false;
		oTarget.onmouseover = function(){isStop=true;}
		oTarget.onmouseout = function(){isStop=false;}
		iSpeedTime = iSpeedTime?iSpeedTime:10;
		iStep = iStep?iStep:1;
		iConWidth = iConWidth?(iConWidth>0?iConWidth:0):0;
		iConHeight = iConHeight?(iConHeight>0?iConHeight:0):0;
		sDir = sDir?(sDir=="left"?sDir:(sDir=="right"?sDir:(sDir=="down"?sDir:"up"))):"up";
		var iIndex = 1;
		var oContainer =  document.createElement("div");
		oContainer.className = "roll_Div";
		oContainer.id = "";
		oContainer.style.top = "0px";
		oContainer.style.left = "0px";
		var oCon1 = oTarget.cloneNode(true);
		oCon1.className = "con_Div";
		oCon1.id = "";
		oContainer.appendChild(oCon1);
		var oCon2 = oTarget.cloneNode(true);
		oCon2.className = "con_Div";
		oCon2.id = "";
		oContainer.appendChild(oCon2);
		oCon1 = null;
		oCon2 = null;
		
		while(oTarget.childNodes.length>0)oTarget.removeChild(oTarget.childNodes[0]);
		oTarget.appendChild(oContainer);
		
		
		var oInitTime = null;
		var oRollTime = null;
		var oTime = null;
		var initRoll = function()
		{
			if(iConWidth>0)
			{
				if(sDir=="left"||sDir=="right")
					oContainer.style.width = iConWidth*2 + "px";
				else
					oContainer.style.width = iConWidth + "px";
				for(var i = 0;i<oContainer.childNodes.length;i++)
					oContainer.childNodes[i].style.width = iConWidth + "px";
			}
			
			if(iConHeight>0)
			{
				if(sDir=="left"||sDir=="right")
					oContainer.style.height = iConHeight + "px";
				else
					oContainer.style.height = iConHeight*2 + "px";
				for(var i = 0;i<oContainer.childNodes.length;i++)
					oContainer.childNodes[i].style.height = iConHeight + "px";
			}
			
			oInitTime = null;
			var W_Height = oTarget.clientHeight;
			var RD_Height = oContainer.scrollHeight;
			var C_Height = RD_Height/2;
			
			var W_Width = oTarget.clientWidth;
			var RD_Width = oContainer.scrollWidth;
			var C_Width = RD_Width/2;
			
			
			if(W_Width >= C_Width&&(sDir=="left"||sDir=="right"))
			{
				oContainer.removeChild(oContainer.childNodes[0]);
				return;
			}
			if(W_Height >= C_Height&&(sDir=="up"||sDir=="down"))
			{
				oContainer.removeChild(oContainer.childNodes[0]);
				return;
			}
			
			
			var W=W_Width,RD=RD_Width,C=C_Width;
			var curr_Count = 0;
			var iSign = 1;
			var oStyle = oContainer.style;
			var sProperty  = "left";
			var sEval1 = "",sEval2 = "";
			
			var roll = function()
			{
				oRollTime = null;
				if(isStop)
				{
					oRollTime = setTimeout(roll,iDelayTime);
					return;
				}
				switch(sDir)
				{
					case "left":
						curr_Count = W_Width / iStep;
						iSign = -1;
						sEval1 = "(parseInt(oStyle[sProperty])*iSign) >= RD - W";
						sEval2 = "C - W + iStep";
						break;
					case "right":
						curr_Count = W_Width / iStep;
						sEval1 = "(parseInt(oStyle[sProperty])*iSign) >= 0";
						sEval2 = "iStep - C";
						break;
					case "up":
						curr_Count = W_Height / iStep;
						sProperty = "top";
						iSign = -1;
						W=W_Height;
						RD=RD_Height;
						C=C_Height
						sEval1 = "(parseInt(oStyle[sProperty])*iSign) >= RD - W";
						sEval2 = "C - W + iStep";
						break;
					case "down":
						curr_Count = W_Height / iStep;
						sProperty = "top";
						W=W_Height;
						RD=RD_Height;
						C=C_Height
						sEval1 = "(parseInt(oStyle[sProperty])*iSign) >= 0";
						sEval2 = "iStep - C";
						break;
				}
				var scrollContainer = function()
				{
					if(isStop)
					{
						oTime = null;
						oTime = setTimeout(scrollContainer,iSpeedTime);
						return;
					}
					if(--curr_Count < 0)
					{
						oRollTime = setTimeout(roll,iDelayTime);
						oTime = null;
						return;
					}
					else
					{
						if(eval(sEval1))
						{
							oStyle[sProperty] = iSign*(eval(sEval2))+"px";
							oTime = null;
							oTime = setTimeout(scrollContainer,iSpeedTime);
						}
						else
						{
							oStyle[sProperty] = (parseInt(oStyle[sProperty]) + iStep*iSign) + "px";
							oTime = null;
							oTime = setTimeout(scrollContainer,iSpeedTime);
						}
					}
				}
				oTime = setTimeout(scrollContainer,iSpeedTime)
			}
			oRollTime = setTimeout(roll,iDelayTime);
		}
		oInitTime = setTimeout(initRoll,10);
	}
}



//----------------------------------------------------------

//调整SelectBox下拉框项目顺序的JAVASCRIPT脚本
//obj：SelectBox对象
//direction：移动方向"Up","Down"
function adjustSort(obj,direction)
{
	var val,str;
	if(obj.options.selectedIndex==-1)
		return false;
	if(direction=="Up")
	//向上移动
	{
		if(obj.options.selectedIndex==0)
			return true;
		else
		{
			val=obj.options[obj.options.selectedIndex].value;
			str=obj.options[obj.options.selectedIndex].text;
			obj.options[obj.options.selectedIndex].value=obj.options[obj.options.selectedIndex-1].value;
			obj.options[obj.options.selectedIndex].text=obj.options[obj.options.selectedIndex-1].text;
			obj.options[obj.options.selectedIndex-1].value=val;
			obj.options[obj.options.selectedIndex-1].text=str;
			obj.options[obj.options.selectedIndex-1].selected=true;
			return true;
		}
	}
	else
	//向下移动
	{
		if((obj.options.length-1)==(obj.options.selectedIndex))
			return true;
		else
		{
			val=obj.options[obj.options.selectedIndex].value;
			str=obj.options[obj.options.selectedIndex].text;
			obj.options[obj.options.selectedIndex].value=obj.options[obj.options.selectedIndex+1].value;
			obj.options[obj.options.selectedIndex].text=obj.options[obj.options.selectedIndex+1].text;
			obj.options[obj.options.selectedIndex+1].value=val;
			obj.options[obj.options.selectedIndex+1].text=str;
			obj.options[obj.options.selectedIndex+1].selected=true;
			obj.options[obj.options.selectedIndex].selected=false;
			return true;
		}
	}
}


//选中下拉框中所有选项，设置页面排序时用
function SelectAllItem(obj)
{
	for(i=0;i<=obj.options.length-1;i++)
		if(!obj.options[i].selected)
			obj.options[i].selected=true;
	return true;
}
