// JavaScript Document Ajax使用方法如下：
//var email_checker_ajax = new Ajax("/reg.php");
//if(email_checker_ajax.post("name="+email+"&task=s"))
function Ajax_search(url)
{
	m_xmlReq = createXMLHttpRequest();
	this.post=function(d)
	{
	    if(!m_xmlReq)  return;
	    m_xmlReq.open('POST',url,false);
	    m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    m_xmlReq.send(d);
		return eval(m_xmlReq.responseText);
	}
}
function SearchMessage(vals)
{
	if(vals==3 || vals==4)
	{
	    if(!(document.mess.isSearch[0].checked || document.mess.isSearch[1].checked))
        {
            alert("Please choose whether you've got results wanted.");
			document.mess.isSearch[0].focus();
            return false;
        }
		if (window.document.mess.content_f.value == "")
        {
             alert("Please enter your suggestions.");
             document.mess.content_f.focus();
             return false;
        }
		vals=(document.mess.isSearch[0].checked==true)?"Y":"N";
		var checker_ajax = new Ajax_search("/SearchMessage.php");
		if(checker_ajax.post("mode=post&sKey="+$('sKey').value+"&isSearch="+vals+"&content="+$('content_f').value)==1)
			{
				sussecc_feedback();
				}
		/*
		else
			{
				alert("Wrong verification code");
				}
		*/
	}
	else
	{
		var checker_ajax = new Ajax_search("/SearchMessage.php");
		if(checker_ajax.post("mode=post&sKey="+escape($('sKey').value)+"&isSearch="+vals+"&content="+$('content_f').value+"&flag_s=yes")==1)
			{
				sussecc_feedback();
				}
		/*
		else
			{
				alert("Wrong verification code");
				}
		*/
	}
} 
function sussecc_feedback()
	{
		$("feedback_search_1").style.display="none";
		$("feedback_search_2").style.display="none";
		$("feedback_search").innerHTML="Thanks for your cooperation, and CUCAS will improve searching quality according to your suggestions!";
		$("feedback_search").style.paddingBottom="15px";
		$("feedback_search").style.color="red";
		}
function feedback_submit(value_feedback)
{
	var num_1=value_feedback-1;
	document.getElementsByName('isSearch').checked=true;
	var value_s=(value_feedback==1)?"Y":"N";
	SearchMessage(value_s);
	}

window.onload=function(){
	var Ptr=document.getElementsByTagName("tr");
	for(var i=0;i<Ptr.length;i++) {
		Ptr[i].onmouseover=function(){
		this.tmpClass=this.className;
		this.className = "t3";
		
		};
		Ptr[i].onmouseout=function(){
		this.className=this.tmpClass;
		};
	}
	for(var i=1;i<$('subjectOne').length;i++)
		{
			if($('subjectOne').options[i].value==$('subjectOneID').value)
				$('subjectOne').options[i].selected=true;
			}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
var x,y 
var drag_=false 
var D=new Function('obj','return document.getElementById(obj);') 
var IE=new Function('','if(navigator.appName.indexOf("Explorer")>=0)return 1;if(navigator.appName.indexOf("Netscape")>=0)return 2') 
function Move_obj(obj){//1 
                     D(obj).onmousedown=function(e){drag_=true//4 
                              with(this){style.position="absolute";temp1=offsetLeft;temp2=offsetTop;//5 
                              if(IE()==1){x=event.clientX;y=event.clientY//6 
                                  document.onmousemove=function(e){//7 
                                     if(drag_==false)return false 
                                     with(this){style.left=temp1+event.clientX-x+"px";style.top=temp2+event.clientY-y+"px"} 
                                     }//7 
                              }//6 
                              if(IE()==2){x=e.pageX;y=e.pageY;//8 
                                  document.onmousemove=function(e){//9 
                                     if(drag_==false)return false 
                                     with(this){style.left=temp1+e.pageX-x+"px";style.top=temp2+e.pageY-y+"px"} 
                                     }//9 
                              }//8 
                        }//5 
           			document.onmouseup=new Function("drag_=false") 
                     }//4 
}//1 
function change(id){
   	document.getElementById(id).src = '/antispamex01.php?'+Math.random(1);
	}

// JavaScript Document
//引导进入比较页
function compareItems(num)
{
	var school_id_var="";
	var num_top=0;
	var flag_compare=false;
	for(var i=1;i<=num;i++)
		{
			if($("sID"+i).checked==true)
			{
				school_id_var=($("sID"+i).value+","+school_id_var);
				num_top++;
				}
			
			}
	if(num_top>4)
		{
		alert("Comparing schools cannot exceed 4!");
		return;
		}
	(school_id_var!="")?flag_compare=true:"";
	var Url=window.location.href;
	var u=Url.split("?");
	var ul=(u.length>1)?u[1].split("#"):"list=all";
	var var_le=(u.length>1)?ul[0]:ul;
	(flag_compare==false)?alert("Please click check box to add a school to compare!"):window.open("cucas_schoo_compare.php?"+var_le+"&back_Page="+$("back_Page").value+"&school_id="+school_id_var.substring(0,(school_id_var.length-1)));	
	}

function CollectItems(num)
{
	var school_id_var="";
	var num_top=0;
	var flag_compare=false;
	for(var i=1;i<=num;i++)
		{
			if($("sID"+i).checked==true)
			{
				school_id_var=($("sID"+i).value+","+school_id_var);
				num_top++;
				}
			
			}
	if(num_top < 1)
	{
		alert("Please click check box to collect the school!");
		return;
	}else{
		window.open (DomainnameName+'Personal/uMyCollection.php?listID='+school_id_var+'&task=add&kind=school&sid=1'); //应该跳转到申请页面；
	}
}