//alert("boo");

var $j = jQuery.noConflict();

$j(function(){
	$j('#name').focus(function(){
		if(this.value=='NOMBRE')
		{
			this.value=''
		}
 	});
	$j('#name').focus(function(){
		if(this.value=='NAME')
		{
			this.value=''
		}
 	});
	$j('#drktyd-drktyd').focus(function(){
		if(this.value=='CORREO')
		{
			this.value=''
		}
 	});
	$j('#drktyd-drktyd').focus(function(){
		if(this.value=='EMAIL')
		{
			this.value=''
		}
 	});
 	$j('#email').focus(function(){
		if(this.value=='CORREO ELECTRONICO* (NO SERA EXHIBIDO)')
		{
			this.value=''
		}
 	});
 			$j('#author').focus(function(){
		if(this.value=='NOMBRE* (REQUERIDO)')
		{
			this.value=''
		}
 	});
 	
 	$j(".videos ul li").animate({ "opacity" : 0.3 });
	jQuery(".videos ul li").hover(function(){
	   jQuery(this).stop().animate({
	       opacity: 1
	   }, 300);
	}, function(){
	   jQuery(this).stop().animate({
	       opacity: 0.4
	   }, 300);
	});

 		             
               
    //Ajax Submit Form   
	$j(".cmsubmit").click(function() {	

	// First, disable the form from submitting
		$j('#formcm').submit(function() { return false; });

		// Grab form action
		formAction = $j("#formcm").attr("action");
						
		// Hack together id for email field
		emailId = formAction.replace("http://etrivomail.createsend.com/t/y/s/", "");
		emailId = emailId.replace("/", "");
		emailId = emailId + "-" + emailId;
			
		// Validate email address with regex
		if (!checkEmail(emailId)) 
		{
			alert("Please enter a valid email address");
			$j('#drktyd-drktyd').focus();
			return;
		}
		
		// Serialize form values to be submitted with POST
		var str = $j("#formcm").serialize();
		
		// Add form action to end of serialized data
		final = str + "&action=" + formAction;
			
		// Submit the form via ajax
		$j.ajax({
			url: "http://www.reportevirtual.com/wp-content/themes/reportev/proxy.php",
			type: "POST",
			data: final,
			success: function(html){
				$j("#formcm").hide(); // If successfully submitted hides the form
				$j("#confirmation").fadeIn(1500);  // Shows "Thanks for subscribing" div
				}
			});
	});

});

	function checkEmail(email)
	{	
		var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var emailVal = $j.trim($j("#" + email).val());
		return pattern.test(emailVal);
	}


var addthis_brand = "reportV";
var addthis_header_color = "#f38b1e";
var addthis_header_background = "#1D1D1F";
var addthis_options = 'email, facebook, twitter,delicious, wordpress, digg';

// You already voted alert box!
$j(function(){

	$j('.voted').each(function(){
		$j('.starsbar').bind('click', function(){
				if (jlang == 'es') {
					alert('Gracias por tu participacion, ya recibimos tu voto.');
				}
				if (jlang == 'en') {
					alert('Thank you for your participation, we have received your rating.');
				}
		});
	})
});
