//alert("start commonV1_2.js")
//Error(title,msg)
//getHTML_functionViewerPad()
//Obj()	
//getObjectProperties(msg,obj,winname)
//popup(filename,width,height)
function Status(obj,iMaxTextAreaLength) {
	var s=""
	s+=obj.title + "." 
	if (obj.type != "textarea") {
		if ((typeof(obj.maxLength))!="undefined") s+=" Characters allowed: " + obj.maxLength + ". Current length: " + obj.value.length + "."
	} else {
			if ((typeof(iMaxTextAreaLength))!="undefined") {
				var iCurrentLength = obj.value.length
				if (!(iCurrentLength<=iMaxTextAreaLength)) {
					var temp = obj.value.substring(0, (iMaxTextAreaLength))
					obj.value = temp
				}
				s+=" Characters allowed: " + iMaxTextAreaLength + ". Current length: " + obj.value.length + "."
			} else {
				s+=" Characters allowed: unlimited! Current length: " + obj.value.length + "."
			}
	}
	status = s
}
function isNumber(mynum) {
	x = mynum
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if ((anum.test(x))) {
		return true
	} else {
		return false
	}
}
function trimStr(s) {
	var temps = s
	if (temps.length == 0) return ""
	if (temps.indexOf(' ')==-1) return temps
	while (temps.indexOf(' ')==0) {
		if (temps.length == 1) return ""
		var temps2 = temps.substring(1, temps.length)
		temps = temps2
	}

	if (temps.length == 0) return ""
	if (temps.lastIndexOf(' ')==-1) return temps
	while (temps.lastIndexOf(' ')==(temps.length-1)) {
		if (temps.length == 1) return ""
		var temps2 = temps.substring(0,temps.length-1)
		temps = temps2
	}
	var t1,t2,
		myregCR=/\r/g,
		myregNL=/\n/g;
	t1 = temps.replace(myregCR,"")
	t2 = t1.replace(myregNL,"") 
	return t2
}

function Error(title,msg) {
	alert('Error: ' + title + '\n\n' + msg)
	return false
}

function _open_popup(){
	var s="" 
	if (this.bStatus==true) s+= "status" 
	if (this.bMenubar==true) {if (s!="") s+=",";s+="menubar"} 
	if (this.bLocation==true) {if (s!="") s+=",";s+="location"} 
	if (this.bResizable==true) {if (s!="") s+=",";s+="resizable"}
	if (this.bToolbar==true) {if (s!="") s+=",";s+="toolbar"}
	if (this.bScrollbars==true) {if (s!="") s+=",";s+="scrollbars"}
	if (this.iWidth!=-1) {if (s!="") s+=",";s+="width="+this.iWidth}
	if (this.iHeight!=-1) {if (s!="") s+=",";s+="height="+this.iHeight}
	this.objWin = window.open(this.sFileName, this.sWindowName, s); 
	this.objWin.focus()
}
function _close_popup() {
	this.objWin.Close()
}
function winPopup() {
	this.sFileName = ""
	this.bLocation = true
	this.bMenubar = true
	this.bScrollbars = true
	this.bStatus = true
	this.bToolbar = true
	this.bResizable = true
	
	this.sFilename = ""
	this.sWindowName = "popupwindow"
	this.iWidth = -1
	this.iHeight = -1
	this.iScreenX = -1
	this.iScreenY = -1
	this.objWin = -1
}
winPopup.prototype.Open = _open_popup
winPopup.prototype.Close = _close_popup

function popup(filename,width,height,s) {
	if (filename!="") {
		var myformwin = window.open(filename,'information', ("'status,resizable,toolbar=yes,scrollbars,width=" + width + ",height="+ height + "'")); 
	} else {
		var myformwin = window.open('','information', ("'status,resizable,toolbar=yes,scrollbars,width=" + width + ",height="+ height + "'")); 
		myformwin.document.write(s)
	}
	
	myformwin.focus() 
}

function getObjectProperties(msg,obj,winname) {
	 var s="MSG = <b>" + msg + "</b><br><br><br>"
	 for (prop in obj) {
	 	if (prop!="Resizable") { //required ie5 - iframe obj - bug???
			if ((prop!="outerHTML") && (prop!="innerHTML")) {
			s+= prop + " = " + obj[prop] + "<br>"
			}
		}
	}
	var win = window.open('',winname)
	win.document.open()
	win.document.write(s)
	win.document.close()
	win.focus()
}

function getHTML_functionViewerPad() {
	var s = "", f = "", w;
	s+="<html><head><title>Function Viewer</title>\n"
	s+="</head><body>\n"
	s+="<table border=0 cellspacing=0 cellpadding=0>\n"
	s+="<tr><td><b>Function Pad Viewer</b></td></tr>\n"
	s+="<tr><td>view source of this html document and scroll to see function.</td></tr>\n"
	s+="<tr class='text9'><td><br>[ <b><a href=# onclick='window.close()'>close</a></b>] </td></tr>\n"
	s+="</table>\n"

	if (typeof(document.all) !="undefined") s+="<script language=javascript><!--\n"
	s+="\n"
	for (var i=0;i<arguments.length;i++) {
		if (f != "") f+="\n\n\n"
		f+="/*\n"
		f+= arguments[i] + ""
		f+="\n*/\n"
	} 

	s+=f
	s+="\n"	 
	if (typeof(document.all) !="undefined") s+="--></script>\n" 
	if ((browser.version > 4) && (browser.Name="Netscape")) {
		s+="sorry, doesnt work in N6<br>"
	}
	s+="</body>"
	s+="</html>"
	w = window.open('','funcViewer','width=200,height=140,menubar=yes')
	w.document.open()
	w.document.write(s)
	w.document.close()

	w.focus()
}

function Obj() { //v2
	if (document.layers) {//name: comma separated for Netscape4: topdiv,innerdiv1,innerdiv2,...
		var s = ""
		for (var i=0;i<arguments.length;i++) { if (s != "") s += "."; s += "document['" + arguments[i] + "']";}
		this.obj = eval(s)
		this.style = this.obj
		if (typeof(this.obj) != "object") alert('function Obj: problem with this object, check it exists='+arguments)
	} else if (typeof(document.getElementById) != "undefined") { //NS6, I5
		var name=arguments[arguments.length-1]
		if (typeof(name)=="object") {
			this.obj=name
		} else {
			this.obj = document.getElementById(name)
		}
		if (typeof(this.obj) != "object") alert('function Obj: problem with this object, check it exists='+name)
		this.style = this.obj.style
	} else {//IE4
		var name=arguments[arguments.length-1]
		this.obj = document.all[name]
		if (typeof(this.obj) != "object") alert('function Obj: problem with this object, check it exists='+name)
		this.style = document.all[name].style
	} 
	this.Visible = false
	this.Content = new Function('do_nothing','if (document.layers) {return ("//not avaiable for netscape, see div " + this.obj.name)} else {return ("see div " + this.obj.id + "\\n\\n\\n" + this.obj.innerHTML)}')
	this.Form = new Function('name','if (document.layers) {return this.obj.document.forms[name]} else {return document.forms[name]}')
	this.Forms = new Function('name','if (document.layers) {return this.obj.document.forms} else {return document.forms}')
	this.X = parseInt(this.style.left); this.Y = parseInt(this.style.top);
	this.Hide = new Function('do_nothing','this.style.visibility = "hidden";this.Visible = false')
	this.Show = new Function('do_nothing','this.style.visibility = "visible";this.Visible = true')
	this.Print = new Function('s','if (document.layers) {this.obj.document.open();this.obj.document.write(s);this.obj.document.close()} else {this.obj.innerHTML = s};return')
	this.MoveTo = new Function('X,Y','this.style.left = X;this.style.top = Y;this.X=X;this.Y=Y')
	this.SetBGColor = new Function('color','this.style.background=color') //ie5,ns6
}