//Creazione delle chiamate per sistema ajax
//var aro = new AjaxRenderObject();



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])
}

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>")
    
}
