var statusWin, toppos, leftpos;
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = (navigator.product == 'Gecko');
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_regexp = (window.RegExp) ? true : false;
var win = window;
var n = 0;
var abobjects = new Array();
var abDOMtype = '';
if (document.getElementById) { abDOMtype = "std"; }
else if (document.all) { abDOMtype = "ie4"; }
else if (document.layers) { abDOMtype = "ns4"; }

function show_hide_table(theTable,TheImage) {
	var curtable = fetch_object(theTable);
	var curimg = fetch_object(TheImage);
     if (curtable.style.display == 'none') {
          curtable.style.display = 'block';
          curimg.src = '../includes/acp/images/b_up.gif';
     }
     else {
          curtable.style.display = 'none';
          curimg.src = '../includes/acp/images/b_down.gif';
     }
}

function open_close_group(group, doOpen) {
	var curdiv = fetch_object("d_" + group);
	var curbtn = fetch_object("m_" + group);
	if (doOpen) {
		curdiv.style.display = "block";
		curbtn.src = "../includes/acp/images/b_up.gif";
		curbtn.title = "";
	}
	else {
		curdiv.style.display = "none";
		curbtn.src = "../includes/acp/images/b_down.gif";
		curbtn.title = "";
	}
}

function fetch_object(idname, forcefetch) {
	if (forcefetch || typeof(abobjects[idname]) == "undefined") {
		switch (abDOMtype) {
			case "std": {
				abobjects[idname] = document.getElementById(idname);
			}
			break;
			case "ie4":	{
				abobjects[idname] = document.all[idname];
			}
			break;
			case "ns4":	{
				abobjects[idname] = document.layers[idname];
			}
			break;
		}
	}
	return abobjects[idname];
}

// DELETE Confirm ...

function confirm_del(confirm_message) {
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm(confirm_message)) {
		return true;
	}
	else {
		ht[0].style.filter = "";
		return false;
	}
}

// -- Set Hover Text.
function setf(object,text) {
	if(object.value == "") {
    	object.value = text;
        this.focus();
    }
}
// -- Clear Hover Text.
function clearf(object,text) {
	if (object.value == text) {
		object.value = "";
		object.focus();
	}
}

function JS_display(object) {
	if (object == 0) {
	  	   document.all['text'].style.display = "block";
	  	   document.all['attachment'].style.display = "none";
	}
	else  {
  	   document.all['text'].style.display = "none";
  	   document.all['attachment'].style.display = "block";
	}
}

function JS_Open(url,width,height) {
   one_1 = Math.round(100*Math.random());
   win1 = window.open(url,one_1,"statusbar='yes',scrollbars=no,width="+width+",height="+height+",resizable=yes")
   return false;
}

function Chat_Open(urlx) {
   one_1 = Math.round(100*Math.random());
   win1 = window.open(urlx,one_1,"statusbar=no,scrollbars=no,width=300,height=270,resizable=yes")
   return false;
}


function JS_Open2(url,width,height) {
   one_1 = Math.round(100*Math.random());
   win1 = window.open(url,one_1,"statusbar='yes',scrollbars=yes,width="+width+",height="+height+",resizable=yes")
   return false;
}

function JS_Select(action,status) {
	if (action == 'imgform') {
		for (i = 0; i < document.imgform.length; i++) { document.imgform.elements[i].checked = status; }
    }
	if (action == 'dbform') {
		for (i = 0; i < document.dbform.length; i++) { document.dbform.elements[i].checked = status; }
    }
	if (action == 'BKform') {
		for (i = 0; i < document.BKform.length; i++) { document.BKform.elements[i].checked = status; }
    }
	if (action == 'pmform') {
		for (i = 0; i < document.pmform.length; i++) { document.pmform.elements[i].checked = status; }
    }
	if (action == 'usform') {
		for (i = 0; i < document.usform.length; i++) { document.usform.elements[i].checked = status; }
    }
	if (action == 'PMform') {
		for (i = 0; i < document.PMform.length; i++) { document.PMform.elements[i].checked = status; }
    }
	if (action == 'nsform') {
		for (i = 0; i < document.nsform.length; i++) { document.nsform.elements[i].checked = status; }
    }
	if (action == 'Library') {
		for (i = 0; i < document.Library.length; i++) { document.Library.elements[i].checked = status; }
    }

}

function JS_OpenMOD() {
   width = 785
   height = 520
   c = window.open("modcp/index.php","","statusbar='yes',scrollbars=no,width="+width+",height="+height+",resizable=yes")
   c.moveTo(0,0);
   return false;
}

function JS_Online(url,type) {
   c = window.open(url,Math.round(100*Math.random()),"statusbar='yes',scrollbars=no,width=300,height=258,resizable=no")
   c.moveTo(200,200);
   return false;
}