

var d;
 	function b(thisform)
  	{
  		d.close();
  	    d=new dialog();
		d.width=400;
		d.height=200;
	   if(thisform.type.value==0){
		   	   d.html="<font color=red>举报类型不能为空</font>";
			
	   d.html+='</br>';
	   d.html+='<input id="dialogOk" type="button" value=" 返回 " onclick="new dialog().close();" /> ';
	   d.title='窗口提示';
	   d.show();
	   }
	   else if($.trim(thisform.info.value)==""){
	   d.html="<font color=red>举报条件不能为空</font>";
			
	   d.html+='</br>';
	   d.html+='<input id="dialogOk" type="button" value=" 返回 " onclick="new dialog().close();" /> ';
	   d.title='窗口提示';
	   d.show();
		}
		
		else{
			   var s="rep_reasonid="+ thisform.elements["type"].value;
                   s += "&rep_reason="+ thisform.info.value;
				   s += "&action="+ thisform.elements["action"].value;
				   s += "&id="+ thisform.elements["id"].value;
				  
   			  
		$.ajax({ 
			url:'/index.php/ajax/report',
		    type:'post',
		    data:s,
			success: 	function(t){
				if(t=="ok")
				{
					d.html = "<font color=red>举报发送成功!</a>";
					d.html+='</br>';
					d.html+='<input id="dialogOk" type="button" value=" 确定 " onclick="new dialog().close();" /> ';
					d.title='成功发送举报';
					//d.show();
				}
				if(t=="repeat")	
				{ 
				  d.html="<font color=red>您已经举报过这个资源了!</a>";
			   	  d.html+='</br>';
			      d.html+='<input id="dialogOk" type="button" value=" 返回 " onclick="new dialog().close();" /> ';
			      d.title='重复举报';
				 }
					d.show();		
				if(t=="error")
				{
				  d.html="<font color=red>举报失败</a>";
			   	  d.html+='</br>';
			      d.html+='<input id="dialogOk" type="button" value=" 返回 " onclick="new dialog().close();" /> ';
			      d.title='举报失败';
				}
	         }

	
    
	});
	
	
  			}
	return false;
  	}

  	function rep(sourceid,url,writer,status){
  			$.ajax({ 
			url:'/index.php/ajax/getcurusername',
		    type:'post',
		    data:'',
			success: 	function(t){
				if(t=='')
				{
				if (confirm("您还没有登录")) 
				{
				window.location.href=url;
				}
				}
				else{
					if(t==writer || status<0)
					alert('不能举报');
					else
					showrepwin(sourceid);
				}
			}
			});
  	}
  	
  	function showrepwin(id){
  			d=new dialog();
            d.html='<form id="repform" method="post" onsubmit="return b(this);">';
            d.html+='<DIV class="f12 lh15 xx_hd c9" style="TEXT-ALIGN: left">如果您发现违背下载频道原则的资料和用户，请即刻告诉我们！</DIV>';
			d.html+='<DIV class="spta f12 c9 lh20" style="TEXT-ALIGN: left"><B>举报类型：</B>';
			d.html+='<SELECT name=type>';
			d.html+='<option value="0" selected>==请选择举报类型==</option>'; 
			d.html+='<option value="1">发表资源含有危害国家安全等内容</option>';
            d.html+='<option value="2">发表资源含有反动色情等内容</option>';
			d.html+='<option value="3">资源属广告性质</option>';
			d.html+='<option value="4">资源标题与内容不符</option>';
			d.html+='<option value="5">资源不能下载或其他</option>';
			d.html+='<option value="6">发表了别人的资源</option></SELECT>';
			d.html+='<DIV>';
			d.html+='<font color="red">详细原因:</font>';	   
			d.html+='<DIV align=right><TEXTAREA style="WIDTH: 375px; HEIGHT: 70px" name=info rows=5 cols=28></TEXTAREA><BR><FONT class="lh15 f12" color=#7f9db9>可输入150个汉字</DIV>';
			d.html+='<input type="hidden" name="id" name="action" value="'+id+'" />';
			d.html+='<input type="hidden" name="action" name="action" value="submitcomment" />';
  			d.html+='<DIV align="center"><input id="dialogOk" type="submit" value=" 确 定 " /> ';
  			d.html+='<input id="dialogOk" type="button" value=" 取消 " onclick="new dialog().close();" /> </DIV>';
  			d.html+='</form>';
			d.title='举报提示'
  			d.width=400;
  			d.height=200;
  			d.show();
  		}
 function dialog()
{
	this.width=400;
	this.height=300;
	this.title_height=20;
	this.html='';
	this.title='';
	var self = this;
	var bgObj,msgObj,titleObj;
	this.close=function()
	{
		document.body.removeChild(document.getElementById("bgDiv")); 
		document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle")); 
		document.body.removeChild(document.getElementById("msgDiv")); 		
	}

	this.show=function()
	{
		var msgw,msgh,bordercolor; 
		msgw=self.width;
		msgh=self.height;
		bordercolor="#336699";
		titlecolor="#99CCFF";
		
		var sWidth,sHeight; 
		sWidth=document.body.offsetWidth; 
		sHeight=screen.height; 
		bgObj=document.createElement("div"); 
		bgObj.setAttribute('id','bgDiv'); 
		bgObj.style.position="absolute"; 
		bgObj.style.top="0"; 
		bgObj.style.background="#777"; 
		bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
		bgObj.style.opacity="0.6"; 
		bgObj.style.left="0"; 
		bgObj.style.width=sWidth + "px"; 
		bgObj.style.height=sHeight + "px"; 
		bgObj.style.zIndex = "10000"; 
		document.body.appendChild(bgObj); 
		
		msgObj=document.createElement("div") 
		msgObj.setAttribute("id","msgDiv"); 
		msgObj.setAttribute("align","center"); 
		msgObj.style.background="white"; 
		msgObj.style.border="1px solid " + bordercolor; 
		msgObj.style.position = "absolute"; 
		msgObj.style.left = "50%"; 
		msgObj.style.top = "50%"; 
		msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
		msgObj.style.marginLeft = "-225px" ; 
		msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; 
		msgObj.style.width = msgw + "px"; 
		msgObj.style.height =msgh + "px"; 
		msgObj.style.textAlign = "center"; 
		msgObj.style.lineHeight ="25px"; 
		msgObj.style.zIndex = "10001"; 
		
		titleObj=document.createElement("h4"); 
		titleObj.setAttribute("id","msgTitle"); 
		titleObj.setAttribute("align","center"); 
		titleObj.style.margin="0"; 
		titleObj.style.padding="3px"; 
		titleObj.style.background=bordercolor; 
		titleObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
		titleObj.style.opacity="0.75"; 
		titleObj.style.border="1px solid " + bordercolor; 
		titleObj.style.height=self.title_height+"px"; 
		titleObj.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
		titleObj.style.color="white"; 
		titleObj.style.cursor="pointer"; 
		titleObj.innerHTML=self.title; 
		//titleObj.onclick=function(){self.close();} 
		document.body.appendChild(msgObj); 
		document.getElementById("msgDiv").appendChild(titleObj); 
		var txt=document.createElement("div"); 
		txt.style.margin="1em 0" 
		txt.setAttribute("id","msgTxt"); 
		txt.innerHTML=self.html; 
		document.getElementById("msgDiv").appendChild(txt); 
	}
} 		