﻿$(document).ready(function() {
    $('#lfic').mouseover(function() {
        $(document).moveLeft('#crouDivin', 1, 500, 'rfic', 'lfic', '', $(this))
    })
    $('#rfic').mouseover(function() {
        $(document).moveRight('#crouDivin', 1, 500, 'lfic', 'rfic', '', $(this))
    })
    $('#ltBanR').click(function() {
        $(document).moveRight('#ltBan', 1, 500, 'ltBanL', 'ltBanR', '', $(this), 'ltBD')
    })
    $('#ltBanL').click(function() {
        $(document).moveLeft('#ltBan', 1, 500, 'ltBanR', 'ltBanL', '', $(this), 'ltBD')
    })

    $('#jbcMore').click(function() {
        var offset = $(this).offset();
        var curObj = $(this);
        var relA = $('#' + curObj.attr('rel'));
        relA.css({ 'top': offset.top + 30 + 'px', 'left': offset.left + 'px', 'display': 'block' })

        curObj.mouseout(function() {
            relA.hide();
        })
        relA.mouseover(function() {
            $(this).show();
            $(this).mouseout(function() {
                $(this).hide();
            })
            $(this).click(function() {
                $(this).hide();
            })
        })
    })

    $('#ltBD a[rel]').click(function() {
        $(document).paginCR(this, 'ltBD', 'ltBan');
    })

    $('#srcBg input.ddSel').focus(function() {
        $(this).showSelect();
    })
    $('#srcBg span.dd').click(function() {
        $(this).children('input').showSelect();
    })

    $('#srcCont select').click(function() {
        $(this).parent().hide();
    })

    $('#srcCont select').blur(function() {
        $(this).parent().hide();
    })

    $('#expSL').keydown(function(e) {
        $(document).moveFocus(e, 'exp');
    })
    $('#fareaSL').keydown(function(e) {
        $(document).moveFocus(e, 'farea');
    })
    $('#minSalSL').keydown(function(e) {
        $(document).moveFocus(e, 'minSal');
    })
    $('#maxSalSL').keydown(function(e) {
        $(document).moveFocus(e, 'maxSal');
    })

    $.fn.paginCR = function(obj, linkID, contentID) {
        var curObj = $(obj)
        var getRel = curObj.attr('rel');
        var totalObj = $('#' + linkID + ' a[rel]');
        for (j = 0; j < totalObj.length; j++) {
            $(totalObj[j]).removeClass('sel');
        }

        var getLI = $('#' + contentID + ' li');
        for (i = 1; i < getLI.length + 1; i++) {
            if (getRel == i) {
                $(getLI[i - 1]).show(200);
                $(totalObj[i - 1]).addClass("sel");

            }
            else if (getRel >= i)
                $(getLI[i - 1]).hide(200);
            else
                $(getLI[i - 1]).show();
        }
    }


    $.fn.chTxt = function(id, txt) {
        var getObj = $('#' + id);
        if (getObj.val() == '') {
            getObj.val(txt).css({ 'color': "#8D8D8D" });
            return false;
        }
        if (getObj.val() == txt)
            getObj.val('').css({ 'color': "#333" });
    }
    var setVarKey = 'Type your Skills, Designation etc.';
    var setVarLoc = 'Type City name where you want to work';
    var $InlineError = 'Please enter Keywords or select Category to search.';

    $('#qp').focus(function() {
        $(document).chTxt('qp', setVarKey);
        $(document).removeErr();
    })
    $('#farea').focus(function() {
        $(document).removeErr();
    })
    $.fn.removeErr = function() {
        $('#qp').parent().removeClass('errIN');
        $('#farea').parent().removeClass('errIN');
        $('#divInlineErrMsg').html('');
    }
    $('#qp').blur(function() {
        $(document).chTxt('qp', setVarKey);
    })
    $('#ql').focus(function() {
        $(document).chTxt('ql', setVarLoc);
    })
    $('#ql').blur(function() {
        $(document).chTxt('ql', setVarLoc);
    })



    $.fn.formSubmit = function() {
        var locinChar = /[^a-zA-Z,.;&\\\/\s\-()]/;

        if ($('#qp').val() == setVarKey && $('#farea').val() == 'Select') {
            $('#qp').parent().addClass('errIN');
            $('#farea').parent().addClass('errIN');
            $('#divInlineErrMsg').html($InlineError);
            $('#autosuggest').hide();
            $('#autosuggest1').hide();
            $('#DivShim').hide();

            return false;
        }
        else if (locinChar.test($('#ql').val())) {
            $('#divInlineErrMsg').html('Please avoid entering any number/special character in location field.');
            $('#autosuggest').hide();
            $('#autosuggest1').hide();
            $('#DivShim').hide();
            return false;
        }
        else {
            $('#fareaval').val($('#fareaSL').val());
            $('#expval').val($('#expSL').val());
            $('#minSalval').val($('#minSalSL').val());
            $('#maxSalval').val($('#maxSalSL').val());
        }
    }

    $('#fareaval').val('');
    $('#expval').val('');
    $('#minSalval').val('');
    $('#maxSalval').val('');

    $('#farea').val('Select');
    $('#exp').val('Select');
    $('#minSal').val('Min');
    $('#maxSal').val('Max');


    $.fn.changeVal = function(id, obj) {

        var str = obj.options[obj.selectedIndex].innerHTML;

        str = str.replace(/&lt;/, '<', str);
        str = str.replace(/&gt;/, '>', str);
        str = str.replace(/&amp;/, '&', str);
        var $Obj = $('#' + id);
        $Obj.val(str);

        if (id == 'minSal') {
            var $mxSal = $('#maxSalSL');
            $mxSal.html('').parent().hide();
            $mxSal.append($('<option>').html('Max'));
            if (str != 'Min') {
                $(document).expSLFN(parseInt(str), 50, 'maxSalSL');
                $mxSal.append($('<option>').html('>50').val('10000000'))
                $('#maxSalCont').css({ 'left': '-1000px', 'top': '-1000px' });
                $mxSal.hide();
            }
            $('#maxSal').val('Max').css({ 'color': "#8D8D8D" });
            $mxSal.show();
            $mxSal.hide();
            var getOptLen = $('#maxSalSL option').length;
            if (getOptLen == 1) {
                $mxSal.attr('size', '2').css({ 'height': '20px' });
            }
            else if (getOptLen < 10 && getOptLen >= 2) { $mxSal.attr('size', getOptLen).css({ 'height': getOptLen * 15 + 'px' }); } else { $mxSal.attr('size', 10).css({ 'height': '160px' }); }


        }
        (str == "Select" || str == "Max" || str == "Min" || str == "Exp.") ? $Obj.css({ 'color': "#8D8D8D" }) : $Obj.css({ 'color': "#333" });
    }

    /*header*/
    $('#mNav a[rel]').mouseover(function() {
        var curObj = $(this);
        var offset = curObj.offset();
        var relA = $('#' + curObj.attr('rel'));
        relA.css({ 'top': offset.top + 28 + 'px', 'left': offset.left + 'px', 'display': 'block' })
        curObj.addClass('selul');

        curObj.mouseout(function() {
            relA.hide();
            curObj.removeClass('selul');
        })
        relA.mouseover(function() {
            $(this).show();
            curObj.addClass('selul');
            $(this).mouseout(function() {
                $(this).hide();
                curObj.removeClass('selul');
            })
            $(this).click(function() {
                $(this).hide();
                curObj.removeClass('selul');
            })
        })
    })
    /*header*/
    $.fn.moveRight = function(id, displayItem, speed, prevEn, nextEn, enPref, curObj, paginationID) {
        try {
            var crgetLI = $(id).children('ul').children('li');
            paginationID = paginationID || '';
            var paginA = '';
            if (paginationID)
                paginA = $('#' + paginationID + ' a[rel]');
            var getCurPos = 0;
            for (i = 0; i < (crgetLI.length) - displayItem; i++) {
                getCurPos = i;
                if (crgetLI[i].style.display == '' || crgetLI[i].style.display == 'block' || crgetLI[i].style.display == 'list-item') {
                    $(crgetLI[i]).hide(speed);
                    $(crgetLI[i + displayItem]).show();
                    if (paginationID) {
                        for (j = 0; j < paginA.length; j++) {
                            $(paginA[j]).removeClass('sel');
                        }

                        $(paginA[i + 1]).addClass('sel');
                    }
                    if (i == 0) {
                        $('#' + prevEn).removeClass(prevEn).addClass(prevEn + enPref);
                    }
                    else if (i == (crgetLI.length) - displayItem - 1) {
                        $(curObj).removeClass(nextEn + enPref).addClass(nextEn);
                    }
                    break;
                }
                if (getCurPos + 1 == crgetLI.length - displayItem)
                    $(document).moveLeft(id, crgetLI.length - displayItem, speed, prevEn, nextEn, enPref, curObj, paginationID)

            }
        } catch (e) { }
    }
    $.fn.moveLeft = function(id, displayItem, speed, prevEn, nextEn, enPref, curObj, paginationID) {
        try {
            var crgetLI = $(id).children('ul').children('li');
            var crLI = 0;
            for (i = 0; i < crgetLI.length; i++) {
                if (crgetLI[i].style.display == 'none')
                    crLI++;
                else
                    break;
            }

            paginationID = paginationID || '';
            var paginA = '';
            if (paginationID)
                paginA = $('#' + paginationID + ' a[rel]');
            var getCurPos = 0;
            for (i = crLI; i >= displayItem; i--) {
                if (crgetLI[i].style.display == 'block' || crgetLI[i].style.display == '' || crgetLI[i].style.display == 'list-item') {
                    getCurPos = i;
                    $(crgetLI[i - displayItem]).show(speed);
                    $(crgetLI[i]).hide(speed);
                    if (paginationID) {
                        for (j = 0; j < paginA.length; j++) {
                            $(paginA[j]).removeClass('sel');
                        }
                        $(paginA[i - displayItem]).addClass('sel');
                    }

                    if (i == (crgetLI.length - displayItem - 1)) {
                        $('#' + prevEn).removeClass(prevEn).addClass(prevEn + enPref);
                    }
                    else if (i == displayItem)
                        $(curObj).removeClass(nextEn + enPref).addClass(nextEn);

                    break;
                }


            }
            if (getCurPos == 0) {
                $(document).moveRight(id, crgetLI.length - displayItem, speed, prevEn, nextEn, enPref, curObj, paginationID);
                if ($('#' + paginationID + ' a[rel]').length > 0) {
                    $(document).paginCR($('#' + paginationID + ' a[rel]').last(), paginationID, 'ltBan');
                }

            }
        } catch (e) { }
    }
    $.fn.getLoop = function() {
        $(document).moveRight('#ltBan', 1, 500, 'ltBanL', 'ltBanR', '', $(this), 'ltBD')
        setTimeout('$(document).getLoop()', 10000)
    }
    setTimeout('$(document).getLoop()', 10000)

    $.fn.getLoop1 = function() {
        $(document).moveRight('#crouDivin', 1, 500, 'lfic', 'rfic', '', $(this))
        setTimeout('$(document).getLoop1()', 10000)
    }

    $.fn.showSelect = function() {
        var inputObj = $(this).parent().children('input')
        var getCurId = inputObj.attr('id');
        var curObj = $(this);
        var getSelObj = $("#" + getCurId + "Cont");
        getSelObj.show();
        var getSelctObj = $("#" + getCurId + "SL");

        var getSelctObjOld = getCurId + "SL";
        $('#' + getSelctObjOld).show();
        var getwidthLi = inputObj.parent().parent().width() - 4;
        getwidthSel = getSelctObj.width();
        if (getwidthLi > getwidthSel)
            getSelctObj.css('width', getwidthLi + 'px');

        var offset1 = inputObj.offset();
        getSelObj.css('top', offset1.top + 22 + 'px').css('left', offset1.left - 1 + 'px');
        getSelctObj.focus();


    }
    $.fn.moveFocus = function(e, evId) {

        code = e.keyCode ? e.keyCode : e.which;
        var codeS = false;
        if (code == 9 && navigator.appName == 'Microsoft Internet Explorer')
            codeS = event.shiftKey;
        else if (code == 9)
            codeS = e.shiftKey;

        if (codeS && code == 9) {
            e.preventDefault();
            var srcTObj = $('#srcBg input[type="text"]');
            for (i = srcTObj.length - 1; i > 0; i--) {
                if (evId == srcTObj[i].id) {
                    srcTObj[i - 1].focus();
                    $('#' + evId + "Cont").hide();
                    break;
                }
            }
        }
        else if (code == 9) {
            e.preventDefault();
            var srcTObj = $('#srcBg input[type="text"]');
            for (i = srcTObj.length - 1; i > 0; i--) {
                if (evId == srcTObj[i].id) {
                    try { srcTObj[i + 1].focus(); }
                    catch (e) { $('#search').focus(); }
                    $('#' + evId + "Cont").hide();
                    break;
                }
            }
        }
        else if (code == 13) {
            e.preventDefault();
            $('a:first').focus();
            $('#' + evId + "Cont").hide();
        }
    }
    $(document).click(function(e) {

        $('#vCardID').hide();
        var e = e || window.event;
        if (e.which == null) {
            /* IE case */
            button = (e.button < 2) ? "LEFT" :
			((e.button == 4) ? "MIDDLE" : "RIGHT");
        }
        else {
            /* All others */
            button = (e.which < 2) ? "LEFT" :
			((e.which == 2) ? "MIDDLE" : "RIGHT");
        }

        var tgt = e.target || e.srcElement;
        if (tgt.parentNode.id != 'chCDD' && tgt.id != 'ct_DD' && button != 'RIGHT' && tgt.id != 'chCDD')
        { $('#ct_DD').hide(); }
        if (tgt.id != 'more' && button != 'RIGHT') {
            $('#moreD').hide();
        }
    })
    $('#cattab a').attr('target', '_self');
    $('#chCDD').click(function() {
        var offset = $(this).offset();
        $(this).focus();
        $('#ct_DD').css({ 'top': offset.top + 17 + 'px', 'left': offset.left - $('#ct_DD').width() + $(this).width() + 'px', 'display': 'block' })
    })
    $('#ct_DD a').click(function() {
        $('#chCDD strong').html($(this).html());
        $('#chCDD').focus();
        $('#ct_DD').hide();
        var getRel = $(this).attr('rel');
        if (getRel) {
            $(document).FTMC_changediv('ftmc' + getRel);
            $.ajax({
                type: "POST",
                url: "homepage_ajax.php",
                data: "select=ftmc" + getRel,
                success: function(msg) {
                    if (msg != '')
                        $('#ftmc' + getRel).html(msg).append('<span class="sp10 dspB"></span>')
                    $('#ftmc' + getRel + ' a[id]').mouseover(function(e) {
                        $(document).a_mouseover(this);
                    })
                    $('#ftmc' + getRel + ' a[id]').mouseout(function(e) {
                        $('#vCardID').html('');
                        $('#vCardID').hide();
                    })
                }
            })
        }
        else
        { $(document).FTMC_changediv('ftmcall') }
    })
    $('<div class="vCard" id="vCardID" style="display:none"></div><iframe class="vCardiframe" id="vCardiFrameID" style="display:none"></iframe>').appendTo('body');
    $('#vCardID').mouseover(function() { $(this).html('').hide(); })
    $('#ftmcall a[id]').mouseover(function(e) {
        $(document).a_mouseover(this);
    })
    $('#ftmcall a[id]').mouseout(function() {
        $('#vCardID').html('');
        $('#vCardID').hide();
    })
    $('#crBD a[rel]').click(function() {
        $(document).paginCR(this, 'crBD', 'crBan');
    })

    var $flag = 0;
    $.fn.FTMC_changediv = function(part) {
        $("#ftmcall").hide();
        $("#ftmcdelhi").hide();
        $("#ftmcmumbai").hide();
        $("#ftmcbangalore").hide();
        $("#ftmcchennai").hide();
        $("#ftmchyderabad").hide();
        $("#ftmcpune").hide();
        $("#ftmcahmedabad").hide();
        $("#ftmckolkata").hide();
        $("#" + part).show();
    }
    $.fn.a_mouseover = function(obj) {
        try {
            $('#vCardID').html('').hide();
            $.ajax({
                type: "POST",
                url: "homepage_ajax.php",
                data: "compid=" + $(obj).attr('id'),
                success: function(msg) {
                    if ($flag == 0) {
                        var offset = $(obj).offset();
                        $flag = 1;
                    }
                    if (msg != '')
                        $('#vCardID').html(msg);
                    if (($(window).height() + $(window).scrollTop()) > (offset.top + $('#vCardID').height())) {
                        $('#vCardID').css({ 'top': offset.top - 24 + 'px', 'left': offset.left - $('#vCardID').width() - 27 + 'px' })
                        $('#vCardArr').css({ 'top': '17px', 'bottom': 'auto' })
                    }
                    else {
                        $('#vCardID').css({ 'top': offset.top + 48 - $('#vCardID').height() + 'px', 'left': offset.left - $('#vCardID').width() - 27 + 'px' })
                        $('#vCardArr').css({ 'bottom': '29px', 'top': 'auto' })
                    }

                    if (msg != '') {
                        $('#vCardID').show();
                    }
                    $flag = 0;
                } 
            })
        }
        catch (e)
    { }
    }
    $.fn.expSLFN = function(start, end, id) {
        var getIDOBJ = $('#' + id);
        for (i = start; i <= end; i++) {
            getIDOBJ.append($('<option value="' + i + '">').html(i));
        }
    }
    $(document).expSLFN(3, 30, 'expSL');
    $(document).expSLFN(15, 50, 'minSalSL');


    $.fn.expFAFN = function(id) {
        var $obj = $('#' + id);
        for (x in a1) {
            $obj.append($('<optgroup>').attr('label', x))
            for (y in a1[x]) {
                $obj.append($('<option>').html(a1[x][y]).val(y))
            }
        }
    }

    var a1 = { "Top Categories": { "1": "Accounts, Finance, Tax, CS, Audit", "6": "Banking, Insurance", "21": "Engineering Design, R&D", "12": "HR / Administration, IR", "8": "ITES/BPO/KPO, Customer Service, Ops.", "15": "Marketing, Advertising, MR, PR", "19": "Production, Maintenance, Quality", "22": "Sales, BD", "20": "Site Engg., Project Management", "24": "Telecom" }, "IT Software Categories": { "24.01": "Application Programming, Maintenance", "24.02": "Client Server", "24.03": "DBA, Datawarehousing", "24.12": "E-Commerce, Internet Technologies", "24.05": "Embedded/EDA/VLSI/ASIC/Chip Design", "24.04": "ERP, CRM", "24.13": "Mainframe", "24.15": "Middleware", "24.14": "Mobile", "24.06": "Network Administration, Security", "24.08": "QA & Testing", "24.09": "System Programming", "24.11": "Systems, EDP, MIS", "24.07": "Other" }, "More Categories": { "2": "Architecture, Interior Design", "5": "Content, Journalism", "7": "Corporate Planning, Consulting", "10": "Export, Import, Merchandising", "42": "Fashion, Garments, Merchandising", "16": "Healthcare, Medical, R&D", "4": "Hotels, Restaurants", "37": "IT-Support, Telecom, Hardware ", "13": "Legal", "catid_28": "NGO, Government, Defence Jobs", "catid_29": "Overseas, International Jobs", "18": "Packaging", "catid_31": "Pharma, Biotech", "14": "Purchase, Logistics, Supply Chain", "catid_57": "Retailing", "11": "Secretary, Front Off, Data Entry", "9": "Self Employed, Consultants", "36": "Teaching, Education", "24.10": "Telecom Software", "catid_2": "Top Management- IT Jobs", "catid_1": "Top Management- Non IT Jobs", "44": "Travel, Ticketing, Airlines", "43": "TV, Films, Production", "3": "Web, Graphic Design, Visualiser"} };
    $(document).expFAFN('fareaSL');

    $.fn.getRowBG = function() {
        try {
            var getMediaBlock;
            var $GMi = 2
            var $gmJ = 1;
            while ($('#premiumJobs' + $gmJ).html()) {
                getMediaBlock = $('#premiumJobs' + $gmJ + ' .mediaBlock');
                $gmJ++;
            }
            while ($GMi < getMediaBlock.length) {
                $(getMediaBlock[$GMi]).addClass('mediaB_Bg');
                $(getMediaBlock[$GMi + 1]).addClass('mediaB_Bg');
                $GMi += 4;
            }
            if ((getMediaBlock.length) % 4 == 3) {
                $('#premiumJobs' + (--$gmJ)).append('<div class="mediaBlock mediaB_Bg"></div>');
            }
        }
        catch (e) { }
    }
})

function trim(inputString) {
    if (typeof inputString != "string") { return inputString; }
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == " ") {
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length - 1, retValue.length);
    while (ch == " ") {
        retValue = retValue.substring(0, retValue.length - 1);
        ch = retValue.substring(retValue.length - 1, retValue.length);
    }
    while (retValue.indexOf("  ") != -1) {
        retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ") + 1, retValue.length);
    }
    return retValue;
}
function showCrit(obj) {
    var getCurObj = obj.parentNode.getElementsByTagName('b');
    if (getCurObj[0].style.display == '') {
        getCurObj[0].style.display = 'none';
        obj.innerHTML = 'Show Criteria';
        obj.parentNode.className = 'pt8 blockwidget';
        return;
    }
    var getObj = obj.parentNode.parentNode.getElementsByTagName('b');
    var getObja = obj.parentNode.parentNode.getElementsByTagName('a');
    for (i = 0; i < getObj.length; i++) {
        getObj[i].style.display = 'none';
    }
    for (i = 0; i < getObja.length; i++) {
        if (getObja[i].innerHTML == 'Hide Criteria') {
            getObja[i].innerHTML = 'Show Criteria';
            getObja[i].parentNode.className = 'pt8 blockwidget';
        }
    }
    if (getCurObj[0].style.display == 'none')
        getCurObj[0].style.display = '';
    obj.innerHTML = 'Hide Criteria';

    obj.parentNode.className = 'pt8 arr12 blockwidget';
}





