<?php
require_once ('../init.php');
?>

errore=new Array();

function ie6LBfix() {
	var labels = new Array('loading', 'velata');
	for (i=1; i<=2; i++) {
		for (j=0; j<labels.length; j++) {
			var div = eval("document.getElementById('"+labels[j]+i+"').style;");
			if (div.display == 'block' || div.display == '') div.display = "none";
			else div.display = "block";
		}
	}
}

function chiudiRigaSessione() {
    var tmp = new AJAX("risp_ajax_cancella_sessione.php");
    var params = {};
    tmp.doSyncPost(params);
}

function execCode(code) {
	if (code != "") {
		if ((code.match('^document') || code.match('^objselect')) && (errore[1]=='C' || errore[1]=='N'))
		eval(code);
	}
}

function addslashes(str) {

str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}

function stripslashes(str) {

str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

function visibile(id, stato) {
	if (document.getElementById(id)) {
		var dom = document.getElementById(id).style;
		if (stato == 'si')
			dom.display = 'block';
		else if (stato == 'no')
			dom.display = 'none';
	}
}

function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

function pageScroll() {
    	window.scrollBy(-3000,-3000);
     	//scrolldelay = setTimeout('pageScroll()',100);
}


function showImgFullscreen(src) {
	var imgClose = new Image();
	imgClose.className = "close";
	imgClose.onclick = hideImgFullscreen;
	imgClose.src = "images/close.gif";
	var imgBig = new Image();
	imgBig.onload = function() {
		var nuovo = document.getElementById('nuovo');
		nuovo.style.display = "block";
		nuovo.innerHTML =
		'<div id="opacita"></div>' +
		'<div id="opacita_img">' +
		'<div id="opacita_img_content"></div>' +
		'</div>';
		var container = document.getElementById("opacita_img_content");
		container.style.width = (this.width + 30) + "px";
		var top = (document.documentElement.clientHeight - this.height - 30) / 2;
		container.style.marginTop = top < 0 ? "0" : top + "px";
		container.appendChild(this);
		container.appendChild(imgClose);
	}
	imgBig.className = "full_avatar";
	imgBig.src = src;

	var nuovo = document.getElementById('nuovo');
	nuovo.style.display = "block";
	nuovo.innerHTML =
	'<div id="opacita"></div>' +
	'<div id="opacita_img">' +
	'<div id="opacita_img_content"></div>' +
	'</div>';
}

function hideImgFullscreen() {
	var container = document.getElementById('nuovo');
	container.innerHTML = "";
	container.style.display = "none";
}

function getNome(str)
{
	errore[0]='Errore interrogazione database!';
	errore[1]='N';
	var ai = new AJAX("risp_ajax.php", execCode);
	ai.doPost('ajax=yes&id1='+str);
}
function getEmail(str)
{
	errore[0]='Errore interrogazione database!';
	errore[1]='N';
	var ai = new AJAX("risp_ajax_email.php", execCode);
	ai.doPost('ajax=yes&id1='+str);
}

function blurConfEmail(str){
	var cop = document.getElementById('ajaxconfemail');
	if(document.getElementById('uemail').value != str && document.getElementById('confemail').value.length > 0)
		cop.innerHTML = "<img src=\"images/icons/warning.gif\"> <?= _('Le due email non coincidono'); ?>";
}

function getConfEmail(str)
{
	len = new String(str);
	var cop = document.getElementById('ajaxconfemail');
	var passwd = new String(document.getElementById('uemail').value);
	if (len.length > 0 && len[len.length-1] != passwd[len.length-1]){
			cop.innerHTML = "<img src=\"images/icons/warning.gif\"> <?= _('Le due email non coincidono'); ?>";
	}
	else{
		if(len.length > 0 && len.substring(0,len.length-1) != passwd.substring(0,len.length-1))
			cop.innerHTML = "<img src=\"images/icons/warning.gif\"> <?= _('Le due email non coincidono'); ?>";
		else	
			cop.innerHTML = '';
	}

	return false;
}

function getConfPwd(str)
{
	var cop = document.getElementById('erroreconfpwd');
	if (str != document.getElementById('pwd').value){
		cop.innerHTML = "<img src=\"images/icons/warning.gif\"> <?= _('Le due password non coincidono'); ?>";
	}
	else{
		cop.innerHTML = '';
	}
	return false;
}

function controlloPwd(str)
{
	var cop = document.getElementById('iderrorepwd');
	if (str.length < 6){
		cop.innerHTML = "<img src=\"images/icons/warning.gif\"> <?= _('La password deve avere almeno 6 caratteri'); ?>";
		document.getElementById('phppwd').innerHTML = '';
	}
	else
	cop.innerHTML = "";
}

function getCitta(str,nazID,citID)
{
	errore[0]='Errore interrogazione database!';
	errore[1]='N';
	var fm = document.getElementById(nazID);
	var ai = new AJAX("risp_ajax_2.php", execCode);
	ai.doPost('ajax=yes&id2='+ fm.value +'&id1='+ str+'&idc='+citID);
}

function getRegioni(str,regID)
{
	errore[0]='Errore interrogazione database!';
	errore[1]='N';
	var ai = new AJAX("risp_ajax_1.php", execCode);
	ai.doPost('ajax=yes&id1='+str+'&idr='+regID);
}
function insRichiedente(nick)
{
//alert('Parte ajax');
//document.getElementById('ajax').innerHTML = 'Lo cambio';
errore[0]='Errore interrogazione database!';
errore[1]='N';
var ai = new AJAX("risp_ajax_ric.php", execCode);
ai.doPost('ajax=yes&id1='+nick);
}

function openHistory(nick) {
	popHis = window.open("chat/popupHis.php?nick=" + escape(nick), "History_" + nick, "top="+((screen.availHeight)-(403))+",left="+((screen.availWidth/2)-(700/2))+", width=700, height=403, status=no, menubars=no, scrollbars=no, resizable=no");
}

