var left = Math.ceil((screen.width-550) / 2);
var top = Math.ceil((screen.height-500) / 2);
var lefts = Math.ceil((screen.width-350) / 2);
var tops = Math.ceil((screen.height-250) / 2);
var leftcoo = Math.ceil((screen.width-400) / 2);
var topcoo = Math.ceil((screen.height-400) / 2);

function popup550(str, popname)  {
        if (popname == "") {
			PopItUp =  window.open(str, 'popitup',"scrollbars=yes,resizable=no,width=550,height=480,status=yes,location=no,toolbar=no,top="+top+",left="+left);
		} else {
			PopItUp =  window.open(str, popname,"scrollbars=yes,resizable=no,width=550,height=480,status=yes,location=no,toolbar=no,top="+top+",left="+left);
		}
		PopItUp.focus();
}

function popup_coo(str) {
		PopItUp =  window.open(str,'popitup',"scrollbars=yes,resizable=yes,width=400,height=400,status=no,location=no,toolbar=no,top="+topcoo+",left="+leftcoo);
}

function popupfreepass(str, popname)  {
        if (popname == "") {
			PopItUp =  window.open(str, 'popitup',"scrollbars=yes,resizable=no,width=700,height=480,status=yes,location=no,toolbar=no,top="+top+",left="+left);
		} else {
			PopItUp =  window.open(str, popname,"scrollbars=yes,resizable=no,width=700,height=480,status=yes,location=no,toolbar=no,top="+top+",left="+left);
		}
		PopItUp.focus();
}

function popupsml(str) {
        PopItUp =  window.open(str,'popitup','scrollbars=yes,resizable=yes,width=350,height=250,status=no,location=no,toolbar=no');
}

function popupuol(str) {
        PopItUp =  window.open(str,'popitup','scrollbars=yes,resizable=yes,width=300,height=550,status=no,location=no,toolbar=no');
}

function popupchat() {
		str = 'http://irc.virgilio.it/chat.php?channel=%23etz';
		var chatleft = Math.ceil((screen.width-780) / 2);
		var chattop = Math.ceil((screen.height-530) / 2);
        PopItUp =  window.open(str,'popitup',"scrollbars=no,resizable=yes,width=780,height=530,status=no,location=no,toolbar=no,top=" + chattop + ",left="+chatleft);
}

function popupagain(str) {
        PopItUp =  window.open(str,'popagain',"scrollbars=yes,resizable=yes,width=350,height=250,status=no,location=no,toolbar=no,top="+tops+",left="+lefts);
}
function popupsmlagenzie(str) {
        PopItUp =  window.open(str,'popitup','scrollbars=no,resizable=no,width=350,height=200,status=no,location=no,toolbar=no, top="+tops+",left="+lefts"');
}

function popupagenzie(str) {
        PopItUp =  window.open(str,'popagain',"scrollbars=yes,resizable=yes,width=550,height=350,status=no,location=no,toolbar=no,top="+tops+",left="+lefts);
}

function popupcns(str) {
        popcns =  window.open(str,'popcns','scrollbars=yes,resizable=no,width=350,height=500,status=no,location=no,toolbar=no');
}

function post(str){
PopItUp =  window.open('', 'popitup',"scrollbars=yes,resizable=no,width=550,height=400,status=no,location=no,toolbar=no,top="+top+",left="+left);
PopItUp.focus();
PopItUp.document.location.replace(str + "?text=" + document.formcomm.text.value + "&itemid=" + document.formcomm.itemid.value + "&father=" + document.formcomm.father.value);
}

function kk() {
window.opener.location.reload()
window.opener.focus();
window.close();
}
function kkconsole() {
window.opener.location.href=('http://www.estesia.com/pubblicazione/');
window.close()
}
function kkurl(url) {
window.opener.location.href( url );
window.close()
}

function inputok(x) { 
if (x.value=='') { x.value=initialValues[x.id];} else if (x.value != initialValues[x.id]) { x.style.fontWeight = "bold"; }}

function controllo()    //funzione per il controllo dei dati inseriti nella sezione pubblicazione

        {
				var controllo_stat=false;
				var campivuoti = 0;
                if (document.pubblicazione.title.value == "" )
                        {
                                controllo_stat=true;
                                campivuoti = campivuoti + 1;
				campo = "titolo"; 
                        }
               if (document.pubblicazione.text.value == "" )
               	{
                        controllo_stat=true;
                        if (campivuoti == 1) {
						campo = campo + " e testo";
						campivuoti = campivuoti + 1; 
						}
						else { campo = "testo"; campivuoti = campivuoti + 1; } }     
				if (campivuoti == 1) {
				alert("Il campo " + campo + " va compilato!"); 		 }
				else {
				alert ("I campi " + campo + " vanno compilati!"); }
				
                if (controllo_stat)
                 {return false}
                else {return true}

}

function createMarker(point, url_fotuzza, fotuzza, testo) {
	var marker = new GMarker(point);

	var html = '<table><tr>';
	html += '<td><a href="' + url_fotuzza + '"><img src="' + fotuzza + '" width="100" height="75.5" border="0" style="border: 1px solid black" /></a></td>';
	html += '<td valign="top"><a href="' + url_fotuzza + '" style="color:black; font-size: small">' + testo + '</a></td>';
	html += '</tr></table>';

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
	return marker;
}
