function modificarCInformativa(formulario){
	var cInformativa = document.getElementById("cInformativa");
	cInformativa.checked = !cInformativa.checked;
}

function modificarPDatos(formulario){
	var pDatos = document.getElementById("pDatos");
	pDatos.checked = !pDatos.checked;
}

function grabarDatos(formulario){
	var cInformativa = document.getElementById("cInformativa");
	var pDatos = document.getElementById("pDatos");
	
	var proteccionDatos = parent.document.getElementById("proteccionDatos");
	
	if( proteccionDatos )
		{
		if (pDatos.checked){
			parent.document.getElementById("proteccionDatos").value = pDatos.value;
		} else {
			parent.document.getElementById("proteccionDatos").value = "0";
		}
		if (cInformativa.checked){
			parent.document.getElementById("camInformativa").value = cInformativa.value;
		} else {
			parent.document.getElementById("camInformativa").value = "1";
		}
	}
	else {
		if (pDatos.checked){
			parent.document.getElementById("datosGeneralesVO.proteccionDatos").value = pDatos.value;
		} else {
			alert(parent.document.getElementById("datosGeneralesVO.proteccionDatos").value);
		}
		if (cInformativa.checked){
			parent.document.getElementById("datosGeneralesVO.camInformativa").value = cInformativa.value;
		} else {
			parent.document.getElementById("datosGeneralesVO.camInformativa").value = "1";
		}
	}
	alert("Gracias por leer y aceptar las condiciones generales de protecci\u00f3n de datos.");
	$.facebox.close();
}

function validarProteccionDatos(form) {
	
	var valido = true;
	proteccionDatos=document.getElementById("proteccionDatos");
	
	if (proteccionDatos) {
		if (proteccionDatos.value != "1") {
			valido=false;
		}
	} else {
		var pDatos=document.getElementById("datosGeneralesVO.proteccionDatos");
		if (pDatos.value != "1") {
			valido=false;
		}
	}
	if (!valido) {
		alert(mensajeMensajeProteccionDatos); 
	} 
	return valido; 
}

function comprobarCheckSostenible(form){
	var pDatos = document.getElementById("proteccionDatos");
	var cInformativa = document.getElementById("camInformativa");
	var prDatos = document.getElementById("pDatos");

	if (pDatos.checked) {
			document.getElementById("pDatos").value = "1";
			document.getElementById("pDatos").checked = true;
			pDatos.value = "1";
		} else {
			document.getElementById("pDatos").value = "0";
			document.getElementById("pDatos").checked = false;
			pDatos.value = "0"
		}
	
	if (cInformativa.checked){
		cInformativa.value = "1";
	}else {
		cInformativa.value = "2"
	} 

	cerrar(form);
}

function cerrar(form){
	var estilo = $('#textoProteccion').attr("style");
	if (estilo != null) {
		if (estilo.match(/block/)) {
				$('#textoProteccion').attr("style", "display: none;");
				$('#LOPD').slideUp();
		} else {
			$('#textoProteccion').attr("style", "display: block;");
			$('#LOPD').slideDown();
		}
	}
}
