function toggleCheckbox(cbid,fk){
	var cb=document.getElementById(cbid);
	cb.value=fk;
	}
	
function checkUncheckAll(theElement) {
   var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
}

function disableEnableAll(theElement) {
   var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'all'){
	  theForm[z].disabled = theElement.checked;
	  }
     }
}

function launchHelp(app,sarg){
	help=window.open("/"+app+"/help.html?topic="+sarg,"Help","width=700,height=400,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no")
	help.focus();
}

function launchMDID(sarg){
	mdid=window.open('multidid.html?'+sarg,'MDid','width=320,height=400,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no')
	if (!mdid.opener)
         mdid.opener = self; 
	mdid.focus();
}

function launchFRP(sarg){
	frp=window.open('frp.html?'+sarg,'FRP','width=320,height=400,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no')
	if (!frp.opener)
        frp.opener = self; 
	frp.focus();
}

function launchPWRecovery(appm,sarg){
	pwrecover=window.open('/'+ appm +'/recover.html?'+sarg,'pwrecover','width=420,height=250,resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no,statusbar=no')
	if (!pwrecover.opener)
         pwrecover.opener = self; 
	pwrecover.focus();
}


function launchVirtual(sarg){
	virt=window.open('/ent/addvirtual.html?'+sarg,'Virtual','width=320,height=400,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no')
	virt.focus();
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function submitToPage(frm, x)
{
	frm.action.value = x;
	frm.submit();
}


function MsgOkCancel()
    {
      var fRet;
      fRet = confirm('Are you sure?');
      alert(fRet);
    }

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

// shrink element until it disappears
function shrinkElement(id){
	
	var millisec = 500;
	var timer = 0;
	var speed = Math.round(millisec / 100);
	
  var theheight = document.getElementById(id).offsetHeight;
	
	for (var i = theheight; i >= 0; i--) {
		   
		setTimeout("changeElementHeight(" + i + ",'" + id + "')",(timer * speed));
   	timer++;
  
  }
	
}

function changeElementHeight(eh,id){
	
	var div = document.getElementById(id);
  div.style.height = eh + "px";
	
}

function clickIVRAlways(tf){
	if (tf.always.checked==true) {
		tf.start.disabled=true; 
		tf.stop.disabled=true;
		tf.monday.disabled=true;
		tf.tuesday.disabled=true;
		tf.wednesday.disabled=true;
		tf.thursday.disabled=true;
		tf.friday.disabled=true;
		tf.saturday.disabled=true;
		tf.sunday.disabled=true;
		tf.holidayrules.disabled=true;
	} else  {
		tf.start.disabled=false; 
		tf.stop.disabled=false; 
		tf.monday.disabled=false;
		tf.tuesday.disabled=false;
		tf.wednesday.disabled=false;
		tf.thursday.disabled=false;
		tf.friday.disabled=false;
		tf.saturday.disabled=false;
		tf.sunday.disabled=false;
		tf.holidayrules.disabled=false;
	}
}

function updateContent(ucon,uurl){
	 
	 var xmlHttp=null; 
	 
	 try {
	    // Firefox, Opera 8.0+, Safari, IE7+
	    xmlHttp = new XMLHttpRequest();
	 } catch (e) {
	    // Internet Explorer
	    try {
	       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	 }
	 
	 xmlHttp.onreadystatechange = function() {
	    if (xmlHttp.readyState == 4)
	       try { 
	             
	          if (xmlHttp.status == 200) {
	
	             document.getElementById(ucon).innerHTML 
	                = xmlHttp.responseText;
	          }
	       } catch (e) {
	          document.getElementById(ucon).innerHTML 
	             = "error on return call : " + e.description;
	       }
	 
	 }
	 xmlHttp.open("get",uurl);
	 xmlHttp.send(null);
 
}

function readVM(fld,amsg){
	
	location.href='/panel/playvm.html?&msg=' + amsg;
	setTimeout("updateContent('updatespace','/panel/vmtable.html?folder=" + fld + "')",1000);
	
}

