// <reference path="jquery-1.3.2-vsdoc.js"

//-----------------------------------------------------------------------------
// Menu
//
function navegar(pagina)
{	
	window.location = pagina;
}

//-----------------------------------------------------------------------------
// Abre Ventanas
//
function openWin(Pagina, Width, Height) {
var Propiedades = "center:yes; dialogWidth:" + Width + "px; dialogHeight:" + Height + "px; help:no; resizable:no; status:no";
showModalDialog(Pagina, "", Propiedades);
}

//-----------------------------------------------------------------------------
// SubMenu
//
function Mostrar(){
spMenu.style.display = "inline";
}
function Ocultar(){
spMenu.style.display = "none";
}

//-----------------------------------------------------------------------------
// Submit
//

function onClick_submit()
{
	var contolado = controla(); // Funcion para controlar campos

	if (!contolado.control)
	{
    	alert("Controlar: " + contolado.campo);
  	} else {
		document.getElementById('FormMail').submit()
	}
}


//-----------------------------------------------------------------------------
// Controla Campos
//

function controla()
{
var control = true;
var campo = "";	
	
	// Controlo Campos
	jQuery.each(jQuery("#FormMail").find("input"),function() {		
		if (control)
		{			
			if (jQuery(this).attr("type") != "hidden")
			{
				if ((jQuery(this).val()=="") && (jQuery(this).attr("class") == "obliga"))
				{					
					control = false;
					campo = jQuery(this).attr("title");
				}
			} 
		}
	});
	
	
	// Controlo E-Mail
  	if (control)
	{
		if (!CtrolInput.ChequearEMail(jQuery("#Email").val()))
		{
			control = false;
    		campo = " E-mail ";
		}
	};
	
	// Controlo Comentario
  	if (control)
	{
		if($('textarea:first').val()=="")
		{
	        control = false;
    	    campo = " Comentario "; //title
      	}
   	};
	
   	return {'control':control,'campo':campo};
}
