﻿include_once('/js/sardalya.js');

function newsClick() {
	document.location.href = _.gid('DialogContent').firstChild.href;
}

function homePopup() {
	var ajax = _.ajax();
	
	ajax.oncomplete = function(strResponseText, objResponseXML) {
		if (strResponseText != '') {
			_.l('DialogContent').changeContent(strResponseText);
			
			//imposto il link su tutto il layer
			_.chain('DialogContent', 'click', newsClick, false);
			
			g_Modal.show();
			g_Modal.enableClose();
		}
	};
	
	ajax.onerror	 = function(intStatus, strStatusText) {
		alert('Errore [' + intStatus + '] [' + strStatusText + '].');
	};
	
	//se non è già stato visualizzato in questa sessione
	if (!_.gcook('hp')) {
		_.scook('hp', '1', 0);
		
		ajax.get('/ajax.homepopup.asp')
	}
}

_.chain(window, 'load', homePopup, false);