



//Ajax
function NuevoAjax(){
var xmlhttp=false;
try{
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
	try{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 	}catch(E){
		xmlhttp = false;
	}
}

if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
	xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

$(document).ready(function()
{

$("div#preloader").hide();

function Cargar(url){
        var contenido, preloader;
        contenido = document.getElementById('contenido');
        preloader = document.getElementById('preloader');
        ajax=NuevoAjax(); 
        ajax.open("GET", url,true); 
        ajax.onreadystatechange=function(){
                if(ajax.readyState==1){
						$("div#preloader").fadeIn("slow");
                }else if(ajax.readyState==4){
                        if(ajax.status==200){
						$("div#preloader").fadeOut("fast");
                               contenido.innerHTML = ajax.responseText; 
                        }else if(ajax.status==404){
                                preloader.innerHTML = "La página no existe";
                        }else{
                                preloader.innerHTML = "Error:".ajax.status; 
                        }
                }
        }
        ajax.send(null);
}


$("#esp").click(function() {Cargar('index_es.html'); });
$("#eng").click(function() {Cargar('index_en.html'); });
});	




//
//funcion div#form (contacto)
$(document).ready(function()
{
$("div#contactForm").hide();
$(".click").click(function()
	{
	$("div#container").fadeOut("slow");
	$("div#contactForm").fadeIn("slow");
	});
});	

		$(document).ready(function ()
	{
			$(".cancelar").click(function (){
			$("div#contactForm").fadeOut("slow");
			$("div#container").fadeIn("slow");
		});
	});


//end funcion div#form (contacto)
//
//funcion preloader principal

$(document).ready(function() {
		$("#wrapper").hide();


$(window).bind("load",function() {

$("#loadweb").fadeOut(500,function() {
$("#wrapper").fadeIn("slow");
$(window).unbind("load");

});
});
});

//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------

//MENU

$(document).ready(function()
{
$("#menu_esp").hide();
$("#menu_eng").hide();
$("#head").click(function()
	{
		    $("#menu_esp").fadeOut("slow");
			$("#menu_eng").fadeOut("slow");
			$("#start").fadeOut("slow");
			$("#profile").fadeOut("slow");
			$("#design").fadeOut("slow");
			$("#works").fadeOut("slow");
			$("#works2").fadeOut("slow");
		  $("#foot,#langs").fadeIn("slow");
		  $("#galeria").fadeOut("slow");
		  $("#formulario").fadeOut("slow");
		//  $("#wrapperdesign").fadeOut("slow");
});
});	

//show principal window
$(document).ready(function()
{
	

$("#langs").click(function()
	{
		$("#start").fadeIn("slow");
		$("#links_menu").fadeIn("fast");
	});
});	



//function div#principal (Main content) 
//Spanish
$(document).ready(function()
						   						   
{
			$("#principal").hide();
			$("#start").hide();
$("#esp").click(function()
	{
				$(".design_txt_esp").fadeIn("fast");
				$(".works_txt_esp").fadeIn("fast");
			$("#langs").fadeOut("slow");
			$("#menu_eng").fadeOut("fast");
			$("#menu_esp").fadeIn("slow");
			$("#start").fadeIn("slow");
			$("#principal").fadeIn("slow");
	});
});	

//function div#principal (Main content)
// English
$(document).ready(function()
{

			$("#principal").hide();
			$("#start").hide();

$("#eng").click(function()
	{
				$(".design_txt_eng").fadeIn("fast");
				$(".works_txt_eng").fadeIn("fast");
			$("#langs").fadeOut("slow");
			$("#menu_esp").fadeOut("fast");
			$("#menu_eng").fadeIn("slow");
			$("#start").fadeIn("slow");
			$("#principal").fadeIn("slow");
	});
});	



//function LINKS (#links_menu)



    $(document).ready(function(){
		$("#start").hide();
		$("#profile").hide();
		$("#design").hide();
		$("#design2").hide();
		$("#works").hide();
        $("#wrapperdesign").hide();
		$("#wrapperworks").hide();
		$("#formulario").hide();
		
		
        $("#link_contacto").click(function()
            {
				  $("#start,#profile,#wrapperworks,#wrapperdesign,#formulario,#galeria").css("display", "none");
		  $("#formulario").fadeIn("slow");
		  $("#foot").fadeOut("slow");
            });
		
		
        $("#link_profile").click(function()
            {
				  $("#start,#profile,#formulario,#galeria").css("display", "none");
		  $("#profile").animate({opacity: 0.7}, 400) 
		  $("#profile").fadeIn("slow");
		  $("#foot").fadeOut("slow");
            });
		
		
		
	$("#link_design").click(function (){
				  $("#start,#profile,#wrapperworks,#wrapperdesign,#formulario,#galeria").css("display", "none");
		  $("#galeria").fadeIn("slow");
		  $("#wrapperdesign").fadeIn("slow");
					});
											   
											   
	$("#link_works").click(function (){
				  $("#start,#profile,#wrapperdesign,#wrapperworks,#formulario,#galeria").css("display", "none");
		  $("#galeria").fadeIn("slow");
		  $("#wrapperworks").fadeIn("slow");
					});
											  
											  
		
		
    });


