// JavaScript Document
jQuery(document).ready(function() {
    jQuery.noConflict();
    
    //Ankiro Search Keyword highligh for link and title
    if(jQuery('#searchResultsPage') && jQuery('ul.searchResultsList li').length > 0) {
    
        var searchText = jQuery('input#textSearch').val();
    
        jQuery('ul.searchResultsList li').each(function() {
            jQuery(this).children('h2').html(jQuery(this).children('h2').html().replace(new RegExp(searchText,"gi"), '<span class="searchBlue">' + searchText + '</span>'));
            jQuery(this).children('p').children('a').html(jQuery(this).children('p').children('a').html().replace(new RegExp(searchText,"gi"), '<span class="searchBlue">' + searchText + '</span>'));
        });
    }
    
    if(window.location.pathname.toString().toLowerCase() == '/sitecore/content/esf.aspx') {
        window.location = '/';
    }

    if (jQuery.browser.msie) {

    } 


	jQuery("#ctl03_ctl07_form_current > div").css("position","relative");
	jQuery("#ctl03_ctl07_form_current > div > span").css("display","block").css("background","none");
	jQuery("#ctl03_ctl07_form_current input:radio").addClass("inputRadio");
	jQuery("#ctl03_ctl07_form_current input:checkbox").addClass("inputCheckbox");
	jQuery("#ctl03_ctl07_form_current input:submit").addClass("inputSubmit");
	
	

 	if(jQuery(".toolsArea").length == 0){
		jQuery("#mainContent h1").css("margin-bottom","15px");
	}


    if ((jQuery("#mainContent h1").height() > 40) && (jQuery(".toolsArea").length  != 0)){
        var addMoreSpaceAbove = jQuery("#mainContent h1").height() ;
        jQuery(".toolsArea").css("top",addMoreSpaceAbove+7);
    }   

    jQuery(".searchPageProfileChangeAreaList p").click(function() {
        if (jQuery(".searchPageProfileChangeAreaList").hasClass('open'))
            jQuery(".searchPageProfileChangeAreaList").removeClass("open");
        else
            jQuery(".searchPageProfileChangeAreaList").addClass("open");
        return false;
    })
    jQuery("body").click(function() {
        jQuery(".searchPageProfileChangeAreaList").removeClass("open");

    })

/*
    jQuery(".recomandationForAllProfile a, .recomandationForActiveProfile a").corner("top 5px");
*/

    jQuery(".FAQList .answer").hide();





    jQuery(".recomandationForActiveProfile").click(function() {
        jQuery(this).addClass("activeTab");
        jQuery(this).siblings(".recomandationForAllProfile").removeClass("activeTab");
        jQuery(this).parent().siblings(".recomandationActiveProfileList").show();
        jQuery(this).parent().siblings(".recomandationAllProfileList").hide();
        return false;
    })


    jQuery(".recomandationForAllProfile").click(function() {
        jQuery(this).addClass("activeTab");
        jQuery(this).siblings(".recomandationForActiveProfile").removeClass("activeTab");
        jQuery(this).parent().siblings(".recomandationAllProfileList").show();
        jQuery(this).parent().siblings(".recomandationActiveProfileList").hide();
        return false;
    })
	


    /*
    jQuery(".FAQList h2").click(function(){
    if(jQuery(this).addClass("opened")){
    jQuery(this).removeClass("opened");
    }else{
    jQuery(this).addClass("opened");
    }
    jQuery(this).siblings(".answer").slideToggle("fast");
    })



    jQuery(".FAQList h2").toggle(
    function () {
    jQuery(this).addClass("opened");
    jQuery(this).siblings(".answer").slideDown("fast");
    },
    function () {
    jQuery(this).removeClass("opened");
    jQuery(this).siblings(".answer").slideUp("fast");
    }
    );
    */

    jQuery(".FAQList h2").click(function() {
		if (jQuery(this).hasClass("opened")){
		}else{
			jQuery(".FAQList h2").removeClass("opened");
			jQuery(".FAQList h2").siblings(".answer").slideUp("fast");
			jQuery(this).addClass("opened");
			jQuery(this).siblings(".answer").slideDown("fast");
		}
    })

    /*
    jQuery(function(){jQuery('.teaserBigImage h1, #profileCreateLink').pngFix();});
    */

    jQuery(".tools > ul > li, .FAQList h2").hover(function() {
        jQuery(this).addClass("hover");
    }, function() {
        jQuery(this).removeClass("hover");
    })

    jQuery(".tools > ul > li").each(function(i) {
        jQuery(this).children().children("li:last").addClass("lastChild")
    });



    jQuery(".tools  ul li ul li:last").addClass("lastChild");

    jQuery("#profileLink").addClass("darkRow");

    /*
    -----------------------------------------------
    / Equalize height of the Graphic Teasers on the same line
    -----------------------------------------------
    */

    jQuery('.employeePicture').append('<img src="/images/esf/employee_photo_corners.gif" alt="employee photo corners" class="employeePictureCorners" />');

    var profileTopOpen = false;

    jQuery('#profileCreateLink').click(function() {
        if (profileTopOpen == true) {
            //jQuery('#profileAreaWrapper').animate({ marginTop: "-316px" }, 1500 );
            //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a, .profileChange').removeClass('arrowDown');
            profileTopOpen = false
            return false;
        } else {
            jQuery('#profileAreaWrapper').animate({ marginTop: "0px" }, 1500);
            //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a, .profileChange').addClass('arrowDown');
            profileTopOpen = true;
            return false;
        }
    })

    jQuery('.profileChange, #profileActiveLink > a').click(function() {
        if (profileTopOpen == true) {
            return false;
        } else {
            jQuery('#profileAreaWrapper').animate({ marginTop: "0px" }, 1500);
            //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a, .profileChange').addClass('arrowDown');
            profileTopOpen = true;
            return false;
        }
    })

    jQuery('.recomandationsAreaChangeProfile a').click(function() {
        if (profileTopOpen == true) {
            //jQuery('#profileAreaWrapper').animate({ marginTop: "-316px" }, 1500 );
            //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a, .profileChange').removeClass('arrowDown');
            profileTopOpen = false
        } else {
            jQuery('#profileAreaWrapper').animate({ marginTop: "0px" }, 1500);
            //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a, .profileChange').addClass('arrowDown');
            profileTopOpen = true;
        }
    })
    /*
    jQuery(".searchPageProfileChange").click(function(){
	
	jQuery(".searchPageProfileChangeArea fieldset").slideToggle("fast");
    return false;
	
})
    */


    jQuery('#profileAreaCloseBtn').click(function() {
        jQuery('#profileAreaWrapper').animate({ marginTop: "-316px" }, 1500);
        //jQuery('#topMenu li#profileCreateLink a, .pageSearchLeftCol .searchPageProfileChange a').removeClass('arrowDown');
        profileTopOpen = false
        return false;
    })
    /*
    jQuery('#profileCreateLink, .profileChange').click(function(){
    jQuery('#profileAreaWrapper').animate({ marginTop: "0px" }, 1500 );
    return false;																
    })

jQuery('#profileAreaCloseBtn').click(function(){
    jQuery('#profileAreaWrapper').animate({ marginTop: "-316px" }, 1500 );
    return false;					
    })
    */


    // if there are less than three teasers on a row, we need to clear the content or it won't take into consideration the .graphicTeaser{margin-bottom: 10px;}


});
