

var newwin='';
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 swapImage(object,image) {
	document.getElementById(object).src="images/" + image
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function setTooltip(text) {
	var d=document; var o=d.getElementById('tooltip'); if(!o)return; if(!text)text='&nbsp;';
	o.innerHTML = text;
}


function Popup(url, window_name, window_width, window_height) 
  { 
    settings="toolbar=no,location=no,directories=no,"+ 
             "status=no,menubar=no,scrollbars=yes,"+ 
             "resizable=yes,width="+window_width+",height="+window_height; 
    NewWindow=window.open(url,window_name,settings); 
  }
function showhide_select(state){
     for(var no=0;no<document.forms.length;no++){
          for(var no2=0;no2<document.forms[no].elements.length;no2++){
               if(document.forms[no].elements[no2].tagName=="SELECT"){
                    document.forms[no].elements[no2].style.visibility=state;}}}
}
function setbackground(thisid) {
	document.getElementById(thisid).style.cssText='background:darkblue;color:white'
}
function clearbackground(thisid) {
	document.getElementById(thisid).style.cssText='background:white;color:black'
}
function formatMsgBox(msgbox,formname,textbox,subjectbox){
	var y=document.getElementById(msgbox).innerHTML
	newString = ""
	rExp = /<P>/gi;
	y=y.replace(rExp, newString)
	rExp = /<\/P>/gi;
	newString = "<BR>"
	document.getElementById(textbox).value=y

	if(subjectbox=='admin'){
		if(formname=="editwelcome"||formname=="ticketupdate"){document[formname].submit()}}
	else{	var x=document[formname][subjectbox].value
		if(x==''||y==''){alert('Please fill in the Subject and Body fields');return false}
		else{
			if(formname=="newticket"||formname=="mainticket"||formname=="addfaq"){document[formname].submit()}}}
}


function confirmDelete(field,id,formname){
	if(formname==""){formname="userfields"}
	answer=confirm('Are you sure you want to delete this field')
	if(answer==true){
		if(formname=="userfields"){
			document[formname].action="index.asp?doupdate=1&page=admin_user_staff_fields&title=238&do=delete&field="+field+"&recid="+id}
		else{
			document[formname].action="index.asp?doupdate=1&title=216&page=admin_ticketfields&do=delete&tablename="+formname+"&field="+field+"&recid="+id}
		document[formname].submit()}
}
function deletedomain(recid,msg){
		answer=confirm(msg)
		if(answer!=false){location.href="index.asp?page=admin_domainlist&title=382&doupdate=1&do=deletedomain&id="+recid}
		else{return false}
}
function checkAll(allbox) {
	for (var i = 0; i < document.search["delete"].length; i++) {
	document.search["delete"][i].checked = allbox.checked;}
}
function showhide(id){
	if( document.getElementById("article_"+id).style.display=="block"){
		document.getElementById("article_"+id).style.display="none"
		document.getElementById("kbfolder"+id).src="images/kbfolder_closed.gif"}
		else{
		document.getElementById("article_"+id).style.display="block"
		document.getElementById("kbfolder"+id).src="images/kbfolder.gif"}
}
function FormatText(iebox,command,option){
	document.getElementById(iebox).document.execCommand(command, false,option)
}

function AddImage(iebox){ 
	imagePath = prompt('Enter path to image', 'http://');    
	if ((imagePath != null) && (imagePath != "")){ 
	document.getElementById(iebox).document.execCommand('InsertImage', false, imagePath);}
}
function gotoTickets(sql){
	location.href="index.asp?page=tickets&sql=" + sql
}
function popUpEditContact(URL){
	window.open(URL,'help','scrollbars=1,left=200,top=100,width=490,height=590')
}
function gettab(what){
	for(x=1;x<=6;x++){
		document.getElementById('t' + x).style.backgroundColor='#EBEBEB';
	} 
	document.getElementById('t' + what).style.backgroundColor='#CCCCCC';
}
function openmonitor(uid){
	monitor=window.open("livehelp/LiveMonitor.asp?status=start&uid="+uid,"LM","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=450,height=160");
	monitor.focus();
}
function openwebhelp(){
	monitorq=window.open(theurl,"HELP","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=480,height=314");
	monitorq.focus();
}
function chat(uid, init){
		newWin = window.open(theurl, "chatWin","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=475,height=340");
		newWin.focus();
}
function chatdept(theurl, init){
		newWin = window.open(theurl, "chatWin","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=475,height=340");
		newWin.focus();
}
function showsidemenu(){
	var x=document.getElementById("sidemenu")
	if(x.style.display=="none"){x.style.display="block";document.getElementById("exp2_link").innerHTML="Hide Side Menu"}
	else{x.style.display="none";document.getElementById("exp2_link").innerHTML="Show Side Menu"}
}
function SubmitDelete(recID){
	answer = confirm(document.users.subdelete.value)
	if(answer!=false){document.users.action="index.asp?page=admin_users&doupdate=1&do=delete&id=" + recID;document.users.submit()}
}
function ChangeAccess(recID){
	answer=confirm('Are you sure you want to change the users account status')
	if(answer!=false){document.users.action="index.asp?page=admin_users&doupdate=1&do=changeaccess&id=" + recID;document.users.submit()}
}
function ChangeKBAccess(recID){
	answer=confirm('Are you sure you want to change the articles visibility')
	if(answer!=false){document.kb.action="index.asp?page=admin_faqlist&title=3&db=changeaccess&do=1&id=" + recID;document.kb.submit()}
}
function ChangeKBInternal(recID){
	answer=confirm('Are you sure you want to change the articles privacy')
	if(answer!=false){document.kb.action="index.asp?page=admin_faqlist&title=3&db=changeinternal&do=1&id=" + recID;document.kb.submit()}
}


var xmlhttp
function loadXMLDoc(url){
if (window.XMLHttpRequest)  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)  }
else if (window.ActiveXObject)  {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
    if (xmlhttp){
    xmlhttp.onreadystatechange=state_Change
    xmlhttp.open("GET",url,true)
    xmlhttp.send() }}}