var galleryActive = false;
var loadImages = false;
/*function ajax_Active_Layout(content){
	$("#menu ul li a").click(function (e){
			e.preventDefault();
			var a = e.target;
			var url_r = $(a).attr("href");
			$.ajax({
			  url: url_r+"&active_ajax=true",
			  context: document.body,
			  success: function(data){
				  //alert(data);
			    $('.'+content).replaceWith(data);
				$('.'+content).fadeIn();
			  } 
			});
		});
}*/
function play_music(){
  $('.play').trigger('click');
}
	
$(document).ready(function(){
	//if ($.browser.msie && $.browser.version > 6 ){
	if ($.browser.msie ){
		alert('Este sitio web ha sido diseñado con estandares DOM por lo que ecomendamos de manera encarecida el uso del navegador Mozilla Firefox  para la navegación. NO recomendamos el uso de Internet Explorer ya que dicho navegador presenta inconvenientes. Otros navegadores tambien pueden ser utilizados en nuestro sitio Web como Google Chrome.');
	}
  
	var description = 'Carlos Grijalva';
	$("#cg_more").click(function (e){
		//alert(document.getElementById("wrapper_right").style.right);
		if(document.getElementById("wrapper_right_cg").style.right == '200px'){
			document.getElementById("wrapper_right_cg").style.right = '0px';
			document.getElementById("menu").style.right='-200px';
			document.getElementById("cg_higher").style.right='100px';
			//$(this).html("+");
			//$(this).addClass("cg_more");
			$(this).toggleClass("cg_more cg_less");
			//$('#wrapper_right').style.right = '0px';
			//$('#cg_higher').style.right = '120px';
			//$('#menu').style.right = '-160px';
		}else{
			$("#wrapper_right_cg, #menu,#cg_higher").animate({right: "+=200px"}, "fast");
						

			$(this).toggleClass("cg_more cg_less");
			//$(this).addClass("cg_less");
			//$(this).html("-");
		}
		});
		var count=0;
		var count_img=1;
		var width_screen=$(window).width();;
		
		$(window).resize(function() {
		   width_screen = $(window).width();
		   $(".gallery img").css({"width": width_screen});

		   $(".gallery").css("left",'-'+width_screen * (count_img-1)+"px");
		  // alert('gallery next'+$(".gallery").css("left"));
		   //count=0;
		   //count_img=1;
		});
		//saca el ancho de la ventana y varia deacuerdo si masximiza o minimiza
		//var c_screen=screen.width; saca el ancho de la ventana unico
		//$(".cg_img").css({"width": width_screen});
		$(".gallery img").css({"width": width_screen});
		var img=$(".gallery img").length;
		var span=$(".gallery span").length;
		count=img;
		$('#cg_higher').click(function(e){
			if(!galleryActive){
				elements=img+span;
				//alert(elements);
				galleryActive = true;
				if(!loadImages && $(".gallery span").length!=''){
					//count_img=count;
					$("#tmp_img"+count).replaceWith('<img src="'+$("#tmp_img"+count).attr("title")+'" alt="" >');
					$(".gallery img").css({"width": width_screen});
					//alert('reemplaza'+count);
				}
				//alert(count_img+'x'+count+'x'+elements);
				if(count_img==elements)	{
					//alert("end");
					count=0;
					count_img=0;
					loadImages = true;
					$(".gallery").animate({left: "0px"}, "slow", function (){galleryActive = false;});
					
				}else{
					$(".gallery").animate({left: "-="+width_screen+"px"}, "slow", function (){galleryActive = false;});
					//alert($(".gallery").css("left"));
					//$(".gallery").css({"left": "-"+width_screen});
				}

				count++;
				count_img++;
			}
			/*if($(".content").hasClass('show')){
			$(".content").removeClass("show").addClass('hidden');	
			}*/
		});
	$("#content_menu ul li a, #contact, #news").click(function (e){
		if($("#cg_close").hasClass('hidden')){
			$("#cg_close").removeClass('hidden').addClass("show");	
		}
		if(($('#contact_phone').length > 0)&& !$('#contact_phone').hasClass('hidden')){
			$('#contact_phone').addClass('hidden');
		}
		
	});

    $('#content_menu').accordion();
	$("#cg_close").click(function (e){
		//$(".content").toggleClass("show hidden");
		$('.content').removeClass('show').addClass('hidden');
		$('#cg_close').removeClass('show').addClass('hidden');
	});

});

