//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 openPopImage(imagePath) {
	var modalNew = window.open("/viewPic.aspx?imagePath=" + imagePath,"picture","scrollbars=no,height=350,width=604,resizable=no,status=yes,toolbar=no,menubar=no,location=no")
	modalNew.focus();
}

function openPopFile(imagePath,whidth,height) {
	var modalNew = window.open(imagePath,"picture","scrollbars=no,width=" + whidth + ",height=" + height + "resizable=yes,status=yes,toolbar=no,menubar=no,location=no")
	modalNew.focus();
}