﻿//该方法用来显示错误单词的正确信息
//参数说明：caption: 显示的标题 contentTags：由内容提取出的Tag myTags：我的常用标签 subTags：本学科常用标签 objTag：Tag编辑控件
function sAlert(caption,contentTags,myTags,subTags,objTag){
if(document.getElementById ("shield")==null) 
{
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "left";
	alertFram.style.zIndex = "10001";

	var sTitle="["+caption+"]";
	var index=0;
	strHtml = "<div style=\"margin:0px;padding:0px;width:100%;\">\n";
	strHtml += "<div class='msg_title' >"+sTitle+"</div>";
	strHtml += "<div class=\"msg_content\">";
	
	strHtml += "<span class=\"item_title\">内容提取的Tag：</span><br>";
	for(index=0;index<contentTags.length;index++) {
		strHtml += getTagSpanHtml(contentTags[index],objTag);
	}
	strHtml += "<br>";

	strHtml += "<span class=\"item_title\">我的常用Tag：</span><br>";
	for(index=0;index<myTags.length;index++) 
	{
		strHtml += getTagSpanHtml(myTags[index],objTag);
	}
	strHtml += "<br>";

	strHtml += "<span class=\"item_title\">本学科常用Tag：</span><br>";
	for(index=0;index<subTags.length;index++) 
	{
		strHtml += getTagSpanHtml(subTags[index],objTag);
	}
	strHtml += "<br></div>";

	strHtml += "<div class=\"msg_tail\"><input type=\"button\" value=\"完  成\" id=\"do_OK\" onclick=\"doOk()\" /></div>\n";
	strHtml += "</div>\n";
	alertFram.innerHTML = strHtml;
	$("select").hide();
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	this.selectTag = function(obj)
	{
		addTag(obj.innerText);
		obj.className = "tag_selected";
	}

	this.setOpacity = function(obj,opacity){
	if(opacity>=1)opacity=opacity/100;
	try{ 
	obj.style.opacity=opacity; }catch(e){}
	try{ 
	if(obj.filters.length>0&&obj.filters("alpha")){
	obj.filters("alpha").opacity=opacity*100;
	}else{
	obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
	}
	}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
	if (++c > 20){clearInterval(ad);return 0;}
	setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
	document.body.removeChild(alertFram);
	document.body.removeChild(shield);
	document.body.onselectstart = function(){return true;}
	document.body.oncontextmenu = function(){return true;}
	$("select").show();
	}
 
	document.body.oncontextmenu = function(){return false;}

	function getTagSpanHtml(sTag)
	{
		if(IsContain(sTag))
			return "<span class=\"tag_selected\">"+sTag+"</span>";
		else
			return "<span class=\"item_tags\" onclick=\"selectTag(this)\">"+sTag+"</span>";
	}
	function IsContain(sTag)
	{
		if(objTag.value=="") return false;
		return (objTag.value.indexOf(sTag)>=0);
	}

	this.addTag = function(sTag)
	{
		var sTags = objTag.value;
		if(sTags=="") sTags = sTag + " ";
		else
		{
			if(!IsContain(sTag))
			{
				//这里判断字符串结尾是否为空格，判断不出来，不知道为何
				//if(sTags.charAt(sTags.lenght-1)!=" ")
				//	sTags += " ";
				sTags += sTag + " ";
			}
		}
		objTag.value = sTags;
	}
	}
}

//该方法用来显示错误单词的正确信息
//参数说明：caption: 显示的标题 contentTags：由内容提取出的Tag myTags：我的常用标签 subTags： Tag编辑控件
function sAlert_soft(caption,contentTags,myTags,objTag){
     
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "left";
	alertFram.style.zIndex = "10001";

	var sTitle="["+caption+"]";
	var index=0;
	strHtml = "<div style=\"margin:0px;padding:0px;width:100%;\">\n";
	strHtml += "<div class='msg_title' >"+sTitle+"</div>";
	strHtml += "<div class=\"msg_content\">";
	
	strHtml += "<span class=\"item_title\">内容提取的Tag：</span><br>";
	for(index=0;index<contentTags.length;index++) {
		strHtml += getTagSpanHtml(contentTags[index],objTag);
	}
	strHtml += "<br>";

	strHtml += "<span class=\"item_title\">我的常用Tag：</span><br>";
	for(index=0;index<myTags.length;index++) 
	{
		strHtml += getTagSpanHtml(myTags[index],objTag);
	}
	 

	 
	strHtml += "<br></div>";
    
	strHtml += "<div class=\"msg_tail\"><input type=\"button\" value=\"完  成\" id=\"do_OK\" onclick=\"doOk()\" /></div>\n";
	strHtml += "</div>\n";
	alertFram.innerHTML = strHtml;
	$("select").hide();
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	this.selectTag = function(obj)
	{
		addTag(obj.innerText);
		obj.className = "tag_selected";
	}

	this.setOpacity = function(obj,opacity){
	if(opacity>=1)opacity=opacity/100;
	try{ 
	obj.style.opacity=opacity; }catch(e){}
	try{ 
	if(obj.filters.length>0&&obj.filters("alpha")){
	obj.filters("alpha").opacity=opacity*100;
	}else{
	obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
	}
	}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
	if (++c > 20){clearInterval(ad);return 0;}
	setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
	document.body.removeChild(alertFram);
	document.body.removeChild(shield);
	document.body.onselectstart = function(){return true;}
	document.body.oncontextmenu = function(){return true;}
	$("select").show();
	}
 
	document.body.oncontextmenu = function(){return false;}

	function getTagSpanHtml(sTag)
	{
		if(IsContain(sTag))
			return "<span class=\"tag_selected\">"+sTag+"</span>";
		else
			return "<span class=\"item_tags\" onclick=\"selectTag(this)\">"+sTag+"</span>";
	}
	function IsContain(sTag)
	{
		if(objTag.value=="") return false;
		return (objTag.value.indexOf(sTag)>=0);
	}

	this.addTag = function(sTag)
	{
		var sTags = objTag.value;
		if(sTags=="") sTags = sTag + " ";
		else
		{
			if(!IsContain(sTag))
			{
				//这里判断字符串结尾是否为空格，判断不出来，不知道为何
				//if(sTags.charAt(sTags.lenght-1)!=" ")
				//	sTags += " ";
				sTags += sTag + " ";
			}
		}
		objTag.value = sTags;
	}
}



//该方法用来显示错误单词的正确信息
//参数说明：caption: 显示的标题 contentTags：由内容提取出的Tag myTags：我的常用标签 subTags： Tag编辑控件
function report(caption,objTag){
 
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "left";
	alertFram.style.zIndex = "10001";

	var sTitle="["+caption+"]";
	var index=0;
	strHtml = "<div style=\"margin:0px;padding:0px;width:100%;\">\n";
	strHtml += "<div class='msg_title' >"+sTitle+"</div>";
	strHtml += "<div class=\"msg_content\">";
	
	//strHtml += "<span class=\"item_title\">内容提取的Tag：</span><br>";
	var contentTags=new Array(7);
	contentTags[0]="资源文件无法下载";
	contentTags[1]="资源文件无法打开";
	contentTags[2]="资源文件和标题不匹配";
	contentTags[3]="资源含病毒、木马及流氓插件";
	contentTags[4]="资源需要密码才能打开";
	contentTags[5]="资源含色情、反动内容等非法内容";
	contentTags[6]="其他内容请手动输入";
	
	for(index=0;index<contentTags.length;index++) {
	
		strHtml +=getTagSpanHtml(contentTags[index],index);
		 
		strHtml += "<br>";
	}
	strHtml += "<textarea rows=\"5\" cols=\"50\" id=\"others\" >资源文件无法下载</textarea><br>";
  
	strHtml += "<br></div>";
    
	strHtml += "<div class=\"msg_tail\"><input type=\"button\" value=\"完  成\" id=\"do_OK\" onclick=\"doOk()\" />"+
	                                    "<input type=\"button\" value=\"取 消\" id=\"do_cancle\" onclick=\"cancle()\" />"+
	                                    "</div>\n";
	strHtml += "</div>\n";
	alertFram.innerHTML = strHtml;
	$("select").hide();
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	this.selectTag = function(obj)
	{
		addTag(obj.innerText);
		obj.className = "tag_selected";
	}

	this.setOpacity = function(obj,opacity){
	if(opacity>=1)opacity=opacity/100;
	try{ 
	obj.style.opacity=opacity; }catch(e){}
	try{ 
	if(obj.filters.length>0&&obj.filters("alpha")){
	obj.filters("alpha").opacity=opacity*100;
	}else{
	obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
	}
	}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
	if (++c > 20){clearInterval(ad);return 0;}
	setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	
	
	this.doOk = function(){
	objTag.value=document.getElementById("others").value;
	document.body.removeChild(alertFram);
	document.body.removeChild(shield);
	document.body.onselectstart = function(){return true;}
	document.body.oncontextmenu = function(){return true;}
	
	$("select").show();
	finish();
	}
 this.cancle = function(){
	 
	document.body.removeChild(alertFram);
	document.body.removeChild(shield);
	document.body.onselectstart = function(){return true;}
	document.body.oncontextmenu = function(){return true;}
	
	$("select").show();
 
	}
	document.body.oncontextmenu = function(){return false;}

	function getTagSpanHtml(sTag,initialIndex)
	{
		 if(initialIndex==0)
		return "<input type=\"radio\" name=\"con\" value=\""+sTag+"\" onclick=\"setResult(this)\" checked>"+sTag+" ";
		 else if(initialIndex==6)
		 return "<input type=\"radio\" name=\"con\" value=\""+sTag+"\" onclick=\"setLastResult(this)\">"+sTag+" ";
		 else
		return "<input type=\"radio\" name=\"con\" value=\""+sTag+"\" onclick=\"setResult(this)\">"+sTag+" ";
 
	}
	function IsContain(sTag)
	{
		 
		if(objTag.value=="") return false;
		 
		return (objTag.value.indexOf(sTag)>=0);
	}
    this.setResult=function(selStr)
    {
      
      document.getElementById("others").value=selStr.value;
    }
    this.setLastResult=function(selStr)
    {
       document.getElementById("others").value="";
       document.getElementById("others").select();
    }
//	this.addTag = function(sTag)
//	{
//		var sTags = objTag.value;
//		if(sTags=="") sTags = sTag + " ";
//		else
//		{
//			if(!IsContain(sTag))
//			{
//				//这里判断字符串结尾是否为空格，判断不出来，不知道为何
//				//if(sTags.charAt(sTags.lenght-1)!=" ")
//				//	sTags += " ";
//				sTags += sTag + " ";
//			}
//		}
//		objTag.value = sTags;
//	}
	
}

