;(function($) { 
   $(document).ready(function() { 
		// Menu
		$(".header .navigation li").hoverIntent({
			sensitivity: 1, 
			interval: 1, 
			over: function() {
				$(this).addClass("selected");
				$(".sub", this).removeClass("hide").animate({opacity: 1}, 100);
			}, 
			timeout: 50, 
			out: function() {
				$(this).removeClass("selected");
				$(".sub", this).addClass("hide").animate({opacity: .0}, 100);
			}
		});
		$(".header .sub").addClass("hide");
		
		if(!document.getElementById('home')) {
			$(".screen h2").each(
				function() {
					$(this).text($(this).text().replace("%", "%25"));
				}
			);
		}
		// Flash-Text Replacement: Content H1
		$('#default .screen .content h1 span').flash(
			{ 
				src: basePath+'interface/flash/avenir-light.swf',  
				flashvars: { 
					css: [
						'* { color: #878360; }',
						'a { color: #878360; text-decoration: none; }',
						'a:hover { text-decoration: underline; }'
					].join(' ')
				},
				wmode: "transparent"
			},
			{ version: 7 },
			function(htmlOptions) {
				htmlOptions.flashvars.txt = this.innerHTML;
				this.innerHTML = '<span>'+this.innerHTML+'</span>';
				var $alt = $(this.firstChild);
				htmlOptions.height = $alt.height();
				htmlOptions.width = $alt.width();
				$alt.addClass('alt');
				$(this)
					.addClass('flash-replaced')
					.prepend($.fn.flash.transform(htmlOptions));						
			}
		);
		// Flash-Text Replacement: Content H2
		$('.screen .content h2, .screen .navigation h2').flash(
			{ 
				src: basePath+'interface/flash/avenir-medium.swf',  
				flashvars: { 
					css: [
						'* { color: #5B558D; }',
						'a { color: #5B558D; text-decoration: none; }',
						'a:hover { text-decoration: underline; }'
					].join(' ')
				},
				wmode: "transparent"
			},
			{ version: 7 },
			function(htmlOptions) {
				htmlOptions.flashvars.txt = this.innerHTML;
				this.innerHTML = '<span>'+this.innerHTML+'</span>';
				var $alt = $(this.firstChild);
				htmlOptions.height = $alt.height();
				htmlOptions.width = $alt.width();
				$alt.addClass('alt');
				$(this)
					.addClass('flash-replaced')
					.prepend($.fn.flash.transform(htmlOptions));						
			}
		);
		// Flash-Text Replacement: Content H3
		$('.screen .content h3').flash(
			{ 
				src: basePath+'interface/flash/avenir-light.swf',  
				flashvars: { 
					css: [
						'* { color: #878360; }',
						'a { color: #878360; text-decoration: none; }',
						'a:hover { text-decoration: underline; }'
					].join(' ')
				},
				wmode: "transparent"
			},
			{ version: 7 },
			function(htmlOptions) {
				htmlOptions.flashvars.txt = this.innerHTML;
				this.innerHTML = '<span>'+this.innerHTML+'</span>';
				var $alt = $(this.firstChild);
				htmlOptions.height = $alt.height();
				htmlOptions.width = $alt.width();
				$alt.addClass('alt');
				$(this)
					.addClass('flash-replaced')
					.prepend($.fn.flash.transform(htmlOptions));						
			}
		);
		
		$("#home .banner").append('<ul class="banner-btns"></ul><a href="#ctrNext" id="ctrNext"></a><a href="#ctrPrev" id="ctrPrev"></a>');
		$("#home .banner .cycle").cycle({ 
			fx:     'fade', 
		    speed:   400, 
		    timeout: 8000, 
		    pause:   1,
			prev:   '#ctrPrev', 
			next:   '#ctrNext',
			pager: '.banner-btns',
			pagerAnchorBuilder: function bannerBtns(ind) {
				if (ind == 0) return '<li><a href="#"><img src="themes/maximusuk/interface/images/home-banner-buttons-jobseekers.jpg" width="113" height="186" alt="Jobseekers"><strong class="offleft">Jobseekers</strong></a></li>';
				else if (ind == 1) return '<li><a href="#"><img src="themes/maximusuk/interface/images/home-banner-buttons-employers.jpg" width="113" height="186" alt="Employers"><strong class="offleft">Employers</strong></a></li>';
				else if (ind == 2) return '<li><a href="#"><img src="themes/maximusuk/interface/images/home-banner-buttons-government.jpg" width="113" height="186" alt="Government"><strong class="offleft">Government</strong></a></li>';
				else if (ind == 3) return '<li><a href="#"><img src="themes/maximusuk/interface/images/home-banner-buttons-partners.jpg" width="113" height="186" alt="Partners"><strong class="offleft">Partners</strong></a></li>';
				else if (ind == 4) return '<li><a href="#"><img src="themes/maximusuk/interface/images/home-banner-buttons-worldwide.jpg" width="113" height="186" alt="Worldwide"><strong class="offleft">Worldwide</strong></a></li>';
				else if (ind == 5) return '<li class="offleft"></li>';
			}
		});
		
		//
		
		
			
		var homepageScroller = setInterval(function(){
			var iOldScrollerTop = $("#home .news ul").scrollTop(); 
			$("#home .news ul").scrollTop(iOldScrollerTop + 1);
			if(iOldScrollerTop == $("#home .news ul").scrollTop()){
				$("#home .news ul").scrollTop(0);
			}
		}, 40);
		
		// Consitina 
		$(".jse .extended").slideUp(10);
		$(".jse .expand").each(
			function() {
				$(this).prepend('<a href="#" class="ctr more"><span class="offleft">more +</span></a>');
				$("a.more", this).click(
					function() {
						consitinaIt($(this));
						/*
						if($(this)[0].className=="more") {
							//$(this).parents(".expand").addClass("expanded");
							$(this).parents(".expand").find(".extended").slideDown(320);
							
							$(this).removeClass("more").addClass("less");
							$("span", this).text("less -");
						} else {
							//$(this).parents(".expand").removeClass("expanded");
							$(this).parents(".expand").find(".extended").slideUp(160);
							
							$(this).removeClass("less").addClass("more");
							$("span", this).text("more +");
						} 
						*/
						return false;
					}
				);
				$(this).click(
					function() {
						consitinaIt($("a.ctr", this));
					}
				);
			}
		);
		
		// Custom
		$(".split").next().addClass("cleft");	
   }) 
})(jQuery);

function consitinaIt(linkRef) {
	;(function($) { 
		if(linkRef[0].className=="ctr more") {
			linkRef.parents(".expand").find(".extended").slideDown(320);
			
			linkRef.removeClass("more").addClass("less");
			$("span", linkRef[0]).text("less -");
		} else {
			linkRef.parents(".expand").find(".extended").slideUp(160);
			
			linkRef.removeClass("less").addClass("more");
			$("span", linkRef[0]).text("more +");
		}
	})(jQuery);	
}

function printPage() {
	;(function($) { 
		if (window.print) {
			window.print() ;
		} else {
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
		}
	})(jQuery);
}

// Debugging
jQuery.fn.debug = function() {
  return this.each(function(){
    alert(this);
  });
};
jQuery.log = function(message) {
  if(window.console) {
     console.debug(message);
  } else {
     alert(message);
  }
};

