YAHOO.namespace("example.contenedor");
function dialog_enviar_secreto(){/*ventana enviar secreto rapido*/
if(document.getElementById("contenedor"))
	document.getElementById("contenedor").style.display = "block";
	var handleSubmit = function(){
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};

	var handleSuccess = function(o) {
	var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("resp").innerHTML = response;
	};

	var handleFailure = function(o) {
		alert("Error al enviar el secreto, intente mas tarde!");
	};

	YAHOO.example.contenedor.enviar_secreto = new YAHOO.widget.Dialog("enviar_secreto",
		{
			width: "605px",
			fixedcenter: true,
			close: true,
			draggable: true,
			zindex:4,
			modal: false,
			visible: false,
			constraintoviewport:true,
			buttons : [ { text:"Enviar", handler:handleSubmit, isDefault:true },
						{ text:"Cancelar", handler:handleCancel } ]
		}
	);
	/*configuracion de los textareas avanzados*/
		tinyMCE.init({
			// General options
			mode : "textareas",
			theme : "advanced",
			editor_selector : "secreto_rapido",
			plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,emotions,image,media,|,forecolor,backcolor",
			theme_advanced_buttons2 : "cut,copy,paste,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : false,//para que el textarea sea resizable
			template_replace_values : {
				username : "confiezateya",
				staffid : "731193"
			}
		});
	/*fin configuracion de los textareas avanzados*/
var kl = new YAHOO.util.KeyListener(document, { keys:27 },
										  { fn:YAHOO.example.contenedor.enviar_secreto.hide,
											scope:YAHOO.example.contenedor.enviar_secreto,
											correctScope:true }, "keyup" );
											// keyup is used here because Safari won't recognize the ESC
											// keydown event, which would normally be used by default
	YAHOO.example.contenedor.enviar_secreto.cfg.queueProperty("keylisteners", kl);
	YAHOO.example.contenedor.enviar_secreto.render();
var kl2 = new YAHOO.util.KeyListener(document, { ctrl:true, keys:89 },
										   { fn:YAHOO.example.contenedor.enviar_secreto.show,
											 scope:YAHOO.example.contenedor.enviar_secreto,
											 correctScope:true } );
	kl2.enable();

	YAHOO.util.Event.addListener("escribir_secreto_menu", "click", YAHOO.example.contenedor.enviar_secreto.show, YAHOO.example.contenedor.enviar_secreto, true);
	YAHOO.util.Event.addListener("escribir_secreto_img", "click", YAHOO.example.contenedor.enviar_secreto.show, YAHOO.example.contenedor.enviar_secreto, true);
	YAHOO.example.contenedor.enviar_secreto.validate = function(){
		var data = this.getData();
		var datos = {"tit": data.tit, "edad": data.edad, "sexo": data.sexo, "secreto": data.secreto, "email": data.email, "check": data.check};
		enviar_secreto(datos,1);
	};

	YAHOO.example.contenedor.enviar_secreto.callback = { success: handleSuccess,failure: handleFailure
	};
	YAHOO.example.contenedor.enviar_secreto.render();

}

YAHOO.namespace("example.conte_contac");
function dialog_contacto() {
if(document.getElementById("conte_contac"))
document.getElementById("conte_contac").style.display = "block";
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};

	var handleSuccess = function(o) {
	var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("resp").innerHTML = response;
	};

	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	YAHOO.example.conte_contac.contacto = new YAHOO.widget.Dialog("contacto",
		{
			width: "390px",
			fixedcenter: true,
			close: true,
			draggable: true,
			zindex:4,
			modal: false,
			visible: false,
			constraintoviewport:true,
			buttons : [ { text:"Enviar", handler:handleSubmit, isDefault:true },
						{ text:"Cancelar", handler:handleCancel } ]
		}
	);

	var kl = new YAHOO.util.KeyListener(document, { keys:27 },
										  { fn:YAHOO.example.conte_contac.contacto.hide,
											scope:YAHOO.example.conte_contac.contacto,
											correctScope:true }, "keyup" );
	YAHOO.example.conte_contac.contacto.cfg.queueProperty("keylisteners", kl);
	YAHOO.example.conte_contac.contacto.render();



	YAHOO.util.Event.addListener("contactenos", "click", YAHOO.example.conte_contac.contacto.show, YAHOO.example.conte_contac.contacto, true);
	YAHOO.example.conte_contac.contacto.validate = function() {
		enviar(document.form_contactenos,22);
	};

	YAHOO.example.conte_contac.contacto.callback = { success: handleSuccess,failure: handleFailure };
	YAHOO.example.conte_contac.contacto.render();

}

YAHOO.namespace("example.conte_moderador");
function dialog_moderador() {
document.getElementById("conte_moderador").style.display = "block";
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};

	var handleSuccess = function(o) {
	var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("resp").innerHTML = response;
	};

	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	YAHOO.example.conte_moderador.moderador = new YAHOO.widget.Dialog("moderador",
		{
			width: "240px",
			fixedcenter: true,
			close: true,
			draggable: true,
			zindex:4,
			modal: false,
			visible: false,
			constraintoviewport:true,
			buttons : [ { text:"Enviar", handler:handleSubmit, isDefault:true },
						{ text:"Cancelar", handler:handleCancel } ]
		}
	);

	var kl = new YAHOO.util.KeyListener(document, { keys:27 },
										  { fn:YAHOO.example.conte_moderador.moderador.hide,
											scope:YAHOO.example.conte_moderador.moderador,
											correctScope:true }, "keyup" );
	YAHOO.example.conte_moderador.moderador.cfg.queueProperty("keylisteners", kl);
	YAHOO.example.conte_moderador.moderador.render();



	YAHOO.util.Event.addListener("root", "click", YAHOO.example.conte_moderador.moderador.show, YAHOO.example.conte_moderador.moderador, true);
	YAHOO.example.conte_moderador.moderador.validate = function() {
		login_moderador(document.form_moderador.username.value, document.form_moderador.pw.value);
	};

	YAHOO.example.conte_moderador.moderador.callback = { success: handleSuccess,failure: handleFailure };
	YAHOO.example.conte_moderador.moderador.render();

}

YAHOO.util.Event.addListener(window, "load", dialog_enviar_secreto);
YAHOO.util.Event.addListener(window, "load", dialog_contacto);
//YAHOO.util.Event.addListener(window, "load", dialog_moderador);