/**
 * Optimized by http://javascriptcompressor.com/
 */
$(document).ready(function(){
		$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
		$('#wp125adwrap_2c').append('<div class="clear"></div>');
		
		// #################################
		// Lightbox for YouTube videos
		// #################################
		jQuery.fn.contains = function(txt) { return jQuery(this).indexOf(txt) >= 0; };
		// Scan for add Class
		$("a:has(img)").each(function (index, el) {
			var href=$(this).attr('href');
			if (href.indexOf("http://www.youtube.com")==0) {
				$(this).addClass('YoutubeVideoLightBox');
			} else if (href.indexOf("http://vimeo.com")==0) {
				$(this).addClass('VimeoVideoLightBox');
			}
		});
		// Add Event Click
		$("a:has(img)").click(function() {
			var href=$(this).attr('href');
			var isYouTube = href.indexOf("http://www.youtube.com");
			var isVimeo = href.indexOf("http://vimeo.com");
			if (isYouTube==0) {
				
					$.fancybox({
					'padding'		: 5,
					'autoScale'		: false,
					'transitionIn'	: 'elastic',
					'transitionOut'	: 'elastic',
					'title'			: this.title,
					'width'		: 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
						 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					},
					'titleShow' : true,
					'overlayShow'	:	false
				});
				return false;
			} else if (isVimeo==0) {
				
				$.fancybox({
					'padding'		: 10,
					'autoScale'		: false,
					'transitionIn'	: 'elastic',
					'transitionOut'	: 'elastic',
					'title'			: this.title,
					'width'		: 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
					'type'			: 'swf',
					'swf'			: {
						 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					},
					'titleShow' : true,
					'overlayShow'	:	false
				});
				return false;
			} else {
				return true;
			}
			
		});
		
		// #################################
		// Lightbox for images
		// #################################
		
		
		$("a:has(img)").click(function() {
			var str = $(this).attr('href');
			var ext = str.split('.').pop();
			//alert(ext );
			
			if ($.inArray(ext.toLowerCase(), ['jpg','gif','png', 'bmp', 'tiff'])!=-1) {
				$.fancybox({
					'titleShow' : true,
					'transitionIn'	:	'elastic',
					'transitionOut'	:	'elastic',
					'speedIn'		:	600, 
					'speedOut'		:	200, 
					'overlayShow'	:	false,
					'href'			: str,
					'padding'		: 10,
					'autoScale'		: true
				});		
				return false;	
			}				
		});
		
		$(".gallery a:has(img)").fancybox({
			'titleShow' : true,
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
		});	
		
		// #################################
		// IMAGE GALLERY FADE OPACITY WHEN HOVER
		// #################################
		$(function() {
		
			$(".gallery img, a:has(img)").css("opacity", "1");
	
			// ON MOUSE OVER
			$(".gallery img, a:has(img)").hover(function () {
	
				// SET OPACITY TO 100%
				$(this).stop().animate({
				opacity: 0.5
				}, "fast");
			},
	
			// ON MOUSE OUT
			function () {
	
				// SET OPACITY BACK TO 100%
				$(this).stop().animate({
				opacity: 1
				}, "fast");
			});	
		});
	}); 

$(document).ready(function () {   
	createTicker();  
});                                  

function createTicker(){    	
	// put all list elements within #ticker-area into array   
	var tickerLIs = $("#ticker-area ul").children();          
	tickerItems = new Array();                                
	tickerLIs.each(function(el) {                             
		tickerItems.push( jQuery(this).html() );                
	});                                                       
	i = 0  ;                                                 
	rotateTicker();                                           
}                                                           
function rotateTicker(){                                    
	if( i == tickerItems.length ){                            
	  i = 0;                                                  
	}                                                         
  tickerText = tickerItems[i];                              
	c = 0;                                                    
	typetext();                                               
	setTimeout( "rotateTicker()", 5000 );                     
	i++;                                                      
}                                                           
var isInTag = false;                                        
function typetext() {	                                      
	var thisChar = tickerText.substr(c, 1);                   
	if( thisChar == '<' ){ isInTag = true; }                  
	if( thisChar == '>' ){ isInTag = false; }                 
	$('#ticker-area').html("&nbsp;" + tickerText.substr(0, c++));   
	if(c < tickerText.length+1)                                     
		if( isInTag ){                                                
			typetext();                                                 
		}else{                                                        
			setTimeout("typetext()", 28);                               
		}                                                             
	else {                                                          
		c = 1;                                                        
		tickerText = "";                                              
	}	                                                              
}   
