//v1.02 - General js functions for every program
var funcs = {
	winsopen : 0,
	rwinhandle : null,
	msgbox : function(strmsg, strtitle, bokbutton, bhidewin, mwidth, mheight){
	//Creates a messagebox: bokbutton = if ok button is shown or not, bhidewin= (bool) remove window after 9 seconds
		if (strmsg==null) return;
		if (strtitle==null) strtitle="Message";
		if (bokbutton==null) bokbutton=true;
		if (bhidewin==null) hidebutton=false;
		//if msgbox already exists, append new message to it
		if (tmpobj=document.getElementById("divmsgboxtext")){
			if (tmpobj){
				var ts=new Date().getTime();
				if (tmpobj.getAttribute("ts")&&((ts-tmpobj.getAttribute("ts"))>5000)) tmpobj.innerHTML=strmsg;
				else tmpobj.innerHTML+="<br>"+strmsg;
				return;
			}
		}
		this.tmsgbox=document.createElement("div");
		this.tmsgbox.id="divmsgbox";
		var ts=new Date().getTime();
		strmsg="<table style='border-collapse:collapse;width:100%;' cellspacing='0' cellpadding='0'><tr><td class='tdmsgboxtitle' id='tdmsgboxtitle' onmousedown=\"ezdrag.start(event, document.getElementById('divmsgbox'));\">"+strtitle+"</td><td class='tdmsgboxx' onclick='funcs.removemsg();'>X</td></tr><tr><td colspan='2'><div id='divmsgboxtext' ts='"+ts+"'>"+strmsg+"</div>";
		//ie8 fix on button to center
		if (bokbutton) strmsg+=" <br><br><div style='text-align:center;'> <table style='margin:auto;'><tr><td><input type='button' value='OK' onclick='funcs.removemsg();'></td><tr></table> </div>";
		strmsg+="</td></tr></table>";
		this.tmsgbox.innerHTML=strmsg;
		
		//added with jquery
		//this.tmsgbox.style.display='none';
		
		document.body.appendChild(this.tmsgbox);
		//added with jquery
		//$("#divmsgbox").fadeIn(300);
		this.winsopen++;
		//this marginTop part has to be separated from original prototype to work right
		this.tempbox=document.getElementById("divmsgbox");
		if (mwidth==null)mwidth=500;
		this.tempbox.style.width=mwidth+"px";
		document.getElementById("tdmsgboxtitle").style.width=(mwidth-20)+"px";
		
		if (mheight!=null){
			this.tempbox.style.height=mheight+"px";
		}	
		//this.tempbox.style.left="250px";
		//this.tempbox.style.top=(10+document.body.scrollTop)+"px";
		scrtop=0;
		scrleft=0;
		if (document.body.scrollTop>0||document.body.scrollLeft>0){
			scrtop=document.body.scrollTop;
			scrleft=document.body.scrollLeft;
		}else if(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0){
			scrtop=document.documentElement.scrollTop;
			scrleft=document.documentElement.scrollLeft;
		}
		mleft=this.getClientWidth()/2-Math.ceil(mwidth/2);
		this.tempbox.style.left=(mleft+scrleft)+"px";
		if (this.getClientHeight()/2-Math.ceil(this.tempbox.offsetHeight/2)+scrtop<0) mtop=0;
		else mtop=this.getClientHeight()/2-Math.ceil(this.tempbox.offsetHeight/2)+scrtop;
		this.tempbox.style.top=mtop+"px";
		
		this.showbg();
		
		if (bhidewin) setTimeout("funcs.removemsg();", 9000);
	},
	removemsg : function(){
		if (tmpobj=document.getElementById("divmsgbox")){
			if (tmpobj){
				tmpobj.parentNode.removeChild(tmpobj);
				this.winsopen--;
				this.hidebg();
			}
		}
	},
	statusbox : function (strcontent){
		if (tmpobj=document.getElementById('sb_main')){
			if (tmpobj){return;}
		}
		var proto = document.createElement("div");
		proto.id='sb_main';
		proto.style.position='absolute';
		var mytop=0;
		var myleft=0;
		scrtop=0;
		scrleft=0;
		if (document.body.scrollTop>0||document.body.scrollLeft>0){
			scrtop=document.body.scrollTop;
			scrleft=document.body.scrollLeft;
		}else if(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0){
			scrtop=document.documentElement.scrollTop;
			scrleft=document.documentElement.scrollLeft;
		}
		proto.style.top=(mytop+scrtop)+'px';
		proto.style.left=(myleft+scrleft)+'px';
		proto.style.width='200px';
		proto.style.height='35px';
		proto.style.background='#FFF';
		proto.style.border="1px solid #BBB";
		proto.style.zIndex=100;
		proto.style.verticalAlign="middle";
		proto.className='printhide';
		proto.style.display='none';
		proto.innerHTML="<table><tr><td><img src='images/loader.gif'></td><td style='font:bold 9pt arial;'> &nbsp; "+strcontent+"</td></tr></table>";
		document.body.appendChild(proto);
		$("#sb_main").slideDown(200);
		setTimeout("funcs.statusboxhide();",1200);
	},
	statusboxhide:function(){
		$("#sb_main").slideUp(200, function(){funcs.statusboxremove();});
	},
	statusboxremove:function(){
		if (tmpobj=document.getElementById("sb_main")){
			if (tmpobj) tmpobj.parentNode.removeChild(tmpobj);
		}
	},
	createwin : function (strid, strcontent, strtitle, mzindex, mtop, mleft, topcolor, mwidth, topbar){
		if (tmpobj=document.getElementById(strid+"txt")){
			if (tmpobj){
				tmpobj.innerHTML=strcontent;
				return;
			}
		}
		if (topcolor==null) topcolor="#232588";
		if (mwidth==null) mwidth=500;
		if (mzindex==null)mzindex=10;
		if (mtop==null) mtop=0;
		if (mleft==null) mleft=0;
		if (topbar==null)topbar=true;
		tmpwin=document.createElement('div');
		tmpwin.id=strid;
		tmpwin.style.zIndex=mzindex;
		tmpwin.style.width=mwidth+"px";
		tmpwin.style.overflowX='hidden';
		//that is so the window doesn't look messed up in most browsers if too much width is put inside of it
		tmpwin.style.position="absolute";
		scrtop=0;
		scrleft=0;
		if (document.body.scrollTop>0||document.body.scrollLeft>0){
			scrtop=document.body.scrollTop;
			scrleft=document.body.scrollLeft;
		}else if(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0){
			scrtop=document.documentElement.scrollTop;
			scrleft=document.documentElement.scrollLeft;
		}
		if (mleft<=0) mleft=document.body.offsetWidth/2-Math.ceil(mwidth/2)+mleft;
		tmpwin.style.left=(mleft+scrleft)+"px";
		tmpwin.style.top=(mtop+scrtop)+"px";
		tmpwin.style.border='2px solid #333';
		if (topbar) tmpwin.innerHTML="<table style='border-collapse:collapse;width:100%;' cellspacing='0' cellpadding='0'><tr><td style='background-color:"+topcolor+";width:"+(mwidth-20)+"px;font:bold 9pt arial;cursor:move;border-bottom:1px solid #333;border-right:1px solid #333;height:20px;color:#EEE;' onmousedown=\"ezdrag.start(event, document.getElementById('"+strid+"'));\"> &nbsp; "+strtitle+"</td><td style='width:20px;text-align:center;font:bold 9pt arial;cursor:pointer;background:#BBB;border-bottom:1px solid #333;' onclick=\"funcs.removewin('"+strid+"');\">X</td></tr></table>";
		tmpwin.innerHTML+="<div id='"+strid+"txt' style='background:#FFF;'>"+strcontent+"</div>";
		//added with jquery
		//tmpwin.style.display='none';
		this.winsopen++;
		document.body.appendChild(tmpwin);
		//added with jquery
		//$("#"+strid).fadeIn(200);
		
		if (mtop<=0){
			if (this.getClientHeight()/2-Math.ceil(tmpwin.offsetHeight/2)+scrtop+mtop<0) mtop=0;
			else mtop=this.getClientHeight()/2-Math.ceil(tmpwin.offsetHeight/2)+scrtop+mtop;
			tmpwin.style.top=mtop+"px";
		}
		
		this.showbg();
	},
	printElement:function(node, styles){
		var content=node.innerHTML;
		var strbody='<html><head>';
		if (styles){
			for(i=0;i<styles.length;i++){
				strbody+="<link href='style/"+styles[i]+"' rel='stylesheet' type='text/css' media='all'>";
			}
		}
		strbody+='</head><body><div style="width:'+node.offsetWidth+'px;">'+content+'</div></body></html>';
		var pwin=window.open('','print_content','width=100,height=100');
		if (!(pwin)) alert("Allow pop ups (for this site or page) to print this");
		pwin.document.open();
		pwin.document.write(strbody);
		pwin.print();
		pwin.document.close();
	},
	refreshwin:function(){
		window.location=window.location;
	},
	removewin : function(strid){	
		if (tmpobj=document.getElementById(strid)){
			if (tmpobj){
				//$("#"+strid).fadeOut(300, function(){funcs.fnremovewin(strid);});
				tmpobj.parentNode.removeChild(tmpobj);
				this.winsopen--;
				this.hidebg();
			}
		}
		//***just for scu***
		if (strid=="invItemWin") document.onkeydown=null;
	},
	fnremovewin:function(strid){
		if (tmpobj=document.getElementById(strid)){
			if (tmpobj){
				tmpobj.parentNode.removeChild(tmpobj);
			}
		}
	},
	debugmsg : function(strin){
		if (tmpobj=document.getElementById("debugwintxt")){
			if (tmpobj){
				tmpobj.innerHTML=strin;
				return;
			}
		}
		this.tmsgbox=document.createElement("div");
		this.tmsgbox.id="debugwin";
		this.tmsgbox.innerHTML="<table style='border-collapse:collapse;width:100%;' cellspacing='0' cellpadding='0'><tr><td class='tdmsgboxtitle' onmousedown=\"ezdrag.start(event, document.getElementById('debugwin'));\">Debug Window</td><td class='tdmsgboxx' onclick='funcs.closedebug();'>X</td></tr><tr><td colspan='2'><div id='debugwintxt' style='width:500px;height:200px;overflow-y:auto;'>"+strin+"</div></td></tr></table>";
		document.body.appendChild(this.tmsgbox);
	},
	closedebug: function(){
		if (tmpobj=document.getElementById("debugwin")){
			if (tmpobj) tmpobj.parentNode.removeChild(tmpobj);
		}
	},
	showbg : function(){
		if (tmpobj=document.getElementById("transparentbg")){
			if (tmpobj) return;
		}
		this.bg=document.createElement("div");
		this.bg.id="transparentbg";
		//this.bg.style.display='none';
		document.body.appendChild(this.bg);
		funcs.resizebg();
		//$('#transparentbg').fadeTo(300,.6);
	},
	hidebg : function(){
		if (this.winsopen>0) return;
		if (tmpobj=document.getElementById("transparentbg")){
			if (tmpobj){
				//$("#transparentbg").fadeOut(300, function(){funcs.fnhidebg()});
				tmpobj.parentNode.removeChild(tmpobj);
			}
		}
	},
	fnhidebg : function(){
		if (this.winsopen>0) return;
		if (tmpobj=document.getElementById("transparentbg")){
			if (tmpobj){
				tmpobj.parentNode.removeChild(tmpobj);
			}
		}
	},
	resizebg : function(){
		theight=0;
		if (tmpobj=document.getElementById("transparentbg")){
			if (funcs.isIE()){
				theight=document.documentElement.scrollHeight;
				if (tmpobj) tmpobj.style.height=theight+"px";
			}else if(document.body.scrollHeight>0){
				theight=document.body.scrollHeight;
				if (tmpobj) tmpobj.style.height=theight+"px";
			}
		}
	},
	showele : function (idstr, posx, posy){
		if(tmpwin=document.getElementById(idstr)){
			if (tmpwin.style.display!="block"){
				tmpwin.style.display="block";
				coords=this.winSize();
				addtop=0;
				if (document.documentElement.scrollTop>0)addtop=document.documentElement.scrollTop;
				topval=coords.y/2-(parseInt(tmpwin.offsetHeight)/2)+addtop;
				if (posy=='top') topval=20+addtop;
				if (topval<0) topval=0;
				if (idstr=="itemwin") topval=10;
				tmpwin.style.top=topval+"px";
				if (posx=='left') tmpwin.style.left = "20px";
				else tmpwin.style.left=(coords.x/2-(parseInt(tmpwin.offsetWidth)/2))+"px";
				this.winsopen++;
				this.showbg();
			}
		}
	},
	hideele : function (idstr){
		if (tmpwin=document.getElementById(idstr)){
      tmpwin.style.display="none";
			this.winsopen--;
			if (this.winsopen<1) this.hidebg();
    }
	},
	winSize : function(){
    var myWidth = 0, myHeight = 0;
    var coord = Array("x", "y");
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    coord.x = myWidth;
    coord.y = myHeight;
    return coord;
  },
	mygebn : function(strname, objtype){
		var tmparray=new Array();
		if (tmplist=document.getElementsByTagName(objtype)){
			for(i=0;i<tmplist.length;i++){
				if (strname==tmplist[i].getAttribute("name")) tmparray.push(tmplist[i]);
			}
		}
		return tmparray;
	},
	findoffset : function(element){
		var tempvar = new Object();
		tempvar.x = parseInt(element.offsetLeft);
		tempvar.y = parseInt(element.offsetTop);
		if (element.tagName != "BODY") tempvar.y -= parseInt(element.scrollTop);
		if (element.tagName != "BODY") tempvar.x -= parseInt(element.scrollLeft);
		var parent = element.offsetParent;
		while (parent) {
			tempvar.x += parseInt(parent.offsetLeft);
			tempvar.y += parseInt(parent.offsetTop);
			//these correct a scrolling inner window offset
			if (parent.tagName != "BODY") tempvar.y -= parseInt(parent.scrollTop);
			if (parent.tagName != "BODY") tempvar.x -= parseInt(parent.scrollLeft);
			parent = parent.offsetParent;
		}
		return tempvar;
	},
	getClientWidth:function() {
		return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
	},
	 
	getClientHeight:function() {
		return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	},
	getIEVersion : function(){
		// Returns the version of Internet Explorer or a -1
		// (indicating the use of another browser).
		var rv = -1; // Return value assumes failure.
		if (navigator.appName == 'Microsoft Internet Explorer'){
			var ua = navigator.userAgent;
			var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
			if (re.exec(ua) != null)
				rv = parseFloat( RegExp.$1 );
		}
		return rv;
	},
	isIE : function(){
		return (navigator.appName=="Microsoft Internet Explorer");
	},
	isNumorDot : function(evt){
		var charCode = (evt.which) ? evt.which : event.keyCode;
		if ((charCode > 47 && charCode < 58)||charCode==46)
			return true;
		return false;
	},
	isNumeric:function(input){
		return !isNaN(parseFloat(input)) && isFinite(input);
	},
	clearselection:function(){
		//this is used when dragging elements to clear selected text
		if (document.selection) document.selection.empty();
		else if (window.getSelection) window.getSelection().removeAllRanges();
	},
	addCommas : function(nStr){
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	},
	dump : function(arr,level) {
		var dumped_text = "";
		if(!level) level = 0;

		//The padding given at the beginning of the line.
		var level_padding = "";
		for(var j=0;j<level+1;j++) level_padding += "    ";

		if(typeof(arr) == 'object'){ //Array/Hashes/Objects
			for(var item in arr){
				var value = arr[item];
				if(typeof(value) == 'object'){ //If it is an array,
					dumped_text += level_padding + "'" + item + "' ...\n";
					dumped_text += funcs.dump(value,level+1);
				}else{
					dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				}
			}
		}else{ //Stings/Chars/Numbers etc.
			dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
		}
		return dumped_text;
	},
	checkddr : function(){
		bgood=true;
		for (i=0;i<arguments.length;i++){
			if (tmpobj=document.getElementById(arguments[i])){
				if (tmpobj.options[tmpobj.selectedIndex].value==""){
					bgood=false;
					tmpobj.style.backgroundColor="#FF6565";
				}else tmpobj.style.backgroundColor="";
			}else bgood=false;
		}
		return bgood;
	},
	checktxtr : function(){
		//checks txt boxes with id equal to any args for values
		bgood=true;
		for(i=0;i<arguments.length;i++){
			if (tmpobj=document.getElementById(arguments[i])){
				if (tmpobj.value==""){
					bgood=false;
					tmpobj.style.backgroundColor="#FF6565";
				}else tmpobj.style.backgroundColor="";
			}else{
				bgood=false;
			}
		}
		return bgood;
	},
	checktxt : function(){
		//checks txt boxes with id equal to any args for values
		bgood=true;
		for(i=0;i<arguments.length;i++){
			if (tmpobj=document.getElementById(arguments[i])){
				if (tmpobj.value==""){
					bgood=false;
				}
			}else bgood=false;
		}
		return bgood;
	},
	addPStr: function(strkey, strid){
		//creates post formatted str, retrieves value from txtbox with strid id
		if (tmpobj=document.getElementById(strid)){
			if ((tmpobj)&&(tmpobj.value))return "&"+strkey+"="+escape(tmpobj.value);
		}
		return "";
	},
	printContent:function(contentid){
		//opens a new window and prints the content of the passed ID
		var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
		sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";
		if (tmpobj=document.getElementById(contentid)){
			var sWinHTML = document.getElementById(contentid).innerHTML; 
			var winprint=window.open("","",sOption); 
			winprint.document.open(); 
			winprint.document.write("<html><head><link rel='stylesheet' type='text/css' href='style/default.css'><link rel='stylesheet' type='text/css' href='style/inv.css'></head><body>"); 
			winprint.document.write(sWinHTML);          
			winprint.document.write("</body><script type='text/javascript'>window.print();</script></html>"); 
			winprint.document.close(); 
			winprint.focus(); 
		}else alert("Couldn't find an element with ID: "+contentid);
	},
	getCheckedValue: function(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	},
	getquerystring:function(form) {
		var qstr = "";
		function GetElemValue(name, value) {
			//qstr += (qstr.length > 0 ? "&" : "")
			qstr += "&"
				+ escape(name).replace(/\+/g, "%2B") + "="
				+ escape(value ? value : "").replace(/\+/g, "%2B");
				//+ escape(value ? value : "").replace(/\n/g, "%0D");
		}
		var elemArray = form.elements;
		for (var i = 0; i < elemArray.length; i++) {
			var element = elemArray[i];
			var elemType = element.type.toUpperCase();
			var elemName = element.name;
			if (elemName) {
				if (elemType == "TEXT"
						|| elemType == "TEXTAREA"
						|| elemType == "PASSWORD"
						|| elemType == "BUTTON"
						|| elemType == "RESET"
						|| elemType == "SUBMIT"
						|| elemType == "FILE"
						|| elemType == "IMAGE"
						|| elemType == "HIDDEN")
					GetElemValue(elemName, element.value);
				else if (elemType == "CHECKBOX" && element.checked)
					GetElemValue(elemName, 
						element.value ? element.value : "On");
				else if (elemType == "RADIO" && element.checked)
					GetElemValue(elemName, element.value);
				else if (elemType.indexOf("SELECT") != -1)
					for (var j = 0; j < element.options.length; j++) {
						var option = element.options[j];
						if (option.selected)
							GetElemValue(elemName,
								option.value ? option.value : option.text);
					}
			}
		}
		return qstr;
	},
	getUrlVars:function(){
		var vars = [], hash;
		if (window.location.href.indexOf('?')==-1) return vars;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 
    for(var i = 0; i < hashes.length; i++){
			hash = hashes[i].split('=');
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	autoformatdate: function(objin,event,enterfunc){
		//forces a date format on a textbox: dd/mm/yyyy, executes enterfunc on enter keypress
		var k;
		document.all ? k =event.keyCode : k = event.which;
		if (enterfunc!=null&&enterfunc!=""){
			if (k==13){
				if(typeof(calendar.remove)=="function") calendar.remove();
				if(typeof(eval(enterfunc))=="function") eval(enterfunc);
			}
		}
		if(!(k>=48&&k<=57||k==8||k==37||k==39)){event.returnValue=false;return false;}
		if (objin.value.length==2&&k!=8) objin.value=objin.value.substr(0,2)+"/";
		else if (objin.value.length==5&&k!=8) objin.value=objin.value.substr(0,5)+"/";
		else if (objin.value.length>9&&k!=8&&k!=0) {event.returnValue=false;return false;}
	},
	openrwin:function(strpath, strid, strsettings){
		//opens a real window
		var isChrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
		var rndnum=Math.floor(Math.random()*500);
		if (strsettings.length>0)	funcs.rwinhandle = window.open(strpath, strid, strsettings);
		else alert("No settings sent to funcs.openrwin() (js)");
		if (funcs.rwinhandle){
			if (isChrome){
				funcs.rwinhandle.blur();
				setTimeout("funcs.rwinhandle.focus();", 0);
			}else funcs.rwinhandle.focus();
		}else{
			alert("Turn off popup blocker");
		}
	},
	txtFillSel:function(txtboxid, fillstr, ichar, bSelEnd){
		if (ichar==null) ichar=0;
		if (bSelEnd==null) bSelEnd=true;
		if (mytxt=document.getElementById(txtboxid)){
			if (mytxt){
				if (mytxt.value.length==ichar){
					mytxt.value=fillstr;
					this.setCursorPosition(mytxt, ichar, bSelEnd);
				}
			}
		}
	},
	setCursorPosition:function(el, iCaretPos, bSelEnd){
		if (typeof(bSelEnd)=="undefined")bSelEnd=false;
		if (document.selection){
			//IE
			var range
			range = document.selection.createRange();
			if (el.type == 'text'){
				if (bSelEnd){
					range.moveStart('character',-el.value.length+iCaretPos);
					range.moveEnd('character', 0);
					range.select();
				}else{
					range.moveStart ('character', -el.value.length);
					range.moveEnd ('character', -el.value.length);
					range.moveStart ('character', iCaretPos);
					range.select();
				}
			}else{
				range.collapse(false);
				range.move("character",iCaretPos-el.value.length+el.value.split("\n").length -1);
				range.select();
			}
		}else if (el.selectionStart || el.selectionStart == '0'){
			//FF
			if (bSelEnd){
				el.setSelectionRange(iCaretPos,el.value.length);
			}else{
				el.setSelectionRange(iCaretPos, iCaretPos);
			}
		} 
	},
	miniwin:function(strid, strcontent, mwidth, mheight, attachobjid){
		coords=this.findoffset(document.getElementById(attachobjid));
		tmpobj=document.createElement("div");
		tmpobj.style.position="absolute";
		tmpobj.style.zIndex=15;
		tmpobj.style.background="#FFF";
		tmpobj.style.width=mwidth+"px";
		tmpobj.style.height=mheight+"px";
		tmpobj.style.top=coords.y+"px";
		tmpobj.style.left=coords.x+"px";
		tmpobj.style.overflowY="auto";
		tmpobj.style.border="2px solid #AAA";
		tmpobj.innerHTML=strcontent;
		tmpobj.id=strid;
		document.body.appendChild(tmpobj);
	},
	removeminiwin:function(strid){
		if (tmpobj=document.getElementById(strid)){
			if (tmpobj){
				tmpobj.parentNode.removeChild(tmpobj);
			}
		}
	},
	cancelbubble:function(event){
		if (!(event)) event=window.event;
		event.cancelBubble=true;
		if (event.stopPropagation)event.stopPropagation();
	},
	php_urlencode:function(str) {
		str = escape(str);
		return str.replace(/[*+\/@]|%20/g, 
		function (s) {
			switch (s) {
				case "*": s = "%2A"; break;
				case "+": s = "%2B"; break;
				case "/": s = "%2F"; break;
				case "@": s = "%40"; break;
				case "%20": s = "+"; break;
			}
			return s;
		});
	},
	setTabs:function(strid){
		$(function(){$("#"+strid).tabs();});
	}
};

var ezdrag = {
	objx : 0,
	objy : 0,
	mousex : 0,
	mousey : 0,
	obj : null,
	start : function (event, objin){
		if (!(event)) event=window.event;
		ezdrag.obj=objin;
		document.onmousemove=ezdrag.move;
		document.onmouseup=ezdrag.stop;
		coords = ezdrag.findoffset(objin);
		ezdrag.objx=coords.x;
		ezdrag.objy=coords.y;
		ezdrag.mousex=event.clientX;
		ezdrag.mousey=event.clientY;
	},
	move : function (event){
		if (!(event)) event=window.event;
		movedx=event.clientX-ezdrag.mousex;
		movedy=event.clientY-ezdrag.mousey;
		topmove=ezdrag.objy+movedy+document.documentElement.scrollTop;
		if (topmove<0)topmove=0;
		ezdrag.obj.style.left=(ezdrag.objx+movedx+document.documentElement.scrollLeft)+"px";
		ezdrag.obj.style.top=(topmove)+"px";
		if (window.getSelection) window.getSelection().removeAllRanges();
		else if (document.selection) document.selection.empty();
	},
	stop : function (){
		document.onmousemove=null;
		document.onmouseup=null;
		ezdrag.obj=null;
		if (window.getSelection) window.getSelection().removeAllRanges();
		else if (document.selection) document.selection.empty();
	},
	findoffset : function(element){
		var tempvar = new Object();
		tempvar.x = parseInt(element.offsetLeft);
		tempvar.y = parseInt(element.offsetTop);
		if (element.tagName != "BODY") tempvar.y -= parseInt(element.scrollTop);
		if (element.tagName != "BODY") tempvar.x -= parseInt(element.scrollLeft);
		var parent = element.offsetParent;
		while (parent) {
			tempvar.x += parseInt(parent.offsetLeft);
			tempvar.y += parseInt(parent.offsetTop);
			if (parent.tagName != "BODY") tempvar.y -= parseInt(parent.scrollTop);
			if (parent.tagName != "BODY") tempvar.x -= parseInt(parent.scrollLeft);
			parent = parent.offsetParent;
		}
		return tempvar;
	}
};

