﻿function isBlank(str)
{
		var reg = /^\s*$/;
		return reg.test(str);
}

function catalogselected(str)
{
	var len = document.searchform.searchfield.options.length;
	
	for(var i = 0 ; i++ ; i < len)
	{
		alert(document.searchform.searchfield.options[i].value);
		if(document.searchform.searchfield.options[i].value == str)
			document.searchform.searchfield.options[i].selected = true;
	}
}

function subsearch()
{
	//以下是得到总表达式
	if(document.searchform.searchword.value=="")
	{
		alert('对不起,请您输入检索词');
		document.searchform.searchword.focus();
		return false;
	}
	else
	{
		if(isBlank(document.searchform.searchword.value))
		{
			alert('对不起,检索词不能为空格');
			document.searchform.searchword.focus();
			return false;
		}
		/*
		if(document.searchform.searchfield[document.searchform.searchfield.selectedIndex].value != "")
		   document.searchform.searchword.value = "(doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80) ) AND CATALOGCODE=(" + document.searchform.searchfield.value+")";
		else
		   document.searchform.searchword.value = "doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80)";	
		*/
		//document.searchform.searchword.value = "doctitle=like('"+document.searchform.searchwordall.value+"',80) or like('"+ document.searchform.searchwordall.value +"',70)";
		//document.searchform.searchword.value = "doctitle/20,content/10 += like['"+document.searchform.searchwordall.value+"',60]/sen";
	}		
}
//search_2008_all的提交验证以及传值
function subsearchall()
{

    //以下是将数据拼写到searchword里面
    document.searchform.searchword.value=document.searchform.biaoti.value+' ,'+document.searchform.neirong.value+' ,'+document.searchform.zuozhe.value+' , '+document.searchform.shijian.value;
	//以下是得到总表达式
 
	if(document.searchform.searchword.value==" , , , ")
	{
		alert('对不起,请您输入检索词');
		document.searchform.biaoti.focus();
		return false;
	}
	else
	{

		if(isBlank(document.searchform.searchword.value))
		{
			alert('对不起,检索词不能为空格');
			document.searchform.searchword.focus();
			return false;
		}
	
		/*
		if(document.searchform.searchfield[document.searchform.searchfield.selectedIndex].value != "")
		   document.searchform.searchword.value = "(doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80) ) AND CATALOGCODE=(" + document.searchform.searchfield.value+")";
		else
		   document.searchform.searchword.value = "doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80)";	
		*/
		//document.searchform.searchword.value = "doctitle=like('"+document.searchform.searchwordall.value+"',80) or like('"+ document.searchform.searchwordall.value +"',70)";
		//document.searchform.searchword.value = "doctitle/20,content/10 += like['"+document.searchform.searchwordall.value+"',60]/sen";
	}		
}

function secondsearch()
{
	//以下是得到总表达式
	if(document.searchform.searchwordall.value=="")
	{
		alert('对不起,请您输入检索词');
		document.searchform.searchwordall.focus();
		return false;
	}
	else
	{
		if(isBlank(document.searchform.searchwordall.value))
		{
			alert('对不起,检索词不能为空格');
			document.searchform.searchwordall.focus();
			return false;
		}
		/*
		if(document.searchform.searchfield[document.searchform.searchfield.selectedIndex].value != "")
			document.searchform.searchword.value = "(doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80) ) AND (" + document.searchform.presearchword.value+") AND CATALOGCODE=(" + document.searchform.searchfield.value+")";
		else
			document.searchform.searchword.value = "(doctitle='"+document.searchform.searchwordall.value+"' or like('"+ document.searchform.searchwordall.value +"',80) ) AND (" + document.searchform.presearchword.value+")";
		*/
		//document.searchform.searchword.value = "(doctitle=like('"+document.searchform.searchwordall.value+"',80) or like('"+ document.searchform.searchwordall.value +"',70) ) AND (" + document.searchform.presearchword.value+")";

		//document.searchform.searchword.value = "doctitle/20,content/10 += like['"+document.searchform.searchwordall.value+"',60]/sen  AND (" + document.searchform.presearchword.value+")";
	}		
}

function displayMediaType(type,contentid)
{
	if(type!=205)
		document.write("<a href='http://www.vodone.com/vodplayer/text/"+contentid+".shtml' target='_blank' >[图文]</a>");
	else
		document.write("<a href='http://www.vodone.com/vodplayer/content/"+contentid+".shtml' target='_blank' >[视频]</a>");
}

function displayMediaLink(type,contentid)
{
	if(type!=205)
		document.write("http://www.vodone.com/vodplayer/text/"+contentid+".shtml");
	else
		document.write("http://www.vodone.com/vodplayer/content/"+contentid+".shtml");
}

function displayMediaLinkWith(type,contentid)
{
	if(type!=205)
		document.write("<a href='http://www.vodone.com/vodplayer/text/"+contentid+".shtml' target='_blank'>");
	else
		document.write("<a href='http://www.vodone.com/vodplayer/content/"+contentid+".shtml' target='_blank'>");
}

function displayPic(type,coverhref,contentid)
{
    alert(type+"@@@"+coverhref+"$$$4"+contentid);
	if(type==205)
	{
		if(coverhref!="")
			document.write("<a href=\"http://www.vodone.com/vodplayer/content/"+contentid+".shtml\" target=\"_blank\"><img src=\""+coverhref+"\" border=\"0\" width=\"112\" height=\"84\" onerror=\"this.src='style/img/content_2008/pic_sp.jpg'\"/></a>");
		else
			document.write("<a href=\"http://www.vodone.com/vodplayer/content/"+contentid+".shtml\" target=\"_blank\"><img src=\"style/img/content_2008/pic_sp.jpg\" border=\"0\" width=\"112\" height=\"84\"/></a>");
	}
	else
	{
		if(coverhref!="")
			document.write("<a href=\"http://www.vodone.com/vodplayer/text/"+contentid+".shtml\" target=\"_blank\" ><img src=\""+coverhref+"\" border=\"0\" width=\"112\" height=\"84\" onerror=\"this.src='style/img/content_2008/pic_sp.jpg'\"/></a>");
		else
			document.write("<a href=\"http://www.vodone.com/vodplayer/text/"+contentid+".shtml\" target=\"_blank\"><img src=\"style/img/content_2008/pic_sp.jpg\" border=\"0\" width=\"112\" height=\"84\"/></a>");
	}
}


function textCounter(field,counter,maxlimit,linecounter) 
{
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="已输入 "+percentage+"%"
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}


//在此开始使用ajax调用置标页面对检索词进行数据库操作
var req;
function TranSearch(searchWord){
	 //alert(searchWord);
	 req=new ActiveXObject("Microsoft.XMLHttp");
     req.open("get","http://so.vodone.com/VODOne/TranSearch.jsp?searchWord="+searchWord);    
     req.send(null);
	}

//在此结束ajax的使用   
