/*********************************************************************************************************************************/
/* DOCUMENT READY CALLS **********************************************************************************************************/
/*********************************************************************************************************************************/

$(document).ready(function(){
	
	/* PNGFIX start *******************************************************************/
		$(document).pngFix();
	/* PNGFIX end *********************************************************************/
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	/* EXTERNAL LINKS end *************************************************************/
	
	/* SLIDESHOW start ***************************************************************/
	setInterval( "slideSwitch()", 5000 );
	/* SLIDESHOW end *****************************************************************/
	
	/* PRODUCTS BY CATEGORY start ****************************************************/
	$('#nav-products-by-category ul li ul').hide();
	$('#nav-products-by-category ul li.active ul').show();
	$('#nav-products-by-category ul li span').click(function(){
		var $dropdown = $('ul',$(this).parent());
		var $this = $(this).parent();
		
		if($('#nav-products-by-category ul li').length >0){
			if($dropdown.is(':hidden')){
				$dropdown.show('slow');
				$this.addClass('active');
			}
			else{
				$this.removeClass('active');
				$dropdown.hide('slow');
			}
		}
	});
	/* PRODUCTS BY CATEGORY end *****************************************************/

}); //close document.ready

/*********************************************************************************************************************************/
/* DOCUMENT READY FUNCTIONS ******************************************************************************************************/
/*********************************************************************************************************************************/
/* SLIDESHOW function start *********************************************************/
function slideSwitch() {
	var $active = $('#slideshow span.active');

	if ( $active.length == 0 ) $active = $('#slideshow span:last');

	var $next =  $active.next('span').length ? $active.next()
			: $('#slideshow span:first');

	$active.addClass('last-active');
	
	$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 500, function() {
			 $active.removeClass('active last-active');
	});
	
}
/* SLIDESHOW function end ***********************************************************/

/*
function galleryPopup(id,width,height){
	var image = $('#'+id).attr('src');	
	if (width !=""){ var width_display = ' width="'+width+'"'; }else{var width_display = '';}
	if (height !=""){ var height_display = ' height="'+height+'"'; }else{var height_display = '';}	
	var description = $('#'+id).attr('title');
	
	$('body').prepend('<div id="popup-bg"></div><div id="gallery-image"><a class="close" onclick="popUpClose();">close [X]</a><img src="'+image+'"'+width_display+ height_display+'><p>'+description+'</p></div>');

	$("#popup-bg").css({ width:$('html').width(),height: $('html').height(),opacity:0.5  });
	$("#gallery-image").css({ "top": getYX("Y")+40,	"left": (document.documentElement.clientWidth/2)-($("#gallery-image").width()/2) });
	$('#popup-bg').click(function(){ popUpClose(); });
	$('#gallery-image .close').click(function(){ popUpClose(); });
	return false;
}
*/

