function change_currencies(e, imot) {				
	document.getElementById(imot).innerHTML=e.value;
}

function openPrintWindow() {
    childWin = window.open("/print.html","","height=600,width=650,dependent=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,toolbar=yes");
}

function go() {
	box = document.forms['list_obj'].sort_order;
	destination = box.options[box.selectedIndex].value;
	//if (destination) location.href = destination+'_'+document.forms['list_obj'].sort_asc.value+'/';
	if (destination) location.href = destination+'_'+document.forms['list_obj'].sort_asc.value+'/';
}

function searchGo() {
	var forms;
	box = document.forms['form'].sorts;
	document.forms['form'].sort_order.value=box.options[box.selectedIndex].value;
	//destination = box.options[box.selectedIndex].value;
	//if (destination) location.href = destination+'_'+document.forms['list_obj'].sort_asc.value+'/';
	form.submit();
}

function searchLong() {
	var forms;
	document.forms['search'].changetown.value='yes';
	//destination = box.options[box.selectedIndex].value;
	//if (destination) location.href = destination+'_'+document.forms['list_obj'].sort_asc.value+'/';
	//search.submit();
	document.search.submit();
}

var foto1;
function CaricaFoto(img) {
	foto1 = new Image();
	foto1.src = (img);
	Controlla(img);
}

function Controlla(img) {
	if ( (foto1.width != 0) && (foto1.height != 0) ) {
		viewFoto(img);
//		alert(foto1.width +"::"+ foto1.height)
	}
	else{
		funzione = "Controlla('" + img + "')";
		intervallo = setTimeout(funzione, 500);
	}
}

function viewFoto(img) {
	largh = foto1.width+20;
	altez = foto1.height+30;
	stringa = "width=" + largh + ",height=" + altez + ",status=0";
//	alert (stringa);
	finestra=window.open(img, "photo_wnd", stringa);
	if (finestra != null)
	{
		finestra.focus();
	}
	else
	{
		alert('Pop up blocker activated!\nTo view large image, please use \'ctl\' + click.');
	}	
		
	return false;
}

// mark unmark
var marked_row = new Array;

function markAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {
        checkbox = rows[i].getElementsByTagName( 'input' )[0];
        if ( checkbox && checkbox.type == 'checkbox' ) {
        	if (checkbox.disabled == false ) {
        		unique_id = checkbox.name + checkbox.value;
                if (checkbox.checked==false) {
                	checkbox.checked=true;
					if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
						rows[i].className += ' marked';
						marked_row[unique_id] = true;
					}
                }
                else {
                	checkbox.checked=false;
					rows[i].className = rows[i].className.replace(' marked', '');
					marked_row[unique_id] = false;
                }
            }
	    }
	}

	return true;
}