// JavaScript Document
$(document).ready(function(){
						   
	$.ifixpng('/images/pixel.gif');
	
	$('.png').ifixpng();
	
	$('img[@src$=.png]').ifixpng(); // apply IE6 transparent PNG fix
	
	// img on home page
	/*if($('#home_super_spices_slide_bar').html() != undefined){
		$('#bottle').css('left','-10000px');
		
		setTimeout('spicesImgRotate()', 5000);
	}*/
	
	// pop up
	$('.spice_tabs li a').mouseover(function(){
		$(this).parent().parent().children('li').removeClass('current');
		$(this).parent().addClass('current');
		
		var brokenstring = $(this).parent().attr('id').split("_");
		showPopup(brokenstring[0], brokenstring[1]);
		 
		return false;
	});
	
	// from homepage to '7 super spices' page and show pop up
	if($('#super_spices_txt_wrap').html() != undefined){
		var id = self.location.hash;
		id = id.substr(1);
		showPopup(id, 'general');
	}
});

// jCarouselLite - sliding bar
$(function() {
	
	if($("#media_info_sliding_bar").html() != undefined){
		$("#media_info_sliding_bar").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			start: 0,
			visible: 2,
			scroll: 2,
			speed: 1000,
			circular: false
		});
	}
	
	if($("#recipe_bk_sliding_bar").html() != undefined){
		$("#recipe_bk_sliding_bar").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			start: 0,
			visible: 2,
			scroll: 2,
			speed: 1000,
			circular: false
		});
	}
	
	// vertical sliding bar
	if($("#faq_sliding_bar").html() != undefined){
		
		var start = $('#start').html();
		
		$("#faq_sliding_bar").jCarouselLite({
			btnNext: ".down",
			btnPrev: ".up",
			start: start,
			visible: 5.75,
			scroll: 2,
			speed: 1000,
			vertical: true,
			circular: false
		});
	}
	
	if($("#media_lib_sliding_bar").html() != undefined){
		$("#media_lib_sliding_bar").jCarouselLite({
			btnNext: ".down",
			btnPrev: ".up",
			start: 0,
			visible: 6.1,
			scroll: 2,
			speed: 1000,
			vertical: true,
			circular: false
		});
	}
});

/*function spicesImgRotate() {
	if($('#minis').css('left') == '0px') {
		$('#minis').css('left','-10000px');
		$('#bottle').css('left','0px');
	} else {
		$('#minis').css('left','0px');
		$('#bottle').css('left','-10000px');
	}
	
	setTimeout('spicesImgRotate()', 5000);
}*/

function showPopup(id, section) {
	
	if($('#popup_'+id).css('display') == 'none') {
		// close all popups
		$('.spice_popup').each(function() {
			$(this).css('display','none');
		});
		
		// highlight only the first tab
		$('#popup_'+id+' .spice_tabs li').removeClass('current');
		$('#popup_'+id+' .spice_tabs li:first').addClass('current');
		
		// show only content of first tab
		$('#popup_'+id+' .right').each(function(){
			$(this).css('display','none');
		});
		$('#popup_'+id+' #'+section+'_txt').css('display','block');
		
		// show required popup
		$('#popup_'+id).css('display','block');
	} else {
		$('#popup_'+id+' .right').each(function(){
			$(this).css('display','none');
		});
		$('#popup_'+id+' #'+section+'_txt').css('display','block');
	}
}

function closePopup() {
	
	$('.spice_popup').each(function() {
		$(this).css('display','none');
	})
}
