// JavaScript Document


$(document).ready(function(){

//$(".leftnav_header_select, .leftnav_select, .subnav_select, .fourthnav_select").append(" &gt;&gt;");
  
/*------SEARCH POPULATE------*/
	function populateElement(selector, defvalue) {
		$(selector).each(function() {
			if($.trim(this.value) == "") {
				this.value = defvalue;
			} else if (this.value != defvalue) {
				$(this).css("font-size", "14px");
				$(this).css("font-weight", "normal");				
			}
		});
	  
		$(selector).focus(function() {
			if(this.value == defvalue) {
				this.value = "";
				$(this).css("font-size", "14px");
				$(this).css("font-weight", "normal");
			}
		});
		
		$(selector).blur(function() {
			if($.trim(this.value) == "") {
				$(this).css("font-size", "18px");
				$(this).css("font-weight", "bold");
				this.value = defvalue;
			}
		});
	 }
	populateElement('#topnav_searchbox', 'SEARCH');

	/*------END SEARCH POPULATE------*/

	/*------ START TOP NAV DROP DOWN ------*/
	var $overlay_wrapper, $topnav_bgbox;
	
	if ( !$overlay_wrapper ) { // Create overlay div if not already there
		append_overlay();
	}

	$("#topnav_search").hover(function() {
		$("#topnav_box").css("height", "42px");
		$("#topnav_box").css("top", "50px");
		$("#topnav_box").css("width", "219px");
		$("#topnav_box").css("left", "721px");
		$("#topnav_box").show();
//		$overlay_wrapper.css({opacity: 1}); // reset opacity to 1 every time.
//		$overlay_wrapper.stop(true).fadeIn(100);
//		$overlay_wrapper.stop(true).show();
//		Opacity reset and fadeIn/fadeOut breaks IE. Replace with show/hide.
		$overlay_wrapper.show();	
	}, function() {
		$("#topnav_box").hide();
		$("#topnav_box").css("width", "705px");
		$("#topnav_box").css("left", "235px");
		
//		$overlay_wrapper.stop(true).fadeOut(100);
		$overlay_wrapper.hide();
	});
	
	$("ul#topnav li#solution_menu").hover(function() { //Hover over event on list item
			$(this).addClass('current');
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/solutions_on.gif" });

			$(this).find(".topnav_content").show(); //Show the subnav
			$("#topnav_box").css("height", function() {
				return $("li.current > .topnav_content").height() + 65 + "px";
			});
			$("#topnav_box").show();
			$overlay_wrapper.show();
		}, function() { //on hover out...
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/solutions.gif" });
			$(this).removeClass('current');
			$("#topnav_box").hide();
			$(this).find(".topnav_content").hide(); //Hide the subnav
			$overlay_wrapper.hide();
		});
	
	$("ul#topnav li#resource_menu").hover(function() { //Hover over event on list item
			$(this).addClass('current');
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/resources_on.gif" });

			$(this).find(".topnav_content").show(); //Show the subnav
			$("#topnav_box").css("height", function() {
				return $("li.current > .topnav_content").height() + 65 + "px";
			});
			$("#topnav_box").show();
			$overlay_wrapper.show();
		}, function() { //on hover out...
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/resources.gif" });
			$(this).removeClass('current');
			$("#topnav_box").hide();
			$(this).find(".topnav_content").hide(); //Hide the subnav
			$overlay_wrapper.hide();
		});

	$("ul#topnav li#customer_menu").hover(function() { //Hover over event on list item
			$(this).addClass('current');
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/customers_on.gif" });

			$(this).find(".topnav_content").show(); //Show the subnav
			$("#topnav_box").css("height", function() {
				return $("li.current > .topnav_content").height() + 65 + "px";
			});
			$("#topnav_box").show();
			customer_on = true;
			$overlay_wrapper.show();
		}, function() { //on hover out...
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/customers.gif" });
			$(this).removeClass('current');
			$("#topnav_box").hide();
			$(this).find(".topnav_content").hide(); //Hide the subnav
			customer_on = false;
			$overlay_wrapper.hide();
		});		

	$("ul#topnav li#innovation_menu").hover(function() { //Hover over event on list item
			$(this).addClass('current');
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/innovation_on.gif" });

			$(this).find(".topnav_content").show(); //Show the subnav
			$("#topnav_box").css("height", function() {
				return $("li.current > .topnav_content").height() + 65 + "px";
			});
			$("#topnav_box").show();
			experience_on = true;
			$overlay_wrapper.show();

		}, function() { //on hover out...
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/innovation.gif" });
			$(this).removeClass('current');
			$("#topnav_box").hide();
			$(this).find(".topnav_content").hide(); //Hide the subnav
			experience_on = false;
			$overlay_wrapper.hide();
		});

	$("ul#topnav li#company_menu").hover(function() { //Hover over event on list item
			$(this).addClass('current');
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/company_on.gif" });

			$(this).find(".topnav_content").show(); //Show the subnav
			$("#topnav_box").css("height", function() {
				return $("li.current > .topnav_content").height() + 65 + "px";
			});
			$("#topnav_box").show();
			company_on = true;
			$overlay_wrapper.show();

		}, function() { //on hover out...
			$("li.current > a > img.menu_img").attr({ src: "Images/Navigation/company.gif" });
			$(this).removeClass('current');
			$("#topnav_box").hide();
			$(this).find(".topnav_content").hide(); //Hide the subnav
			company_on = false;
			$overlay_wrapper.hide();
		});
				
	/* END TOP NAV DROP DOWN  */

	function append_overlay() {
		$overlay_wrapper = $('<div id="overlay"></div>').appendTo( $('body') );
	}
  
  /* NEWS LETTER POPUP SCRIPT */
  
  
	$('a#newsletter_link').click(function(ev){
		  window.open('news_letter_form.html','Sign Up for Workday\'s Newsletter','width=350,height=200');
		  ev.preventDefault();
		  return false;
		
	});
	
	$('a.givefeedback').click( function() {
		loc = location.href;
		loc = loc.substring(loc.indexOf(".com") + 5);	
		window.open('https://www.workday.com/PreBuilt/feedback.php?loc=' + loc,'Feedback','scrollbars=yes,width=400,height=450', 'window1');
		return false; 
	});

	$('a.tellfriend').click( function() {
		loc = location.href;
		loc = loc.substring(loc.indexOf(".com") + 5);	
		window.open('https://www.workday.com/PreBuilt/tellafriend.php?loc=' + loc,'Tell a friend about Workday','scrollbars=yes,width=400,height=525', 'window2');
		return false; 
	});	

	/* POPULAR SEARCH DROPDOWN SCRIPT */
	var showing = false;	
	$('#arrow').css({backgroundPosition: '0px -15px'});
	$('#popularSearches').hide();
	
	$('#popularSearchBtn').click(function() {
	if (showing == false) {
	  showing = true;  
	  $('#arrow').animate({backgroundPosition: '0px 0px'});
	  $('#popularSearches').slideDown(100);
	  //$('#popularSearches').animate({height: '100px'});
	}
	else {
	  showing = false;
	  $('#arrow').animate({backgroundPosition: '0px -15px'});
	  $('#popularSearches').slideUp(100);
	}
	});
	
	
	$('#popularSearches').mouseleave(function() {
		if (showing == true) {
			showing = false;
			setTimeout(function() {				
				$('#arrow').animate({backgroundPosition: '0px -15px'});				
				$('#popularSearches').slideUp(100);
			}, 1300);	  
		} 
	});	
  
}); // END ALL JS


// BEGIN PNG FIX CODE

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);







