﻿function checkItem(strFun,strVal,divName){
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    if (!http_request) {
      alert('Cannot create an XMLHTTP instance');
      return false;
    }
    http_request.onreadystatechange = function() { 
        if (http_request.readyState == 4) {
          if (http_request.status == 200) {
          	IgotIt = http_request.responseText;
          	if(divName == undefined){
			   done = eval(IgotIt)
			}else{
			   document.getElementById(divName).innerHTML = IgotIt;
			}
          } else {
            if(document.getElementById(divName) != null){
                document.getElementById(divName).innerHTML = http_request.responseText;
            }else{
                alert('There was a problem with the request.');
            }    
                
          }
        }
    };
    var url = '/includesU/resumeCheckItem.asp?itemfun=' + strFun + '&itemVal=' + escape(strVal)
    http_request.open('GET', url, true);
    http_request.send(null);
}

function checkItemOther(divName,url){
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
      try {
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }
    if (!http_request) {
      alert('Cannot create an XMLHTTP instance');
      return false;
    }
    http_request.onreadystatechange = function() { 
        if (http_request.readyState == 4) {
          if (http_request.status == 200) {
          	IgotIt = http_request.responseText;
          	if(divName == undefined){
			   done = eval(IgotIt)
			}else{
			   document.getElementById(divName).innerHTML = IgotIt;
			}
          } else {
            if(document.getElementById(divName) != null){
                document.getElementById(divName).innerHTML = http_request.responseText;
            }else{
                alert('There was a problem with the request.');
            }    
                
          }
        }
    };
    http_request.open('GET', url, true);
    http_request.send(null);
}

function chkLiveSearch(kind,tno,sno,tcolor){ //活版搜尋
    for(j=0;j<tno;j++){
	    var imgShow = document.getElementById(kind+j+'_img');
	    var divShow = document.getElementById(kind+j);
	    if(imgShow != null && divShow != null){
	        if(j == sno){
			    //imgShow.src = '/images/default/'+tcolor+'/label0'+(j+1)+'-o.gif';
			    //if(j == 0){
			    //    imgShow.style.backgroundImage = 'url(/images/default/'+tcolor+'/label01-o.gif)';
                //}else{
                //   imgShow.style.backgroundImage = 'url(/images/default/'+tcolor+'/label02-o.gif)';
                //}
                //imgShow.style.color = '#FFFFFF';
			    divShow.style.display = '';
			    divShow.style.visibility = 'visible';
			    if(document.getElementById('twinsStar') != null){if(j > 1){document.getElementById('twinsStar').style.display = 'none';}else{document.getElementById('twinsStar').style.display = '';}}
		    }else{
			    //imgShow.src = '/images/default/'+tcolor+'/label0'+(j+1)+'.gif';
			    //if(j == 0){
			    //    imgShow.style.backgroundImage = 'url(/images/default/'+tcolor+'/label01.gif)';
                //}else{
                //    imgShow.style.backgroundImage = 'url(/images/default/'+tcolor+'/label02.gif)';
                //}
                //if(tcolor == 'blue'){
                //    imgShow.style.color = '#3C57D0';
                //}else{
                //    imgShow.style.color = '#636363';    
                //}                    
			    divShow.style.display = 'none';
			    divShow.style.visibility = 'hidden';
		    }
	    }
    }
}

  function chkBanner(kind,tno,sno){
	  //var divKind = document.getElementById(kind);
	  for(j=0;j<tno;j++){
		  var imgShow = document.getElementById(kind+j+'_img');
		  if(imgShow != null){
			  if(j == sno){
				  imgShow.src = '/images/icon_'+(j+1)+'on.gif';
			  }else{
				  imgShow.src = '/images/icon_'+(j+1)+'off.gif';
			  }
		  }
	  }
	  for(i=0;i<tno;i++){
		  var divShow = document.getElementById(kind+i);
		  if(divShow != null ){
			  if(i == sno){
				  //divKind.style.display = 'none';
				  divShow.style.display = '';			
			  }else{
				  divShow.style.display = 'none';			
			  }
		  }
	  }
	  
	  if(document.getElementById('twinsStart') != null){document.getElementById('twinsStart').style.display = 'none'}
  }

  function chkMore(kind,rep){
	  if(rep != 0){var intRep = rep-1;rep == 1;}
	  if(intRep == 0 || rep == 0){
		  for(i=0;i<99;i++){
			  var divKind = document.getElementById('tr'+kind+i);
			  if(divKind != null){
			      if(divKind.style.display == ''){
					  var x=i+1;
					  if(document.getElementById('tr'+kind+x) != null){
						  document.getElementById('tr'+kind+x).style.display = '';
						  divKind.style.display = 'none';
					  }else{
						  divKind.style.display = 'none';
						  document.getElementById('tr'+kind+'0').style.display = '';
					  }
					  break;
				  }else{
					  divKind.style.display = 'none';
				  }
			  }else{
			    if(document.getElementById('tr'+kind+'0') != null){
				    document.getElementById('tr'+kind+'0').style.display = '';
				}  
			  }
		  }
	  }
	  if(intRep == 1 || rep == 1){if(intRep ==0){intRep++};setTimeout("chkMore('"+kind+"'," + intRep + ")",5000);}
  }

  function chkMoreMore(kind){
	  for(i=0;i<99;i++){
		  var divKind = document.getElementById('tr'+kind+i+'0');
		  if(divKind != null){
			  chkMore(kind+i,2);
		  }
	  }	
  }
  
  function chkRadMore(kind){
    for(i=0;i<99;i++){
        if(document.getElementById('tr' + kind + i) == null){
            i--;
            break;
        }
    }
    
    var maxNum = i;
    var minNum = 0;
    var t = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
    //var now = new Date();
    //var s = now.getSeconds();
    //var t = (((s+i)%2)) ;
    if(i > 0){
        for(x=0;x<=i;x++){
            if(x == t){document.getElementById('tr' + kind + x).style.display = 'block';}else{document.getElementById('tr' + kind + x).style.display = 'none';}
        }
    }
  }

  function redir(lNo) {
	  location.href='/includes_xml/linkRedir.asp?lNo='+(lNo);
  }

function chkReset(formName){ //重置清空欄位值
    if(document.forms[formName]['keys'] != null && document.forms[formName]['keys'] != ''){document.forms[formName]['keys'].value = '';}
    if(document.forms[formName]['city0'] != null && document.forms[formName]['city0'] != ''){document.forms[formName]['city0'].value = '';}
    if(document.forms[formName]['city1'] != null && document.forms[formName]['city1'] != ''){document.forms[formName]['city1'].value = '';}
    if(document.forms[formName]['city2'] != null && document.forms[formName]['city2'] != ''){document.forms[formName]['city2'].value = '';}
    if(document.forms[formName]['city0Cht'] != null && document.forms[formName]['city0Cht'] != ''){document.forms[formName]['city0Cht'].value = '';}
    if(document.forms[formName]['city1Cht'] != null && document.forms[formName]['city1Cht'] != ''){document.forms[formName]['city1Cht'].value = '';}
    if(document.forms[formName]['city2Cht'] != null && document.forms[formName]['city2Cht'] != ''){document.forms[formName]['city2Cht'].value = '';} 
    if(document.forms[formName]['duty0'] != null && document.forms[formName]['duty0'] != ''){document.forms[formName]['duty0'].value = '';}
    if(document.forms[formName]['duty1'] != null && document.forms[formName]['duty1'] != ''){document.forms[formName]['duty1'].value = '';}
    if(document.forms[formName]['duty2'] != null && document.forms[formName]['duty2'] != ''){document.forms[formName]['duty2'].value = '';}
    if(document.forms[formName]['duty0Cht'] != null && document.forms[formName]['duty0Cht'] != ''){document.forms[formName]['duty0Cht'].value = '';}
    if(document.forms[formName]['duty1Cht'] != null && document.forms[formName]['duty1Cht'] != ''){document.forms[formName]['duty1Cht'].value = '';}
    if(document.forms[formName]['duty2Cht'] != null && document.forms[formName]['duty2Cht'] != ''){document.forms[formName]['duty2Cht'].value = '';}          
    if(document.forms[formName]['trade0'] != null && document.forms[formName]['trade0'] != ''){document.forms[formName]['trade0'].value = '';}
    if(document.forms[formName]['trade1'] != null && document.forms[formName]['trade1'] != ''){document.forms[formName]['trade1'].value = '';}
    if(document.forms[formName]['trade2'] != null && document.forms[formName]['trade2'] != ''){document.forms[formName]['trade2'].value = '';}
    if(document.forms[formName]['trade0Cht'] != null && document.forms[formName]['trade0Cht'] != ''){document.forms[formName]['trade0Cht'].value = '';}
    if(document.forms[formName]['trade1Cht'] != null && document.forms[formName]['trade1Cht'] != ''){document.forms[formName]['trade1Cht'].value = '';}
    if(document.forms[formName]['trade2Cht'] != null && document.forms[formName]['trade2Cht'] != ''){document.forms[formName]['trade2Cht'].value = '';}      
    if(document.forms[formName]['major0'] != null && document.forms[formName]['major0'] != ''){document.forms[formName]['major0'].value = '';}
    if(document.forms[formName]['major1'] != null && document.forms[formName]['major1'] != ''){document.forms[formName]['major1'].value = '';}
    if(document.forms[formName]['major2'] != null && document.forms[formName]['major2'] != ''){document.forms[formName]['major2'].value = '';}
    if(document.forms[formName]['major0Cht'] != null && document.forms[formName]['major0Cht'] != ''){document.forms[formName]['major0Cht'].value = '';}
    if(document.forms[formName]['major1Cht'] != null && document.forms[formName]['major1Cht'] != ''){document.forms[formName]['major1Cht'].value = '';}
    if(document.forms[formName]['major2Cht'] != null && document.forms[formName]['major2Cht'] != ''){document.forms[formName]['major2Cht'].value = '';}      
    if(document.forms[formName]['experience'] != null && document.forms[formName]['experience'] != ''){document.forms[formName]['experience'].selectedIndex = 0;}
    if(document.forms[formName]['compSkill_Title'] != null && document.forms[formName]['compSkill_Title'] != ''){document.forms[formName]['compSkill_Title'].value = '';}      
    if(document.forms[formName]['skill'] != null && document.forms[formName]['skill'] != ''){document.forms[formName]['skill'].value = '';}      
    if(document.forms[formName]['certify_Title'] != null && document.forms[formName]['certify_Title'] != ''){document.forms[formName]['certify_Title'].value = '';} 
    if(document.forms[formName]['certify'] != null && document.forms[formName]['certify'] != ''){document.forms[formName]['certify'].value = '';}      
    if(document.forms[formName]['capital'] != null && document.forms[formName]['capital'] != ''){document.forms[formName]['capital'].selectedIndex = 0;}
    if(document.forms[formName]['staff'] != null && document.forms[formName]['staff'] != ''){document.forms[formName]['staff'].selectedIndex = 0;}
    if(document.forms[formName]['salary'] != null && document.forms[formName]['salary'] != ''){document.forms[formName]['salary'].selectedIndex = 0;}
    if(document.forms[formName]['grade'] != null && document.forms[formName]['grade'] != ''){for(i=0;i<document.forms[formName]['grade'].length;i++){document.forms[formName]['grade'][i].checked = false;document.forms[formName]['grade'].selectedIndex = 0;}}
    if(document.forms[formName]['character'] != null && document.forms[formName]['character'] != ''){for(i=0;i<document.forms[formName]['character'].length;i++){document.forms[formName]['character'][i].checked = false;}}
    if(document.forms[formName]['attribute'] != null && document.forms[formName]['attribute'] != ''){for(i=0;i<document.forms[formName]['attribute'].length;i++){document.forms[formName]['attribute'][i].checked = false;}}
    if(document.forms[formName]['benefit'] != null && document.forms[formName]['benefit'] != ''){for(i=0;i<document.forms[formName]['benefit'].length;i++){document.forms[formName]['benefit'][i].checked = false;}}
}