// JavaScript Document

function classChange(element,newclass) {
	var elemento = document.getElementById(element);
	elemento.className = newclass;
	}

function ocultartodo() {
	classChange('s1','DisplayNone');
	classChange('s3','DisplayNone');
	classChange('s4','DisplayNone');
	classChange('ss4','DisplayNone');
	}

	

function initFontSize(){
		document.getElementById("contenidoCentralinterior").style.fontSize="1em";
	}
	
	function aumentar(){
		var oDiv = document.getElementById("contenidoCentralinterior");
		var iSize = parseFloat(oDiv.style.fontSize);
		iSize+=0.2;
		oDiv.style.fontSize=iSize+"em";
		return false;
	}
	function reducir(){
		var oDiv = document.getElementById("contenidoCentralinterior");
		var iSize = parseFloat(oDiv.style.fontSize);
		if(iSize>0.2) iSize-=0.2;
		oDiv.style.fontSize=iSize+"em";
		return false;
	}	

function devObj(obj) { 	return document.getElementById(obj);}


function cambiaFoto(obj,ruta,fondo) { 
	devObj(obj).src=ruta;
	if(fondo!=null)	devObj('Imagen00').src=fondo;
}

// form de envio a amigo
function validaEnvio() {
 	var f = document.formInvitacion;
 	
 	if(f.tu_nombre.value == "") {
 	 	alert("Your name is not correct or is empty, please review it.")
 		f.tu_nombre.focus()
 	 	return
 	}
	
	if(!validamail(f.tu_mail.value) ) {
		alert("Your e-mail is not correct or is empty, please review it.");
	    f.tu_mail.focus();
		return
	}
	
	
 	if(f.su_nombre.value == "") {
 	 	alert("His name is not correct or is empty, please review it.")
 	 	f.su_nombre.focus()
 	 	return
 	}

	if(!validamail(f.su_mail.value) ) {
		alert("His e-mail is not correct or is empty, please review it.");
	    f.su_mail.focus();
		return
	}
	
	f.submit()
}
/**
*  Válida la sintaxis del email
*
*  Comprobaciones :
*    - Mínimo de 5 caracteres
*    - Caracteres no permitidos : "+*|,\":<>[]{}`';()&$#% "
*    - Que la @ tenga algún caracter delante y alguno detrás
*    - Que exista '.' a partir del cuarto carácter (x@x.x)
*    - Que no acabe en '.'
*    - Que el punto esté detrás de la @
*/

function validamail(email){

	// Mínimo de 5 caracteres
	if (email.length < 5)
		return false

	// Cadena de caracteres no permitidos
	var iChars = "+*|,\":<>[]{}`';()&$#% ";	

	

	// Primero comprobamos que en el email no haya algún 
	// caracter no permitido
	var eLength = email.length;	
	for (var i=0; i < eLength; i++)	{		
		if (iChars.indexOf(email.charAt(i)) != -1)
			return false
	}	

	

	// Comprobamos que la @ tenga algún caracter delante y alguno detrás
	var atIndex = email.lastIndexOf("@");	
	if(atIndex < 1 || (atIndex == eLength - 1))
		return false



	// Comprobamos que exista '.' a partir del cuarto carácter, pero
	// que no acabé en '.'
	var pIndex = email.lastIndexOf(".");	
	if(pIndex < 3 || (pIndex == eLength - 1))	
		return false;	

	// Por último, comprobamos que el punto esté detrás de la @

	if(atIndex > pIndex)	
		return false	
	return true

}

function PrintMessage(){
    var msgid=getQueryParameter(document.location.href,"ReadMessageId");
    var opcionesPopup = "width=600px,height=400px,menubar=no,location=no,toolbar=no,resizable=yes,scrollbars=yes";
    var oWindow=window.open(sUrl,"",opcionesPopup);
}

// Impresión de la página actual 
function printpage() {

    var opcionesPopup = "width=800px,height=600,menubar=no,location=no,toolbar=no,resizable=yes,scrollbars=yes";
    var oWindow=window.open("print_preview.php?url=" + escape(location.href),"",opcionesPopup);  

}

function enviarMensaje() {
    
    var f = document.createElement("FORM");
    f.method = "post"
    f.action = "send_friend.php"
    
    var i = document.createElement("INPUT");
    i.type = "hidden"
    i.name = "url"
    i.value = location.href

    f.appendChild(i)
    document.body.appendChild(f)
    
    f.submit()
}

function sendComments() {
    var f = document.formEnviaCom
    
    if ( f.comments.value == "" ) {
        alert("Write your comments, please")
        f.comments.focus()
        return
    }
    
    f.submit()
}
function cambioCapa(r) {
	
	if ( r.value == "propietario" && r.checked ) {
		document.getElementById('cc_prop').style.display = "block";
		document.getElementById('cc_noprop').style.display = "none";
	} else if ( r.value == "nopropietario" && r.checked ) {
		document.getElementById('cc_prop').style.display = "none";
		document.getElementById('cc_noprop').style.display = "block";
	} else {	
		document.getElementById('cc_prop').style.display = "none";
		document.getElementById('cc_noprop').style.display = "none";
	}
	
}




	function Capa(){

		obj=document.getElementById("profesional").style.display;

		if(obj=="none"){

			document.getElementById("profesional").style.display="block";
	

		}else{

			document.getElementById("profesional").style.display="none";	



		}

	}