// POP-UP FUNCTIONS USED BY CMS
// ---------------------------------------------------------------------------------------

function open_in_popup_window(url, name, width, height) {
	window.open(url.href,name,'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	return false;
}
function open_in_new_window(url) {
	window.open(url.href,'external_link','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	return false;
}

// CODE FOR DROP-DOWN MENU SUPPORT IN IE6
// ---------------------------------------------------------------------------------------

sfHover = function() {
	var sfEls = document.getElementById("main_nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// JQUERY SCRIPTS FOR LIGHTBOX AND SLIDING PANELS
// ---------------------------------------------------------------------------------------
$(function()
{
	//apply behaviours to lightbox links
	$(".lightbox").lightbox();
	
	/* OLD FUNCTIONALITY //slides the element with class "slide_panel" when mouse is over the h3
	$("#sliding_panels h3").click(function()
	{
   		$(this).next("div.slide_panel").slideDown(500).siblings("div.slide_panel").slideUp(500).siblings('h3').removeClass("current");
		$(this).addClass("current");
	});
	*/
	
	//slides the element with class "slide_panel" when mouse is over the h3
	$("#sliding_panels h3").click(function()
	{
   		$(this).next("div.slide_panel").slideToggle(500);
		if ($(this).hasClass('current')) {
				$(this).removeClass("current");
		}
		else $(this).addClass("current");
	});
	
	
	//Homepage Slider
		$('#banner-images img').not(':first').hide();
	
	img1 = $('#banner-images img:eq(0)');
	img2 = $('#banner-images img:eq(1)');
	$tab1 = $('#tab-1');
	$tab2 = $('#tab-2');
	
	
	$tab1.mouseover(function(){
		$tab1.animate({'paddingRight':'100px'},'fast',function(){
			img1.fadeIn('fast');
			img2.fadeOut('fast');
		}).css({'zIndex':'1002'});
		$tab2.animate({'paddingRight':'38px'},'fast').css({'zIndex':'1001'});
	});
	
	$tab2.mouseover(function(){
		$tab2.animate({'paddingRight':'100px'},'fast',function(){
			img2.fadeIn('fast');
			img1.fadeOut('fast');
		}).css({'zIndex':'1002'});;
		$tab1.animate({'paddingRight':'38px'},'fast').css({'zIndex':'1001'});
	});
	
	$('#tab-1 a img, #tab-2 a img').hover(function(){
		$(this).attr('src',$(this).attr('src').replace('.png','_over.png'));
	},function(){
		$(this).attr('src',$(this).attr('src').replace('_over.png','.png'));
	});

});