// JavaScript Document
//Validador de Forma
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

function Form1_Validator(theForm)
{

  if (theForm.nombre.value == "" || theForm.nombre.value== "* Su Nombre")
  {
    alert("Por favor Introduzca su Nombre.");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.nombre.value.length < 3)
  {
    alert("Por favor introduzca al menos 3 caracteres.");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.nombre.value.length > 50)
  {
    alert("Campo Nombre demasiado largo (50 caracteres).");
    theForm.nombre.focus();
    return (false);
  }

   if (theForm.email.value == "" || theForm.email.value== "* Correo Electronico")
  {
    alert("Por favor introduzca su correo electronico.");
    theForm.email.focus();
    return (false);
  }

  
  if (theForm.email.value.length < 3)
  {
    alert("Correo electronico invalido.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length > 40)
  {
    alert("Campo correo electronico demasiado largo.");
    theForm.email.focus();
    return (false);
  }

 if (theForm.pais.value == "" || theForm.pais.value== "* Pais / Ciudad")
  {
    alert("Por favor Introduzca su Pais.");
    theForm.pais.focus();
    return (false);
  }

  if (theForm.nombre.value.length < 3)
  {
    alert("Por favor introduzca al menos 3 caracteres.");
    theForm.pais.focus();
    return (false);
  }

  if (theForm.nombre.value.length > 50)
  {
    alert("Campo Pais demasiado largo (50 caracteres).");
    theForm.pais.focus();
    return (false);
  }

 if (theForm.comentarios.value == "" )
  {
    alert("Por favor Introduzca sus Comentarios.");
    theForm.comentarios.focus();
    return (false);
  }



  if (theForm.codigo.value == "")
  {
    alert("Por favor Introduzca el codigo de verificacion.");
    theForm.codigo.focus();
    return (false);
  }

  if (theForm.codigo.value.length < 4)
  {
    alert("El campo de verificacion debe de tener 4 caracteres.");
    theForm.codigo.focus();
    return (false);
  }

  if (theForm.codigo.value.length > 4)
  {
    alert("El campo de verificacion debe de tener 4 caracteres..");
    theForm.codigo.focus();
    return (false);
  }

  var chkVal = theForm.codigo.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal == 7448))
  {
    alert("Debe de colocar \"7448\" en el campo de verificacion.");
    theForm.codigo.focus();
    return (false);
  }
  return (true);
}

//Funcion para colocar texto en los formularios por defecto
function init(){
	var inp = document.getElementsByTagName('input');
	for(var i = 0; i < inp.length; i++) {
		if(inp[i].type == 'text') {
			inp[i].setAttribute('rel',inp[i].defaultValue)
			inp[i].onfocus = function() {
				if(this.value == this.getAttribute('rel')) {
					this.value = '';
				} else {
					return false;
				}
			}
			inp[i].onblur = function() {
				if(this.value == '') {
					this.value = this.getAttribute('rel');
				} else {
					return false;
				}
			}
			inp[i].ondblclick = function() {
				this.value = this.getAttribute('rel')
			}
		}
	}
}
if(document.childNodes) {
	window.onload = init
}


			$().ready(function() {
                $('#coda-slider-1').codaSlider({
                    autoSlide: true,
                    autoSlideInterval: 6000,
                    autoSlideStopWhenClicked: true,
                    dynamicArrows:false,
                    dynamicTabs:false,
                    slideEaseDuration:1000,
                    slideDirection: "vertical",
        		autoHeightEaseFunction: "easeInOutElastic", 
       	 	 	slideEaseFunction: "easeInOutElastic",
				autoSlideStopWhenClicked: false
                });
 
            });
	
	$(document).ready(function () {

	//Append a div with hover class to all the LI
	$('#navMenu li').append('<div class="hover"><\/div>');


	$('#navMenu li').hover(
		
		//Mouseover, fadeIn the hidden hover class	
		function() {
			
			$(this).children('div').fadeIn('1000');	
		
		}, 
	
		//Mouseout, fadeOut the hover class
		function() {
		
			$(this).children('div').fadeOut('1000');	
		
	}).click (function () {
	
		//Add selected class if user clicked on it
		$(this).addClass('selected');
		
	});

});

jQuery(document).ready(function($) {
        $('ul#orbs').imgbubbles({ factor: 1.75 }) //add bubbles effect to UL id="orbs"
    })


/*Image Bubbles Effect (April 4th, 2010)
* This notice must stay intact for usage 
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/

jQuery.fn.imgbubbles=function(options){
	var $=jQuery
	
	var setting=$.extend({}, {factor:2, speed:'fast'}, options) //merge options w/ default settings
	return this.each(function(){ //return jQuery obj
		var $bubblewrap=$(this)
		var $imgs=$bubblewrap.find('li img')
		$imgs.each(function(){
			var $img=$(this)
			var $parentli=$img.offsetParent()
			var od={width:this.offsetWidth, height:this.offsetHeight} //original dimensions of image
			var nd={width:od.width*setting.factor, height:od.height*setting.factor} //enlarged dimensions of image
			var ncoords=[-(nd.width-od.width)/2, -(nd.height-od.height)/2] //coords to move enlarged image to
			$img.data("specs", { //cache image specs
				od: od,
				nd: nd,
				ncoords: ncoords
			})
			if ($img.attr('alt')){ //if tooltip for image defined
				var $tip=$('<div class="tooltip" style="z-index:1001" />').html($img.attr('alt')).css('visibility', 'hidden').appendTo($img.offsetParent())
				var tipd={width:$tip.outerWidth(), height:$tip.outerHeight()} //tip dimensions
				$tip.data("specs", {
					d: tipd,
					ocoords: [ncoords[0]-tipd.width/2+nd.width/2, ncoords[1]-tipd.height/2], //resting tip coords
					ncoords: [-tipd.width/2+od.width/2, -tipd.height] //tip coords to animate to
				})
				$img.data('$tip', $tip)
			}
		})

		$bubblewrap.mouseover(function(e){
			if (e.target.tagName=="IMG"){
				var $img=$(e.target), $tip=$img.data('$tip')
				var imgspecs=$img.data('specs')
				var ncoords=imgspecs.ncoords
				var od=imgspecs.od
				var nd=imgspecs.nd
				$img.stop().css('zIndex', 1000).animate({left:ncoords[0], top:ncoords[1], width:nd.width, height:nd.height}, setting.speed) //animate image
				if ($img.attr('alt')){
					var tipspecs=$tip.data("specs")
					$tip.css({zIndex:1000, visibility:'visible', left:-tipspecs.d.width/2+od.width/2, top:-tipspecs.d.height})
						.animate({left:ncoords[0]-tipspecs.d.width/2+nd.width/2, top:ncoords[1]-tipspecs.d.height}, setting.speed) //animate tip			
				}
			}
		})
	
		$bubblewrap.mouseout(function(e){
			if (e.target.tagName=="IMG"){
				var $img=$(e.target), $tip=$img.data('$tip')
				var imgspecs=$img.data('specs')
				var od=imgspecs.od
				var nd=imgspecs.nd
				$img.stop().css('zIndex', 999).animate({left:0, top:0, width:od.width, height:od.height}, setting.speed) //animate image
				if ($img.attr('alt')){
					var tipspecs=$tip.data("specs")
					$tip.css({zIndex:999, visibility:'hidden'}) //hide tip
				}
			}
		})
	
	})
}

$(function() {
// OPACITY OF BUTTON SET TO 100%
$(".latest_img").css("opacity","1.0");
		
// ON MOUSE OVER
$(".latest_img").hover(function () {
										  
// SET OPACITY TO 50%
$(this).stop().animate({
opacity: 0.7
}, "slow");
},
		
// ON MOUSE OUT
function () {
			
// SET OPACITY BACK TO 100%
$(this).stop().animate({
opacity: 1.0
}, "slow");
});
});

