//Font Replacements
Cufon.replace('h1', { fontFamily: 'League Gothic' });
Cufon.replace('#content h2', { fontFamily: 'League Gothic' });
Cufon.replace('.subheading p', { fontFamily: 'League Gothic' });
Cufon.replace('div.banner-typo, .banner-typo1', { fontFamily: 'League Gothic' });


/*******Subheadings effect***********/
$(document).ready(function(){
	$(".subheading").prepend('<img src="' + BASE_URL + 'files/theme/images/body/subtitle.png" />');
	
	
	$('.subheading p').each(function(){
		var div = $(this).parent('div');
		var img = $(this).prev('img');
		img.width($(this).width() + 24);
	})
	
	$('.subheading p').hover(function(){
		var img = $(this).prev('img');
		if (!img.data('animating')) {
			img.data('animating', 1);
			img.animate({
				width: "+=40"
			}, "fast");
		}
	},
	function(){
		var img = $(this).prev('img');
		if (img.data('animating') == 1) {
			img.data('animating', 2);
			img.animate({
				width: "-=40"
			}, "slow", function(){
				img.data('animating', false);
			});
		}
	})
})
/***************************************/

/******Menubar related code****/
$(document).ready(function(){
	var nav = $("#menubar");
	var magic_line = $("li.magic-line", nav);
	var selected = $('li.menubar_selected', nav);
	var timer; 
	
	magic_line.css('left', selected.position().left + selected.outerWidth());
	
	var selected_a = $('a',selected); 
	var selected_back_x = selected_a.css('background-position');
	if (selected_back_x == undefined) { //if IE browser
		selected_a.css('background-position-y', '-25px');
	}
	else {
		selected_back_x = selected_back_x.substring(0, selected_back_x.indexOf('px'));
		selected_a.css('background-position', selected_back_x + 'px -25px');
	}
	
	$('li:not(.magic-line) > a', nav).hover(function(){ //mouse in
		clearTimeout(timer);
		var cur = $(this).parent('li');
		var newLeft = $(this).position().left + $(this).outerWidth() + 6;
		
		magic_line.stop().animate({
			left: newLeft
		}, 500, 'easeOutExpo')
	},
	function(){ //mouse out
		timer = setTimeout(function(){
								magic_line.animate({
									left: selected.position().left + selected.outerWidth()
								}, 500, 'easeOutExpo')
							}, 1500)
	})
	
});

/******************Header Slides Concept****************/
$(document).ready(function(){
	var header_slideshow = $("#header-slideshow");
	var loader = $("div.loader", header_slideshow);
	var main_banner = $("#main-banner");
	var img_url = BASE_URL + 'files/images/slides/' + main_banner.attr('class') + '.png';
	var banner_id = parseInt(main_banner.attr('class').substr(7));
	

	$('<img />').attr('src', img_url).load(function(){
		loader.fadeOut("slow", function(){
			main_banner.css('background-image', 'url(' + img_url + ')');
			
			switch(banner_id)
			{
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
					main_banner.animate({opacity: 'toggle',bottom: '+=70'}, 1500);
					setTimeout(function(){
						$('div.text1', header_slideshow).animate({top: 15,opacity: 'toggle'}, 1000, 'easeOutBack', function(){
									$('div.text2', header_slideshow).slideDown('slow', function(){
										$('div.text3', header_slideshow).fadeIn('slow');
									});
						});
					}, 550);
					
					
					break;
			}
		});
    })
})

/***********Misc*************/
$(document).ready(function(){
	var back_to_top = $("#back-to-top");
	back_to_top.fadeTo('slow', 0.4);
	
	back_to_top.hover(function(){
		$(this).stop().fadeTo('slow', 1);
	}, function(){
		$(this).stop().fadeTo('slow', 0.4);
	})
	
	$("#womo").fadeTo(1, 0.6).hover(function(){
		$(this).stop().fadeTo('slow', 1);
	}, function(){
		$(this).stop().fadeTo('slow', 0.6);
	})
})

