/////////////////////////////////////	GLOBAL VARIABLES START	///////////////////////////////////////////////
var imageResourceArrayForImagePlayer= null;
var imageTextArrayForImagePlayer 	= null;
var imagePlayerObject 				= null;

/////////////////////////////////////	GLOBAL VARIABLES END	///////////////////////////////////////////////

/////////////////////////////////////	CUSTOM OBJECTS START	///////////////////////////////////////////////

function ImagePlayerObject(height,width,divIdImageContainer,imageTextId,resourcesArray,textArray,intervalTime){
	var oInstance			= this;
	this.imageElement 		= null;
	this.playerHeight		= 300;
	this.playerWidth		= 300;
	this.imageResourceArray = resourcesArray;
	this.imageTextArray 	= textArray;
	this.counter 			= 0;
	this.interval			= null;
	this.imageTextElement   = document.getElementById(imageTextId); 
	var divElement 			= document.getElementById(divIdImageContainer);
	if(divElement){
		this.imageElement = divElement.getElementsByTagName("img")[0];
	}
	this.playerHeight		= height;
	this.playerWidth		= width;
	
	/*
	alert('imageElement.src:'+imageElement.src);
	alert('imageResourceArray.length:'+resourcesArray.length);
	alert('imageTextArray.length:'+textArray.length);
	*/
	this.play = function(){
		if(this.interval == null){
			this.interval = setInterval(function(){oInstance.changeImage()}, intervalTime);
			 
		}		
	}
	
	this.stop = function(){
		if(this.interval != null)
			clearInterval(oInstance.interval);	
		this.interval = null;
	}
	
	this.first= function(){
		if(this.interval != null)
			clearInterval(oInstance.interval);	
		this.interval = null;	
		this.counter = -1;	
		this.changeImage();
		
	}
	
	this.last= function(){
		if(this.interval != null)
			clearInterval(oInstance.interval);	
		this.interval = null;	
		this.counter = this.imageResourceArray.length - 2 ;	
		this.changeImage();
		
	}
	
	this.changeImage = function (){
		this.counter++;
		//alert('timer');
		if(this.imageElement ){
			if(this.counter < this.imageResourceArray.length){
				this.imageElement.src="/servlets/resources?resourceId="+this.imageResourceArray[this.counter];	
			}else {
				this.counter = 0; 
				this.imageElement.src="/servlets/resources?resourceId="+this.imageResourceArray[this.counter];
			}
			if(this.imageTextArray != null && this.imageTextArray.length ==  this.imageResourceArray.length && this.imageTextElement != null)	
				this.imageTextElement.innerHTML = this.imageTextArray[this.counter];
			try{
				var heightDiff = (this.playerHeight - this.imageElement.height)/2 ;
				this.imageElement.parentNode.style.top = 	heightDiff+"px";
				var widthDiff = (this.playerWidth - this.imageElement.width)/2 ;
				this.imageElement.parentNode.style.left = 	widthDiff+"px";
				this.imageElement.parentNode.parentNode.className= divElement.className;
			}catch(e){}

			

		}	
	}
	
}


function EterbitGoogleMapObject(divIdMapContainer,containerWidth,containerHeight,divDetailID,address,vMarkers,sName,sFeatures,zoom,smallControlEnabled,typeControlEnabled,disableDragging,disableScrollWheelZoom,disableDoubleClickZoom){
	//document.write('<script type="text/javascript\" src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&hl=it"></script>');
	//document.write('<script type="text/javascript\" src="http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js"></script>');
	this.sFeatures 		= sFeatures;
	this.sName	 		= sName;
	this.address		= address; 
	this.markers		= null;
	this.markersIterator= 0;
	this.divElement 	= null;
	this.divElementWidth= null;
	this.divElementHeight= null;
	this.map			= null;
	this.dcenter 		= null;
	this.dzoom 			= null;
	this.smallControlEnabled = true;
	this.typeControlEnabled  = true;
	this.disableDragging 	 = true;
	this.disableScrollWheelZoom = true;
	this.disableDoubleClickZoom= true;
	this.detailElement	= null;
	this.mmgr 			= null;
	var geocoder 		= null;
	var gLatLngTmp 		= null;
	////////	START INIT	/////
	
	this.divElement 		= document.getElementById(divIdMapContainer);
	this.divElementWidth	= containerWidth;
	this.divElementHeight	= containerHeight;
	
	geocoder 		= new GClientGeocoder();
	this.markers	= vMarkers;
	//this.dcenter 	= address;
	this.dzoom 		= zoom;
	this.detailElement	= document.getElementById(divDetailID);
	this.smallControlEnabled = smallControlEnabled;
	this.typeControlEnabled  = typeControlEnabled;
	this.disableDragging 	 = disableDragging;
	this.disableScrollWheelZoom = disableScrollWheelZoom;
	this.disableDoubleClickZoom= disableDoubleClickZoom;
	
	document.body.onunload="GUnload();";
	////////	END INIT	/////
	
	
	
	this.loadMap = function (instanceO){
		geocoder.getLatLng(
		    instanceO.address,
		    function(point) {
		      if (!point) {
			alert(instanceO.address + " not found");
		      } else {
			 	//this.dcenter = point;
				//alert(point.lat());
			 	try{
					instanceO.dcenter 	= point;
			 		try{
			 			instanceO.map 		= new GMap2(instanceO.divElement);
			 		}catch(er){}
			 		instanceO.map.setCenter(point);
			 		instanceO.map.setZoom(instanceO.dzoom);
			 		instanceO.detailElement	= document.getElementById(divDetailID);
					if(instanceO.smallControlEnabled)
			 			instanceO.map.addControl(new GSmallMapControl());
					if(instanceO.typeControlEnabled)
						instanceO.map.addControl(new GMapTypeControl());
					if(instanceO.disableDragging)
						instanceO.map.disableDragging();
					if(instanceO.disableScrollWheelZoom)
						instanceO.map.disableScrollWheelZoom();
					if(instanceO.disableDoubleClickZoom)
						instanceO.map.disableDoubleClickZoom();
					instanceO.mmgr      = new MarkerManager(instanceO.map);
					//GEvent.addListener(instanceO.map, 'tilesloaded', function() {instanceO.loadMarkers(instanceO);});
					window.setTimeout(function(){instanceO.loadMarkers(instanceO);},1000);  
			 	}catch(e){}
				
		      }
		    }
		  );
		instanceO.divElement.style.width	= instanceO.divElementWidth;
		instanceO.divElement.style.height	= instanceO.divElementHeight;
	}
	
	this.loadMarkers = function (instanceO){
			//alert("ciao");
			if(instanceO.markersIterator < instanceO.markers.length){
				var markerInfo = instanceO.markers[instanceO.markersIterator];
				if(markerInfo){
					var text 		= markerInfo.TEXT;
					var url  		= markerInfo.URL;
					var address  	= markerInfo.ADDRESS;
						geocoder.getLatLng(
						    address,
						    function(point) {
						      if (!point) {
							alert(address + " not found");
						      } else {
									var marker = new GMarker(point);
									instanceO.mmgr.addMarker(marker,0,17);
									if(url!=null && url != ""){
										GEvent.addListener(marker, 'click', function() {
										window.open(url,instanceO.sName,instanceO.sFeatures);
											}
											);
									}		
									if(text!=null && text != ""){
										GEvent.addListener(marker, 'mouseover', function() {
										instanceO.detailElement.innerHTML = text;
											}
											);
										
										GEvent.addListener(marker, 'mouseout', function() {
										instanceO.detailElement.innerHTML = '<em>'+""+'</em>';
											}
											);	
									}	 
									instanceO.markersIterator ++;	
									instanceO.loadMarkers(instanceO);
						      }
						    }
						);	    			
					
				}
			}
		
	}
	

	
	
}


/////////////////////////////////////	CUSTOM OBJECTS END	///////////////////////////////////////////////

function setWMode(value){
	var elements = document.getElementsByName('wmode');
	for (i=0;i<elements.length;i++){
		elements[i].value=value;
	}
}

function fnAppendDiv(id,classe){
	var oNewNode = document.createElement("DIV");
	oNewNode.id=id;
	oNewNode.className=classe;
	document.body.appendChild(oNewNode);
}


function loadYUILibraries(){
	if(!isYUILoaded){
		document.write('<link rel="stylesheet" type="text/css" href="wmanager/yui/build/fonts/fonts-min.css" />');
		document.write('<link rel="stylesheet" type="text/css" href="wmanager/yui/build/container/assets/skins/sam/container.css" />');
		document.write('<script type="text/javascript" src="wmanager/yui/build/container/container-min.js" ></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/animation/animation-min.js"></script>');
		document.write('<script type="text/javascript" src="wmanager/yui/build/yahoo/yahoo-min.js" ></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/event/event-min.js"></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/dragdrop/dragdrop-min.js"></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/utilities/utilities.js"></script>');
		document.write('<script type="text/javascript\" src="manager/yui/build/container/container_core-min.js"></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/element/element-beta-min.js"></script>');
		document.write('<script type="text/javascript\" src="wmanager/yui/build/connection/connection-min.js"></script>');
	}
	isYUILoaded = true;
 }
 
 
 function getWindowSize() {
  var myWidth = 0, myHeight = 0, ar = new Array();

  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;
  }
  ar[0]=myWidth;
  ar[1]=myHeight;
  return ar;
}

function printIframeContent(divId)  {  
// var url = document.getElementById(divId).src;
 var a = window.open('','','width=500,height=400');  
 a.document.open("text/html");  
 a.document.write(document.getElementById(divId).contentWindow.document.body.innerHTML);  
 a.document.close();  
 a.print();  
}  
function copyIframeContent(divId){
	try{
	document.getElementById(divId).contentWindow.document.execCommand('SelectAll',false);
	document.getElementById(divId).contentWindow.document.execCommand("Copy", true);
	document.getElementById(divId).contentWindow.document.execCommand("UnSelect", true); 
	}catch(e){}
}


function galleryImagesGoUp(previuosButtonId,nextButtonId,divName,rowsMaxNumber){
	try{
		var divList = document.getElementsByName(divName);
		if((parseInt(divList.length) > parseInt(rowsMaxNumber)) && (divList[divList.length-1].style.display == 'none' )){
			var lastDisplayed = divList.length;
			for (i=divList.length-1;i>=0;i--){
				var element = divList[i];
				if(element.style.display == 'block' || element.style.display == ''){
					lastDisplayed = i;	
					break;
				}
			}
			var firstNotDisplayed = 0;
			for (i=0;i<divList.length;i++){
				var element = divList[i];
				if(element.style.display == 'none' && i > lastDisplayed){
					firstNotDisplayed = i;	
					break;
				}
				
			}
			for (i=0;i<divList.length;i++){
				var element = divList[i];
				element.style.display = 'none';
			}
			var temp = firstNotDisplayed+rowsMaxNumber;
			if(temp > parseInt(divList.length))
				temp = parseInt(divList.length);
			for (i=firstNotDisplayed;i<temp;i++){
				var element = divList[i];
				element.style.display = 'block';
			}
		}
		checkDisplayPreviousNextButton(previuosButtonId,nextButtonId,divName);
	}catch(e){}
}

function galleryImagesGoDown(previuosButtonId,nextButtonId,divName,rowsMaxNumber){
	try{
		var divList = document.getElementsByName(divName);
		if((parseInt(divList.length) > parseInt(rowsMaxNumber)) && (divList[0].style.display == 'none' )){
			var firstNotDisplayed = 0;
			for (i=0;i<divList.length;i++){
				var element = divList[i];
				if(element.style.display != 'none' ){
					firstNotDisplayed = i;	
					break;
				}
				
			}
			for (i=0;i<divList.length;i++){
				var element = divList[i];
				element.style.display = 'none';
			}
			var temp = firstNotDisplayed-rowsMaxNumber;
			for (i=temp;i<firstNotDisplayed;i++){
				var element = divList[i];
				element.style.display = 'block';
			}
		}
		checkDisplayPreviousNextButton(previuosButtonId,nextButtonId,divName);
	}catch(e){}
}

function checkDisplayPreviousNextButton ( previuosButtonId,nextButtonId,divName) {
	try{
		var imgPreviousId 	= document.getElementById(previuosButtonId);
		var imgnextId 		= document.getElementById(nextButtonId);
		var divList 		= document.getElementsByName(divName);
		imgPreviousId.parentNode.style.display='none';
		imgnextId.parentNode.style.display='none';
		if(divList!=null && divList[0]!=null && divList[0].style.display=='none' ){
			imgPreviousId.parentNode.style.display='block';	
		}
		if(divList!=null && divList[divList.length-1] !=null && divList[divList.length-1].style.display=='none' ){
			imgnextId.parentNode.style.display='block';	
		}
	}catch(e){}	
}


function getElementLeft(elm) {
    var x = 0;
    //set x to elms offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elms offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null){
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) {
    var y = 0;
    //set x to elms offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elms offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}

function OpenLargeImageOnMouseOver(obj,bigImagePath,resizeEnabled,height,width){
try{	
        
    var smallImageWidth  = 40;
	var smallImageHeight = 40;
	var smallImageLeft   = 0;
	var smallImageTop    = 0;	
	try{
		var objImgElement = obj.getElementsByTagName("IMG")[0];	
		if(objImgElement!= null){
			//obj = objImgElement	;
			smallImageWidth 	= objImgElement.width;
			smallImageHeight 	= objImgElement.height;
		}else{
			objImgElement = obj;
			smallImageWidth = obj.getElementsByTagName('IMG')[0].width;
			smallImageHeight = obj.getElementsByTagName('IMG')[0].height;
		}
		smallImageLeft = getElementLeft(objImgElement);
		smallImageTop  = getElementTop(objImgElement);
	    }catch(er){}		
	var left	= smallImageLeft+smallImageWidth;
	var top		= smallImageTop+smallImageHeight;    
	if(height == "" || height == "null")
    		height = 250;
    if(width == "" || width == "null")
    	width = 250;
    var imgbox=document.getElementById("imgbox");
	if(!imgbox){
		fnAppend(document.body,"IMG","imgbox","");
		imgbox=document.getElementById("imgbox");
	 }
	var image = new Image();
	image.src = bigImagePath;
	image.onload = function(){
		imgbox.style.visibility='visible';
		imgbox.src=bigImagePath;	
		if(!resizeEnabled){
			width = image.width;
			height = image.height; 	
		}	
		imgbox.style.width=width+'px';
		imgbox.style.height=height+'px';
		if((top + height) > document.documentElement.clientHeight)
			top	= smallImageTop - height;
		if((left + width) > document.documentElement.clientWidth)
			left	= smallImageLeft - width;	
		imgbox.style.left=left +'px';
		imgbox.style.top=top + 'px';	
	};
	imgbox.style.visibility='visible';
	imgbox.src=bigImagePath;	
	if(!resizeEnabled){
		width = image.width;
		height = image.height; 	
	}	
	imgbox.style.width=width+'px';
	imgbox.style.height=height+'px';
	if((top + height) > document.documentElement.clientHeight)
		top	= smallImageTop - height;
	if((left + width) > document.documentElement.clientWidth)
		left	= smallImageLeft - width;	
	imgbox.style.left=left +'px';
	imgbox.style.top=top + 'px';
			 
	if(imgbox.addEventListener){
		obj.addEventListener('mouseout',Out,false);
	 } else {
		obj.attachEvent('onmouseout',Out);
	 }
	
	}catch(e){}
}

function Out(){
    document.getElementById("imgbox").style.visibility='hidden';
}

function fnAppendDiv(id,classe){
	var oNewNode = document.createElement("DIV");
	oNewNode.id=id;
	oNewNode.className=classe;
	document.body.appendChild(oNewNode);
}

function fnAppend(NodeToAppendTo,nodeType,id,name){
	var oNewNode = document.createElement(nodeType);
	oNewNode.name=name;
	oNewNode.id=id; 
	NodeToAppendTo.appendChild(oNewNode);
}   

function changeTextOnMouseOver(obj,elementName,text){

	try{	
	    var element =document.getElementById(elementName);
	    element.innerHTML= text;
	}catch(e){}

} 

function outImage(elementName){
	
	try{	
	    var element =document.getElementById(elementName);
	    element.innerHTML = "";	    
	}catch(e){}
}

function isNumeric(evt){
	evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)){
		return false;
	}
    return true;
}
 


/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Mozilla code.
 *
 * The Initial Developer of the Original Code is
 * Simon Bünzli <zeniko@gmail.com>
 * Portions created by the Initial Developer are Copyright (C) 2006-2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

/**
 * Utilities for JavaScript code to handle JSON content.
 * See http://www.json.org/ for comprehensive information about JSON.
 *
 * Import this module through
 *
 * Components.utils.import("resource://gre/modules/JSON.jsm");
 *
 * Usage:
 *
 * var newJSONString = JSON.toString( GIVEN_JAVASCRIPT_OBJECT );
 * var newJavaScriptObject = JSON.fromString( GIVEN_JSON_STRING );
 *
 * Note: For your own safety, Objects/Arrays returned by
 *       JSON.fromString aren't instanceof Object/Array.
 */

var EXPORTED_SYMBOLS = ["JSON"];

// The following code is a loose adaption of Douglas Crockford's code
// from http://www.json.org/json.js (public domain'd)

// Notable differences:
// * Unserializable values such as |undefined| or functions aren't
//   silently dropped but always lead to a TypeError.
// * An optional key blacklist has been added to JSON.toString

var JSON = {
  /**
   * Converts a JavaScript object into a JSON string.
   *
   * @param aJSObject is the object to be converted
   * @param aKeysToDrop is an optional array of keys which will be
   *                    ignored in all objects during the serialization
   * @return the object's JSON representation
   *
   * Note: aJSObject MUST not contain cyclic references.
   */
  toString: function JSON_toString(aJSObject, aKeysToDrop) {
    // we use a single string builder for efficiency reasons
    var pieces = [];
    
    // this recursive function walks through all objects and appends their
    // JSON representation (in one or several pieces) to the string builder
    function append_piece(aObj) {
      if (typeof aObj == "string") {
        aObj = aObj.replace(/[\\"\x00-\x1F\u0080-\uFFFF]/g, function($0) {
          // use the special escape notation if one exists, otherwise
          // produce a general unicode escape sequence
          switch ($0) {
          case "\b": return "\\b";
          case "\t": return "\\t";
          case "\n": return "\\n";
          case "\f": return "\\f";
          case "\r": return "\\r";
          case '"':  return '\\"';
          case "\\": return "\\\\";
          }
          return "\\u" + ("0000" + $0.charCodeAt(0).toString(16)).slice(-4);
        });
        pieces.push('"' + aObj + '"')
      }
      else if (typeof aObj == "boolean") {
        pieces.push(aObj ? "true" : "false");
      }
      else if (typeof aObj == "number" && isFinite(aObj)) {
        // there is no representation for infinite numbers or for NaN!
        pieces.push(aObj.toString());
      }
      else if (aObj === null) {
        pieces.push("null");
      }
      // if it looks like an array, treat it as such - this is required
      // for all arrays from either outside this module or a sandbox
      else if (aObj instanceof Array ||
               typeof aObj == "object" && "length" in aObj &&
               (aObj.length === 0 || aObj[aObj.length - 1] !== undefined)) {
        pieces.push("[");
        for (var i = 0; i < aObj.length; i++) {
          arguments.callee(aObj[i]);
          pieces.push(",");
        }
        if (aObj.length > 0)
          pieces.pop(); // drop the trailing colon
        pieces.push("]");
      }
      else if (typeof aObj == "object") {
        pieces.push("{");
        for (var key in aObj) {
          // allow callers to pass objects containing private data which
          // they don't want the JSON string to contain (so they don't
          // have to manually pre-process the object)
          if (aKeysToDrop && aKeysToDrop.indexOf(key) != -1)
            continue;
          
          arguments.callee(key.toString());
          pieces.push(":");
          arguments.callee(aObj[key]);
          pieces.push(",");
        }
        if (pieces[pieces.length - 1] == ",")
          pieces.pop(); // drop the trailing colon
        pieces.push("}");
      }
      else {
        throw new TypeError("No JSON representation for this object!");
      }
    }
    append_piece(aJSObject);
    
    return pieces.join("");
  },

  /**
   * Converts a JSON string into a JavaScript object.
   *
   * @param aJSONString is the string to be converted
   * @return a JavaScript object for the given JSON representation
   */
  fromString: function JSON_fromString(aJSONString) {
    if (!this.isMostlyHarmless(aJSONString))
      throw new SyntaxError("No valid JSON string!");
    
    var s = new Components.utils.Sandbox("about:blank");
    return Components.utils.evalInSandbox("(" + aJSONString + ")", s);
  },

  /**
   * Checks whether the given string contains potentially harmful
   * content which might be executed during its evaluation
   * (no parser, thus not 100% safe! Best to use a Sandbox for evaluation)
   *
   * @param aString is the string to be tested
   * @return a boolean
   */
  isMostlyHarmless: function JSON_isMostlyHarmless(aString) {
    const maybeHarmful = /[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/;
    const jsonStrings = /"(\\.|[^"\\\n\r])*"/g;
    
    return !maybeHarmful.test(aString.replace(jsonStrings, ""));
  }
};
  
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
function selectOptionFromValue(cc,valore){
	oo = cc.options
  	for(i=0;i<oo.length;i++){
	    if(oo[i].value==valore)
	      oo[i].selected=true
	}
}
  
  