// <![CDATA[

function log(asd){
	if(typeof(console) == 'object'){
		console.log(asd);
	}
	
	return false;
}

function JS_header(sUrl){
	window.location.href = (typeof(sUrl) == undefined && sUrl == '') ? window.location.href : sUrl;
}


// opacity
function opacity(element, value) {
	var value_noie = value / 100;
	$(element).css('filter', 'alpha(opacity=' + value + ')');
	$(element).css('-moz-opacity', value_noie);
	$(element).css('-khtml-opacity', value_noie);
	$(element).css('opacity',value_noie);
}

// center horizontally
function centerHoriz(lo_que) {
	var x = parseFloat($(window).width()) / 2 - parseFloat($(lo_que).width()) / 2;
	var y = $(window).scrollTop() + $(window).height() / 2 - parseFloat($(lo_que).height()) / 2;
	x = x + 'px';
	y = y + 'px';
	$(lo_que).css({'left': x, 'top': y});
}

// center vertically
function centerVert(lo_que) {
	var y = $(window).scrollTop() + $(window).height() / 2 - parseFloat($(lo_que).height()) / 2;
	$(lo_que).css({'top': y});
}

// no dotted outline for IE in As
if ($.browser.msie) {
	$('a').focus(
		function() {
			$(this).blur()
		}
	);
}

var container;
var currentblock;

	$(document).ready(
		function() {
			/*
				// slider href
				$('a#hrefImg').click(function() {
					var url = $('.blockbanners a').attr('href');
					$('a#hrefImg').attr("href", url);
				});
				*/
				
			$('.btnSpecial').click(function(){
				$(this).toggleClass("active").next().slideToggle("slow");
			});	
				
			//tabs mi cuenta
			 $('.myaccountblock .tabs ul li:nth-child(1)').addClass('first_item' );
       $('.myaccountblock .tabs ul li:nth-child(2)').addClass('second_item');
       $('.myaccountblock .tabs ul li:nth-child(3)').addClass('third_item');
       $('.myaccountblock .tabs ul li:nth-child(4)').addClass('fourth_item');
       $('.myaccountblock .tabs ul li:nth-child(5)').addClass('last_item');

			 $('#coda-slider-1').codaSlider({
           autoSlide: true,
           autoSlideInterval: 4000,
           autoSlideStopWhenClicked: true,
					 callBack: function(){
						 container = $(this);
						 currentblock = jQuery('#sliderBlock').find('.current').parent().index();
						 
						 a = container.find('a').eq(currentblock);
						 if(a.length > 0){
							 if(a.attr('href') == '')
								 return false;
							 
							 jQuery('a#hrefImg').attr('href', a.attr('href'));
						 }
					 }
       });
				
			 //paginatio width fixed
       test = $('#pagination ul').width();
			 if (test > 0) {
				 $('#pagination ul').css({width: 'auto', height: 'auto'});
			 }
				 
/*			 if ($('#divErrorMessages').length > 0) {
				  $('body').addClass('bgactiveerror');
			 }
			 if ($('#divMessages').length > 0) {
				  $('body').addClass('bgactiveerror');
			 }*/
			 
			//startingSession
			$('#startingSession.buttonLogin').click(
				function(){
					$('#enterBlock').addClass('active');
					$('#enterBlock').removeClass('noactiveuser');
				}																							
			);
			
			//Menu Vertical active accordion
			$('ul.menuVertical li ul.submenuVertical').parent().addClass('parent');
			
			$('#categories ul.menuVertical li span.accordion').click(function(){
				li = $(this).parent(':visible');
				ul = $('.submenuVertical', li);
				
				// Mostrar / Ocultar hijos
				if(ul.length > 0){
					if(ul.is(':visible')){
						ul.slideUp();
						li.removeClass('active');
					}else{
						ul.slideDown();
						li.addClass('active');
					}

					return false;
				}

				return true;
			});
			
			/*
			// Menu Vertical
			$('ul.submenuVertical li a').removeClass('itemMenu');
			
			$('ul.menuVertical li span.accordion').click(function() {

				var subMn = $(this).parent().find('ul.submenuVertical');

				$('ul.menuVertical li span.accordion').parent().removeClass('active');


				if(subMn.is(':animated') || subMn.is(':visible')) {
					$(this).parent().addClass('active');
				}
				
				$('ul.submenuVertical').slideUp(300);
				if (subMn.length > 0) {
					$(this).parent().addClass('active');
					subMn.slideDown(300);
				}
			});
			*/

			// onmouseover
			$('ul.more li.item a.moreactions').click(
					function() {
					$(this).addClass('active');
					$('ul.sub').hide();
					var subMn = $(this).parent().find('ul.sub');
					if(subMn.is(':animated') || subMn.is(':visible')) {
						return false;
					}
					$(subMn).fadeIn(400);	
						return false;
						}
				);
				$('ul.more li.item').hover(
					function() {},
					function() {
					$('ul.more li.item a.moreactions').removeClass('active');
					$('ul.sub').fadeOut(400);	
						return false;
					}
				);
		});
// ]]>
