// JavaScript Document

// ----- START Search box focus/blur clear + refill -----
window.onload = function() {
	document.getElementById('searchfield').onfocus = function() {
		if (this.value == 'Search site') {
			this.value = '';
		}
		document.getElementById('search').className='focus';
	}
	document.getElementById('searchfield').onblur = function() {
		if (this.value == '') {
			this.value = 'Search site';
			document.getElementById('search').className='unfocus';
		}
	}

	if (document.getElementById('search2')) {
		document.getElementById('searchfield2').onfocus = function() {
			if (this.value == 'Search again') {
				this.value = '';
			}
			document.getElementById('search2').className='focus2';
		}
		document.getElementById('searchfield2').onblur = function() {
			if (this.value == '') {
				this.value = 'Search again';
				document.getElementById('search2').className='unfocus2';
			}
		}
		
	}

}





/* ##### jQuery Video preview fuction ##### */
jQuery(document).ready(function(){
	
	//if this is not the first preview, hide it
	jQuery(".preview-content:not(:first)").hide();
	
	//to show first
	jQuery(".preview-content:first").show();
	
	//when we click one of the preview list
	jQuery("#video-preview-list .list-content h4 a").click(function(){

		//get the ID of the element we need to show
		stringref = jQuery(this).attr("href").split('#')[1];

		// switch all preview list off
		jQuery(".activeitem").removeClass("activeitem");

		// switch this preview list on
		jQuery('#list-'+stringref).addClass("activeitem");

		//hide the preview that doesn't match the ID
		jQuery('.preview-content:not(#'+stringref+')').hide();
		//fix
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
			jQuery('.preview-content#' + stringref).show();
			//stay with me
			return false;
		}
		else {
			//display our preview fading it in
			jQuery('.preview-content#' + stringref).fadeIn();
			//stay with me
			return false;
		}
	});
});


/* ##### jQuery Tab fuction ##### */
jQuery(document).ready(function(){
	
	//if this is not the first tab, hide it
	jQuery(".tab-content:not(:first)").hide();
	
	//to show first
	jQuery(".tab-content:first").show();
	
	//when we click one of the tabs
	jQuery(".tabs a").click(function(){

		// switch all tabs off
		jQuery(".activetab").removeClass("activetab");

		// switch this tab on
		jQuery(this).addClass("activetab");

		//get the ID of the element we need to show
		stringref = jQuery(this).attr("href").split('#')[1];
		//hide the tabs that doesn't match the ID
		jQuery('.tab-content:not(#'+stringref+')').hide();
		//fix
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
			jQuery('.tab-content#' + stringref).show();
			//stay with me
			return false;
		}
		else {
			//display our tab fading it in
			jQuery('.tab-content#' + stringref).fadeIn();
			//stay with me
			return false;
		}
	});
});


/* ##### jQuery Accordion fuction ##### */
jQuery(document).ready(function(){

//if this is not the first accordion, hide it
	jQuery(".accordion-content:not(:first)").hide();
	
	//to show first
	jQuery(".accordion-content:first").show();
	
	//when click one of the accordion
	jQuery(".accordion-head a").click(function(){

		// switch all accordion off
		jQuery(".activeaccordion").removeClass("activeaccordion");

		// switch this accordion on
		jQuery(this).addClass("activeaccordion");

		//get the ID of the element we need to show
		stringref = jQuery(this).attr("href").split('#')[1];
		//hide the accordion that doesn't match the ID
		jQuery('.accordion-content:not(#'+stringref+')').hide();
		//fix
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
			jQuery('.accordion-content#' + stringref).show();
			//stay with me
			return false;
		}
		else {
			//display our accordion fading it in
			jQuery('.accordion-content#' + stringref).fadeIn();
			//stay with me
			return false;
		}
	});
});



/* ##### jQuery Left nav fuction ##### */
jQuery(document).ready(function(){

	//when click one of the top level nav items
	jQuery("#left-nav li a.parentlevel").click(function(event){

		// switch all accordion off
		jQuery("#left-nav li.toplevelcurrent").removeClass("toplevelcurrent");
		jQuery("#left-nav li.current").removeClass("current");

		// switch this accordion on
		jQuery(this).parent().addClass("toplevelcurrent");

	});

	//when click one of the sub level nav items
	jQuery("#left-nav li ul li a").click(function(event){

		// switch all accordion off
		jQuery("#left-nav li ul li.current").removeClass("current");

		// switch this accordion on
		jQuery(this).parent().addClass("current");

	});

});






