﻿var ApplicationPath = '';
/*function initBodyWidth(){var cw=document.body.clientWidth-994; document.body.style.marginLeft=cw/2;}*/
/*检查永久性Cookie是否可用*/
function CookieEnable(){
    if(navigator.cookiesEnabled)return true;
    document.cookie = "testcookie=yes;";
    var cookieSet = document.cookie;
    if (cookieSet.indexOf("testcookie=yes")>-1)return true;
    return false;
}




var nowTime=new Date().getTime();

function GetNews(){Ajax.get("../Ajax/Default/News.aspx?CT="+nowTime,function finishLogin(msg){$("left1-3").innerHTML=msg;});}
//function GetTuiJian(){Ajax.get("Ajax/Default/TuiJian.aspx",function finishLogin(msg){$("left3-3").innerHTML=msg;});}
//function GetLatestJobs(){Ajax.get("Ajax/Default/LatestJobs.aspx",function finishLogin(msg){$("latestJobs").innerHTML=msg;},function(msg){alert(msg);});}
//function GetRecruitment(){Ajax.get("Ajax/Default/Recruitment.aspx",function finishLogin(msg){$("Left5-2").innerHTML=msg;});}
function GetLatestResume(){Ajax.get("Ajax/Default/LatestResume.aspx",function finishLogin(msg){$("R52").innerHTML=msg;});}
function GetTjLOGO(){Ajax.get("Ajax/Default/LOGO.aspx?CT="+nowTime,function finishLogin(msg){$("right4-2").innerHTML=msg;});}
function GetLeftLog(){Ajax.get("Ajax/Default/IndexLOGO.aspx?Type=4&Num=6&CT="+nowTime,function finishLogin(msg){ $("left1-1").innerHTML=msg;});}
function GetRightLog(){Ajax.get("Ajax/Default/IndexLOGO.aspx?Type=5&Num=4&CT="+nowTime,function finishLogin(msg){$("right1-1").innerHTML=msg;});}
//function GetSpecial(){Ajax.get("Ajax/Default/Special.aspx",function finishLogin(msg){$("Left6-2").innerHTML=msg;});}
//function GetOtherArticles(){Ajax.get("Ajax/Default/OtherArticles.aspx?CT="+nowTime,function finishLogin(msg){ $("otherArt").innerHTML=msg;});}
//function GetLinks(){Ajax.get("Ajax/Default/Links.aspx",function finishLogin(msg){$("bottom1").innerHTML=msg;});}

function InitPageData(){
 GetNews(); 
 // GetTuiJian(); 
//  GetRecruitment();
//  GetLatestJobs(); 
   //GetLeftLog();
 //  GetRightLog();
 // GetTjLOGO(); 
 // GetLatestResume();
 // GetSpecial(); 
 // GetOtherArticles(); 
 // GetLinks();
}

function OpenDataLayer(url,parentID,ValueID)
{
    var objBody = document.getElementsByTagName('body').item(0);
    //建立背景遮罩层
    if(!$(parentID)){
        var parentDiv = document.createElement('iframe');
        parentDiv.id = parentID;
		parentDiv.style.position = 'absolute';
		parentDiv.style.zIndex = 999;
		parentDiv.style.left = parentDiv.style.top = '0px';
		parentDiv.style.backgroundColor = '#999';
		parentDiv.style.display = 'none';
	parentDiv.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50,finishOpacity=50,style=0)';
		parentDiv.style.opacity = 0.5;
        parentDiv.oncontextmenu = function(){ return false; }
        objBody.appendChild(parentDiv);
    }
    //重置遮罩层的高度和宽度，避免页面变化后，无法自动设置全屏幕的遮罩
	$(parentID).style.width = ((document.documentElement.clientWidth>document.documentElement.scrollWidth)?document.documentElement.clientWidth:document.documentElement.scrollWidth) + "px";
	$(parentID).style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight) + "px";
    //新建iframe数据显示层
    if(!$(ValueID)){
        var DataLayer =document.createElement('iframe');
        DataLayer.id = ValueID;
        DataLayer.style.zIndex = 1000;
        DataLayer.style.position = 'absolute'; 
        DataLayer.style.border = "0px";
        DataLayer.style.overflow = "hidden";
        DataLayer.style.backgroundColor = '#fff';
        DataLayer.style.width = '100px';//默认，等待页面加载的时候再处理
        DataLayer.style.height = '100px';	
DataLayer.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100,finishOpacity=100,style=0)';
		DataLayer.style.opacity = 1;
	    DataLayer.style.left = (((document.documentElement.clientWidth>document.documentElement.scrollWidth)?document.documentElement.clientWidth:document.documentElement.scrollWidth) - 100)/2 + 'px';
        DataLayer.style.top = '100px';
	    objBody.appendChild(DataLayer);
    }
    $(ValueID).src = url;
    $(ValueID).style.display = '';
    $(parentID).style.display = '';
}

function OpenAreaLayerWindow(clientInputID,showUnlimited,parentID,ValueID){var url = MapPath('/Common/AreaPop.htm?clientInputID=' + clientInputID+'&locklayer=' + parentID +'&datalayer=' + ValueID); var a=OpenDataLayer(url,parentID,ValueID);}
//映射目标路径
function MapPath(path){var val = ApplicationPath + path; return val;}

function GotoJobsUrl(){
  var keyWords=$V("searchK").trim();
  var SerachUrl = "";
  if(keyWords==""){alert("请输入搜索关键字！"); return false;}
  else SerachUrl="NewSearchResult.aspx?key="+keyWords +"&keyType="+GetKeyIndex();
  var area=$V("tbxSelectedArea").trim();
  if(area!="") SerachUrl+="&AID="+area;
  window.location.href = SerachUrl;
  return false;
}
function GetKeyIndex(){
  var as=document.getElementById("stL").getElementsByTagName("a");
  for(var i=0;i<as.length;i++){
    if(as[i].className.trim()=="curSearch")return i;
  }
}
function ClearCounts(){
  var key=$V("comKey").trim();
  var inputKey=$("comKey");
  if(key=="输入姓名、简历名、招聘职位等关键词搜索人才")inputKey.value="";
  inputKey.onblur=function(){
    if($V("comKey").trim()=="")inputKey.value="输入姓名、简历名、招聘职位等关键词搜索人才";
  }
}
function ComSearchKey(){
  var key=$V("comKey").trim();
  if(key=="" || key=="输入姓名、简历名、招聘职位等关键词搜索人才" ){ alert("请填写搜索关键词进行搜索！"); return false; }
  var SerachUrl="/Company/SearchResultMoreInfo2.aspx?Keywords="+key;
  window.location.href=SerachUrl;
  return false;  
}

function ComSearchCon(){
  var key=$V("comKey").trim();
  var Industry = $V("tbxSelectedIndustry3").trim();
  var SerachUrl="";
  if((key=="" || key=="输入姓名、简历名、招聘职位等关键词搜索人才")&& Industry==""){ alert("搜索关键词或行业类别至少选择一项！"); return false; }
  var Professional=$("ddlProfessional").options[$("ddlProfessional").selectedIndex].value.trim();
  SerachUrl="/Company/SearchResultMoreInfo2.aspx?Keywords="+key+"&Industry="+Industry+"&Professional="+Professional;
  window.location.href=SerachUrl;
  return false;  
}
function SetKey(id){
  var text=$(id).innerHTML;
  $("searchK").value=text
  return false;
}
function addEvent(){
  var as=$("rmzwss").getElementsByTagName("a");
  for(var i=0;i<as.length;i++){
    as[i].href="javascript:return false;";
    as[i].id="rm"+i;
    as[i]["onclick"]=function(){ return SetKey(this.id);}
  }
}
function showOrHid(){
   var childs=document.getElementById("stL").getElementsByTagName("a");
   for(var i=0;i<childs.length;i++){
     childs[i].temp=i;
     childs[i].onclick=function(){exectEvent(this.temp);}
   }
   function exectEvent(cur){
     for(var i=0;i<childs.length;i++){
       if(i==cur)childs[i].className="curSearch";
       else childs[i].className=" ";
     }
  }
}



function InitMarque(){
  Ajax.get("/Ajax/ServerTime.aspx",showDTime);
  function showDTime(msg){
        var times=msg.split(';');
        var nowstr=times[1].split(' ')[0];
        var ns = nowstr.split('-');
        var now = new Date(parseInt(ns[0],10),parseInt(ns[1],10)-1,parseInt(ns[2],10))
        var html="<marquee onmouseover='this.stop()' onmouseout='this.start()' behavior='alternate' scrollamount=2  bgcolor ='#fdf7e6'>";
        html+="<div style='width:750px;height:22px; line-height:22px;vertical-align:middle; display:inline; float:left; color:#333;'>兴达人力·2010年第三届·英雄会英雄 大型中高级人才交流会定于１１月１０-１３日(周三至周六)隆重举行 敬请关注</div>";
//        html+=GetDate(now)+"   英雄会英雄开幕还有 <span style='color:red; font-size:16px; font-weight:bold;'>";
//        var num = DateDiff(now,'2010-08-10');
//        html+= num+"</span> 天</div>";
　//        html+="<iframe src='http://m.weather.com.cn/m/pn1/weather.htm' style=' display:inline; float:left;' width='250' height='20' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' scrolling='no'></iframe>";
　//        html+="</marquee>";
　//        $("wether").style.height=22;
        $('wether').innerHTML=html;
        
        var dnum = '<div style="width:16px; text-align:center; font-weight:bolder; font-size:20px; margin-left:148px; margin-top:-81px; *margin-top:-74px; height:18px;">'+num+'</div>';
        $('r12LR').innerHTML += dnum;
    }    
}

function GetDate(now){
   return now.toLocaleDateString()+"  "+ GetWeek(now.getDay());
}

function GetDate2(){}

function GetWeek(day){
   switch(day){
      case 1:return "星期一";
      case 2:return "星期二";
      case 3:return "星期三";
      case 4:return "星期四";
      case 5:return "星期五";
      case 6:return "星期六";
      case 0:return "星期日";
   }
}

function DateDiff(priDate,aftDate){
   priDate=FormatDate(priDate);aftDate=FormatDate(aftDate);
   var ps = priDate.split('-'),as = aftDate.split('-');
   var py= parseInt(ps[0],10),ay = parseInt(as[0],10);
   var pm =parseInt(ps[1],10),am = parseInt(as[1],10);
   var pd =parseInt(ps[2],10),ad = parseInt(as[2],10);
   var d=0;
   if(py<ay){
       for(var i = py+1;i<ay;i++){
          var isleap = IsLeap(i);
          if(isleap)d+=366;
          else d+=365;
       }
       for(var i=pm+1;i<13;i++){d+=Day(i);}//py年
       for(var i=1;i<am;i++){d+=Day(i);}//ay年
       d+=Day(pm)-pd; d+=ad;
       if(pm<=2 && IsLeap(py))d+=1;
       if(am>2 && IsLeap(ay))d+=1;
   }
   else if(py==ay){ 
       for(var i=pm+1;i<am;i++){
           d+=Day(i);
       }
       if(pm==am)d+=ad-pd;
       else{
           d+=Day(pm)-pd;
           d+=ad;
           if(IsLeap(py) && pm<=2)ad+=1;
       }  
   }
   return d;
}

function IsLeap(year){
   if( year%400==0 || (year%4==0 && year%100==0) )return true;
   return false;
}

function FormatDate(date){
   if(typeof date == 'string')return date;
   return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
}

function Day(m){
   switch(m){
      case 4:
      case 6:
      case 9:
      case 11: return 30;
      case 2: return 28;
      default: return 31;
   }
   return 0;
}

function NoError() {    
return true;    
}   
//window.onerror = NoError; 


