// JavaScript Document


	// image rollovers
	$(function() {
		
		// any image with the classname 'rollover'
		// the image must have version in the same location appended with '-over'
		// ie: image.jpg -> image-over.jpg
		$('.rollover').each(function() {
			var src = $(this).attr('src');
			if (src) {
				var over = src.replace(/(\.){1}(.{3,4})$/, "-over.$2");
				if ($(this).hasClass('active')) $(this).attr('src', over);
				else {
					var pic = new Image();
					pic.src = over;
					$(this).hover( function() {
						$(this).attr('src', over);
					}, function() {
						$(this).stop(true, false).attr('src', src);
					});
				}
			}
		});
		
		// images nested inside an '<a>' tag will fade on rollover
		// if not IE, and image doesn't have the classname 'rollover'
		/*
		if (navigator.appName != 'Microsoft Internet Explorer') {
			$("a img").each( function() {
				var img = $(this);
				if (!img.hasClass('rollover')) {
					img.parents('a').hover( function() {
						img.css({ opacity: 0.5 });
					}, function() {
						img.stop(true, false).css({ opacity: 1.0 });
					});
				}
			});
		}
		*/
		
	});
	
	
	// apply a scrolling effect to with class of 'horizontal_marquee' or 'lazy_horizontal_marquee'
	$(window).load(function() {

		if ($('.lazy_horizontal_marquee img.lazy').length > 0)
		{
			$('img.lazy').jail({event : "load", callback : function(){
				$('.lazy_horizontal_marquee').each(function(){
					lazyHorizontalMarquee = this;
					
					window.setTimeout(function(){
						HorizontalMarquee.call( lazyHorizontalMarquee, 30, 0 );
					},
					200); // wait for resize event
				});
			}});
		}		

		window.setTimeout(function(){
			$('.horizontal_marquee').each(function() {
				HorizontalMarquee.call( this, 50, 0 );
			});
		},
		200); // wait for resize event
	});
	
	
	// display country or language dropdown on rollover
	function onShow_CountryLanguage(elem, idx) {
		// target 'header_utility_language' element
		parent = $(elem).parents('.header_utility_language');
		
		if (idx == 0) {
			// remove hover class to hide dropdowns
			$(parent).attr('class', 'header_utility_language');
		} else {
			// add hover class to display dropdown
			$(parent).attr('class', 'header_utility_language header_utility_language_hover_' + idx);
			
			// add rollout event on 'header_utility_language_container'
			$('.header_utility_language_container', parent).unbind('mouseleave').bind('mouseleave', function() {
				onShow_CountryLanguage(this, 0);
			});
		}
	};
	
	
	// change home page banner image during navigation roll over
	function onSwitchBanner(btn, idx) {
		// remove active class from any links
		$('.header_navigtion_links li.active1').removeClass('active1');
		
		// add active class to moused over element
		$(btn).parent('li').addClass('active1');
		
		// hide all banner images, then show banner corresponding to link's position
		if (idx != undefined) {
			$('.homepage_banners_container').children().hide().eq(idx).show();
		}
	};
	
	
	// expand / contract page content
	$(function() {
		$('a.content_expand').click(function() {
			$(this).parents('div.content_expand').hide().next('div.content_collapse').show();
		});
		$('a.content_collapse').click(function() {
			$(this).parents('div.content_collapse').hide().prev('div.content_expand').show();
		});
	});


