// JavaScript Document
	function chiudifinestra() {
		setTimeout('self.close()',0100);
		}

	function contattaautore(strURL) {
		opener.location = strURL;
		setTimeout('self.close()',0100);
		}

	function GetTime() {
   		var d = new Date();
   		return d.getTime()/1000;
		}

	function nuovafinestra(url,w,h) {
		parametri = "toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", top=100, left=200";
		scheda = window.open('','galleria', parametri);
		scheda.location.href=url;
		if (!scheda.opener) scheda.opener = self;
		if (scheda == null) alert('Il sito delle pecorElettriche.it sta cercando di visualizzare una immagine,\r\nma apparentemente un blocco dei popup lo impedisce.\r\nSe vuoi vedere la immagine, elimina il blocco');
		}

	function maxChar(form) {
		var MaxLen=300;
		inputStr = form.txtMessaggio.value;
		strlength= inputStr.length;
		if (strlength > MaxLen ) form.txtMessaggio.value=inputStr.substring(0,MaxLen);
		form.charsleft.value = (MaxLen - form.txtMessaggio.value.length);
		form.charsleft1.value = form.charsleft.value;
		form.txtMessaggio.focus();
		}

	function maxChar1(form) {
		form.charsleft.value = form.charsleft1.value;
		}

	function Help(url) {	
		scheda = window.open('','help', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=300, top=100, left=200');
		scheda.location.href=url;
		}

	function ListaUtenti(url) {	
		scheda = window.open('','listautenti', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=250, height=300, top=100, left=200');
		scheda.location.href=url;
		}

	function ridimensiona() {
  		var myWidth = 0, myHeight = 0;
  		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			} else if( document.documentElement &&
			( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			}
			document.iframechat.resizeTo(myWidth-140,myHeight-71)
		}

	function Chat_MessaggioPrivato(url) {	
		scheda = window.open('','messaggio', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=auto, resizable=yes, copyhistory=no, width=400, height=170, top=100, left=200');
		scheda.location.href=url;
		}

	function toggleAutore(objEnabled,objDisabled) {
		obj=document.getElementById(objEnabled);
		obj1=document.getElementById(objDisabled);
		obj.disabled=false;
		obj.value="";
		obj.focus();
		obj1.disabled=true;
		obj1.value=""
		}

	function Forum_SubmitSezione(codArgomento,codSezione){
    		document.myform.action = "forum_gestione.asp?op=CambioSezione&Target=" + codArgomento + "&NewSez=" + codSezione;
    		document.myform.submit();
		}

	function Forum_SubmitPagina(strParametro){
		document.FormPost.action = strParametro;
		document.FormPost.submit();
		}

	function Forum_SubmitFiltro(strFiltro){
    		document.myform.action = "forum_visualizzaargomenti.asp?flt=" + strFiltro;
    		document.myform.submit();
		}

	function Foto_AggiungiAPreferite(strURL) {
		location = strURL;
		window.resizeTo(450,200);
		}

	function Foto_SpedisciCartolina(strURL) {
		scheda = window.open('','cartolina', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=auto, resizable=yes, copyhistory=no, width=680, height=420, top=100, left=50');
		scheda.location.href=strURL;
		if (!scheda.opener) scheda.opener = self;
		}

	function Foto_CambiaAnteprima(picture) {
		parent.document.anteprima.src = "/immagini/fotografie/miniature/" + picture + ".jpg";
		}

	function Utenti_CambiaAnteprima(picture) {
		parent.document.anteprima.src = "/script/ThumbnailImage.aspx?img=/public/utentiweb/" + picture + "&fn=l&w=120&h=120";
		}

// codice preso da onlinetools.org

    function checkform(of)
		 {
	    if(!document.getElementById || !document.createTextNode){return;}
	    if(!document.getElementById('required')){return;}
	    var errorID='errormsg';
	    var errorClass='error'
	    var errorMsg='Per favore, inserire e/o modificare i campi indicati con ';
	    var errorImg='/immagini/alert.gif';
	    var errorAlt='(Errore!)';
	    var errorTitle='Questo campo contiente un errore!';
	    var reqfields=document.getElementById('required').value.split(',');
	    // Cleanup old mess
	    // if there is an old errormessage field, delete it
	    if(document.getElementById(errorID))
		    {
		    var em=document.getElementById(errorID);
		    em.parentNode.removeChild(em);
	    }
	    // remove old images and classes from the required fields
	    for(var i=0;i<reqfields.length;i++)
			 {
		    var f=document.getElementById(reqfields[i]);
		    if(!f){continue;}
		    if(f.nextSibling && /img/i.test(f.nextSibling.nodeName))
			    {
			    f.parentNode.removeChild(f.nextSibling);
		    }
		    f.className='';
	    }
	    // loop over required fields
	    for(var i=0;i<reqfields.length;i++)
			{
			// check if required field is there
			var f=document.getElementById(reqfields[i]);
			if(!f){continue;}
			// test if the required field has an error,
			// according to its type
			switch(f.type.toLowerCase())
			    {
			    case 'text':
				    if(f.value=='' && f.id!='txtEmail'){cf_adderr(f)}
				    // email is a special field and needs checking
				    if(f.id=='txtEmail' &&
				    !cf_isEmailAddr(f.value)){cf_adderr(f)}
				    break;
			    case 'textarea':
				    if(f.value==''){cf_adderr(f)}
				    break;
			    case 'checkbox':
				    if(!f.checked){cf_adderr(f)}
				    break;
			    case 'select-one':
				    if(!f.selectedIndex && f.selectedIndex==0){cf_adderr(f)}
				    break;
			}
	    }
	    return !document.getElementById(errorID);

	    /* Tool methods */
	    function cf_adderr(o)
		    {
		    // create image, add to and colourise the error fields
		    var errorIndicator=document.createElement('img');
		    errorIndicator.alt=errorAlt;
		    errorIndicator.src=errorImg;
		    errorIndicator.title=errorTitle;
		    o.className=errorClass;
		    //o.parentNode.insertBefore(errorIndicator,o);
		    o.parentNode.insertBefore(errorIndicator,o.nextSibling);

		    // Check if there is no error message
		    if(!document.getElementById(errorID))
			    {
			    // create errormessage and insert before submit button
			    var em=document.createElement('div');
			    em.id=errorID;
			    var newp=document.createElement('p');
			    newp.appendChild(document.createTextNode(errorMsg))
			    newp.setAttribute('class','messaggio')
			    // clone and insert the error image
			    newp.appendChild(errorIndicator.cloneNode(true));
			    em.appendChild(newp);
			    // find the submit button
			    for(var i=0;i<of.getElementsByTagName('input').length;i++)
				    {
				    if(/submit/i.test(of.getElementsByTagName('input')[i].type))
					    {
					    var sb=of.getElementsByTagName('input')[i];
					    break;
				 	 }
		    	 }
			    if(sb)
				    {
				    sb.parentNode.insertBefore(em,sb);
			    }
		    }
	    }

	    function cf_isEmailAddr(str)
		    {
		    return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
	    }
    }
