var $j = jQuery.noConflict();
function initTabs() {
	$j(".tab_content").hide(); //Hide all content
	if(location.hash != "") {
		var target = location.hash.split("#")[1]
		$j(location.hash).show(); //Show first tab content
		$j("ul.tabs li:has(a[href=#"+target+"])").addClass("active").show();
	} else {
		$j("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$j(".tab_content:first").show(); //Show first tab content
	}
	
	//On Click Event
	$j("ul.tabs li").click(function(e) {
		$j("ul.tabs li").removeClass("active"); //Remove any "active" class
		$j(this).addClass("active"); //Add "active" class to selected tab
		$j(".tab_content").hide(); //Hide all tab content
		var activeTab = $j(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$j(activeTab).fadeIn(); //Fade in the active content
		e.preventDefault();
	});
}

$j(document).ready(function() {
	initTabs();
	$j(".mainnav li:first").addClass("first");
	$j(".mainnav li:last").addClass("last");
	
	//special offer
	$j('#special-offer-bg').cycle({
		fx: 'fade',
		speed:  300,
		timeout: 1000
	});
	
	//popup header image
	//$j("#headerimgwrap img").thumbPopup({
	//	imgSmallFlag: "_s",
	//	imgLargeFlag: "_l"
	//});
	
	//dropdown menu
	$j("ul.mainnav").superfish({hoverClass:'sfHover', pathClass:'active', pathLevels:0, delay:800, animation:{opacity:'show'}, speed:'def', autoArrows:1, dropShadows:1})
		jQuery.event.special.hover.delay = 100;
		jQuery.event.special.hover.speed = 100;
		
	//video play btn
	$j('.video').mouseenter(function() {
		//$j(this).find('div.btn-play').stop(false,true).fadeIn(200);
	})
	
	$j('.video').mouseleave(function() {
		//$j(this).find('div.btn-play').stop(false,true).fadeOut(200);
	})
	
	//slideshow
	$j(".container").wtRotator({
					width:592,
					height:421,
					thumb_width:24,
					thumb_height:24,
					button_width:24,
					button_height:24,
					button_margin:5,
					auto_start:true,
					delay:5000,
					play_once:false,
					transition:"fade",
					transition_speed:800,
					auto_center:true,
					easing:"",
					cpanel_position:"inside",
					cpanel_align:"BR",
					timer_align:"top",
					display_thumbs:true,
					display_dbuttons:true,
					display_playbutton:true,
					display_thumbimg:false,
					display_side_buttons:false,
					display_numbers:true,
					display_timer:true,
					mouseover_pause:false,
					cpanel_mouseover:false,
					text_mouseover:false,
					text_effect:"fade",
					text_sync:true,
					tooltip_type:"image",
					lock_tooltip:true,
					shuffle:false,
					block_size:75,
					vert_size:55,
					horz_size:50,
					block_delay:25,
					vstripe_delay:75,
					hstripe_delay:180			
				});

	
	//thumbnails caption
	var move = -15;
	var zoom = 1.2;

	//On mouse over those thumbnail
	$j('.item').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $j('.item').width() * zoom;
		height = $j('.item').height() * zoom;
		
		//Move and zoom the image
		$j(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$j(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$j(this).find('img').stop(false,true).animate({'width':$j('.item').width(), 'height':$j('.item').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$j(this).find('div.caption').stop(false,true).fadeOut(200);
	});
});
