var dimLogin = 20;
var loginInterval = null;
var dimAlert = -131;
var alertInterval = null;
var alertID = "alert";
var alertMotion = 100;
var visitDelay = 10000;
var eyeDelay = 20000;
var msgDelay = 30000;
var sessDelay = 300000;

function muoveLogin() {
	var popupDiv = document.getElementById(alertID);
	if (dimLogin >= -131) {
		dimLogin = dimLogin - 3;
		popupDiv.style.top = dimLogin + "px";
	}
	else {
		clearInterval(loginInterval);
		setTimeout('chiudiAlert()', 5000);
	}
}

function submitForm(id) {
var myForm = document.forms[id];
myForm.submit();
return true;
}

function muoveAlert() {
	var popupDiv = document.getElementById(alertID);
	if (dimAlert <= 20) {
		dimAlert = dimAlert + 3;
		popupDiv.style.top = dimAlert + "px";
	}
	else {
		clearInterval(alertInterval);
		//setTimeout('chiudiAlert()', 5000);
	}
}

function chiudiAlert(tipo) {
  var popupDiv = document.getElementById(alertID);
  popupDiv.innerHTML = "";
  popupDiv.style.display = "none";
  var ai = new AJAX("risp_ajax_tempora.php");
  var params = { tipo: tipo };
  ai.doPost(params);
}

function alertControl(text) {
  if (text != "") {
    try {
	  var code = stripslashes(text);
      		var popupDiv = document.getElementById(alertID);
   			popupDiv.innerHTML = code;
   			noticeInterval = setInterval("muoveAlert()",alertMotion);
      		popupDiv.style.display = "block";
      		popupDiv.style.visibility = "visible";
			pageScroll();
    } catch(e) { }
  }
}

function getAvvisi() {
  var ai = new AJAX("risp_ajax_avvisi.php", alertControl);
  ai.doGet();
}

function chiudiAvviso(nick) {
  var ai = new AJAX("risp_ajax_avvisi.php");
  var params = { notified: "yes", nick: nick };
  ai.doPost(params);
}

function getVisiteProfilo() {
  var ai = new AJAX("risp_ajax_visite.php", alertControl);
  ai.doGet();
}

function getOcchio() {
  var ai = new AJAX("risp_ajax_occhiolini.php", alertControl);
  ai.doGet();
}

function getMessaggi() {
  var ai = new AJAX("risp_ajax_messaggi.php", alertControl);
  ai.doGet();
}

function setFakeSession() {
  var ai = new AJAX("fsession.php", null);
  ai.doGet();
}

function loadAlbum(id,classe) {
	var att = new AJAX('risp_ajax_album.php', printAlbum);
	var params = {aid: id, classe: classe};
	att.doPost(params);
}

function printAlbum(text) {

	if (text != "") {
		var parti = text.split("|");
      	//var popupDiv = document.getElementById("album_"+parti[1]);
   		//popupDiv.innerHTML = parti[0];
      	var caruDiv = document.getElementById("mycarousel_"+parti[1]);
		//caruDiv.style.display = 'block';
   		//caruDiv.innerHTML = parti[0];
		var li = createDom('li','mycarousel-item-1','','<a href="Gallery/1dublay.jpg" rel="lightbox"><img src="Gallery/1dublay.jpg"></a>');
		caruDiv.appendChild(li); 
	}
}

function createDom(tag, id, class, html) {

        var n = document.createElement(tag);
        n.id = id;
        n.className = class;
        n.innerHTML = html;
        return n;
}

//setFakeSession();
//setInterval("getAvvisi()", 30000); 
//setInterval("getVisiteProfilo()", visitDelay); 
//setInterval("getOcchio()", eyeDelay); 
//setInterval("getMessaggi()", msgDelay); 
//setInterval("setFakeSession()", sessDelay); 

