var php_path="http://cgi.data.edu.qq.com/front/web/";
String.prototype.rTrim=function(){return this.replace(/\s*$/,"");}
String.prototype.trim=function(){return this.rTrim().lTrim();}
String.prototype.hasChinese=function(){return/[^\x00-\xff]/g.test(this);}
String.prototype.onlyChinese=function(){return/^[\u0391-\uFFE5]+$/g.test(this);}
String.prototype.hash_filter=function(){return this.replace(/[^a-f0-9]/gi,'');}
String.prototype.getLength=function()
{return this.replace(/[^\x00-\xff]/gi,'xx').length;}

function MM_goToURL()
{ //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    var req = args[0]+".open('"+args[1]+"?";

    for (i = 2 ; i< args.length ; i++){
	if (i != 2) req+="&";	
	var element = document.getElementById(args[i]);
	req+=args[i];
	req+="=";
	if (element.name.indexOf("major_zhuanye") != -1){
		var value=element.value+"&majorname="+arrData["major"][element.value];
		req+=value;
		continue;
	}
	if (element.name.indexOf("score") == -1)
	{
		var value = (element.options[element.selectedIndex]).value;	
	}
	else
	{
		var value = element.value;

	}
  
	req+=value;
}
req+="&page=1')";

eval(req);
}	
function RightGo(elementid,type){
	var id = document.getElementById(elementid).options[document.getElementById(elementid).options.selectedIndex].value;
	var url = "window.open('http://data.edu.qq.com/college/all_col_info.shtml?"+type+"="+id+"')";
	
	eval(url);
}

function goToURL()		
{ 

document.goToURL_returnValue = false;
var args = goToURL.arguments;
var req = args[0]+".open('"+args[1]+"&proid="+document.getElementById(args[2]).value;
var filterattr = "&filterattr=";
var filtervalue = "&filtervalue=";

for (i = 3 ; i< args.length ; i++)
{
    var res = args[i].split(":");
	
	if(i==3)
	{
	    filterattr += res[0];
		var value = document.getElementById(res[1]).options[document.getElementById(res[1]).selectedIndex].value;
		filtervalue += value;
	}
	else
	{
	    filterattr += "," + res[0];
		var value = document.getElementById(res[1]).options[document.getElementById(res[1]).selectedIndex].value;
		filtervalue += "," + value;
	}
	
}

req += filterattr;
req += filtervalue;
req += "&cnt=1&page=1')";

eval(req);
}

 function GoCharge(id){
							  var buy_id = txid2buyid[id];
							  var url = "http://cgi.data.edu.qq.com/front/web/employ.php?mod=buy&act=colinfo&collegeid="+buy_id;
							  var go_url = "window.open('"+url+"')";
							  eval(go_url);
						  }
function HTMLEncode(html)
{
var temp = document.createElement ("div");
(temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
var output = temp.innerHTML;
temp = null;
return output;
}

 function col_query(){
			var i, args=col_query.arguments; document.query_returnValue = false;
			var e = document.getElementById(args[2]);
			var value = e.value;
			//modify by muserzhang,使用ff的情况，加编码
			if (College.Browser.moz)
			{
				//是ff需要encodeURI
				value = encodeURI(value);
			}
			var req = args[0]+".open('"+args[1]+"?query="+value;
			req+="&page=1')";
			eval(req);
		}

function Top(id)
{//请求top
var top_major_url="http://js.data.edu.qq.com/college/hash_id_top_major.js";
College.JsLoader.load(top_major_url, function()
{
	var fselect = document.getElementById(id);
	if(typeof arrData["id2top"] != "undefined"){
		var len = arrData["id2top"].length;
		for (var i = 0; i < len; i++){
			var arrayTemp = arrData["id2top"][i].split("|");
			fselect.options[i+1] = new Option(arrayTemp[1],arrayTemp[0]);
		}
	}
});
}

function Top2Sub(fromid,toid){//fromid 上一个select选中的 toid是联动select的id
 var url="http://js.data.edu.qq.com/college/hash_id_sub_major.js";
 var ts=document.getElementById(toid);
 College.JsLoader.load(url, function()
{
	if (typeof arrData["sub_top"] != "undefined" && typeof arrData["id_sub_major"] != "undefined"){
		for(var m=ts.options.length-1;m>0;m--)
				     ts.options[m]=null;	
		var index=1;
		var len=arrData["sub_top"].length;
		for (var i = 0; i < len ;i++){
			var arrayTemp = arrData["sub_top"][i].split("|");
			if (arrayTemp[1] == fromid){
				    ts.options[index] = new Option(arrData["id_sub_major"][arrayTemp[0]],arrayTemp[0]);
					index++;
			}	
		}
	}
});
}

//2009-4-19 muserzhang 更改，换成拉取针对性的js
function Sub2Major(fromid,toid){
//2009-4-19 muserzhang 更改部分
//var url="http://js.data.edu.qq.com/college/hash_id_major.js";

var url="http://js.data.edu.qq.com/sub_major/" + fromid + "/majorOfsub.js";

var ts = document.getElementById(toid);
College.JsLoader.load(url, function()
{
	if(typeof arrData["major"] != "undefined" && typeof arrData["majorTosub"] != "undefined"){
		for(var m=ts.options.length-1;m>0;m--)
				     ts.options[m]=null;
		var index=1;
		var len=arrData["majorTosub"].length;
		for (var i = 0; i < len ;i++){
			var arrayTemp = arrData["majorTosub"][i].split("|");
			if (arrayTemp[1] == fromid){
				ts.options[index++] = new Option(arrData["major"][arrayTemp[0]],arrayTemp[0]);
			}	
		}
	}
});
}

function Fid(id){return document.getElementById(id);}

function alert_area()
{
    alert("请选择地区");
}            
function alert_college_area()
{
    alert("请选择高校所在地");
}  
function alert_recruit_area()
{
    alert("请选择招生地");
}
function alert_bebie()
{
    alert("请选择科别");
}
function alert_college()
{
    alert("请选择高校");
}  
function alert_bebie()
{
    alert("请选择科别");
}         
function alert_year()
{
    alert("请选择年份");
}               
function alert_turn()
{
    alert("请选择批次");
}    
function alert_top()
{
    alert("请选择类别");
} 
function alert_sub()
{
    alert("请选择学科");
}
function alert_major()
{
    alert("请选择专业");
}  
function alert_col_leibie()
{
    alert("请选择学校类别");
}     
function alert_col_leixin()
{
    alert("请选择学校类型");
}     
function alert_score()
{
    alert("请输入估分");
}     
function alert_score()
{
    alert("请输入估分");
}           
function alert_score_begin()
{
    alert("请输入估分区间起始分数");
} 
function alert_score_end()
{
    alert("请输入估分区间末尾分数");
}

function show_bbs_login_box()
{
    Fid("college_iframe").src="http://ui.ptlogin2.qq.com/cgi-bin/login?appid=5002901&target=parent&s_url="+window.location.href;
    Fid("login_div").style.display="block";
}
var txid2buyid = new Object();
var url_id_id = "http://js.data.edu.qq.com/college/txid2id.js";
College.JsLoader.load(url_id_id, function()
{
});

//跳转至专业录取分数线排行
	function gohjsscore()
	{
		if(Fid('right_col_year').value==0){alert_year();Fid('right_col_year').focus();return false;}
		if(Fid('right_col_area').value==0){alert_recruit_area();Fid('right_col_area').focus();return false;}
		if(Fid('right_col_turn').value==0){alert_bebie();Fid('right_col_turn').focus();return false;}
		if(Fid('right_col_turn').value==0){alert_turn();Fid('right_col_turn').focus();return false;}
		if(Fid('right_top').value==0){alert_top();Fid('right_top').focus();return false;}
		if(Fid('right_sub').value==0){alert_sub();Fid('right_sub').focus();return false;}
		if(Fid('right_major').value==0){alert_major();Fid('right_major').focus();return false;}

		var urlStr = 'http://data.edu.qq.com/college/hjsscore_bycollege.shtml?mod=search&act=qbymajor&lib=recruit';

		urlStr += '&top=' + Fid('right_top').value + '&sub=' + Fid('right_sub').value;		
		
		goToURL('window',urlStr,'right_col_area','F165:right_major','F5:right_col_subject','F3:right_col_year','F4:right_col_turn');
		return document.MM_returnValue;
	}

	//专业类别到专业的级联问题
	function TopToSub(top)
	{
		//清空专业下拉框
		Fid("right_major").options.length = 1;
		Fid("right_major").options[0].selected;
		Top2Sub(top,'right_sub');
	}

	//top搜索框的处理
	//type:类型:1:学校搜索，2：专业搜索，3：分数线搜索
	function top_search(type)
	{
		var Info = {
			"1" : {
				"objId" : "search_col",
				"url" : "http://data.edu.qq.com/college/search_col.shtml"
			},
			"2" : {
				"objId" : "search_major",
				"url" : "http://data.edu.qq.com/college/search_major.shtml"
			},
			"3" : {
				"objId" : "search_line",
				"url" : "http://data.edu.qq.com/college/search_line.shtml"
			}
		};

		var search_value = Fid(Info[type]["objId"]).value;
		var defaultvalue = Fid(Info[type]["objId"]).defaultValue;

		if(search_value == ''||search_value == defaultvalue)
		{
			alert(defaultvalue);
			return false;
		}
		
		col_query('window',Info[type]["url"],Info[type]["objId"]);
		return document.query_returnValue;
	}
