// <![CDATA[
	// 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});
	}

	// image load
	function loadImg(sID, sURL) {
		$(sID).unbind("load");
		$(sID).bind("load", function() { $(this).fadeIn(); } )
		$(sID).stop(true, true).fadeOut("normal", function () { $(sID).attr('src', sURL); } );
	}

	function seleccionarPais(sPais) {
		$('li.list' + sPais + ' a:first').trigger('click');
	}
	
	$(document).ready(
		function() {
			//greatphoto
			if ($('.greatphoto').length > 0) $('.greatphoto').load(function() 
			{
				var img = document.getElementById($('.greatphoto').attr('id'));
				var width = img.clientWidth;
				var height = img.clientHeight;			
				$('#generalDetails .boxImg').css("width", width + 16);
				$('#generalDetails .boxImgContainer').css("width", width + 8);
				$('#generalDetails .boxContent').css("width", width);
			});
					
			//country
			$('#language .country').mouseenter(function (){
				$('#language .country').slideDown();
			});
			$('#language').mouseleave(function (){
				$('#language .langBra, #language .langUru').slideUp();
			});
			
			//map
			$('.direccionArea .direccionBlock .radios').click(function() {
				$('.direccionArea .direccionBlock').removeClass("active");
				$(this).parent().parent().addClass("active");
			});
				
			//map
			$(".variousMap").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
			
			//product block
			$('.areaEnter').mouseenter(function() {
				$(this).addClass('active');
			});
			$('.areaEnter').mouseleave(function() {
				$(this).removeClass('active');
			});
			
			//Menu Vertical active accordion
			$('ul.listadoPorPaises li ul').parent().addClass('parent');
			
			$('ul.listadoPorPaises>li>a').click(function(){

				var oParentLi = $(this).parents('ul:last');
				$('li:visible', oParentLi).each(function (){
					if($(this).is(':visible')){
						$(this).find('ul').slideUp();
						$(this).removeClass('activo');
					}
				});
				
				li = $(this).parent(':visible');
				ul = $('.sublist', li);
				// Mostrar / Ocultar hijos
				if(ul.length > 0){
					if(ul.is(':visible')){
						ul.slideUp();
						li.removeClass('activo');
					}else{
						ul.slideDown();
						li.addClass('activo');
					}

					return false;
				}
			});
			
			
			$('.areaGaleria ul li a').click(function() {
				$(".areaVideo span").addClass("nodisplay");
			});
			
			//When page loads...
			$(".tab_content").hide(); //Hide all content
			$("ul.tabs li:first").addClass("active").show(); //Activate first tab
			$(".tab_content:first").show(); //Show first tab content
		
			//On Click Event
			$("ul.tabs li").click(function() {
		
				$("ul.tabs li").removeClass("active"); //Remove any "active" class
				$(this).addClass("active"); //Add "active" class to selected tab
				$(".tab_content").hide(); //Hide all tab content
		
				var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
				$(activeTab).fadeIn(); //Fade in the active ID content
				return false;
			});


			// close
			$('.cartBuy .btnClose').click(function() {
				$('.cartBuy').hide();
			});
			
			$('.productBlock .add a').click(function() {
				$('.cartBuy').hide();
				$('.cartBuy').show();
			});	
			
			/* 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())}
				);
			}
			
			$('.bgInput input, .bgTextArea textarea').each(function(){
		 // tomamos el valor actual del input
		 var currentValue = $(this).val();
		 // en el focus() comparamos si es el mismo por defecto, y si es asi lo vaciamos
		 $(this).focus(function(){
				if( $(this).val() == currentValue ) {
					 $(this).val('');
				};
		 });
		 // en el blur, si el usuario dejo el value vacio, lo volvemos a restablecer
		 $(this).blur(function(){
				if( $(this).val() == '' ) {
					 $(this).val(currentValue);
				};
			 });
			});
			
			/* volver */
			$('a.btnBack').click(
				function() {
					history.go(-1);
					return false;
					}
				);

			// no dotted outline for IE in As
			if ($.browser.msie) {
				$('a').focus(
					function() {
						$(this).blur()
					}
				);
			}
		// END DEFAULT //
		}
	);
	
// ]]>
