// JS DOC

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
if(v_length < 0){
return"";
}
	var iTemp = v_length -1;

while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(0,iTemp +1);
	break;
	}
	iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function







function pulisciForm(Form){
	if(Form){
		Form.reset();
	}
	
	
}

function go_back(){
	history.back(-1);

}

function go_home(){
	go_to("/afip/admin/frame.php?pagina=news");
}


function go_to(pg){
	if(parent.frames){
		top.location.href=pg;
	}
	window.location.href=pg;
}

function del(id){
	document.frmAggNews.azione.value='elimina|'+id;
	document.frmAggNews.submit();
}

/*
function agg(id){
	document.frmAggNews.action='aggiornanews.php';
	document.frmAggNews.target='_self';
	document.frmAggNews.azione.value='aggiorna|'+id;
	document.frmAggNews.submit();
}
*/

function agg(id){
	document.getElementById('btn_salva_'+id).style.visibility='visible';
	document.getElementById('testonews_'+id).disabled=false;
	document.getElementById('titolonews_'+id).disabled=false;
	document.getElementById('btn_salva_'+id).disabled=false;
	//document.getElementById('btn_aggiorna_'+id).value='Salva..';
	//document.getElementById('btn_aggiorna_'+id).onclick  = controlla(id);
	//document.frmAggNews.target='_self';
	document.frmAggNews.azione.value='aggiorna|'+id;
	
}

function salva(){
	
	document.frmAggNews.submit();	
	
}

<!--
function crea()
{
for (i = 0; i<crea.arguments.length; i++)
this[i + 1] = crea.arguments[i];
}




//document.write(gg + " " + mesi[mese] + " " + yyyy);
//-->

function msg(m){

alert(m);
	
}



function nuovo(){
	/*
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var checkStr = document.frmNuovaNews.testonews.value;
	var allValid = true;
	
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++){
				if (ch == checkOK.charAt(j)){
					break;
					if (j == checkOK.length)
					{
						allValid = false;
						break;
					}
				}
			}
		}
	
	if (!allValid)
	{
		msg('Attenzione!! < Non è stato inserito nessun testo utile>');
		document.frmNuovaNews.testonews.focus();
		return false;
	}
	*/
	alert(document.frmNuovaNews.testonews.value.indexOf('\r')>0);
	if(Trim(document.frmNuovaNews.testonews.value)=='') {
		
		
		
		
		msg('Attenzione!! < Non è stato inserito nessun testo >');
		document.frmNuovaNews.testonews.focus();
		return false;
	}
	

	if(Trim(document.frmNuovaNews.titolonews.value)=='') {
		msg('Attenzione!! < Non è stato inserito nessun titolo >');
		document.frmNuovaNews.titolonews.focus();
		return false;
	}
	
	
	
	
	
	
	
	
	
	
	var mesi = new crea('Gennaio','Febbraio','Marzo',
		'Aprile','Maggio','Giugno','Luglio','Agosto','Settembre',
		'Ottobre','Novembre','Dicembre');
	
	var mesi = new crea('01','02','03',
		'04','05','06','07','08','09',
		'10','11','12');
	
	var date = new Date();
	var gg = ((date.getDate()<10) ? "0" : "")+ date.getDate();
	var mese = date.getMonth();
	var yy = date.getYear();
	var yyyy = (yy < 1000) ? yy + 1900 : yy;

	document.frmNuovaNews.datanews.value=yyyy+'-'+mesi[mese+1]+'-'+gg + ' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();
	
	
	
	document.frmNuovaNews.azione.value='nuovo';
	document.frmNuovaNews.submit();
}

function data(){
	
	var mesi = new crea('Gennaio','Febbraio','Marzo',
		'Aprile','Maggio','Giugno','Luglio','Agosto','Settembre',
		'Ottobre','Novembre','Dicembre');
	
	var mesi = new crea('01','02','03',
		'04','05','06','07','08','09',
		'10','11','12');
	
	var date = new Date();
	var gg = ((date.getDate()<10) ? "0" : "")+ date.getDate();
	var mese = date.getMonth();
	var yy = date.getYear();
	var yyyy = (yy < 1000) ? yy + 1900 : yy;
	
	document.getElementById('data').innerHTML=""+yyyy+'-'+mesi[mese+1]+'-'+gg+"";
	
	}

function controlla(id) {
		
				if(document.getElementById('testonews_'+id).disabled==false){
					//alert('ok');
				}
		
		
		} 



var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}








<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


function Invia(oForm){
	if( oForm.user.value=="" || oForm.user.lenght==""  ||	    oForm.pass.lenght==0 || oForm.pass.value==""  )	{
		alert('Attenzione inserire username e password ');
		return;
	}
	else
		oForm.staticLogin.value="staticLogin";
		oForm.submit();
		
}

function Invia_contatti(oForm){
	
	if(oForm.email.value ==''){
		alert('Inserire l\'indirizzo e mail');
		return false;
	}
	
	if(oForm.email.value !=''){
		checkMail(oForm);
		//return false;
	}
	
	if( oForm.messaggio.value=="" ){
		
		alert('Il messaggio è vuoto');
		return false;
		}
		
		else{
			oForm.azione_contatti.value="mail";
			oForm.submit();
		}
	
}


function checkMail(oForm)
{
	var x = oForm.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)); //alert('YES! Correct email address');
	else alert('Attenzione! l\'indirizzo  email inserito non ha un formato valido');
}







var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}


function showLayer(id) {
//alert('ccc')
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function attivaAreaTesto(id){
//alert('msg');
 var obj = getElemRefs(id);
		obj.disabled=false;

}



// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}



// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}


<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

function launchCenteredWin(url, name, width, height, otherfeatures) {
//alert(url);
var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  newwin = window.open(url, name, str + ',' + otherfeatures);
  if(parseInt(navigator.appVersion) >= 4) {
    setTimeout('newwin.focus();',250);
  }
}

