﻿function DateSelector(InstanceName) {
    //对象名称
    this.instanceName = InstanceName;
    //保存结果的表单域
    this.oResultField = null;

    //选择器的标题
    this.strTitle = "職位類型選擇";

    //放置选择器的div的id
    this.divId = InstanceName + "Div";

    //点击的按钮
    this.but = null;

    //函数
    this.Init = dateSelectorInit;
    this.checkedBox = dateCheckedBox;
    this.setTitle = dateSetTitle
    this.showSelector = showDateSelector;
    this.initResult = initDateResult;

    //this.chooseType=chooseType;//用于点击父类：当子类隐藏时，父类选中并添加到结果中，当子类显示父类设为没选中

}

function dateSetTitle(strTitle) {
    this.strTitle = strTitle;
}
var isIe=(document.all)?true:false;
//建立selector的各个层次的容器（div，span等）
function dateSelectorInit() {

    var objJobType = document.getElementById(this.divId);
    if (objJobType != null) {
        return;
    }

    
    var styleStr=(isIe)?"filter:alpha(opacity=70);":"opacity:0.7;";
    //var divHtml = "<div id=\"bgDiv\" style=\"background:#CCC;filter:alpha(opacity=70);opacity:0.7;position:absolute;left:0px;top:0px;display:none;z-index:1;\"></div><DIV id=\"" + this.divId + "\" onmousedown=\"drag(event,this)\" style=\'width:450px;height:auto;DISPLAY:none; Z-INDEX:999; POSITION:absolute;  BACKGROUND-COLOR:#ffffff; bordercolor:#ffffff'';>";
    var divHtml = "<div id=\"bgDiv\" style=\"background:#CCC;"+styleStr+"position:absolute;left:0px;top:0px;display:none;width:1000%;z-index:1;\"></div><DIV id=\"" + this.divId + "\" onmousedown=\"drag(event,this)\" style=\'width:450px;height:auto;DISPLAY:none; Z-INDEX:999; POSITION:absolute;  BACKGROUND-COLOR:#ffffff; bordercolor:#ffffff'';>";
    divHtml += "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
    divHtml += "<tr>";
    divHtml += "<td width=\"5\" height=\"5\"><img src=\"../controls/Search/div_01.gif\"></td><td background=\"../controls/Search/div_02.gif\"></td>";
    divHtml += "<td><img src=\"../controls/Search/div_03.gif\"></td></tr>";
    divHtml += "<tr>";
    divHtml += "<td background=\"../controls/Search/div_04.gif\"></td>";
    divHtml += "<td valign=\"top\" bgcolor=\"#FFFFFF\">";
    divHtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"divtt\">";
    divHtml += "<tr>";
    divHtml += "<td class=\"tt\"><font color=\"#FFFFFF\">" + this.strTitle + "</font></td>";
    divHtml += "<td align=\"right\"><a href=\"javascript:openBgDiv(0);showSelect('" + this.divId + "');divClose('" + this.divId + "');\"><font color=\"#FFFFFF\">[確定]</font></a> <a href=\"javascript:openBgDiv(0);showSelect('" + this.divId + "');divClose('" + this.divId + "');\"><font color=\"#FFFFFF\">[關閉]</font></a></td>";
    divHtml += "</tr>";
    divHtml += "</table>";
    divHtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
    divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(11000,'會計'," + this.instanceName + ")\" style='cursor:pointer'>會計</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(12000,'行政/秘書'," + this.instanceName + ")\" style='cursor:pointer'>行政/秘書</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(13000,'廣告'," + this.instanceName + ")\" style='cursor:pointer'>廣告</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(14000,'航空'," + this.instanceName + ")\" style='cursor:pointer'>航空</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(15000,'銀行及金融'," + this.instanceName + ")\" style='cursor:pointer'>銀行及金融</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(16000,'建築設計'," + this.instanceName + ")\" style='cursor:pointer'>建築設計</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(17000,'商務分析'," + this.instanceName + ")\" style='cursor:pointer'>商務分析</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(18000,'商務拓展/合作'," + this.instanceName + ")\" style='cursor:pointer'>商務拓展/合作</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(19000,'飲食'," + this.instanceName + ")\" style='cursor:pointer'>飲食</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(20000,'公司秘書'," + this.instanceName + ")\" style='cursor:pointer'>公司秘書</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(21000,'客戶服務'," + this.instanceName + ")\" style='cursor:pointer'>客戶服務</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(22000,'設計'," + this.instanceName + ")\" style='cursor:pointer'>設計</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(23000,'教育'," + this.instanceName + ")\" style='cursor:pointer'>教育</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(24000,'各類工程'," + this.instanceName + ")\" style='cursor:pointer'>各類工程</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(25000,'畢業生/實習生'," + this.instanceName + ")\" style='cursor:pointer'>畢業生/實習生</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(26000,'博彩會展'," + this.instanceName + ")\" style='cursor:pointer'>博彩會展</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(27000,'酒店及旅遊'," + this.instanceName + ")\" style='cursor:pointer'>酒店及旅遊</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(28000,'健康及美容'," + this.instanceName + ")\" style='cursor:pointer'>健康及美容</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(29000,'人力資源'," + this.instanceName + ")\" style='cursor:pointer'>人力資源</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(30000,'資訊科技'," + this.instanceName + ")\" style='cursor:pointer'>資訊科技</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(31000,'保險'," + this.instanceName + ")\" style='cursor:pointer'>保險</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(32000,'法律'," + this.instanceName + ")\" style='cursor:pointer'>法律</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(33000,'物流'," + this.instanceName + ")\" style='cursor:pointer'>物流</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(34000,'製造業'," + this.instanceName + ")\" style='cursor:pointer'>製造業</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(35000,'市場營銷'," + this.instanceName + ")\" style='cursor:pointer'>市場營銷</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(36000,'新聞媒介'," + this.instanceName + ")\" style='cursor:pointer'>新聞媒介</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(37000,'衛生醫療'," + this.instanceName + ")\" style='cursor:pointer'>衛生醫療</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(38000,'推銷規劃'," + this.instanceName + ")\" style='cursor:pointer'>推銷規劃</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(39000,'地產/物業'," + this.instanceName + ")\" style='cursor:pointer'>地產/物業</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(40000,'公共關係'," + this.instanceName + ")\" style='cursor:pointer'>公共關係</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(41000,'採購'," + this.instanceName + ")\" style='cursor:pointer'>採購</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(42000,'品質管理'," + this.instanceName + ")\" style='cursor:pointer'>品質管理</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(43000,'零售及經銷'," + this.instanceName + ")\" style='cursor:pointer'>零售及經銷</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(44000,'研究及開發'," + this.instanceName + ")\" style='cursor:pointer'>研究及開發</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(45000,'銷售'," + this.instanceName + ")\" style='cursor:pointer'>銷售</td></tr>";
	
	divHtml += "<tr><td align=\"left\" onclick=\"openBgDiv(0);dateClick(46000,'貿易'," + this.instanceName + ")\" style='cursor:pointer'>貿易</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(47000,'翻譯'," + this.instanceName + ")\" style='cursor:pointer'>翻譯</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(48000,'運輸/船舶'," + this.instanceName + ")\" style='cursor:pointer'>運輸/船舶</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick(49000,'其他'," + this.instanceName + ")\" style='cursor:pointer'>其他</td><td align=\"left\" onclick=\"openBgDiv(0);dateClick('','全部'," + this.instanceName + ")\" style='cursor:pointer'>全部</td><td align=\"left\" style='cursor:pointer'></td></tr>";
	
    divHtml += "</table>";
    divHtml += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"divtt\">";
    divHtml += "<tr>";
    divHtml += "<td align=\"right\"><a href=\"javascript:openBgDiv(0);showSelect('" + this.divId + "');divClose('" + this.divId + "');\"><font color=\"#FFFFFF\">[確定]</font></a> <a href=\"javascript:openBgDiv(0);showSelect('" + this.divId + "');divClose('" + this.divId + "');\"><font color=\"#FFFFFF\">[關閉]</font></a></td>";
    divHtml += "</tr>";
    divHtml += "</table>";
    divHtml += "</td>";
    divHtml += "<td background=\"../controls/Search/div_06.gif\">";
    divHtml += "</td></tr>";
    divHtml += "<tr><td>";
    divHtml += "<img src=\"../controls/Search/div_07.gif\"></td>";
    divHtml += "<td background=\"../controls/Search/div_08.gif\"></td>";
    divHtml += "<td width=\"1\" height=\"1\">";
    divHtml += "<img src=\"../controls/Search/div_09.gif\"></td>";
    divHtml += "</tr></table>";
    divHtml += "</div>"
    document.write(divHtml);

}

/**显示选择器，如果选择器的第一层还没有创建则要创建
@param oInstance 选择器对象
*/

function showDateSelector(objBut, resultField) {
    this.but = objBut;
    this.oResultField = resultField;

    setDivInCenter(this.divId);

    objJobType = document.getElementById(this.divId);
    objJobType.style.display = "";
    hiddenSelect(this.divId);

    return;
}

/**选中某一类型后显示下一级所有类型或没有下级时更改选择结果
@param cityId 选中的类型
@param level 选中的类型所处的级别的下一级别。级别从1开始
*/
function dateCheckedBox(days, strName) {
    this.oResultField.value = days;
    this.but.value = strName;
    showSelect(this.divId);
    divClose(this.divId);
}



function dateClick(days, strName, oInstance) {
    oInstance.checkedBox(days, strName);
}

/*显示默认结果
oResultField:保存结果的隐藏域对象
objBut触发选择器的按钮对象
*/
function initDateResult(oResultField, objBut) {
    this.oResultField = oResultField;
    this.but = objBut;
    if (this.oResultField.value == 11000) {
        this.but.value = "會計";
    } else if (this.oResultField.value == 12000) {
        this.but.value = "行政/秘書";
    } else if (this.oResultField.value == 13000) {
        this.but.value = "廣告";
    } else if (this.oResultField.value == 14000) {
        this.but.value = "航空";
    } else if (this.oResultField.value == 15000) {
        this.but.value = "銀行及金融";
    } else if (this.oResultField.value == 16000) {
        this.but.value = "建築設計";
    } else if (this.oResultField.value == 17000) {
        this.but.value = "商務分析";
    } else if (this.oResultField.value == 18000) {
        this.but.value = "商務拓展/合作";
    } else if (this.oResultField.value == 19000) {
        this.but.value = "飲食";
    } else if (this.oResultField.value == 20000) {
        this.but.value = "公司秘書";
    } else if (this.oResultField.value == 21000) {
        this.but.value = "客戶服務";
    }else if (this.oResultField.value == 22000) {
        this.but.value = "設計";
    } else if (this.oResultField.value == 23000) {
        this.but.value = "教育";
    } else if (this.oResultField.value == 24000) {
        this.but.value = "各類工程";
    } else if (this.oResultField.value == 25000) {
        this.but.value = "畢業生/實習生";
    } else if (this.oResultField.value == 26000) {
        this.but.value = "博彩會展";
    } else if (this.oResultField.value == 27000) {
        this.but.value = "酒店及旅遊";
    } else if (this.oResultField.value == 28000) {
        this.but.value = "健康及美容";
    } else if (this.oResultField.value == 29000) {
        this.but.value = "人力資源";
    } else if (this.oResultField.value == 30000) {
        this.but.value = "資訊科技";
    } else if (this.oResultField.value == 31000) {
        this.but.value = "保險";
    } else if (this.oResultField.value == 32000) {
        this.but.value = "法律";
    } else if (this.oResultField.value == 33000) {
        this.but.value = "物流";
    } else if (this.oResultField.value == 34000) {
        this.but.value = "製造業";
    } else if (this.oResultField.value == 35000) {
        this.but.value = "市場營銷";
    } else if (this.oResultField.value == 36000) {
        this.but.value = "新聞媒介";
    } else if (this.oResultField.value == 37000) {
        this.but.value = "衛生醫療";
    } else if (this.oResultField.value == 38000) {
        this.but.value = "推銷規劃";
    } else if (this.oResultField.value == 39000) {
        this.but.value = "地產/物業";
    } else if (this.oResultField.value == 40000) {
        this.but.value = "公共關係";
    } else if (this.oResultField.value == 41000) {
        this.but.value = "採購";
    } else if (this.oResultField.value == 42000) {
        this.but.value = "品質管理";
    } else if (this.oResultField.value == 43000) {
        this.but.value = "零售及經銷";
    } else if (this.oResultField.value == 44000) {
        this.but.value = "研究及開發";
    } else if (this.oResultField.value == 45000) {
        this.but.value = "銷售";
    } else if (this.oResultField.value == 46000) {
        this.but.value = "貿易";
    } else if (this.oResultField.value == 47000) {
        this.but.value = "翻譯";
    } else if (this.oResultField.value == 48000) {
        this.but.value = "運輸/船舶";
    } else if (this.oResultField.value == 49000) {
        this.but.value = "其他";
    }
}
function $(o){ //获取对象
 if(typeof(o) == "string")
 return document.getElementById(o);
 return o;
}
/* 鼠标拖动 */
var oDrag = "";
var ox,oy,nx,ny,dy,dx;
function drag(e,o){
 var e = e ? e : event;
 var mouseD = document.all ? 1 : 0;
 if(e.button == mouseD)
 {
  //oDrag = o.parentNode;
  //oDrag = 'divId';
  oDrag = o;
  //alert(oDrag.id);DateSelectorsearch1$DateSelectorjobtypeDiv
  //alert(document.getElementById("DateSelectorsearch1$DateSelectorjobtypeDiv").style.top);
  ox = e.clientX;
  oy = e.clientY; 
 }
}
function dragPro(e){
 if(oDrag != "")
 {
  var e = e ? e : event;
  //$(oDrag).style.left = $(oDrag).offsetLeft + "px";
  //$(oDrag).style.top = $(oDrag).offsetTop + "px";
//  dx = parseInt($(oDrag).style.left);
//  dy = parseInt($(oDrag).style.top);
  dx = parseInt($(oDrag).offsetLeft);
  dy = parseInt($(oDrag).offsetTop);
  //dx = $(oDrag).offsetLeft;
  //dy = $(oDrag).offsetTop;
  nx = e.clientX;
  ny = e.clientY;
  
  $(oDrag).style.left = (dx + ( nx - ox )) + "px";
  $(oDrag).style.top = (dy + ( ny - oy )) + "px";
  ox = nx;
  oy = ny;
 }
}
document.onmouseup = function(){oDrag = "";}
document.onmousemove = function(event){dragPro(event);}
function openBgDiv(state){ //遮照打开关闭控制
 if(state == 1)
 {
  $("bgDiv").style.display = "block";
  //var h = document.body.offsetHeight > document.documentElement.offsetHeight ? document.body.offsetHeight : document.documentElement.offsetHeight;
 //alert(document.body.offsetHeight);
 //alert(document.documentElement.offsetHeight);
	//window.screen.availHeight-165;
    //alert("当前窗口宽："+document.body.offsetWidth+"；　高："+document.body.clientHeight+" and "+(window.screen.availHeight));
  //$("bgDiv").style.height = h+window.screen.availHeight + "px";
  //$("bgDiv").style.width=window.screen.availWidth-21+"px";
  //$("bgDiv").style.height = document.body.clientHeight+window.screen.availHeight;
  //$("bgDiv").style.height = document.body.clientHeight+"px";
  var bWidth=parseInt(document.documentElement.scrollWidth);
  var bHeight=parseInt(document.documentElement.scrollHeight);
  $("bgDiv").style.width=(isIe)?(window.screen.availWidth-21+"px"):"100%";
  $("bgDiv").style.height =(isIe)?(document.body.clientHeight+"px"):(bHeight+"px");
 }
 else
 {
  $("bgDiv").style.display = "none";
 } 
}

//回車事件
var isIE = navigator.userAgent.indexOf("MSIE")>0;
function KeyDown(obj,ib)
{
    obj.onkeydown = function(e)
    {
        //alert('0');
        if(isIE) // window.eventIE
        {
            //if(event.ctrlKey && getkeyCode(event) == 13)//Ctrl+回車
            if(getkeyCode(event) == 13)//回車
            {
                var obj = document.getElementById(ib);
                obj.click();
                event.returnValue = false;
            }
        }
        else
        {
            //if(e.ctrlKey && getkeyCode(e) == 13)//Ctrl+回車
            if(getkeyCode(e) == 13)//回車
            {
                 var obj = document.getElementById(ib);
                 obj.click();
                 return false;
            }
        }
    } 
}
function getkeyCode(e)
{
    var keynum = "";
    if(isIE) // window.event IE
    {
        keynum = e.keyCode;
    }
    else // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    return keynum;
}
function NoSubmit(obj)
{
    obj.onkeydown = function(e)
    {
        //alert('0');
        if(isIE) // window.eventIE
        {
            //if(event.ctrlKey && getkeyCode(event) == 13)//Ctrl+回車
            if(getkeyCode(event) == 13)//回車
            {
                return false;
            }
        }
        else
        {
            //if(e.ctrlKey && getkeyCode(e) == 13)//Ctrl+回車
            if(getkeyCode(e) == 13)//回車
            {
                 return false;
            }
        }
        return true;
    } 
}
