function led(id, src){
		document.getElementById(id).src=src;
}


function openWindow(nome, url, w, h, scorrimento, status, resizable) {
	var win = null;
	var pagina, nome, LeftPosition, TopPosition, settings;
	nome=nome;
	// scorrimento [yes | no]
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h-(screen.width*5/100))/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scorrimento+', resizable=' +resizable+', status=' +status;
	win = window.open(url,nome,settings);
}

	var control_down=false;

	function checkCharCode(evt) {
		var charCode;
		if (navigator.appName == "Netscape")
			charCode = evt.which ;
		else 
			charCode = evt.keyCode;

		
		if (charCode==46) {
			//TASTO CANC PREMUTO: cancella riga	
			if (selected_field_id!=row_id_backup){
				delRow(row_id_backup);
				}
		}
		alert(charCode);
		
		if (charCode==17) {
			//TASTO CONTROL PREMUTO: ASCOLTA CLICK
			control_down=true;
		}
	}
	
	function delRow(row_id){
		child=document.getElementById(row_id);
		for (var i = 0; i < child.childNodes.length; i++) { 
			nextChild = child.childNodes[i]; 
			nextChild.className='hidden';
			nextChild.innerHTML='';
		} 
	}
	
	function initArray() {
		this.length = initArray.arguments.length
		for (var i = 0; i < this.length; i++) this[i+1]="initArray.arguments[i]" 
	} 
	
	var row_id_backup='';
	var selected_row = new Array();
	var selected_row_count=0;	
	function selRow(id, classe, classeNew){
		if (control_down){
				selected_row[selected_row_count]=id;
				selected_row_count++;
			}else{
				selected_row=new initArray(0);
				selected_row[selected_row_count]=id;
				selected_row_count++;
		}
		
		//try{
			if (control_down){

			}else{
				for (i=0; i<selected_row.length; i++){
					if (selected_row[i]!=row_id_backup){
						unSelRowById(selected_row[i], '<? echo $row_class?>');
					}
				}
				//document.getElementById(row_id_backup).className=classe
			}
			
		//}catch(e){}

		document.getElementById(id).className=classeNew;
		selected_field_id=(row_id_backup==id)?selected_field_id:'';
		row_id_backup=id;
	}

	function unSelRowById(id, classe){
		//try{
		alert(id);
			//document.getElementById(id).className=classe;
		//}catch(e){}
	}

	
	function unSelRow(classe){
		try{
			document.getElementById(row_id_backup).className=classe;
		}catch(e){
			row_id_backup='';
		}
	}
	
	var cell_id_backup='';
	function selCell(id, classe, classeNew){
		try{
			if (control_down){

			}else{
				document.getElementById(cell_id_backup).className=classe;
			}
		}catch(e){
		}
		document.getElementById(id).className=classeNew;
		//selected_field_id=(row_id_backup==id)?selected_field_id:'';
		cell_id_backup=id;
	}
	
	function unSelCell(classe){
		try{
			document.getElementById(cell_id_backup).className=classe;
		}catch(e){
			cell_id_backup='';
		}
	}

	
	var field_backup='';
	var selected_field_id='';
	function selectField(field){
		if (field_backup!=field) {
			selected_field_id=row_id_backup;
			field.select();
			field_backup=field;
			}	
	}
	
	function showModalWin(url, w, h, scorrimento, status, resizable) {
		try{
			settings='dialogWidth:'+w+'px;dialogHeight:'+h+'px';
			o=new Object();
			o.opener=self;
			window.showModalDialog(url,o,settings);
		}catch(e){
			var win = null;
			var pagina, nome, LeftPosition, TopPosition, settings;
			nome='window';
			LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-h-(screen.width*5/100))/2 : 0;
			settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+'yes'+', resizable=' +resizable+', status=' +'yes';
			win = window.open(url,nome,settings);
		}
	}

	function getPkValue(container){
		value=document.getElementById(container).childNodes[0].innerHTML;
		return value;
	}	
	
	
	function getMonths(){
		
		var oDate= new Date();
		
		var int = oDate.getMonth();

		return intToMonth(int);
		
	}
	
	function intToMonth(int){
		switch(int){
			case 0:
				return 'Gennaio';
			
			case 1:
				return 'Febbraio';
			
			case 2:
				return 'Marzo';
			
			case 3:
				return 'Aprile';
			
			case 4:
				return 'Maggio';
				
			case 5:
				return 'Giugno';
				
			case 6:
				return 'Luglio';
				
			case 7:
				return 'Agosto';
				
			case 8:
				return 'Settembre';
				
			case 9:
				return 'Ottobre';
				
			case 10:
				return 'Novembre';
				
			case 11:
				return 'Dicembre';

		}
		
		
	}
	
	
function PopupPic(sPicURL) { 
	window.open("popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=2,WIDTH=2");
}

	
	
