jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
};

//$('body').css({opacity: .9999}); 
$.preloadImages("/images/design/about_emerson.jpg",
"/images/design/bullet.jpg",
"/images/design/certifications.jpg",
"/images/design/change_agents.jpg",

"/images/design/change_what.jpg",
"/images/design/change_who.jpg",
"/images/design/communicates.jpg",
"/images/design/contact_us.jpg",
"/images/design/culture.jpg",
"/images/design/dorian_personal.jpg",
"/images/design/dorian_survey.jpg",
"/images/design/emerson_logo_home.jpg",
"/images/design/emerson_logo_tag.jpg",
"/images/design/erp.jpg",
"/images/design/forum.jpg",
"/images/design/learning_development.jpg",
"/images/design/methodology.jpg",
"/images/design/organization_performs.jpg",
"/images/design/photos.gif",
"/images/design/talk_about_change.jpg",
"/images/design/think_about_change.jpg",
"/images/design/got_change_bkg.jpg",
"/images/design/x.jpg",

"/images/design/agents_survey/a_ferdon_survey.jpg",
"/images/design/agents_survey/b_huanan_survey.jpg",
"/images/design/agents_survey/b_kraska_survey.jpg",
"/images/design/agents_survey/b_rousos_survey.jpg",
"/images/design/agents_survey/c_conway_survey.jpg",
"/images/design/agents_survey/c_harper_survey.jpg",
"/images/design/agents_survey/d_davenport_survey.jpg",
"/images/design/agents_survey/d_hernandez_survey.jpg",
"/images/design/agents_survey/dorian_survey.jpg",
"/images/design/agents_survey/f_adamson_survey.jpg",
"/images/design/agents_survey/j_addison_survey.jpg",
"/images/design/agents_survey/j_johnson_survey.jpg",
"/images/design/agents_survey/j_munagian_survey.jpg",
"/images/design/agents_survey/k_lewis_survey.jpg",
"/images/design/agents_survey/m_stewart_survey.jpg",
"/images/design/agents_survey/m_waller_survey.jpg",
"/images/design/agents_survey/m_webster_survey.jpg",
"/images/design/agents_survey/r_spiros_survey.jpg",
"/images/design/agents_survey/s_simos_survey.jpg",
"/images/design/agents_survey/t_emerson_survey.jpg",
"/images/design/agents_survey/v_cavanaugh_survey.jpg",
"/images/design/agents_gif/t_emerson.gif",
"/images/design/agents_gif/a_caudill.gif",
"/images/design/bubble-l.jpg",
"/images/design/bubble-r.jpg",
"/images/design/bubble-m.jpg"
);

$(document).ready(function() {



//external links to open in new window
$('a[@rel*="external"]').click( function() {
window.open( $(this).attr("href") );
return false;
});


// validation workshops

$('input.workshops').click( function() {

	var validator = $("#workshops").validate();
	validator.resetForm();
		
   $("#workshops").validate().element( "#email");
   $("#workshops").validate().element( "#firstname" );
   $("#workshops").validate().element( "#lastname" );


});


// validation subscription

$('input.subscribe').click( function() {
	var validator = $("#subscribe").validate();
	validator.resetForm();
		
   $("#subscribe").validate().element( "#email");
   $("#subscribe").validate().element( "#firstname" );
   $("#subscribe").validate().element( "#lastname" );

});

// validation unsubscription

$('input.unsubscribe').click( function() {
		 
	var validator = $("#unsubscribe").validate();
	validator.resetForm();
									   
   $("#unsubscribe").validate().element( "#email2");

});


$('input.unsubscribe').click( function() {
	var validator = $("#subscribe").validate();
	validator.resetForm();
									   
   $("#subscribe").validate().element( "#email2");
    $("#email").val("");
	 $("#firstname").val("");
	  $("#lastname").val("");

});

$('#content').find('#FlashArea').addClass('FlashAreaNoFlash');

// Change agents images
$(".survey").fadeTo(3000, 1).fadeOut(2000,nextImg);


 
 function nextImg(){
	 $(".personal").fadeIn("slow"); 
 }
 

//global nav drop downs
$('ul.sf-menu').superfish({ 
           // delay:       1000,                            // one second delay on mouseout 
            animation:   {opacity: 1,height:'show'},  // fade-in and slide-down animation 
           
			speed:  200                         // faster animation speed 
           // autoArrows:  false,                           // disable generation of arrow mark-up 
           // dropShadows: false                            // disable drop shadows 
        });

//adds the right border in the global nav (except the last)
$(".sf-menu > li:not(:last)").css('border-right','1px solid #79bf33');

//adds the right border in the subnav (except the last)
$(".subnav > a:not(:last)").after('&nbsp;&nbsp;...&nbsp;&nbsp;');
$(".subnav2 > a:not(:last)").after(' | ');

//adds the right border in the sidenav (except the last)
$("ul.sidenav > li:not(:last),ul.sidenav_agents > li:not(:last),ul.pr > li:not(:last)").css('border-bottom','1px dotted #79bf33');

$("li  a.togglebtn").click(function(){
							   
		
							 
		$(this).next(".togglethis").animate({ height: 'toggle', opacity: 'toggle' }, 'fast',ctest);
		$(this).siblings(".togglequote").animate({ opacity: 'toggle' }, 'slow' );

		$(this).parent("li").siblings("li").find(".togglethis").slideUp('slow');
	    $(this).parent("li").siblings("li").find(".togglequote").fadeOut('slow');
	
	
		
	
		return false;
  });

function ctest(){
	
		$(this).parent("li").removeClass("inactive");
	$(this).parent("li").addClass("toggleactive");
		//$(this).parent("li.toggleactive").removeClass("toggleactive");
	
		
		$(this).parent("li.toggleactive").siblings("li").removeClass("toggleactive");
};


 $("li.toggleactive a.togglebtn").click(function(){
							   	
	$(this).removeClass("toggleactive");
	$(this).addClass("inactive");

		
		return false;
  });
 



//opens the popupbox and closes the others
$(".popup").click(function(){
			
		$(this).next(".popupbox").removeShadow();
		$(this).next(".popupbox").show("fast", showShadow);
		//$(this).next(".popupbox").dropShadow();
		$(this).parent("li").siblings().find(".popupbox").hide();
		$(this).parent("li").siblings().find(".popupbox").removeShadow();
		return false;
		
  });

function showShadow(){
	$(this).dropShadow();
};
//closes the popup box
$(".close").click(function(){
							 
		$(this).parent(".popupbox").hide();
			$(this).parent(".popupbox").removeShadow();
		
		return false;
		
  });


//opens the popupbox and closes the others
$(".popup2").click(function(){
			
		$(this).next(".popupbox2").removeShadow();
		$(this).next(".popupbox2").show("fast", showShadow2);
		
		$(this).parent(".popupwrap").siblings(".popupwrap").find(".popupbox2").hide();
		$(this).parent(".popupwrap").siblings(".popupwrap").find(".popupbox2").removeShadow();
		
	
		

		return false;
		
  });

function showShadow2(){
	$(this).dropShadow();
};
//closes the popup box
$(".close2").click(function(){
							 
		$(this).parents(".popupbox2").hide();
		$(this).parents(".popupbox2").removeShadow();
		
		return false;
		
  });


$.fn.pause = function(duration) {
    $(this).animate({ dummy: 1 }, duration);
    return this;
};

$("#bubble").pause(10000).fadeIn();

//row striping for pr list
//$('ul.pr li:odd').addClass('alt');


});