$(document).ready(function(){

	/********Cufon*************/
	
	Cufon.replace(['.menu-item'],{hover:true});
//	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('.listing-header');
	Cufon.replace('.footer-header');
	Cufon.replace('.categories-header');
	Cufon.replace('.sub-categories-header');
	Cufon.replace('.product-detail-header');
	Cufon.replace('.footer-column-header');
	Cufon.replace('#main-categories ul li a');


	/********end Cufon**********/

	/********Fancybox*************/

	$("a.grouped_elements").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	100,
		'speedOut'		:	100,
		'overlayShow'	:	true,
		'overlayColor' 	:	'#000',
		'overlayOpacity':	0.4,
		'titleShow'		:	false
	});

	$("a.movie").click(function() {
                 $.fancybox({
                  'padding'             : 0,
                  'autoScale'   : true,
                  'transitionIn'        : 'elastic',
                  'transitionOut'       : 'elastic',
                  'title'               : 'movie',
				  'overlayShow'			: true,
				  'overlayColor'		: '#000',
				  'overlayOpacity'		: 0.6,
                  'width'               : 580,
                  'height'              : 350,
                  'href'                : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
                  'type'                : 'swf',    // <--add a comma here
                  'swf'                 : {'allowfullscreen':'true', 'wmode':'transparant'} // <-- flashvars here
                  });
                 return false;

            });
			

	/******** end Fancybox********/


	/***********************************
	SLIDESHOW
	************************************/

	$("#slider").cycle({
		fx: 'fade',
		speedIn:  2000,
		speedOut: 2000,
		//timeout: 10000,
		delay: 1000
	});



   /***********************************/
	
	function myPopup2() {
		window.open( "templates/controle.php", "myWindow",
		"status = 1, height = 300, width = 300, resizable = 0" )
	}

	$('.menu-item').hover(
		function(){
			
			$(this).css('background', 'url("/public/img/menu_active.gif") no-repeat');
		},
		function(){
			if($(this).hasClass('menu-active'))
			{
				$(this).css('background', 'url("/public/img/menu_active.gif") no-repeat');
			}
			else
			{
				$(this).css('background', 'none');
			}
		}
	);

	$('.empty-click').click(function(){
		var val = $(this).val();
		$(this).val('');
	})

	$('.tab-content').hover(
		function(){
			//over
			$(this).css('background', 'url("/public/img/tab_active_bg.gif") repeat-x');
			$(this).parent('.tab').find('.tab-end').css('background', 'url("/public/img/tab_active_end.gif") no-repeat');


			$(this).parent('.tab').prev('.tab').children('.tab-end-active').css('background', 'url("/public/img/tab_active_both.gif") no-repeat');
			$(this).parent('.tab').prev('.tab').children('.tab-end').css('background', 'url("/public/img/tab_end_prev.gif") no-repeat');

			$(this).parent('.tab').find('.tab-end-last').css('background', 'url("/public/img/tab_active_end_last.gif") no-repeat');
			$(this).css('color', '#5b7497');
			$(this).css('height', '21px');
		},
		function(){
			//out
//			if(!$(this).parent('.tab').hasClass('tab-active'))
//			{
				$(this).css('background', 'url("/public/img/tab_bg.gif") repeat-x');
				$(this).parent('.tab').find('.tab-end').css('background', 'url("/public/img/tab_end.gif") no-repeat');
				$(this).parent('.tab').find('.tab-end-last').css('background', 'url("/public/img/tab_end_last.gif") no-repeat');

				$(this).parent('.tab').prev('.tab').children('.tab-end-active').css('background', 'url("/public/img/tab_active_end.gif") no-repeat');
				$(this).parent('.tab').prev('.tab').children('.tab-end').css('background', 'url("/public/img/tab_end.gif") no-repeat');
				$(this).css('color', '#fff');
//			}
		}
	);

	$(".tab").click(function(){
		var aId = $(this).attr('id').split('-');
	

		var tabId = '';
		for(i = 1 ; i < aId.length; i++)
		{
			if(i!=(aId.length-1))
			{
				tabId += aId[i]+'-';
			}
			else
			{
				tabId+=aId[i];
			}
		}
		
		$('.tab-content-container').each(function(){
			$(this).css('display', 'none');
		})


		$('#'+tabId).css('display','block');

		$('#tab-'+tabId).addClass('tab-active');

		
		$('#tab-'+tabId).children('.tab-content').css('background', 'url("/public/img/tab_active_bg.gif") repeat-x');
		$('#tab-'+tabId).children('.tab-content').parent('.tab').find('.tab-end').css('background', 'url("/public/img/tab_active_end.gif") no-repeat');

		$('#tab-'+tabId).children('.tab-content').parent('.tab').prev('.tab').children('.tab-end-active').css('background', 'url("/public/img/tab_active_both.gif") no-repeat');
		$('#tab-'+tabId).children('.tab-content').parent('.tab').prev('.tab').children('.tab-end').css('background', 'url("/public/img/tab_end_prev.gif") no-repeat');
		
		$('#tab-'+tabId).children('.tab-content').parent('.tab').find('.tab-end-last').css('background', 'url("/public/img/tab_active_end_last.gif") no-repeat');
		$('#tab-'+tabId).children('.tab-content').css('color', '#5b7497');
		$('#tab-'+tabId).children('.tab-content').css('height', '21px');
	});
		
})



