YAHOO.namespace("privacy");

function init(id) {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		var response = eval('(' + o.responseText + ')');
	//	var response = o.responseText;
		if(response.result == 'ok'){
			$('div_msg').innerHTML = 'Módosítás megtörtént';
			$('div_msg').style.display = '';
			if(response.szoveg != 'Mindenki'){
				$('span_pass'+response.dest).innerHTML = '<img src="http://www.ende.hu/img/password.gif" alt="" border="0" /> '+response.szoveg;
			}else{
				$('span_pass'+response.dest).innerHTML = '';	
			}
			setTimeout( "hide_msg()", 5000); 
		}else{
			alert('Hiba történt');						
		}
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	// Instantiate the Dialog
	YAHOO.privacy.dialog_privacy = new YAHOO.widget.Dialog("dialog_privacy", 
							{ width : "334px",
							  xy:[400,100],
							  visible : false, 
							  constraintoviewport : true,
							  modal: true
							});


	// Wire up the success and failure handlers
	YAHOO.privacy.dialog_privacy.callback = { success: handleSuccess,
						     failure: handleFailure };
	
	// Render the Dialog
	YAHOO.privacy.dialog_privacy.render();

}

YAHOO.util.Event.onDOMReady(init);

