$(document).ready(function(){
	
	/* PNGFIX start *******************************************************************/
		$(document).pngFix();
	/* PNGFIX end *********************************************************************/
	
	/* EXTERNAL LINKS start ***********************************************************/
	$('a[@rel$="external"]').click(function(){
		this.target = "_blank";
	});	
	/* EXTERNAL LINKS end *************************************************************/
	
	$('#btn-register-online-now').click(function(){
		alert('You will now be redirected to the Strategic Medical Seminars website to complete your 3C registration.');
		this.target = "_blank";
	});		
	
	/* NAVIGATION start ***************************************************************/
	//$('#nav ul ul').prepend('<li class="top"></li>');
	//$('#nav ul ul').append('<li class="bottom"></li>');
	$('#nav ul ul').hide();
	//hover show next level
	$('#nav ul > li').hover(function() { $('ul:first', this).show(); },function() {$('ul:first', this).hide();});
	//add class for flyouts
	if ($('#nav ul ul ul').length > 0) { $('#nav ul ul ul ').parent().addClass('flyout'); }
	
	$('#nav li.menu-cat:first').addClass('first');
	$('#nav li.menu-cat:last').addClass('last');
	/* NAVIGATION end ****************************************************************/
	
	/* SIFR***************************************************************************/
	sifr('.font-01','font-swis721-ex-bt');
	/* SIFR**************************************************************************/
	
	/* SLIDESHOW start **************************************************************/
	setInterval( "slideSwitch()", 5000 );
	/* SLIDESHOW end ****************************************************************/	
		
}); //close document.ready

/* SIFR function start **************************************************************/
function sifr(x,font){
$(x).flash(
	{ src: '/includes/media/'+font+'.swf' },
	 { version: 8 },
		function(htmlOptions) {
			htmlOptions.flashvars.css = '*%20%7B%20color%3A%23'+RGBstring($(this).css('color'))+'%7D';
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<div>'+this.innerHTML+'</div>';
			var $alt = $(this.firstChild);
			htmlOptions.width = $(this).width(); //$alt.width()
			htmlOptions.height = $(this).height(); //$alt.height()
			$alt.addClass('sifr-alt');
			$(this).addClass('sifr-text-alt').prepend($.fn.flash.transform(htmlOptions));						
		}
	);
}
/* SIFR function end ****************************************************************/

/* sIFR RGB conversion function start **********************************************/
function RGBstring(str) {
	str1 = str.replace("#","");
	str2 = str1.replace("rgb(","");
	str2 = str2.replace(")","");
	str2 = str2.split(",");
	if(navigator.appName == "Microsoft Internet Explorer"){ return str1; }
	else { return toHex(str2[0])+toHex(str2[1])+toHex(str2[2]); }
}
function toHex(N) {
 if (N==null) return "01";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}
/* sIFR RGB conversion function end *************************************************/

/* SLIDESHOW function start *********************************************************/
function slideSwitch() {
	var $active = $('#slideshow img.active');

	if ( $active.length == 0 ) $active = $('#slideshow img:last');

	var $next =  $active.next('img').length ? $active.next()
			: $('#slideshow img: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 ***********************************************************/	
