// JavaScript Document
$(document).ready(
function(){
/* ---------------------------------------- */
	$('a.bot_gallery').click(
		function(){ showImage( this ) }
	)
	$('a.bot_gallery').each(function(){
		 addBackground( this )
	})
	$('a.bot_gallery:first img').css('opacity',0)
	$('.link').mouseenter(function(){
		showDescription(this)
	})
	$('.link').mouseleave(function(){
		hideDescription(this)
	})
	$('.link > span').css('opacity',0);
/* ---------------------------------------- */
		$.event.add(window, "resize", doResize);
		doResize()
})


function showDescription(el){
	$('span',el).animate(
		{opacity: 1},
		'slow',
		function(){}
	)
}

function hideDescription(el){
	$('span',el).animate(
		{opacity: 0},
		'slow',
		function(){}
	)
}


function showImage(el){
	// PONGO LA IMAGEN GRANDE
	
	var imgLarge = $('img',el).attr('rel');
	$('#galleryImage').fadeOut('fast', function() {
		//limpia imagen
		$('#galleryImage').attr('src',' ')
		//termina el fade
    	$('#galleryImage').attr('src',imgLarge)
		//fade in de imagen nueva
		$('#galleryImage').fadeIn('slow',function(){})
  	});
	$('a.bot_gallery img').css('opacity',1)
	$('img',el).animate(
		{opacity: 0},
		'slow',
		function(){}
	)
	// CAMBIO EL THUMB
}

function addBackground(el){
	
	var thumb = $('img',el).attr('src');
	var backgroundThumb = thumb.replace('Off','On')
	$(el).css('background-image','url('+backgroundThumb+')')
	
	}
	
//
var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/i;
//
function customIsEmail(jMls){
    return reEmail.test(jMls);
}

function validateMe() {
    if (document.all)
	{
        var jEFM = document.all['Email'].value;
	}
    else
	{
        var jEFM = document.getElementById('Email').value;
	}
	
    if (!customIsEmail(jEFM)){
        alert('Email Address must be valid.');
        return false;
    }
	
	if( $('#Zip').val() == "" || $('#Zip').val() == "undefined" || $('#Zip').val() == undefined ){
		alert('You need to provide you Zip Code.');
        return false;
	}
	
    return true;
}

function doResize(){
	
	var alto =$(window).height();
	
	if(alto > 783){
		
		$('.footer').css('margin-top', alto-783 )
		
	}else{
		
		$('.footer').css('margin-top' , 0 )
	}
	
}
