/*
Title: Style 5 General Javascript 
Created: 2008-06-01
Author: James Deathe, JaR Design Services Ltd.
Purpose: General Javascript for Style 5 Template
*/

//Hide / Show Elements when javascript is enabled.
$('.js_hide').hide();
$('.js_show').show();

// Date picker (UK Region)
jQuery(function($){
	$.datepicker.regional['en-GB'] = {
		closeText: 'Done',
		prevText: 'Prev',
		nextText: 'Next',
		currentText: 'Today',
		monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
		dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
		weekHeader: 'Wk',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['en-GB']);
});

$(document).ready(function () {
	$(".date_picker").datepicker({
		showOn: 'button',
		buttonImage: '/templates/amptron/images/icons/calendar.png',
		buttonImageOnly: true
	});
});

// Accordion navigation menu
$(document).ready(function () {
	$("#menu").accordion({
		header: 'a.menu',
		collapsible: false,
		//active: 1,
		//navigation: true,
		//event: 'mouseover',
		//fillSpace: true,
		//animated: 'slide',
		animated: false,
		autoHeight: false
	});
});

// Accordion Competencies Box
$(document).ready(function () {
	$("#service_function_competencies").accordion({
		header: 'h3',
		collapsible: false,
		active: 0,
		animated: 'slide',
		/*animated: false,*/
		autoHeight: false,
		icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus' }
	}).css('padding', '10px 10px 10px 18px');
});

//jQuery Cycle Lite Plugin
/*$(document).ready(function() {
	$('.slideshow').cycle();
	
	$('.gallery').cycle({ 
		prev:	'.prev',
		next:	'.next',
		timeout: 0 
	});
});*/

//Set the left alignment of the portfolio infobox to line up with the
//bread width and appear like a drop-down menu.
//$(document).each(function () {
$(document).ready(function () {
	var left_px = $(".bread_width").outerWidth() - $("#bread_end").outerWidth()
	$("#experience_content_box").css("left", left_px);
});
	
// Adjust content height to push the footer to the bottom of the 
// browser window if not enough content exists. Style choise only.
$(document).ready(function() {
//$(window).load(function() {
	// Don't run the equal heights script if in the portfolio section
	// since the transparency of the breadcrumb bar is lost in firefox
	
	if ($('img#experience_static').length > 0) {
		// Set the page body height
		$("#page_body").height($(window).height()-(
			$("#header").outerHeight()+
			$("#breadouter").outerHeight()+
			$("#footer").outerHeight()+
			parseInt($("#page_body").css("padding-bottom"))
		));
		// Set the image height to fill the page
		$("#experience_content_box").hide();
		//$("#experience_background").height($("#page_body").outerHeight());
		$("img#experience_static")
		//$("#experience_background")
			.hide()
			.height($("#page_body").outerHeight())
			.width($(window).width())
			.fadeIn(2000, function () {
				// Fade in the experience content box
				$("#experience_content_box").slideDown("slow");
				//$(".experience_container").corners("10px transparent bottom-right anti-alias");
				/*$(".experience_container")
					.corners("10px transparent bottom-right anti-alias")
					.dropShadow({
						left    : 2, //(default = 4)
						top     : 2, //(default = 4)
						blur    : 2, //(default = 2)
						opacity : 0.3, //(default = 0.5)
						color   : "black", //(default = "black")
						swap    : false //(default = false)
					});*/
			});
	} 
	else {
		var min_window_height = $(window).height()-(
			$("#header").outerHeight()+
			$("#breadouter").outerHeight()+
			$("#footer").outerHeight()+
			parseInt($("#page_body").css("padding-bottom")));
		if ($("#page_body").height() < min_window_height) {
			/* equalHeights Causes an overflow scrolbar issue in IE 6 on the #content or .content_box area with height:100% --*/
			//$("#page_body").equalHeights(min_window_height);
			$("#page_body").height(min_window_height);
		}
	}
});


// Box Hover Effects
$(document).ready(function () {
	$('#business_sector_1, #business_sector_2, #business_sector_3, #business_sector_3, #index_box_2, #index_box_3, #index_box_4, #index_box_5').hover(
		function(){
			$(this).animate({
				opacity: 0.70,
				cursor: 'pointer'
			}, "fast", function() {
				$(this).animate({
					opacity: 1.00,
					cursor: 'pointer'
				}, 800);
			});
		},
		function(){
			$(this).css('cursor', 'auto');
		}
	);
});

// Debug heights
/*$(document).ready(function() {
	alert("#header: " + $("#header").outerHeight() + "\n" +
			"#bread_outer: " + $("#bread_outer").outerHeight() + "\n" +
			"#page_body: " + $("#page_body").outerHeight() + "\n" +
			"#content: " + $("#content").outerHeight() + "\n" +
			"#experience_movie: " + $("#experience_movie").outerHeight() + "\n" +
			"#experience_content_box: " + $("#experience_content_box").outerHeight() + "\n" +
			".business_sector_box height: " + $(".business_sector_box").outerHeight() + "\n" +
			".business_sector_box width: " + $(".business_sector_box").outerWidth() + "\n" +
			".business_sector_box_head: " + $(".business_sector_box_head").outerHeight() + "\n" +
			".business_sector_box_content: " + $(".business_sector_box_content").outerHeight() + "\n" +
			".bread_width width: " + $(".bread_width").outerWidth() + "\n" +
			"#bread_end width: " + $("#bread_end").outerWidth() + "\n" +
			"#footer: " + $("#footer").outerHeight()
	);
});*/

// jQuery EqualHeghts Plugin
/*$(document).ready(function() {
	$(".equal_height").equalHeights(300);
});*/


// jQuery meda plugin for header movie
/*$(document).ready(function() {
	$('#header_movie').media({ 
		bgColor: '#00538f',
		width: 200,
		height: 90,
		params: {
			WMODE: 'transparent',
			menu: false,
			align: 't'
		}
	});
});*/

// Round corners on tabs etc
$(document).ready(function() {
	//$("#tabs").hide().fadeIn("slow");
	//$(".ui-tabs-nav li").corners("3px top anti-alias");
	//$(".column_box_head").corners("2px transparent top anti-alias");
	$(".column_box_head").corners("2px transparent anti-alias");
	$(".column_box_content").corners("2px transparent anti-alias");
	$(".column_box_inner").corners("5px transparent anti-alias");
	//$(".form_area").corners("5px transparent anti-alias");
});

// Messagebox drop shadows
jQuery(function () {
	$(".messagebox_info").dropShadow({
			left    : 0, //(default = 4)
			top     : 0, //(default = 4)
			blur    : 1, //(default = 2)
			opacity : 0.3, //(default = 0.5)
			color   : "black", //(default = "black")
			swap    : false //(default = false)
	});
});

//News feed ticker/scroller
jQuery(function () {
	var page_id = $('body').attr('id');
	if (page_id == 'home') { // Only apply to the home page
		$('ul.news_ticker').show();
		$('.news_ticker').liScroll();
	}
});
