

function valida_captcha(cod,nombre,apellidos,email,telefono,consulta)

{




$.ajax({
        type: "POST",
        url: "captcha/valida_captcha.php",
        data: "captcha="+cod+"&nombre="+nombre+"&apellidos="+apellidos+"&email="+email+"&telefono="+telefono+"&consulta="+consulta,
        success: function(datos)
	{
	if(datos==1)		
		{
		$('#formulario').hide();
		$('#email_ok').show();
		
		}
	else
		{
		alert("Captcha incorrecto");
		}
		}
});


}

function valida_email(str)
{


		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Formato de correo incorrecto")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Formato de correo incorrecto")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Formato de correo incorrecto")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Formato de correo incorrecto")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Formato de correo incorrecto")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Formato de correo incorrecto")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function valida()

{




if(document.forms[0].nombre.value=="")
	{
	alert("Debe rellenar todos los campos obligatorios");
	return 0;
	}
	


if(document.forms[0].apellidos.value=="")
        {
        alert("Debe rellenar todos los campos obligatorios");
        return 0;
        }



if(document.forms[0].consulta.value=="")
        {
        alert("Debe rellenar todos los campos obligatorios");
        return 0;
        }

if(document.forms[0].captcha.value=="")
        {
        alert("Debe rellenar todos los campos obligatorios");
        return 0;
        }






if(!valida_email(document.forms[0].email.value))
	return 0;



if(valida_captcha(document.forms[0].captcha.value,document.forms[0].nombre.value,document.forms[0].apellidos.value,document.forms[0].email.value,document.forms[0].telefono.value,document.forms[0].consulta.value))
{
	document.forms[0].submit();
}

}




function get_rss_feed() {
	//clear the content in the div for the next feed.
	$("#noticias_contenido").empty();
 
	//use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete
	$.get('proxy.php?url=http://noticias.nggn.net/wordpress/?feed=rss2', function(d) {
 
		//find each 'item' in the file and parse it
		$(d).find('item').each(function() {
 
			//name the current found item this for this particular loop run
			var $item = $(this);
			// grab the post title
			var title = $item.find('title').text();
			// grab the post's URL
			var link = $item.find('link').text();
			// next, the description
			var description = $item.find('description').text();
			//don't forget the pubdate
			var pubDate = $item.find('pubDate').text();
 
			// now create a var 'html' to store the markup we're using to output the feed to the browser window
			var html = "<a href="+ link + " >" + title + "<\/a><br>";
			
			//put that feed content on the screen!
			$('#noticias').append($(html));  
		});
	});
 
}




function comprobar_dominio(){
if($("#dominio-sld").val()=="")
{
	alert("Debe especificar un dominio");
}
else
{

var url="http://cps.nggn.net/cart.php?systpl=orden&a=add&domain=register&sld=" + $("#dominio-sld").val() + "&tld=." + $("#domain-selector").val();
window.location=url;
}

}








