DTR = {};

//handles open window
DTR.newWin = function (url,x,y,name)
{
   if((name||"")=="")
  {
   //unique window id
   var curdate=new Date();
   name="popup"+curdate.gettime();
  }

  var winTop = 50;
  var winLeft = 50;
  var proprietes = "dependent=yes"
  proprietes+=", top="+winTop;
  proprietes+=", left="+winLeft;
  proprietes+=", width="+x;
  proprietes+=", height="+y;
  proprietes+=",toolbar=no,location=no,menubar=no,status=no,resizable=yes,scrollbars=yes";

  var newwindow =  window.open(url,name,proprietes);
  if(window.focus) {newwindow.focus()}
}

//handle confirmation
DTR.confirm = function()
{
	return confirm("Are you sure you want to delete?");
}

//handle confirmation for job
DTR.jobconfirm = function(txt)
{
	return confirm(txt);
}

// toggle on checkbox

DTR.Togglecheckbox = function()
{
	var aCollection = document.getElementsByTagName('input');
			
	for(var i = 0; i < aCollection.length; i++)
	{
		if(aCollection[i].className == 'dtrcheckbox')
		{
			if (!aCollection[i].checked) {
				aCollection[i].checked = 1;
			} else {
				aCollection[i].checked = 0;
			}
		}
	
	}


}


// Checkall on checkbox
DTR.checkAll = function (form)
{
        var controlIndex;
        var element;
        var numberOfControls = form.length;
        for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
        {
            element = form[controlIndex];
            if (element.type == "checkbox")
               element.checked = true;
         }

}

// Clearall on checkbox
DTR.clearAll = function (form)
{
        var controlIndex;
        var element;
        var numberOfControls = form.length;
        for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
        {
            element = form[controlIndex];
            if (element.type == "checkbox")
               element.checked = false;
         }

}

DTR.CountCheckedBox = function (form)
{
   var CheckedBoxFlag=0;
   var controlIndex;
   var element;
   var numberOfControls = form.length;
   for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++)
   {
      element = form[controlIndex];
      if (element.type == "checkbox")
      {
         if (element.checked == true)
         {
            CheckedBoxFlag = CheckedBoxFlag + 1;
         }
      }
   }
   form.checkednum.value = CheckedBoxFlag;
   return CheckedBoxFlag;
}

//handles dropdown
DTR.dropdown = {};
DTR.dropdown.hideSub = function() {
	var iColl = document.getElementsByTagName("div");
	for (var i =0;i<iColl.length;i++) {
	
		if(iColl[i].className == "dtrnone") {
			iColl[i].style.display = "none";
		}
	}

}

DTR.dropdown.showSub = function(sel){
	DTR.dropdown.hideSub();
	var f = document.getElementById('dtrselectform');
	switch(sel.value)
		{
			case 'allclients':
				f.action = 'allclients.php';
				document.getElementById('dtrsubselect-allclients').style.display = "inline";
			break;
			case 'groupcommand':
				f.action = 'groupcmd.php';
				document.getElementById('dtrsubselect-groupcommand').style.display = "inline";
			break;
			case 'clientmanager':
				f.action = 'cmanager.php';
				document.getElementById('dtrsubselect-clientmanager').style.display = "inline";
			break;
			case 'ostype':
				f.action = 'ostype.php';
				document.getElementById('dtrsubselect-ostype').style.display = "inline";
			break;
			case 'single':
				f.action = 'single.php';
				document.getElementById('dtrsubselect-single').style.display = "inline";
			break;
			default:
			break;
	}
}


DTR.stretchWidth = function(){


	function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
	function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}
}

