var IE=false;
navigator.userAgent.indexOf("MSIE")>=0?IE=true:IE=false
	function Is_Exit(){
		if(confirm("您确定要退出[WoDig我顶]吗？")){
			top.location.href="default.asp?action=logout";
		}
	}
//获取ID
function $id(id,obj){
	if(obj==null){return document.getElementById(id)}
	else{return obj.getElementById(id)}
	}
	
//获取tagname
function $tag(tanme,obj){
	if(obj==null){
return document.getElementsByTagName(tanme)}
else{return obj.getElementsByTagName(tanme)}
	}
//顶一下
function Hit(srcid,UserID){
	var iddiv_obj=$id("Src_ID"+srcid);
	var hitdiv_obj=$id("Src_HitNum"+srcid);
	var RetCode,RetDes;
  var xmldocumento=GetXMLContent("doajax.asp?action=hit&src_id="+srcid+"&UserID="+UserID);
  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="已顶";
  	  break;
  	case "0001" :
  	  alert(RetDes);
  	   break;
	case "0002" :
  	  alert(RetDes);
  	   break;
  	case "0003" :
  	  hitdiv_obj.innerHTML=(Math.round(hitdiv_obj.innerHTML)+1).toString();
  	  iddiv_obj.innerHTML="已顶";
  	  alert(RetDes);
  	  break;
  	}
  	//window.status=Web_StatusKey;
	}

function Hit2(Post_ID,UserID){
	var iddiv_obj=$id("Post_ID"+Post_ID);
	var hitdiv_obj=$id("Group_HitNum"+Post_ID);
	var RetCode,RetDes;
  var xmldocumento=GetXMLContent("doajax.asp?action=groupHit&groupid="+Post_ID+"&UserID="+UserID);
  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="已支持";
  	  break;
  	case "0001" :
  	  alert(RetDes);
  	   break;
	case "0002" :
  	  alert(RetDes);
  	   break;
  	case "0003" :
  	  hitdiv_obj.innerHTML=(Math.round(hitdiv_obj.innerHTML)+1).toString();
  	  iddiv_obj.innerHTML="已支持";
  	  alert(RetDes);
  	  break;
  	}
  //	window.status=Web_StatusKey;
	}

function Hit3(srcid,UserID){
	var iddiv_obj=$id("aSrc_ID"+srcid);
	var hitdiv_obj=$id("Src_HitNum"+srcid);
	var RetCode,RetDes;
  var xmldocumento=GetXMLContent("doajax.asp?action=hit2&src_id="+srcid+"&UserID="+UserID);
  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="已埋掉";
  	  break;
  	case "0001" :
  	  alert(RetDes);
  	   break;
	case "0002" :
  	  alert(RetDes);
  	   break;
  	case "0003" :
  	  hitdiv_obj.innerHTML=(Math.round(hitdiv_obj.innerHTML)-1).toString();
  	  iddiv_obj.innerHTML="已埋掉";
  	  alert(RetDes);
  	  break;
  	}
  	//window.status=Web_StatusKey;
	}

function Hit4(Post_ID,UserID){
	var iddiv_obj=$id("aPost_ID"+Post_ID);
	var hitdiv_obj=$id("Group_HitNum"+Post_ID);
	var RetCode,RetDes;
  var xmldocumento=GetXMLContent("doajax.asp?action=groupHit2&groupid="+Post_ID+"&UserID="+UserID);
  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="已埋掉";
  	  break;
  	case "0001" :
  	  alert(RetDes);
  	   break;
	case "0002" :
  	  alert(RetDes);
  	   break;
  	case "0003" :
  	  hitdiv_obj.innerHTML=(Math.round(hitdiv_obj.innerHTML)-1).toString();
  	  iddiv_obj.innerHTML="已埋掉";
  	  alert(RetDes);
  	  break;
  	}
  //	window.status=Web_StatusKey;
	}

//创建事件
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="";
		var thelinkarray;
		var a=0;
		thelinkarray=$tag("link")
		if(thelinkarray.length>=0){
			for(a=0;a<thelinkarray.length;a++){
				if(thelinkarray[a].type=="application/rss+xml"){
					return thelinkarray[a].href;
					break;
					}
				}
			}
		return theurl;
		}
//在新窗口打开图片
function OpenImg(imjobj){
	imjobj.style.cursor="pointer";
	var thesrc=imjobj.src;
	CtreateEvent(imjobj,"onclick","window.open('"+thesrc+"')")
	}

//重设图片大小
function ResizeImg(obj,theWidth,theHeight){
	if(obj!=null){
		var imglist=$tag("img",obj);
		if(imglist!=null){
			var a;
			for(a=0;a<imglist.length;a++){
				if(imglist[a].width>theWidth){
					imglist[a].height=Math.round(imglist[a].height*(theWidth/imglist[a].width));
					imglist[a].width=theWidth;
				}
				else if(imglist[a].height>theHeight){
					imglist[a].width=Math.round(imglist[a].width*(theHeight/imglist[a].height));
					imglist[a].height=theHeight;
					}
				OpenImg(imglist[a]);
				}
			}
		}
	}
//重设链接目标
function changeTarget(obj,targetname){
	if(obj!=null){
		var alist=obj.getElementsByTagName("a");
		if(alist!=null){
			var a;
			for(a=0;a<alist.length;a++){
				if(alist[a].target.toLocaleLowerCase()!==targetname){
					alist[a].target=targetname;
					}
				}
			}
		}
	}
