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 overlay()	{
	document.getElementById("overlay").style.display = 'block';	
}

function sendMail(section, text_a, text_b)  {
	//if (section == "telematica")
	//{
		str = "http://www.cdr-mediared.it/popmail/" + section + "?text_a=" + text_a + "&text_b=" + text_b;
		PopItUp =  window.open(str, 'popitup',"scrollbars=yes,resizable=no,width=550,height=467,status=yes,location=no,toolbar=no,top="+top+",left="+left);
		PopItUp.focus();
	//}
}

function sendMail_evo(sel_item, lang_id)  {
	if (lang_id == 'ita')
	{
		str = "http://www.cdr-mediared.it/mail_evo/popmail.php?sel_item=" + sel_item;
	}else if (lang_id == 'eng')
	{
		str = "http://www.cdr-mediared.com/mail_evo/popmail.php?sel_item=" + sel_item;
	}
	PopItUp =  window.open(str, 'popitup',"scrollbars=yes,resizable=no,width=550,height=467,status=yes,location=no,toolbar=no,top="+top+",left="+left);
	PopItUp.focus();
}

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 checkMail(emailInput)
   {
   // Controllo il formato dell'indirizzo e-mail. rstituisce true o false
   var StrMail;
   StrMail=emailInput.value;
   if (StrMail.length>6)
      {
      var pos;
      var dotpos;
      pos = StrMail.indexOf("@");
      if ( (pos >= (StrMail.length-3) ) || (pos < 2) )
         {
         emailInput.focus();
         return (false);
         }
      pos=pos+1;
      dotpos = StrMail.indexOf(".", pos);
      if (dotpos > (StrMail.length-3) )
         {
         emailInput.focus();
         return (false);
         }
      Strmail=StrMail.substr(pos);
      if ( (StrMail.length < 5) || (dotpos <= 0) )
         {
         emailInput.focus();
         return (false);
         }
      }
   else
      {
      emailInput.focus();
      return (false);
      }
   return true;
}