// <![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() {
		//question
		//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
		$(".trigger").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
		});

			
		//treeCategories
		$('.treeSelection ul li label').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;
			});

			
			//tooltips
			$('#shareThis ul li').mouseenter(
			function() {
					$('span.tooltips').hide();
					$(this).find('span.tooltips').show();
				}
			);
			$('#shareThis ul li').mouseleave(
				function() {
					$(this).find('span.tooltips').hide();
				}
			);
			
						
			$('.btnSpecial').click(function(){
				$(this).toggleClass("active").next().slideToggle("slow");
			});	

			 //paginatio width fixed
       test = $('#pagination ul').width();
			 if (test > 0) {
				 $('#pagination ul').css({width: 'auto', height: 'auto'});
			 }
				 
		
			//Menu Vertical active accordion
			$('ul.menuVertical li ul.submenuVertical').parent().addClass('parent');
			
			$('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;
			});
			
			/* styled checks */
			var alt_check = $('input.check').css('height');
			/* CSS valid opacity */
			$('.check').css('filter', 'alpha(opacity=0)');
			$('.check').css('opacity', '0');
			/* already checked inputs */
			$('input.check:checked').parent().css({'background-position' : '0 -' + alt_check});
			/* click */
			$('input.check').click(function() {
					if($(this).is(':checked')) {
						$(this).parent().css({'background-position' : '0 -' + alt_check});
					}
					else {
						$(this).parent().css({'background-position' : '0 0'});
					}
				}
			);
			
		/* styled selects */
		/* doesn't work in IE 6 */
		if (!($.browser.msie && $.browser.version == "6.0")) {
			$('.selectStyle').css('filter', 'alpha(opacity=0)');
			$('.selectStyle').css('opacity', '0');
			$('.selectStyle').change(function() {
				var the_option = $(this).children(":selected").text();
				$(this).parent().children('.spanStyle').text(the_option);
			});
			$('.spanStyle').each(
				function() {$(this).text($(this).parent().children('.selectStyle').children(':selected').text())}
			);
		}

	$('.anclaje').click(function(){
		document.location.hash = $(this).attr('href');
		return false;
	});
	$('.pics').cycle();
});
// ]]>
