// NOTE : This code has been developed with the help of code specified in site http://www.javascriptkit.com/javatutors/navigator.shtml
// Test for internet explorer
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
    var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
     if (ieversion < 7 && 0 > (window.location.pathname).indexOf("version_error")) {
         window.location.href = baseUrl + 'pages/version_error';
     }
 }


// Image path
var imgPath = baseUrl + '/img/';

$(document).ready(function() {
    // Attach auto-complete plugin for other location's city textbox
    try
    {
        $("#JobCity, #JobSeekCity").autocomplete(baseUrl + "countries/autocomplete_cities");
    }
    catch (e)
    {
    }
    
 // hides the slickbox as soon as the DOM is ready (a little sooner that page load)
 // $('#slickbox').show();

 // shows and hides and toggles the slickbox on click
  $('#slick-show').click(function() {
    //$('#closedHeader').slideUp('fast');
    $('#slickbox').slideDown('slow');
    $('#header_section_title').slideDown('fast');
    $('#logo').css('padding-bottom','10px');
    $('#toggle_close').slideDown('slow');
    $('.slickboxClosedHeader').slideUp('fast');
    $('#toggle_open').slideUp('fast');
    // Ajax request to set write the status in the session
    $.get(baseUrl + 'profiles/setSlickboxStatus/open');
    return false;
  });
  $('#slick-hide').click(function() {
    $('#slickbox').slideUp('fast');
    $('#header_section_title').slideUp('fast');
    //$('#closedHeader').slideDown('slow');
    $('.slickboxClosedHeader').slideDown('slow');
    $('#toggle_close').slideUp('fast');
    $('#toggle_open').slideDown('slow');
    // Ajax request to set write the status in the session
    $.get(baseUrl + 'profiles/setSlickboxStatus/close');
    return false;
  });
  $('#slick-toggle').click(function() {
    $('#slickbox').toggle(400);
    return false;
  });
  
  if($("img").hasClass("help")) {
  // Attach tooltip to the current class
    $('.help').cluetip({
        width: 200, 
        local: true, 
        cursor: 'pointer', 
        hideLocal: true , 
        showTitle: false, 
        cluetipClass: 'dark'
     });
   }  
  main_navigation();
});

//function that can be used to disable the screen till we want.
// Can be used when ajax requests are working, remove this by using tb_remove()
function tb_loading() {

    try {
        if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
            $("body","html").css({height: "100%", width: "100%"});
            $("html").css("overflow","hidden");
            if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
                $("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
            }
        } else {//all others
            if(document.getElementById("TB_overlay") === null){
                $("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
            }
        }

        if (tb_detectMacXFF()){
            $("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
        } else {
            $("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
        }

        var caption="";
        $("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
        $('#TB_load').show();//show loader
    } catch(e) {
        //nothing here
    }
}//end tb_loading()

// Function to decrypted the email id
function js_mailto(str_crypted) {
    str_email='';
    for (int_pos=0; int_pos < str_crypted.length; int_pos++)
    str_email += String.fromCharCode(str_crypted.charCodeAt(int_pos)+1);
    location.href='mailto:' + str_email;
}

function main_navigation() {
    $('.navitemsclass').click(function() {

    // current clicked navigation item classes
    var classes = ($(this).attr("class")).split(" ");

    for (var i in classes)
    {
        if (0 == classes[i].indexOf("navitemId"))
        {
            var value = (classes[i]).replace("navitemId", "");
            break;
        }
    }

    // Set needed cookie
    $.cookie('WA[navItemClicked]', value, { path: '/' });

    return true;
  });

}

