//Creazione delle chiamate per sistema ajax
//var aro = new AjaxRenderObject();



function writetop(lingua) {
 document.write('<object classid="clsid:D27CDB6E-AE6D'
 +'-11cf-96B8-444553540000"  codebase="http://downlo'
 +'ad.macromedia.com/pub/shockwave/cabs/flash/swflash'
 +'.cab#version=6,0,29,0"  width="768"  height="178'
 +'"> <param name="movie" value="/include/flash/top_'
 + lingua + '.swf"> <param name="quality" value="high"> <param'
 +' name="wmode" value="transparent"> <embed src="/i'
 +'nclude/flash/top_' + lingua + '.swf"  quality="high"  pluginspa'
 +'ge="http://www.macromedia.com/go/getflashplayer"  '
 +'type="application/x-shockwave-flash"  width="768'
 +'"  height="178" wmode="transparent" > </embed>'
 +' </object>');
    
}
function writegallery(id,idcanale) {
 document.write('<object classid="clsid:D27CDB6E-AE6D'
 +'-11cf-96B8-444553540000" codebase="http://download'
 +'.macromedia.com/pub/shockwave/cabs/flash/swflash.c'
 +'ab#version=6,0,29,0" width="345" height="260"> <p'
 +'aram name="movie" value="/include/flash/gallery'
 +id+'.swf"> <param name="qualit'
 +'y" value="high"> <param name=FlashVars value="fil'
 +'exml=/images/resources/canali/'+idcanale+''
 +'/gallery/gallery.xml"> <param name="wmode" value='
 +'"transparent"> <embed src="/include/flash/gallery'
 +id+'.swf?filexml=/images/res'
 +'ources/canali/'+idcanale+'/gallery/gallery'
 +'.xml" quality="high" pluginspage="http://www.macro'
 +'media.com/go/getflashplayer" type="application/x-s'
 +'hockwave-flash" width="345" height="260" wmode="tr'
 +'ansparent"> </embed> </object> ');
    
}
function writeapplet(urlimage) {
document.write("<APPLET archive = \"/include/java/ptviewer.jar\" code = \"ptviewer.class\" width = 400 height = 300>")
document.write("<PARAM name = wait value = \"/images/vt/pradelletorri.gif\">")
document.write("<PARAM name = bar_x value = 43>")
document.write("<PARAM name = bar_y value = 246>")
document.write("<PARAM name = bar_width value = 305>")
document.write("<PARAM name = bar_height value = 16>")
document.write("<PARAM name = barcolor value = 0066ff>")
document.write("<PARAM name = quality value = 3>")
document.write("<PARAM name = maxspeed value = 7>")
document.write("<PARAM name = frame value = \"/images/vt/bar2.gif\">")
document.write("<PARAM name = bgcolor value = 000000>")
document.write("<PARAM name = shotspot0 value = \" x362 y278 a378 b298 u'ptviewer:startAutoPan(0,0,1.01)' \">")
document.write("<PARAM name = shotspot1 value = \" x345 y279 a361 b299 u'ptviewer:startAutoPan(0,0,0.99)' \">")
document.write("<PARAM name = shotspot2 value = \" x304 y289 a334 b300 u'ptviewer:startAutoPan(0,-1.0,1.0)' \">")
document.write("<PARAM name = shotspot3 value = \" x303 y277 a333 b288 u'ptviewer:startAutoPan(0,1.0,1.0)' \">")
document.write("<PARAM name = shotspot4 value = \" x278 y277 a295 b298 u'ptviewer:startAutoPan(1.0,0,1.0)' \">")
document.write("<PARAM name = shotspot5 value = \" x259 y278 a276 b299 u'ptviewer:startAutoPan(-1.0,0,1.0)' \">")
document.write("<PARAM name = file value = \"ptviewer:0\">")
document.write("<PARAM name = pano0 value = ")
document.write("	\"{file=/images/resources/canali/"+urlimage+"}")
document.write("	{panmin=-180}")
document.write("	{panmax=180}")
document.write("	{pan=179}")
document.write("	{tiltmin=-90}")
document.write("	{tiltmax=90}")
document.write("	{tilt=0}")
document.write("	{fovmin=12}")
document.write("	{fovmax=165}")
document.write("	{fov=72}\">")
document.write("	</Applet>")
    
}

function writeappletOLD(urlimage) {
 document.write("<APPLET archive = '/include/java/ptv"
 +"iewer.jar' code = 'ptviewer.class' width = 400 hei"
 +"ght = 300> <PARAM name = wait value = '/images/vt"
 +"/pradelletorri.gif'> <PARAM name = bar_x value = " 
 +"43> <PARAM name = bar_y value = 246> <PARAM name"
 +" = bar_width value = 305> <PARAM name = bar_heigh"
 +"t value = 16> <PARAM name = barcolor value = 0066"
 +"ff> <PARAM name = quality value = 3> <PARAM name"
 +" = maxspeed value = 7> <PARAM name = frame value "
 +"= '/images/vt/bar2.gif'> <PARAM name = bgcolor va"
 +"lue = 000000> <PARAM name = shotspot0 value = ' x"
 +"362 y278 a378 b298 u'ptviewer:startAutoPan(0,0,1.0"
 +"1)' '> <PARAM name = shotspot1 value = ' x345 y27"
 +"9 a361 b299 u\'ptviewer:startAutoPan(0,0,0.99)\' '> "
 +"<PARAM name = shotspot2 value = ' x304 y289 a334 "
 +"b300 u'ptviewer:startAutoPan(0,-1.0,1.0)' '> <PAR"
 +"AM name = shotspot3 value = ' x303 y277 a333 b288 "
 +"u'ptviewer:startAutoPan(0,1.0,1.0)' '> <PARAM nam"
 +"e = shotspot4 value = ' x278 y277 a295 b298 u'ptvi"
 +"ewer:startAutoPan(1.0,0,1.0)' '> <PARAM name = sh"
 +"otspot5 value = ' x259 y278 a276 b299 u'ptviewer:s"
 +"tartAutoPan(-1.0,0,1.0)' '> <PARAM name = file va"
 +"lue = 'ptviewer:0'> <PARAM name = pano0 value =  "
 +"'{file=/images/resources/canali/" + urlimage + "} {"
 +"panmin=-180} {panmax=180} {pan=179} {tiltmin=-9"
 +"0} {tiltmax=90} {tilt=0} {fovmin=12} {fovmax=1"
 +"65} {fov=72}'> </Applet>");
    
}

function printpr1() { 
var OLECMDID = 7; /* OLECMDID values: 
* 6 - print 
* 7 - print preview 
* 1 - open window 
* 4 - Save As */ 

var PROMPT = 1; // 2 DONTPROMPTUSER 
var WebBrowser= '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 

document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(OLECMDID, PROMPT);
 WebBrowser1.outerHTML = ""; } 

 function printpr(){ 
if (navigator.appName == "Microsoft Internet Explorer") { 
     var PrintCommand = '<OBJECT ID="PrintCommandObject" WIDTH=0 HEIGHT=0 ';
PrintCommand += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
     document.body.insertAdjacentHTML('beforeEnd', PrintCommand); 
     PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = ""; } 
else { window.print();} }


var jsel = {
  // config for first option text e.g '-' or 'Please Select'
  blankOption: '-',
  // Removes the children of the target element
  removeChildren: function(elm) {
     while(elm.hasChildNodes()){
        elm.removeChild(elm.firstChild);
     }
  },
  // Creates select options
  createOpt: function(strVal,strText,objTargetSelect) {
    var opt = document.createElement('OPTION');
    opt.setAttribute('value',strVal);
    var text = document.createTextNode(strText);
    opt.appendChild(text);
    objTargetSelect.appendChild(opt);
  },
  // Loads in the data to the select based on the previous selection
  loadData: function(objData, objTargetSelect) {
	jsel.removeChildren(objTargetSelect);
    // se voglio inserire una selezione vuota
	//jsel.createOpt('',jsel.blankOption,objTargetSelect);
    for(prop in objData) {
        jsel.createOpt(prop,objData[prop],objTargetSelect);
    }

  }
}  

function retrievePeriod(){
	var divcontainer = arguments[3]
	var objSelect = arguments[1]
	AjaxRequest.get(
	  {
		'url':'retrievePeriod.aspx'
		,'parameters':{ 'startday':arguments[0], 'unita':arguments[2] }
		,'onSuccess':function(req){
//				alert('Success!'); 
				divcontainer.style.display = ""
//				alert('Data!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			    //popolaziione del select
				//var objSelData = eval(req.responseText);
				var objSelData = eval('(' + req.responseText + ')');
				jsel.loadData(objSelData, objSelect);
			}
		,'onError':function(req){
				divcontainer.style.display = "none"
				alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			}
		,'onLoading':function(req){
				divcontainer.style.display = "none"
			}

	  }
	);	
//alert(arguments[0] + ' ' + arguments[1] + ' ' + arguments[2])
}
