//funciones para las cosas simples

$(document).ready(function(){
	//roll over de las imágenes de las redes
	$("#titulo .social img").mouseover(function(){
		$(this).attr('src',$(this).attr('src').split('_')[0]+'.gif');		
	}).mouseout(function(){
			$(this).attr('src',$(this).attr('src').split('.')[0]+'_off.gif');
	});
	
	//click al campo de suscribirse al newsletter
	$('.anuncios input[type="text"]').focus(function(){
		if ($(this).attr('value')=="Email Address")
		$(this).css({'color':'#000'}).attr('value','');		
	}).blur(function(){
		if ($(this).attr('value').replace(/^\s*|\s*$/g,"")=="") {//trim
			$(this).css({'color':'#808080'}).attr('value','Email Address');			
		}		
	});
	
	//rollover casilla
	$("#header .home img").mouseover(function(){
		$(this).attr('src',$(this).attr('src').split('.')[0]+'_over.gif');		
	}).mouseout(function(){
			$(this).attr('src',$(this).attr('src').split('_')[0]+'.gif');
	});
	
	//lo de los banners del inicio
	$('#medio .imagenes')	
		.cycle({ 
    	fx:     'fade', 
    	speed:  'slow', 
    	timeout: 5000, 
    	pager:  '.botones' 
	});
	
	//scroll de las frases
	$('#titulo .frases').cycle({ 
    	fx:    'fade', 
    	timeout: 3000,
		next: '#titulo .frases',
		pause: 1
	});
	
	//roll over sobre
	$("#header .sobre_contacto img:first").mouseover(function(){
		$(this).attr('src','images/contacto_over.gif');
		$(this).mouseout(function(){
			$(this).attr('src','images/contacto.gif');
		});
	});
});

function news_letter(form) {
	if (/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/.test(form.email.value)) {
	$("#newsletter input[type=\"image\"]").attr({'value':'','disable':'true','src':'images/ajax-loader.gif','border':'0'});
	//alert(form.email.value);
  var dataString = 'email=' + form.email.value;
  
  $.ajax({
    type: "POST",
    url: "ajax/newsletter.php",
    data: dataString,
    success: function(r) {
     	$("#newsl").fadeOut('slow',function(){$("#newsl").html("<strong style=\"padding-top:30px;display:block;\">Your e-mail was successfully sent. We will contact you soon.</strong>").fadeIn('slow')});		
    }
  });
	}
  return false;
}


