﻿function __createViewSectionByModule(module, parnetContainer, isInsert) {
    var moduleId = module.id;
    var sectionId = "wrap" + moduleId;
    var nLang = ObjectSys.getContextLang();
    var opText = (nLang == 0) ? "修改" : "Edit", opClass = "edit1";
    if (module.isMultiItem) opText = (nLang == 0) ? "修改/添加" : "Edit & Add", opClass = "edit2";
    var viewSection = document.createElement("div");
    viewSection.id = moduleId + "Container";
    viewSection.className = "conblk2";
    if (moduleId != "ResumeName")
        viewSection.innerHTML = "<a name='anchor_" + moduleId + "'></a><div id='" + sectionId + "' class='con' onclick=\"if(typeof(" + moduleId + ".__state)=='undefined'||" + moduleId + ".__state!='Edit') " + moduleId + ".RenderEdit();\"><div class='h2blk'><h2 id='" + moduleId + "_title'>" + ObjectSys.Resource.getTip(moduleId + ".Name") + " </h2> <div class='edit' style='display:none'><input id='op_" + moduleId + "'  type='button' class='" + opClass + "' value='" + opText + "' onclick='" + moduleId + ".RenderEdit();' /></div></div>"
                            + "<div id='" + moduleId + "View'><div class='formblk'><div class='textblk'></div></div></div>"
                            + "<div id='" + moduleId + "EditView'></div></div></div>";
    else
        viewSection.innerHTML = "<a name='anchor_" + moduleId + "'></a><div id='" + sectionId + "' class='con' onclick=\"if(typeof(" + moduleId + ".__state)=='undefined'||" + moduleId + ".__state!='Edit') " + moduleId + ".RenderEdit();\"><div class='h2blk'><h2 id='" + moduleId + "_title'>" + ObjectSys.Resource.getTip(moduleId + ".Name") + " </h2><div class=\"etips\"><p>鼠标点到您要修改的区域即可进行修改，鼠标移开该区域自动为您保存。</p></div> <div class='edit' style='display:none'><input id='op_" + moduleId + "'  type='button' class='" + opClass + "' value='" + opText + "' onclick='" + moduleId + ".RenderEdit();' /></div></div>"
                            + "<div id='" + moduleId + "View'><div class='formblk'><div class='textblk'></div></div></div>"
                            + "<div id='" + moduleId + "EditView'></div></div></div>";
    if (true == isInsert) {
        if (parnetContainer.childNodes.length == 0)
            parnetContainer.appendChild(viewSection);
        else
            parnetContainer.insertBefore(viewSection, parnetContainer.childNodes[0]);
    }
    else {
        parnetContainer.appendChild(viewSection);
    }

    addEvent($(sectionId), 'click', function() { FocusWrap.setFocus(module); }, true);
    addEvent($(module.id + "_title"), 'click', function() { FocusWrap.showSectionTip(module); }, true);
}

function createModuleAnchor(moduleId, parent)//未使用
{
    var anchor = document.createElement("a");
    anchor.id = "a__" + moduleId;
    anchor.setAttribute("name", "anchor_" + moduleId);
    //parent.appendChild(anchor);    
}

function continueInput(leaveAlert)//断续填写
{
    $("leaveAlert").style.display = 'none';
    App.Page.disableControl(document.body, false);

    ObjectSys.WebPage.objectEditSection.validate();
    ObjectSys.setFocus(ObjectSys.WebPage.objectEditSection);
    scrollBy(0, -120);
}

function choose_style()//
{
    var lang = ObjectSys.getContextLang();
    var url;
    if (lang == 1)
        url = "../Resume/ResumeStyleEn56.aspx?group=0&method=0&lang=1&action=0&cvid=" + ObjectSys.getObjectId() + "&close=1";
    else
        url = "../Resume/ResumeStyle56.aspx?group=0&method=0&lang=0&action=0&cvid=" + ObjectSys.getObjectId() + "&close=1";
    window.open(url);
}

function preview(aLink) {
    var lang = ObjectSys.getContextLang();
    var url = "../Resume55/PreviewResume.aspx?lang=" + lang + "&cvid=" + ObjectSys.getObjectId();
	
	if(aLink != null && aLink.tagName.toUpperCase() == "A")
	{
		aLink.onclick = null;
		aLink.href = url;
		aLink.click();
	}
	else
	{
		window.open(url);
	}
}

function toOld() {
    if (typeof __isEdit == "undefined" || __isEdit) {
        url = "../Resume/ViewResume.aspx?group=0&method=0&action=0&lang=" + ObjectSys.getContextLang() + "&cvid=" + ObjectSys.getObjectId();
    }
    else {
        url = "../Resume/AddNew.aspx?r=" + Math.random();
    }
    window.location = url;
}
/*新添加的*/

function globalization(path, lang, useDefault) {
    return path.replace("{$lang}", App.getLangResAbbreviation(lang, useDefault));
}

function loadScripts(scripts) {
    if (scripts != undefined && scripts != null && scripts.length > 0) {
        var lang = ObjectSys.getContextLang().toString();
        var head = document.getElementsByTagName("head")[0];
        for (var i = 0; i < scripts.length; i++) {
            var script = document.createElement("script");
            script.language = "javascript";
            script.type = "text/javascript";
            script.src = globalization(scripts[i], lang); // + (scripts[i].indexOf("?")>0 ? "&" : "?") + "r=" + Math.random();
            head.appendChild(script);
            if (typeof console != "undefined")
                try { console.debug("Load script[%s]", script.src); } catch (e) { }
        }
    }
}

function queryString(val) {
    var uri = window.location.search;
    var re = new RegExp("" + val + "\=([^\&\?]*)", "ig");
    return ((uri.match(re)) ? (uri.match(re)[0].substr(val.length + 1)) : null);
}

function signOut(url) {
    if (url == null)
        url = "/logout.aspx";
    //JobTrends 附加随机数的代码
    //*************************************************************
    url = appendRnd(url);
    //*************************************************************
    top.location.href = url;
}

//JobTrends 附加随机数的代码
//*************************************************************
function appendRnd(url) {
    var temp = url;
    temp = temp.replace(/[&\?]jtr=\d{6,10}&jtrr=(\d{6,10}|-5|-1)?/, "");
    if (typeof jtRefRnd != "undefined" && jtRefRnd != "") {
        jtRnd = "jtr=" + (parseInt(Math.random() * 1000000000)).toString().substr(0, 8) + "&jtrr=" + jtRefRnd;
        temp += (temp.indexOf("?") == -1) ? "?" : "&";
        temp += jtRnd;
    }
    return temp;
}
//*************************************************************

function __resetTipContent(tipFrameId, tip, tipHeight, tipId)//重设帮助信息
{
    var tipFrame = $(tipFrameId);
    if (null == tipFrame) {
        setTimeout(function() { __resetTipContent(tipFrameId, tip, tipHeight, tipId) }, 16);
        return;
    }
    if (null != tipHeight && "undefined" != tipHeight) {
        tipFrame.style.height = (parseInt(tipHeight) + 16).toString() + "px";
    }

    var doc = tipFrame.contentWindow.document;
    doc.write("<html><head><style>");
    doc.write("body {margin:0; background:#ffe;font-size:9pt;}");
    doc.write(".tipblk{width:100%;color:#000;}");
    doc.write(".tipblk img{float:right;margin:4px;cursor:pointer;}");
    doc.write(".tipblk .tiptxt{margin:20px 10px 0 5px;padding:0px;line-height:130%}");
    doc.write(".tipblk .tiptxt p{text-indent:24px;}");
    doc.write("</style></head><body><div id='tip' class='tipblk'>");
    doc.write("<img src='http://st.mychinahr.com/a/My6/images/close_side.gif' onclick='parent." + tipId + ".style.display=\"none\"'/>");
    doc.write("<div class='tiptxt'>");
    doc.write(tip);
    doc.write("</div></div></body></html>");

    return;
}
function getDateString(date, format) {
    if (date == null) return "";
    var dateStr;
    if (0 == ObjectSys.getContextLang()) {
        if (format != null) {
            if (format == "YMD")
                dateStr = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
            else if (format == "YM")
                dateStr = date.getFullYear() + "年" + (date.getMonth() + 1) + "月";
            else if (format == "Y")
                dateStr = date.getFullYear() + "年";
            else if (format == "MD")
                dateStr = (date.getMonth() + 1) + "月" + date.getDate() + "日";
            else
                dateStr = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
        }
        else {
            dateStr = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
        }
    }
    else {
        if (format != null) {
            if (format == "YMD")
                dateStr = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
            else if (format == "YM")
                dateStr = date.getFullYear() + "/" + (date.getMonth() + 1);
            else if (format == "Y")
                dateStr = date.getFullYear();
            else if (format == "MD")
                dateStr = (date.getMonth() + 1) + "/" + date.getDate();
            else
                dateStr = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
        }
        else {
            dateStr = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
        }
    }
    return dateStr;
}
//////////////////////////////////////从SiteOS.web.js移植过来的
SecurePopupContext = function(objctx, objpop, visible) {
    var idx = 20000;
    if (objctx) {
        if (objctx.style) {
            idx = objctx.style.zIndex;
        }
    }

    SecurePopup(idx, objpop, __secureFrames[0], visible);
}

__secureFrames =
["__siteos_securePopup"/*frame id user for contextmenu*/

];

SecurePopup = function(popidx, objpop, frmid, visible) {
    var off = 2;
    var doff = 4;
    var ifid = frmid;
    var ifrm = $(ifid);

    if (visible) {
        if (ifrm != null)
            ifrm.parentNode.removeChild(ifrm);

        ifrm = document.createElement("iframe");
        ifrm.display = 'none';
        ifrm.src = 'about:blank';
        ifrm.scrolling = 'no';
        ifrm.frameBorder = '0';
        ifrm.style.position = 'absolute';
        ifrm.style.backgroundColor = '#ffffff';
        ifrm.id = ifid;

        popidx = popidx == 0 ? 1 : popidx;
        var opzdx = objpop.style.zIndex;
        objpop.style.zIndex = popidx > opzdx ? popidx : opzdx;
        if (objpop.style.left == "" || objpop.style.top == "") return;
        UpdateFramePostion(popidx - 1,
        ifrm,
        objpop.style.left,
        objpop.style.top,
        objpop.offsetWidth,
        objpop.offsetHeight

        );


        objpop.parentNode.appendChild(ifrm);

    }
    else {
        if (ifrm != null) {
            ifrm.style.display = 'none';
            ifrm.parentNode.removeChild(ifrm);
        }
    }

}

UpdateFramePostion = function(idx, frmobj, x, y, w, h) {
    var off = 2;
    var doff = 4;
    if (w == 0) w = doff;
    if (h == 0) h = doff;

    var ifrm = frmobj;

    ifrm.style.top = parseInt(y) + off + "px";
    ifrm.style.left = parseInt(x) + off + "px";

    ifrm.style.width = w - doff + "px";
    ifrm.style.height = h - doff + "px";

    ifrm.style.zIndex = idx;
    ifrm.style.display = 'block';
}
$SE = function() {
    //IE
    if (document.all)
        return window.event;

    func = $SE.caller;
    while (func != null) {
        var arg0 = func.arguments[0];
        if (arg0) {
            if (arg0.constructor == Event || arg0.constructor == MouseEvent)
                return arg0;
        }
        func = func.caller;
    }
    return null;
}
$SE.srcElement = function() {
    if (navigator.userAgent.toLowerCase().indexOf("firefox") > 0)
        return $SE().target;
    else
        return $SE().srcElement;
}

// 取得某节点的第几个元素类型的子节点,从0开始
$Node = function(p, index) {
    if (p.childNodes) {
        var c = p.childNodes[0];
        var i = 0;
        while (c) {
            if (c.nodeType.toString() == "1") {
                if (i == index) return c;
                i++;
            }
            c = c.nextSibling;
        }
        return null;
    }
}

$NodeText = function(p) {
    if (navigator.appName.indexOf("Explorer") > -1)
        return p.innerText;
    else
        return p.textContent;
}

//显示内容的分隔线
$ShowSpacer = function(input) {
    //alert("1");
    //alert(item.section.container.innerHTML);
    var rList = [];
    rList[0] = { r: /(style=['|\"]display: none;*['|\"]\s+)?class=['|\"]?spacer1['|\"]?(\s+style=['|\"]display: none;*['|\"])?/i, s: "class=\"spacer1\"" };
    return App.replaceContent(input, rList);
    //item.section.container.innerHTML = item.section.container.innerHTML.replace(/class/g, "class=\"spacer1\"");
    //alert(item.section.container.innerHTML);
    //item.section.container.innerHTML = item.section.container.innerHTML.replace("class=\"spacer1\" style=\"display: none;\"", "class=\"spacer1\"");
    //item.section.container.innerHTML = item.section.container.innerHTML.replace("class=\"spacer1\" style='display: none'", "class=\"spacer1\"");
}
//隐藏内容的分隔线
$HideSpacer = function(input) {
    //alert("2");
    //alert(item.section.container.innerHTML);
    var rList = [];
    rList[0] = { r: /<div\s*class=['|\"]?spacer1['|\"]?\s*>/i, s: "<div class=\"spacer1\" style=\"display: none;\">" };
    //item.section.container.innerHTML = item.section.container.innerHTML.replace(/(style=['|\"]display: none;*['|\"]\s+)?class=['|\"]?spacer1['|\"]?(\s+style=['|\"]display: none;*['|\"])?/i, "");
    return App.replaceContent(input, rList);
    //alert(item.section.container.innerHTML);
    //item.section.container.innerHTML = item.section.container.innerHTML.replace("class=\"spacer1\"", "class=\"spacer1\" style=\"display: none;\"");

}

//设置范例
$SetExampleValue = function(expValueKey, chkObj, pageSection) {
    if (typeof ExampleValue != "undefined") {
        var ctlObjid = chkObj.id.replace("chkExp_", "");
        if (typeof ExampleValue[expValueKey] != "undefined") {
            if (queryString("lang") == null || queryString("lang") == "0")//中文
                eval("var example=ExampleValue[\"" + expValueKey + "\"]");
            else
                eval("var example=ExampleValue[\"" + expValueKey + "_En\"]"); //英文
            if (JQ("#" + ctlObjid).val() == "")
                JQ("#" + ctlObjid).val(example);
            else
                JQ("#" + ctlObjid).val(JQ("#" + ctlObjid).val() + "\r\n" + example);
            pageSection.setDirty(true); //设置成脏，否则不会自动保存
        }
    }
}
/*
$SetExampleValue = function(chkObj, expValueKey, pageSection,ext) {
    if (chkObj.checked == true) {
        if (typeof ExampleValue != "undefined") {
            eval("var example=ExampleValue[\"" + expValueKey + "\"]");
            JQ("#" + controlId+ext).val(JQ("#" + controlId+ext).val()+"\r\n"+example);
            JQ("#" + controlId).css({ "font-style": "italic", "color": "gray" });
            pageSection.setDirty(true); //把相关section设置成脏，否则保存不了
        }
    }
    else {
        if (typeof ExampleValue != "undefined") {
            eval("var example=ExampleValue[\"" + controlId + "\"]");
            if (JQ("#" + controlId).val() == example) {
                JQ("#" + controlId).val("");
                JQ("#" + controlId).css({ "font-style": "", "color": "" });
            }
        }
    }
}

$ChangeExampleCss = function(txtObj) {
var controlId = txtObj.name;
var chkObj = document.getElementById("chkExp_" + controlId);
if (chkObj.checked == true) {//当勾选了范例框时，才做样式转换
JQ("#" + controlId).css({ "font-style": "", "color": "" });
}
}
*/
var ExampleValue = [];
ExampleValue["txtSkillsAndStrengths_Content"] = "1、出色的培训演讲技巧；\r\n2、组织较大规模的对外人员招聘活动；\r\n3、出色的领导能力；\r\n4、计算机技能：Windows, word, excel, powerpoint, Internet。";
ExampleValue["txtSkillsAndStrengths_Content_En"] = "1.Outstanding training and presentation skills\r\n2.Excellent communication skills\r\n3.Powerful leadership\r\n4.Proficient computer skills: Windows, word, excel, powerpoint, Internet.";
ExampleValue["txtEmploymentHistory_Duty"] = "在XXXX的指导下负责XXXX工作。\r\n具体职责包括：\r\n1、负责XX工作，拓展XXXX业务。\r\n2、根据XX计划，完成部门XX指标。\r\n3、分析XX数据和信息，提交分析报告。\r\n4、协调XX部门完成XXX活动。\r\n5、协助XXX完成XX工作。\r\n\r\n主要业绩：\r\n在职期间完善了公司的XX体系，超额完成部门XX指标。被评为XX年度XXXX。"
ExampleValue["txtEmploymentHistory_Duty_En"] = "Carry out XXX  with xxx‘s guidance\r\n1.	Take up XXX and develop xxx business\r\n2.	Complete KPI of the Department according to xx plan\r\n3.	Analyze xx data and info, and submit the analysis report\r\n4.	Coordinate xxx activities for xxx Department\r\n5.	Assist xxx to complete xx\r\n\r\nMajor achievements:\r\nPerfect the company xxx system in the working period \r\nExceed KPI requirements set for xxx Department\r\nBe nominated as XXX of Year XXXX";

