
function Closeup(img)
{
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}

function Controlla(img)
{
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function viewFoto(img)
{
  
  w=foto1.width+20;
  h=foto1.height+20;
  
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;

  string="width="+w+",height="+h+",top="+wint+",left="+winl;
  
  finestra=window.open(img,"",string);
}
function RadioJump(pickup)
{
	window.location.href = pickup;
}
// Printing
function Printing(id){ 
	if(window.print()){
	var d=eval(id)==null||eval(id+".closed");
	if(!d){eval(id+".print()");}}
}

myPopup = '';

function PopupReturnWindow(file_id,w,h,scl,menu,stat,tool,full,locate,resize,tbar)
{

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var PopUp = 'POPUP';
  
  settings = 'height='+h+',';
  settings += 'width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+scl+',';
  settings +='menubar='+menu+',';
  settings +='statusbar='+stat+',';
  settings +='toolbar='+tool+',';
  settings +='fullscreen='+full+',';
  settings +='titlebar='+tbar+',';
  settings +='locationbar='+locate+',';
  settings +='resizable='+resize;
  
  myPopup = window.open(file_id,PopUp,settings);
    if (!myPopup.opener)
         myPopup.opener = self; 
}
function PopupWindow(file_id,w,h,scl,menu,tool,resize,tbar)
{

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var PopUp = 'POPUP';
  
  settings = 'height='+h+',';
  settings += 'width='+w+',';
  settings +='top='+wint+',';
  settings +='left='+winl+',';
  settings +='scrollbars='+scl+',';
  settings +='menubar='+menu+',';
  settings +='toolbar='+tool+',';
  settings +='titlebar='+tbar+',';
  settings +='resizable='+resize;
  
  myPopup = window.open(file_id,PopUp,settings);
    if (!myPopup.opener)
         myPopup.opener = self; 
}

function jPopupSelect(file_id,w,h)
{
	var sb = 'Yes';
	var mb = 'No';
	var rs = 'Yes';

	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	
	settings = 'height='+h+',';
	settings += 'width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars='+sb+',';
	settings +='menubar='+mb+',';
	settings +='resizable='+rs;
	
	myPopup = window.open(file_id,"",settings);
	if (!myPopup.opener)
		 myPopup.opener = self; 
}

function confirm_delete(url)
{
	var message = 'Are you sure you want to delete this item'; 
	if(confirm(message)) location.href = url;
}

function jJumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function populate_selectmenu(current,optionid,data,values)
{	
	var dataarray = data.split(',');
	var valuearray = values.split(',');
	var element = document.getElementById(optionid);
	dataarray[current.selectedIndex] = dataarray[current.selectedIndex].split('|');
	valuearray[current.selectedIndex] = valuearray[current.selectedIndex].split('|');
	for (count = 0; count < element.options.length;count++) element.remove(count);
	element.options[0] = new Option("","",false,false);
	for (count = 0; count < dataarray[current.selectedIndex].length;count++) element.options[count+1] = new Option(dataarray[current.selectedIndex][count],valuearray[current.selectedIndex][count],false,false);
}

// function loadContent added by Mathew Carter on Friday, 4th August 2006
function loadContent(file)
{
  var head = document.getElementsByTagName('head').item(0)
  var scriptTag = document.getElementById('loadScript');
  if(scriptTag) head.removeChild(scriptTag);
  script = document.createElement('script');
  script.src = file;
	script.type = 'text/javascript';
	script.id = 'loadScript';
	head.appendChild(script)
}
function changeImage(filename)
{
	document.mainimage.src = filename;
}
function checkAll(box)
{
	var i = 0, el, f = box.form, bWhich = box.checked;
	while (el = f.elements[i++])
		if (box != el && /^remove/.test(el.name))
			el.checked = bWhich;
}

/* 
	disable a form (eg. on submit)
	sets all inputs to readonly and submits to disabled
*/
function disableForm (form)
{
	var f = document.getElementById(form);
	for (var i=0; i<f.length; i++)
	{
		if (f.elements[i].type == "input")
		{
			f.elements[i].readOnly = true;
			f.elements[i].style.backgroundColor = "#cccccc";
		}
		if (f.elements[i].type == "submit")
		{
			f.elements[i].disabled = true;
		}
	}
}