$(document).ready(function() {
	$("#JobSearch_lbxJobCategory").focus(function(){
		$(this).removeClass("select");
	}).blur(function(){
		$(this).addClass("select");
	});
	
	/*var unsubscribe = $('#UnsubscribeJobAlert1_UserLogin_ctl01');
	if(unsubscribe.length != 0){
		DD_roundies.addRule('#UnsubscribeJobAlert1_UserLogin_ctl01 label', '7px');		
	}*/
	
	$("input:image").addClass("image");
	$(".error").prepend("<br />");

});
/*  Steps  */
function clearProfileSteps() {
$("ul[id$=stepMenu] li").removeClass("current");
}
/*  ----  */

function pageLoad(sender, args) {

	/* Steps Profile details */
	if (window.location.href.toLowerCase().indexOf("work-preference") != -1) {
		clearProfileSteps();
		$("li[id$=LIStep2]").addClass("current");
	}
	else if (
		window.location.href.toLowerCase().indexOf("email-me-job-filter.") != -1) {
		clearProfileSteps();
		$("li[id$=LIStep3]").addClass("current");
	}
	else if (
		window.location.href.toLowerCase().indexOf("save-and-apply") != -1) {
		clearProfileSteps();
		$("li[id$=LIStep4]").addClass("current");
	}
	/* --------------- */

	if ($("*").is("h1#cms_components")) {
		$("input[id$=btnSend]").wrap("<ol><li>");
	}
	
	if ($("*").is("div#jobResults")) {
		if ($.cookie('yellowNotice')) {
			$("div#jobResults").css("display", "none");
		}
	}
	
	//arrows on the buttons
	$('a.button').prepend('<span>&nbsp;</span>');
	$('input.button').before('<span class="arrow">&nbsp;</span>');
	$("input.button").hover(
		function () {
			$(this).prev("span").addClass("hover");},
		function () {
	     		$(this).prev("span").removeClass("hover");
	  });
	  
	//delete notice on search results
	$(".yellow-notice a.close").click(function(){
		$(this).parents(".yellow-notice").animate({ opacity: "hide" }, "slow");
	 	$.cookie('yellowNotice', 'true');
	});

	// inField
	$("fieldset").addClass("infield");
	$(".infield li label").inFieldLabels();
	
	var jobDetailsHeight = $("#jobdetails").height();
	
	if (jobDetailsHeight != null && jobDetailsHeight < 400) {
            $("input[id$=btnApply]").css("display", "none");
            $("input[id$=btnApply]").prev().css("display", "none");
        }
        
        //Show (show second form on job alerts page)
	$('.reveal').hide(); //Hide second form
	$('.reveal-trigger').show(); //toggles are hidden in CSS so they don't display when JS is disabled, they will show if js is enabled.
	$('.reveal-trigger').click(function(){
		$(this).parent().prev().removeClass('reveal');
		$(this).parent().prev().slideToggle();
		$(this).parent().fadeOut();
		return false; //Prevent the browser jump to the link anchor
	});
}

/*
* In-Field Label jQuery Plugin
* http://fuelyourcoding.com/scripts/infield.html
*
* Copyright (c) 2009 Doug Neiner
* Dual licensed under the MIT and GPL licenses.
* Uses the same license as jQuery, see:
* http://docs.jquery.com/License
*
* @version 0.1
*/
(function($) { $.InFieldLabels = function(b, c, d) { var f = this; f.$label = $(b); f.label = b; f.$field = $(c); f.field = c; f.$label.data("InFieldLabels", f); f.showing = true; f.init = function() { f.options = $.extend({}, $.InFieldLabels.defaultOptions, d); if (f.$field.val() != "") { f.$label.hide(); f.showing = false }; f.$field.focus(function() { f.fadeOnFocus() }).blur(function() { f.checkForEmpty(true) }).bind('keydown.infieldlabel', function(e) { f.hideOnChange(e) }).change(function(e) { f.checkForEmpty() }).bind('onPropertyChange', function() { f.checkForEmpty() }) }; f.fadeOnFocus = function() { if (f.showing) { f.setOpacity(f.options.fadeOpacity) } }; f.setOpacity = function(a) { f.$label.stop().animate({ opacity: a }, f.options.fadeDuration); f.showing = (a > 0.0) }; f.checkForEmpty = function(a) { if (f.$field.val() == "") { f.prepForShow(); f.setOpacity(a ? 1.0 : f.options.fadeOpacity) } else { f.setOpacity(0.0) } }; f.prepForShow = function(e) { if (!f.showing) { f.$label.css({ opacity: 0.0 }).show(); f.$field.bind('keydown.infieldlabel', function(e) { f.hideOnChange(e) }) } }; f.hideOnChange = function(e) { if ((e.keyCode == 16) || (e.keyCode == 9)) return; if (f.showing) { f.$label.hide(); f.showing = false }; f.$field.unbind('keydown.infieldlabel') }; f.init() }; $.InFieldLabels.defaultOptions = { fadeOpacity: 0.5, fadeDuration: 300 }; $.fn.inFieldLabels = function(c) { return this.each(function() { var a = $(this).attr('for'); if (!a) return; var b = $("input#" + a + "[type='text']," + "input#" + a + "[type='password']," + "textarea#" + a); if (b.length == 0) return; (new $.InFieldLabels(this, b[0], c)) }) } })(jQuery);




function VerifyOnFocus(obj)
{
    if (obj.name.indexOf("txtEmail") > 0)
    {
        if (obj.value == "Email Address")
            obj.value = "";            
    }

    if (obj.name.indexOf("txtName") > 0)
    {
        if (obj.value == "Name")
            obj.value = "";
    }

    if (obj.name.indexOf("txtConfirmEmail") > 0) {
        if (obj.value == "Confirm Email Address")
            obj.value = "";
    }
}

function VerifyOnBlur(obj)
{
    if (obj.name.indexOf("txtEmail") > 0)
    {
        if (obj.value == "")
            obj.value = "Email Address";            
    }

    if (obj.name.indexOf("txtName") > 0)
    {
        if (obj.value == "")
            obj.value = "Name";                
    }
}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
	return false;
}
