﻿//key word check for index.jsp
	function checkField(formName){
		var keyin;
		var jobCatSel;
		var industSel;
		var areaSel;
		if( formName == "form3" ){		
			keyin = document.form3.keywordWanted.value;
			jobCatSel = document.form3.jobcat.value;
			industSel = document.form3.industry.value;
			areaSel = document.form3.jobAddrNo.value;
			
			if( (jobCatSel=="0" || jobCatSel=="99") && (industSel=="0" || industSel=="99") && (areaSel=="0" || areaSel=="99") && (keyin=="請輸入關鍵字" || keyin=="" || keyin.replace(/\s/g,"")=="") ){
ShowLayer('searchAlert');
				return false;
			}else{
					if( keyin == "請輸入關鍵字" ){
						document.form3.keywordWanted.value = '';
					}
					document.form3.submit();
			}			
		}
		
		if( formName == "form4" ){		
			keyin = document.form4.keywordWanted.value;			
			jobCatSel = document.form4.jobcat.value;
			industSel = document.form4.industry.value;
			areaSel = document.form4.jobAddrNo.value;
			
			if( (jobCatSel=="0" || jobCatSel=="99") && (industSel=="0" || industSel=="99") && (areaSel=="0" || areaSel=="99") && (keyin=="請輸入關鍵字" || keyin=="" || keyin.replace(/\s/g,"")=="") ){
ShowLayer('searchAlert');
				return false;
			}else{			
					if( keyin == "請輸入關鍵字" ){
						document.form4.keywordWanted.value = '';
					}
					document.form4.submit();
			}		
		}		
	}

	function requestJsonInfo(schoolId){
		var options={method : "GET",
					onSuccess:function(oXHR, oJson){var str = oXHR.responseText;
														if( str.length != 0){//return data
															var aSuggestions = str.evalJSON();
															displayJsonInfo(aSuggestions);
														}else{}
													},
					onFailure:function(){displayJsonInfo("出現錯誤"+ oXHR.statusText);}
					};
		var oRequest = new Ajax.Request("/Campus/defer/defer_ajZhengxiou.action?schoolId="+schoolId ,options);
	}
	
	function displayJsonInfo(aSuggestions){
		if( aSuggestions[0].isParticipant == "1" ){
			document.getElementById("mydiv").innerHTML = "<a href=\"javascript:void(0);\" onclick=\"window.open('/Campus/sttlrc/');return false;\" onmouseover=\"stopHere();\" onmouseout=\"restartHere();\" hidefocus=true>"+
														"<img src=\"/Campus/images/banner/100X200.gif\">"+
														"</a>";
			initEvent();
		}else if( aSuggestions[0].isParticipant == "2" ){
			document.getElementById("mydiv").innerHTML = "<a href=\"javascript:void(0);\" onclick=\"window.open('http://www.polygonworks.net/johnny/hcu/q3d/104_ex.htm');return false;\" onmouseover=\"stopHere();\" onmouseout=\"restartHere();\" hidefocus=true>"+
														"<img src=\"/Campus/images/banner/100X200_1.jpg\">"+
														"</a>";
			initEvent();
		}else{}
	}

	
var shoInterval;
var _x = 0;
var distance = 1;
var winH = document.body.clientHeight;
var divH = document.getElementById("mydiv").offsetHeight+200;
var yy = winH - divH;
var isP = false;
	function initEvent(){
		document.getElementById("mydiv").style.left = _x;
		document.getElementById("mydiv").style.top = yy;
		shoInterval = setInterval("moveEvent()",100);
	}

	function moveEvent(){
		if(isP){
			yy = yy + distance;
		}else{
			yy = yy - distance;
		}

		if(yy < 0){
			isP = true;
			yy=0;
		}
		else if( yy >= winH-divH){
			isP = false;
			yy = winH-divH;
		}
		document.getElementById("mydiv").style.top = yy + document.body.scrollTop;
	}

	function stopHere(){
		clearInterval(shoInterval);
	}

	function restartHere(){
		shoInterval = setInterval("moveEvent()",100);
	}	
