// JavaScript Document
function bgr_color(obj, color) {
    obj.style.backgroundColor=color;
	obj.style.cursor = "pointer";
}


//  //  //  //  //  //  //  //  //  //  //  //  //  //  // 


 // speed in milliseconds
	var scrollSpeed = 30;
	
	// set the default position
	var current = 0;

	// set the direction
	var direction = 'h';

	function bgscroll(){

    	// 1 pixel row at a time
	    current -= 1;
   
	    // move the background with backgrond-position css properties
	    $('div.clouds').css("backgroundPosition", (direction == 'h') ? current+"px 0" : "0 " + current+"px");
   
	}

	//Calls the scrolling function repeatedly
	 setInterval("bgscroll()", scrollSpeed);	





/////////////////////////////////////LOGO SHADOW////////////////////////////////
$(document).ready(function() {
	/* =Shadow Nav
	-------------------------------------------------------------------------- */
	
		// Append shadow image to each LI
		
		$("#nav-shadow li").append('<img class="shadow" src="images/logo_shadow.png" width="77" height="35" alt="" />');
	
		// Animate buttons, shrink and fade shadow
		
		$("#nav-shadow li").hover(function() {
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "-10px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "-10px" }, 250);
		    });
		    $(e).find("img.shadow").stop().animate({ width: "77px", height: "30px", marginLeft: "0", opacity: 0.40 }, 250);
		},function(){
			var e = this;
		    $(e).find("a").stop().animate({ marginTop: "4px" }, 250, function() {
		    	$(e).find("a").animate({ marginTop: "0px" }, 250);
		    });
		    $(e).find("img.shadow").stop().animate({ width: "77px", height: "35px", marginLeft: "0", opacity: 1 }, 250);
		});
						
	// End jQuery
	
	});


/////////////////////////////////////TWITTER TESTIMONIALS////////////////////////////////

$(document).ready(function(){
	
	// Hiding all the testimonials, except for the first one.
	$('#testimonials li').hide().eq(0).show();
	
	// A self executing function that loops through the testimonials:
	(function showNextTestimonial(){
		
		// Wait for 7.5 seconds and hide the currently visible testimonial:
		$('#testimonials li:visible').delay(7500).fadeOut('slow',function(){
			
			// Move it to the back:
			$(this).appendTo('#testimonials ul');
			
			// Show the next testimonial:
			$('#testimonials li:first').fadeIn('slow',function(){
				
				// Call the function again:
				showNextTestimonial();
			});
		});
	})();
	
});

/////////////////////////////////////NAVEGACION////////////////////////////////

 
    $(function() {
        $('ul#menu').lavaLamp();
    });
 
/////////////////////////////////////BANNER SLIDER////////////////////////////////

 $(window).load(function() {
    $('#slider').nivoSlider({
        effect:'fade', 
        directionNav:true, 
        directionNavHide:false, 
        controlNav:false, 
        keyboardNav:true, 
        pauseOnHover:true, 
        prevText: 'Prev', 
        nextText: 'Next',
      
    });
});
 
 
/////////////////////////////////////GALERIA DE PLATILLOS////////////////////////////////

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
		scroll: 1,

    });
});

jQuery(document).ready(function() {
    jQuery('#mycarousel2').jcarousel({
		vertical: true,
		wrap:null,
		scroll: 1,
    });
});

jQuery(document).ready(function() {
    jQuery('#mycarousel3').jcarousel({
		scroll: 1,

    });
});


jQuery(document).ready(function() {
    jQuery('#mycarousel4').jcarousel({
		vertical: true,
		scroll: 1,
    });
});


//contactform

function IsEmail(strEmail){
	if (strEmail.indexOf("@")>0 && strEmail.indexOf(".")>0){
		
		return true;
		
	}else{

       return false;
	}

}

 

function Validation(theNewContact){

 	if (theNewContact.name.value == ""){
			
			var el=document.getElementById("alerta");
			var se;
			se="Favor de llenar todos los campos!";
			el.innerHTML=se;
			theNewContact.name.focus();
		    return (false);
			
			
	}else if (theNewContact.email.value == ""){
			
			var el=document.getElementById("alerta");
			var se;
			se="Favor de llenar todos los campos!";
			el.innerHTML=se;
			theNewContact.email.focus();
		    return (false);
			
	} else if (IsEmail(theNewContact.email.value)==0){

     		var el=document.getElementById("alerta");
			var se;
			se="Correo invalido!";
			el.innerHTML=se;
			theNewContact.email.focus();
			return (false);
    } else {
	 var contenidos='?name='+theNewContact.name.value+'&email='+theNewContact.email.value+'&phone='+theNewContact.phone.value+'&comments='+theNewContact.comments.value;
	 makeRequest('sendmail.php', contenidos, 'contactform');
	 return (false);
	}

 } 


var http_request = false;
      function makeRequest(url, parameters, aidi, donde, numero) {
         http_request = false;
         if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
            }
         } else if (window.ActiveXObject) { // IE
            try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
               try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
               } catch (e) {}
            }
         }
		 
		 
         if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
         }
         http_request.onreadystatechange = alertContents;
         http_request.open('GET', url + parameters, true);
         http_request.send(null);
		 idx=aidi;
		 diver=donde;
		 numeraxo=numero;
		 
      }
	  
	  function alertContents() {
         if (http_request.readyState == 4) {
            if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            //document.getElementById('myspan').innerHTML = result; 
			if (diver==2){
			document.getElementById(idx).src=result;
			}else {
			document.getElementById(idx).innerHTML=result;
			}
			
			
			if (diver == 1){
			diverser(numeraxo);
			} else {
			galeria();
			califica();
			carga();
			}
			
			
            } else {
            alert('There was a problem with the request.');
            }
         }
      }
	  
	  
	  
	  function mostrar(id,contenidos){
	  document.getElementById(id).innerHTML=contenidos;
	  }
	  
	  



