// Java Document

/* creates new functions for the better fade in*/
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);
/* end of creates new functions*/


/*****************************/
/* Main jQuery function area */
/*****************************/
$(function() {
		   
/* test to see if Jquery contacting
$('p').hover(function() {
	$(this).css('color','red');
}); */


/* allows for the increase or decrease in teh fonr size */
/* see lynda.com for furterh info 
$('#typeSize a').click(function(event){
	var theText = $('h1, h2, h3, h4, p, li');
	var triggerEle = this ;
	theText.each( function(idx, ele){
		var $e = $(ele);
		var currentSize = $e.css('fontSize');
		var newSize = parseFloat(currentSize, 10);
		var endString = currentSize.slice(-2);
		if(triggerEle.id == 'largerType') {
			newSize *= 1.2;
		}
		else if (triggerEle.id == 'smallerType') {
			newSize /= 1.2;
		}
		$e.css('fontSize', newSize + endString);
		event.preventDefault();
	});
});
*/


/*when the user hovers over the DIV that contains the image and the text... */
        $('.box_container').hover(function(){
            /*... we get the DIV's width ... '*/
            var width = $(this).outerWidth();

            /*... and change the position of the image to that width with an animation effect... */
       /*         $(this).find('.box_image').fadeOut({queue:false},{duration:1000} );*/
        $(this).find('.box_image').animate({ left : width },{queue:false,duration:300});
            /*queue:false means that if hovered again it won't wait for the previous animation to finish
            duration:300 means that the animation effect will take 0.3 seconds to finish '*/

        }, function(){

            /*... and when he hovers out we get the image back to it's starting position using the same function... '*/
          /*	    $(this).find('.box_image').fadeIn({queue:false},{duration:1000});*/
		          $(this).find('.box_image').animate({ left : '0px' },{queue:false,duration:300});

        });
		
		
/* sets up the function for preloading images */

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

jQuery.preLoadImages(
	/*"images/home_page/homePageBoxOrange.png",*/
	"images/global/EJSmap_Large.jpg",
	"images/about_us/michaela-brug2.png", 
	"images/about_us/tim-johnson-pin.png", 
	"images/about_us/tom-forster.png", 
	"images/about_us/barbara-schonhofer-formal.png", 
	"images/about_us/emma-gant.png", 
	"images/about_us/rachel-dick.png",
	"images/about_us/jadwiga-gromadzka.png", 
	"images/about_us/stuart-mcadam.png", 
	"images/about_us/gaelle-meinguss.png")
;




/******************************
/*jQuery for the whole site*
/****************************/


		/*all h6 tags have a yellow arrow
		$("h6").append('<img src="../../images/global/yellow_arrow.gif" alt="" />');	*/	  
		
		/* rounds the corners of the left side bar to ??px
		$("#leftsidebar").corners("5px");			
		$("#rightsidebarquote").corners("5px");
		$(".whereLevel").corners("5px");
		$('.whatWeDo').corner("10px");
		$(".whoWeAre").corner("10px");
		$(".ourValues").corner("10px");
		$('.RC').corner("10px").parent().css('padding','1px').corner("12px").addClass('shadow');
		$("#toggle-view li").corner("10px");
		$("#toggle-view2 li").corner("10px");
		$("#rightsidebarsubsection").corner("10px");

*/
	
/* if javascript is running this will remove the prompt to turn it back on */
$("#javascriptPrompt").hide();	

/* gets all email addresses and adds a image a[href^=mailto:]*/
$("[href^=mailto]").prepend('<img id="" src="http://ejssearch.com/images/icons/email.png" style="position:relative; top:4px;"/>&nbsp;&nbsp;'); 

$("p:contains(44 )").prepend('<img id="" src="http://ejssearch.com/images/icons/phone.png" style="position:relative; top:3px;"/>&nbsp;&nbsp;');  /* NB the space after the 44 identifies which numbers gets the phone image*/


	
/* adds css to the first para*/
$("#mainContent p, #sectionintrobody p").first().addClass("firstPara"); 
		
/* switches back the css to the first para of relationships page to the standard 
		$(".relationshipscontent p").css("font-size","11px").css("color","#777").css("line-height","14px"); */
		
	
		/*Sets all main content to be invisible and then faded it in - Nice effect, but
		$(".thrColFixHdr #mainContent").css("display","none");
        $(".thrColFixHdr #mainContent").customFadeIn();

		$(".thrColFixHdr #rightsidebar").css("display","none");
        $(".thrColFixHdr #rightsidebar").customFadeIn();*/





/*toggle views like the accodian*/

/* currently used in the Testimonials*/
$('#toggle-view li').click(function () {

		var text = $(this).children('p');

		if (text.is(':hidden')) {
			text.slideDown('200');
			$(this).children('span').html('-');	
			$(this).children('h3').slideUp('200');
			$(this).children('h6.more').hide();
			$(this).children('h6.close').show();
			$(this).css("background-color","#f1f1f1");
		} else {
			text.slideUp('200');
			$(this).children('h3').slideDown('200');
			$(this).children('span').html('+');	
			$(this).children('h6.more').show();
			$(this).children('h6.close').hide();
			$(this).css("background-color","#fff");
		}
		
	});

$('#toggle-view2 li').click(function () {

		var text = $(this).children('p');

		if (text.is(':hidden')) {
			text.slideDown('200');
			$(this).children('span').html('-');	
			$(this).children('h3').slideUp('200');
			$(this).children('h6.more').hide();
			$(this).children('h6.close').show();
			$(this).css("background-color","#f1f1f1");
		} else {
			text.slideUp('200');
			$(this).children('h3').slideDown('200');
			$(this).children('span').html('+');	
			$(this).children('h6.more').show();
			$(this).children('h6.close').hide();
			$(this).css("background-color","#fff");
		}
		
	});




$(".rightsidebarquote").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});



/*allows certain "MainContents to go Wider*/
/*		$(".widerMainContent").css("width","675px");*/
	/*	$(".widerMainContent").css("height","450px");*/


/******************************
/* for Home Page */
/****************************/

/* removes the header boarder when in the class.frontPage */ 
/*$(".frontPage #header").css("border","none").css("height","100px");*/

/*makes the linksTo div clickable and links to the fist link in the div
$("#homePageMenu .linksTo").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});*/


/* does the menu for the home page Alt
$("#homePageMenuAlt .linksToAlt").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});*/

/* this sets the background back to white so if the back button is pressed it is not left as the highlight color 
$("#homePageMenuAlt .linksToAlt").click(function(){
	 	$(this).css("background-image","none"); 
		$(this).find("h1").css("color","#444");
});*/

/* makes the cursor change over .linksToAlt
$("#homePageMenuAlt .linksToAlt").hover(function(){
	$(this).css("background-color","#ffffff");
	$(this).css("background-image","url(http://ejssearch.com/images/home_page/homePageBoxOrange.png)");
	$(this).css("background-image","url(images/home_page/homePageBoxOrange.png)");
	$(this).find("h1").css("color","#ffffff");
}, function(){
	$(this).css("background-image","url(images/home_page/homePageBox.png)");
	$(this).find("h1").css("color","#000");
});*/


/* makes the cursor chanr over .linksTo
$("#homePageMenu .linksTo").hover(function(){
     $(this).addClass("hover");
}, function(){
     $(this).removeClass("hover");
});*/

/* hide the menu from the home page*/
if (document.title == "ejsSearch Home") {
	$("#mainmenu").hide();
	$("#header").css("background","none");
	
}
/* hide if containd */
if (document.title == "ejsSearch - What We Do") {
	$("#breadcrumbs").hide();
}
if (document.title == "ejsSearch - Who We Are") {
	$("#breadcrumbs").hide();
}
if (document.title == "ejs Search - Our Values") {
	$("#breadcrumbs").hide();
}

$(".homePageLinkBoth").hover(function(){
	$(this).stop().animate({left: -242},"1500");
/*	$(this).effect("fade");*/
	}, function(){	
	$(this).stop().animate({left: 0},"1500");
});


/*$(".homePageLinkBoth:eq(0)").css({ opacity: 0.0 }).delay(500).animate({ opacity: 1.0 }, 250);
$(".homePageLinkBoth:eq(1)").css({ opacity: 0.0 }).delay(1500).animate({ opacity: 1.0 }, 250);
$(".homePageLinkBoth:eq(2)").css({ opacity: 0.0 }).delay(2500).animate({ opacity: 1.0 }, 250);*/


		/*any em tag appears in boxes no tables*/
/*			$(".homePageBox .bodyImg").hover(function(){
					$(this).find("img").stop().fadeTo("normal", 0.75);
					$(this).find("em").stop().fadeTo("normal", 1);
			}, function(){
					$(this).find("img").stop().fadeTo("normal", 1);
					$(this).find("em").stop().fadeTo("normal", 0);

			});*/


/******************************
/*jQuery for all sub pages
/****************************/

/* allows the left hand menus to fix thier position is higher than the top of the page 
 var top = $('.scrollWrapper').offset().top - parseFloat($('.scrollWrapper').css('marginTop').replace(/auto/, 0));
  $(window).scroll(function (event) {
    // what the y position of the scroll is
    var y = $(this).scrollTop();

    // whether that's below the form
    if (y >= top) {
      // if so, ad the fixed class
      $('.scrollWrapper').addClass('fixed');
    } else {
      // otherwise remove it
      $('.scrollWrapper').removeClass('fixed');
    }
  });*/

/* end of scrollWrapper




/******************************
/*jQuery for international Pages
/****************************/

/* hide the menu from the international pages*/
if (document.title == "ejsSearch - Deutsch") {
	$(".nav-wrap").hide();
}
if (document.title == "ejsSearch - French") {
	$(".nav-wrap").hide();
}

/******************************
/*jQuery for client services*/
/****************************/

		/*show why use exec search*/
		$(".btn-slide em").hide(); /*hides the em*/
		$(".whyexecsearch a").click(function(){
			$(".whyexecsearchReason").slideToggle();
			$(".btn-slide em").toggle();
			$(".btn-slide p").toggle();
		});
		/*show why use exec search with slide panel*/
		$(".btn-slide").click(function(){
			$(".whyexecsearchReason").slideToggle("slow");
			$(this).toggleClass("active");
			$(".btn-slide em").toggle();
			$(".btn-slide p").toggle();
		});
		
/* makes the whole div clickable as a link*/
$(".boxesNoTableDown").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});


$(".rollOverElement").click(function(){
		  $("#ROE1").slideToggle();
});


/******************************
/*jQuery for Recent Assignments*/
/****************************/
/* fades in and out the notice for looking at the words */

$("#allcontent #rolloverNotice").delay(1000).fadeIn(1000).delay(2000).fadeOut(500);

/******************************
/*jQuery for About Us*/
/****************************/

/* index */

		/*any em tag appears in boxes no tables*/
			$(".boxFadeLink").hover(function(){
					$(this).find("img").stop().fadeTo("normal", 0.1);
					$(this).find("em").stop().fadeTo("normal", 1);
			}, function(){
					$(this).find("img").stop().fadeTo("normal", 1);
					$(this).find("em").stop().fadeTo("normal", 0);

			});



/* makes the whole div clickable as a link*/
$(".boxesNoTable").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});


/* folds down the bit in the right hand colum 
 $("#rightsidebarquote .foldDown").hide();*/
$("#rightsidebarquote span.more").hide();
 /* makes the hide show and visa versa*/
$("#rightsidebarquote").click(function(){
	$("span.more").hide();
    $("#rightsidebarquote .foldDown").slideDown();
}, function(){
	$("span.more").show();
    $("#rightsidebarquote .foldDown").hide();
});


/*change mainContent in .teampics to fill wider space for bios to take a wider area 
	$(".teamPics").css("width","675px");
	$(".teamPics").css("height","450px");
	$(".teamPics p a").css("text-decoration","none");*/
			
/* Values */
		/*changes the width of the content page			$(".relationshipscontent").css("width","700px");
*/

/* Practices 
			$(".practices").css("width","600px");*/

/******************************
/* Contact */
/****************************/

	
/* Print page - this only displays the option to display the code if Java script is enabled */
$('.printPage').prepend('<div class="print"><a href="#print" style="text-decoration:none;"><img src="http://ejssearch.com/images/icons/Printer(2).png" width="16" height="16" />&nbsp;&nbsp;Print this page</a>');
	$('.printPage .print a').click(function() {
  		window.print();
  	return false;
});
			
/* moved the bread crmbs to line up with title*/
$('contactUsBreadcrumbs .breadcrumbs').css("padding-left","200px");



/******************************
/* for language verions  */
/****************************/

/* removes menu bar from language pages */
if (document.title == "ejsSearch - International") {
	$("#mainmenu").hide();
}




/******************************
/* moving menus */
/****************************/

    var $el, leftPos, newWidth;
        $mainNav2 = $("#example-two");
    
    /*
        EXAMPLE ONE
    */
    
    /* Add Magic Line markup via JavaScript, because it ain't gonna work without */
    $("#example-one").append("<li id='magic-line'></li>");
    
    /* Cache it */
    var $magicLine = $("#magic-line");
    
    $magicLine
        .width($(".current_page_item").width())
        .css("left", $(".current_page_item a").position().left)
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#example-one li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });    
    });
    
    /*
        EXAMPLE TWO
    */
    $mainNav2.append("<li id='magic-line-two'></li>");
    
    var $magicLineTwo = $("#magic-line-two");
	var $topPos, $el2;

if ($(".current_page_item_two").length) { //#some element exists // checks to see if the class is in the page is so add teh parameters into magic line two 
	
    $magicLineTwo
		.height($mainNav2.height())  // this was the original
		/*.height($(".current_page_item_two").height())*/
        .css("top", $(".current_page_item_two a").position().top)
        .data("origTop", $(".current_page_item_two a").position().top);
}; // end if

    $("#example-two li").find("a").hover(function() {
        $el2 = $(this);
        topPos = $el2.position().top;
        $magicLineTwo.stop().animate({
            top: topPos
		});
    }, function() {
        $magicLineTwo.stop().animate({
            top: $magicLineTwo.data("origTop")
        });    
    });
	

/*develoment area*/

/*makes the text be displayed

$("#mainContent #button1").hover(function() {
										  $(".riseTextWrapper").show(); 
										  $(".riseText1").stop().animate({top:'0px'});							  
										  $(".riseText2").stop().animate({top:'500px'});
										  $(".riseText3").stop().animate({top:'500px'});

       }, function() {
		    
		
	});
$("#mainContent #button2").hover(function() {
										  $(".riseText1").stop().animate({top:'500px'});
										  $(".riseText2").stop().animate({top:'0px'});
							
										  $(".riseText3").stop().animate({top:'500px'});
       }, function() {
												  
	});
$("#mainContent #button3").hover(function() {
										
										  $(".riseText1").stop().animate({top:'500px'});
										  $(".riseText2").stop().animate({top:'500px'});
										  $(".riseText3").stop().animate({top:'0px'});
       }, function() {

	});										

$("#button4").click(function() {
							/*		$("#mainContent").mouseout(function() {
										  $(".riseText1").stop().animate({top:'500px'});
										  $(".riseText2").stop().animate({top:'500px'});
										  $(".riseText3").stop().animate({top:'500px'});

$(".riseTextWrapper").hide();
		    									
		
	});

*/




/*$(".linksBoxHomePage").hover(function() {
	$(".linksBoxHomePage img").fadeOut("slow");
}, function (){
$(".linksBoxHomePage img").effect("slide", "slow");
});*/

/*$("p, h2, h3, #mainContent li").css({ opacity: 0.0 }).animate({ opacity: 1.0 }, 1000);*/


/*$("p").click(function () {
      $("button").effect("fade", "slow");
    });
*/


/*this is the end brackets for the whole script*/
});
