﻿document.write('<div id="toolTipBody" style="display:none;"></div>')
/***************************************ToolTip functions***************************************************/
// hides display of tool tip on blur of textbox
function HideToolTip() {
    if (document.getElementById('toolTipBody') != null) {
        document.getElementById("toolTipBody").style.display = "none";
    }
}



//display contents to be contained in tooltip
function DisplayToolTip(obj) {

    var content = "";
    var flag = true;
    if (obj.innerHTML == 'Paid') {
        content = "Job paid but awaiting CMDNhotjobs approval.";
    }
    else if (obj.innerHTML == 'New') {
        content = "Job created but awaiting payment.";
    }
    else if (obj.innerHTML == 'Resumed') {
        content = "Job advertisement resumes after being put on hold.";
    }
    else if (obj.innerHTML == 'Approved') {
        content = "Job approved and being advertised on CMDNhotjobs.";
    }
    else if (obj.innerHTML == 'Suspended') {
        content = "Job approved but advertisement put on hold by CMDNhotjobs.";
    }
    else if (obj.innerHTML == 'On Hold') {
        content = "Job approved but advertisement put on hold by you.";
    }
    else if (obj.innerHTML == 'Rejected') {
        content = "Job rejected by CMDNhotjobs.";
    }
    else if (obj.innerHTML == 'Expired')
    {
        content = "Job approved with advertisement date expired on CMDNhotjobs.";
    }
    else {
        content = "Click to Sort.";
        flag = false;
    }
    if (flag) {
        document.getElementById("toolTipBody").innerHTML = "<div style='float:left;margin-left:-14px; border:0px solid green; width:20px; height:auto; font-family:verdana, arial, tahoma'>&#9668;</div><div style='float:left; font-family:Verdana, Arial, Tahoma, Helvetica, sans-serif; font-size:11px; width:190px;padding-top:3px;padding-bottom:3px;text:align:justify;'>" + content + "</div>";
        SetPositionTooltipRequiredWidth(obj, '200');
    }
    else {
        document.getElementById("toolTipBody").innerHTML = "<div style='float:left;margin-left:-14px; border:0px solid green; width:20px; height:auto; font-family:verdana, arial, tahoma'>&#9668;</div><div style='float:left; font-family:Verdana, Arial, Tahoma, Helvetica, sans-serif; font-size:11px; width:80px;padding-top:3px;padding-bottom:3px;text:align:justify;'>" + content + "</div>";
        SetPositionTooltipRequiredWidth(obj,'100');
    }
   
}
//adjust position to display tooltip in required position
function SetPositionTooltip(anchorId) {
    HideToolTip();
    var textBoxWidth; // width of textbox
    
        textBoxWidth = anchorId.offsetWidth;
        document.getElementById('toolTipBody').style.left = getX(anchorId) + textBoxWidth + "px";
        document.getElementById('toolTipBody').style.top = getY(anchorId) + "px";
   
    document.getElementById("toolTipBody").style.display = ""
}

//adjust position to display tooltip in required position
function SetPositionTooltipRequiredWidth(anchorId,width) {
    HideToolTip();
    var textBoxWidth; // width of textbox

    textBoxWidth = anchorId.offsetWidth;
    document.getElementById('toolTipBody').style.left = getX(anchorId) + textBoxWidth + parseInt(15) + "px"; 
    document.getElementById('toolTipBody').style.top = getY(anchorId) + "px";
    document.getElementById('toolTipBody').style.width = width + "px";
    document.getElementById("toolTipBody").style.display = ""
}
function SetPositionTooltipCreateJob(anchorId,changeTop) {
    HideToolTip();
    var textBoxWidth; // width of textbox

    textBoxWidth = anchorId.offsetWidth;
    document.getElementById('toolTipBody').style.left = getX(anchorId) + textBoxWidth + 15 + "px";
    
    if (changeTop) {
        document.getElementById('toolTipBody').style.top = getY(anchorId) -55 + "px";
        document.getElementById('toolTipPtr').style.display = "none";
    }
    else {
        document.getElementById('toolTipBody').style.top = getY(anchorId) + "px";
    }

    document.getElementById("toolTipBody").style.display = ""
}
//to get position from top where we want to display tooltip
function getY(oElement) {
    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}
// to get position from left where we want to display tooltip     
function getX(oElement) {
    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}





function ReplaceXMLEscapeCharacters(rawString) {
    if (rawString == null || trim(rawString) == "") {
        return rawString;
    }
    rawString = new String(rawString);
    var xmlCharacters = ["&gt;", "&lt;", "&quot;", ">", "<", "\"", "'", "&"];
    var escapeCharacters = ["&attributegt;", "&attributelt;", "&attributequot;", "&gt;", "&lt;", "&quot;", "&apos;", "amp;"];

    var formatedString = rawString;
    var regExpression;
    var index;
    for (index = xmlCharacters.length; index > 0; index--) {
        regExpression = new RegExp(escapeCharacters[index - 1], "g");
        formatedString = formatedString.replace(regExpression, xmlCharacters[index - 1]);
    }
    return formatedString;
}

/* Added for showing tool tip in Create Job*/
function DisplayToolTipCreateJob(obj,changeTop) {
    var content = "";
    
    switch (obj.id) {
        case "txtCompanyName": content = "This name will be displayed on CMDNhotjobs as the Employer for this Job Post"; break;
        case "txtCompanyContact": content = "Name of the contact for this Job Post"; break;
        case "txtEmailResume": content = "Applicant resumes for the Job Post will be sent to this Email"; break;
        case "txtCompanyUrl": content = "Website URL to know more about the company"; break;
        case "txtJobID": content = "Job ID / Job Code that you may use internally."; break;
        case "txtJobTitle": content = "Job Title forms the headline for the Job Post as shown in the example above. Type here to see the preview. (Max 35 chars)"; break;
        case "txtShortDescription": content = "Short description of the Job you are advertising (Max 74 chars)"; break;
        case "drpExperienceFrom":
        case "drpExperienceTo":
            obj = document.getElementById('drpExperienceTo');
            content = "Select the experience range"; break;
        case "txtLocation":
        case "txtAreaLocations": content = "Applicable location(s) for this Jobs Post"; break;
        case "txtRole": content = "Example: Full Time or  Part Time"; break;
        case "txtOtherBenefits": content = "Example: Gratuity or Variable Pay"; break;
        case "txtStartDate":
        case "calendar1":
            var browserInfo = GetBrowserInfo();
            if (browserInfo[1].indexOf("MSIE 6.0") > -1) {
                SetControlVisibility("select", "hidden");
            }
            content = "Specify a date from which you wish to stream your Job Post. Please consider max of 1 business day for our Back Office to approve your Job for streaming."; break;
        case "ddlTimeSpan": content = "Mode you prefer to have Job Applications sent to your Email."; break;
        case "RTEJobDescription": content = "Please restrict to Max 3500 chars"; break;
        case "RTEAboutCompany": content = "Please restrict to Max 3500 chars"; break;
        case "lnkValidTill": content = "The date until which the Job Posting will be streamed on CMDNhotjobs. This is set automatically to 1 month from Job creation date."; break;
        case "lnkJobPreviewHelp": content = "Your Job Posting will appear on CMDNhotjobs as shown in the example here. It comprises of \"Job Title\" (max 35 chars), \"Short Description\" (max 74 chars) and \"Location\"."; break;
        default: content = ""; break;
                
    }
    if (content != "") {
        document.getElementById("toolTipBody").innerHTML = "<div id='toolTipPtr' style='float:left;margin-left:-14px; border:0px solid green; width:20px; height:auto; font-family:verdana, arial, tahoma'>&#9668;</div><div id='toolTipContent' style='float:left; font-family:Verdana, Arial, Tahoma, Helvetica, sans-serif; font-size:11px; width:190px;padding-top:3px;padding-bottom:3px;text:align:justify;'>" + content + "</div>";
        SetPositionTooltipCreateJob(obj,changeTop);
        
    }
}
/* Added for showing tool tip in Create Job*/
function GetBrowserInfo() {
    var browserName = "";
    var browserVersion = "";

    if (navigator.appVersion != null) {
        //navigator.appVersion is 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
        var browserVersionDetails = navigator.appVersion.split(";");
        browserVersion = browserVersionDetails[1];
    }
    if (navigator.appName != null) {
        browserName = navigator.appName;
    }
    var browserInfo = new Array(browserName, browserVersion);
    return browserInfo;
}
