<!--
/*
 * 
 *
 */

// Only submit if we have a valid key.
//
// This is used by Hunt Groups, Groups, Call Queues
// when adding a new member to them
//
function SelectSubmit(i,f) {
//alert('Are you sure you want to use SelectSubmit line 10 site.js');
// you might want to use SubmitAsSave
//	if (i.value > 0) {
		document.mainform.submit();
//	}
   return true;
}

function pressSaveButton() {

	document.mainform.saveButton.click();
	return true;
}


function pressAbort_subButtons() {
	document.mainform.Abort_subButtons.click();
	return true;
}


function SubmitAsSave() {

//	if (i.value > 0) {
		document.mainform.submitaction.value = 'save';
		document.mainform.submit();
//	}
   return true;
}

function SubmitAsSaveInboundRoutes(action,rec) {

		document.mainform.inboundAction.value = action;
		document.mainform.inboundPre.value = rec;
		document.mainform.submitaction.value = 'save';
		document.mainform.submit();
   return true;
}

// Take a varaible number of argument and set out Next Menu Item.
//
function setMenu() {


	// Loop through all of the arguments and append them
	// to the return value separated by colons.
	var menu='';
	var sep='';
	for (var i = 0; i < arguments.length; i++) {
		menu += sep;
		menu += arguments[i];
		sep = ':';
	} 

	document.mainform.gMenuNext.value = menu;
	
	document.mainform.submit();
	return true;
}

// Set the logout field, to fake a button
//
function press_logout() {

	document.mainform.logoutButtons.value = 'Logout';
	document.mainform.submit();
	
}


// Take a varaible number of argument and set out Next Menu Item.
//
function setHidden(f,v) {

	document.mainform.id.value = v;
	
	document.mainform.submit();
	return true;
}

/**
 * When tab is clicked set its tab number so PHP knows where to go.
 */
function setTab(tabno) {

	document.mainform.gTab.value = tabno;
	
	document.mainform.submit();
	return true;
}

/**
 * When tab is clicked set its tab number so PHP knows where to go.
 */
function setListOrderBy(colNo) {

	document.mainform.listOrderBy.value = colNo;

	document.mainform.submit();
	return true;
}




// Hide and show DIVS
function toggle(objId, togId, stateId, delId) {

	//visibility: visible;
	  var o = MM_findObj(objId); 
	  var t = MM_findObj(togId);
	  var s = MM_findObj(stateId);

	  var isDel = false;
	  if (delId != 'no') {
      	var d = MM_findObj(delId);
	    if (d != null && d.value == '1') {
	       isDel = true;
	  	}
	  }
	  if (isDel == false) {
		  if (o.style.display == 'none') {
		    o.style.display = 'block';
		    t.innerHTML = '-';
		    s.value='-';
		  } else {
		    o.style.display = 'none';
		    t.innerHTML = '+';
		    s.value='+';
		  }
	  }
}


// MM Stuff

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************


// Hide and show DIVS
function toggleFields(objId, togId, stateId, delId, minusImage, plusImage) {

	//visibility: visible;
	  var o = MM_findObj(objId); 
	  var t = MM_findObj(togId);
	  var s = MM_findObj(stateId);

	  var isDel = false;
	  if (delId != 'no') {
      	var d = MM_findObj(delId);
	    if (d != null && d.value == '1') {
	       isDel = true;
	  	}
	  }
	  if (isDel == false) {
		  if (o.style.display == 'none') {
		    o.style.display = 'block';
		    t.src = minusImage;
		    s.value='-';
		  } else {
		    o.style.display = 'none';
		    t.src = plusImage;
		    s.value='+';
		  }
	  }
}



//-->