//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
var ajaxdiv = '';

//---------------------------------------------------------------------------------------------------------
//	Called when an ajax div is loaded. Put any interactivity that needs to happen inside the div here.
//---------------------------------------------------------------------------------------------------------
function ajaxload()
{
//---------------------------------------------------------------------------------------------------------
//	Close the ajax div
//---------------------------------------------------------------------------------------------------------
	$("a.close").click(function(event){
		event.preventDefault();
		$('#'+ajaxdiv).fadeOut('normal',function(){
			$(this).children('#ajax-inner').remove();
		});
		$("#dim").css('display','none');
	});
	
//---------------------------------------------------------------------------------------------------------
//	Search picker
//---------------------------------------------------------------------------------------------------------
	$('#choose-search').change(function(){
 		var selected = $('#choose-search option:selected').attr('value');
		$('.product-search').hide();
		$('#'+selected).show();
	});
}

$(document).ready(function() {
	//---------------------------------------------------------------------------------------------------------
	//	Ajax loader 
	//---------------------------------------------------------------------------------------------------------
	$("a.ajax,a.ajax-dim").click(function(event){
		event.preventDefault(); //	Don't follow the link
		
		//	Get the variables
		url   			= $(this).attr("href");
		ajaxdiv			= $(this).attr("target");
		selector		= $(this).attr("class");

		//	Load the taget and show
		$('#'+ajaxdiv).load(url,'',ajaxload).css('z-index','1010').fadeIn('normal');
		if (selector == 'ajax-dim') {
			$("#dim").css('display','block');
		};
	});

	//---------------------------------------------------------------------------------------------------------
	//	Overlay
	//---------------------------------------------------------------------------------------------------------
	$("a.showoverlay,a.showoverlay-dim").click(function(event){
		event.preventDefault(); //	Don't follow the link
		
		//	Get the variables
		div			= $(this).attr("rel");
		selector		= $(this).attr("class");

		//	Load the taget and show
		$(div).css('z-index','1010').fadeIn('normal');
		if (selector == 'showoverlay-dim') {
			$("#dim").css('display','block');
		};
	});
	
	//---------------------------------------------------------------------------------------------------------
	//	Product Page Tabs
	//---------------------------------------------------------------------------------------------------------
	$('.product-list h2').click(function(event){
		$(this).parent('.product-list').children('.tab').slideDown('normal',function(){
			$(this).children('.scroll').jScrollPane({scrollbarWidth:17,scrollbarMargin:0,showArrows:true});
		});
		$(this).hide();
	});

	$('.close-tab').click(function(event){
		$(this).parent('.tab').slideUp('normal').parent('.product-list').children('h2').show();
	});

	//---------------------------------------------------------------------------------------------------------
	//	Clear Form Fields
	//---------------------------------------------------------------------------------------------------------
	$('input.select-clear').focus(function(event){
		$(this).attr('value','');
	});
});

/*
if(typeof sIFR == "function"){
	sIFR.replaceElement(named({	sSelector:"body h1",
								sFlashSrc:"/site/sifr/bellgothic_blk_bt_leaded.swf",
								sColor:"#CCCCCC", 
								sLinkColor:"#CCCCCC",
								sHoverColor:"#CCCCCC", 
								nPaddingTop:20, 
								nPaddingBottom:20, 
								sWmode:"transparent", 
								sFlashVars:"textalign=right&offsetTop=0" }));
};
*/
