var zIndex = 100;

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

function center(oNode) {
   var oParent = top.document.body;
   oNode.style.left = oParent.offsetWidth/2 - oNode.offsetWidth/2;
	 oNode.style.top = oParent.offsetHeight/2 - oNode.offsetHeight/2;
}

function mouseMoveSub(el, c) {
	temp = el.className.split(" + ");
	CName = temp[0];
	if (el.className.indexOf("clicked") == -1) {
		el.className = CName
		if(c) el.className = CName + " + " + CName + c;
	}
}

function mouseClickSub(el, group, scr){
	temp = el.className.split(" + ")
 	CName=temp[0]
	
	
	for(i=0;i<document.all.tags(el.tagName).length;i++)
		if(document.all.tags(el.tagName)(i).name == el.name && document.all.tags(el.tagName)(i).className.split(" + ")[0] == CName)
			document.all.tags(el.tagName)(i).className = CName;

	if(scr) {
		for(j=0;j<document.all.tags("DIV").length;j++)
			if(document.all.tags("DIV")(j).name == "scr-" + group) {
				if(document.all.tags("DIV")(j).id==el.scr)
					currentDisplay=document.all.tags("DIV")(j).style.display
				document.all.tags("DIV")(j).style.display = "none"
				
			}

		if(document.all.tags("DIV")(scr)) {
			if(!el.bit || (el.bit && currentDisplay=='none'))
				document.all.tags("DIV")(scr).style.display="inline";
			
			CloseDynSelectLists()
		}
	
	} else if (el.url)
		window.location = el.url

	if(el.noclick) return
	
	
	if(el.button && temp[1] && temp[1].indexOf('clicked')>0) {
		el.className = CName;
	}	else
		el.className = CName + " + " + CName + "clicked";
	
}

function showHelp() {
d=document.all.tags("div")
	for(i=0;i<d.length;i++)
		if (d(i).name == "help-show")
			d(i).style.display = d(i).style.display == 'inline' ? 'none' : 'inline'
}

function getDisplayTab(group) {
	spn=document.all.tags("span")
	for(i=0;i<spn.length;i++){
		s =  spn(i).className.split(" + ");
		if(spn(i).name == group && s.length > 1) {
			return spn(i).scr;
		}
	}
}

function BuildDynamicElements() {
	d = document.all
	for(i=0;i<d.length;i++) {
		if(d(i).dynfld) {
			if(d(i).dynfld=='file')
				BuildDynFileField(d(i), 1)
			else if(d(i).dynfld=='date') 
				BuildDynDateField(d(i))
			else if(d(i).dynfld=='select')
				BuildDynSelectList(d(i))

		}
	}
}


function init() {
	var scr;
	t = event.type;
	el = event.srcElement;
	tag = el.tagName;

	if(event.srcElement.name) {
		n=event.srcElement.name.split("-")
		if(n[0] == 'btn') {
			if(n.length>1)
				group = n[1];
			if(el.scr)
				scr = el.scr;
			if(t=='mouseover' && group) {
				mouseMoveSub(el, 'over')
			} else if(t=='mouseout' && group) {
				mouseMoveSub(el)
			} else if(t=='click' && group) {
				mouseClickSub(el, group, scr)
			}


		}

	}
	
}

function checkForm() {
var errorPage=''
var errorList=''
	for (i=0; i<myform.length; i++) {
		if(myform[i].required == 1 && !myform[i].value) {
			errorList += '\n    -  '+myform[i].elementName+' is required'
		} else if(myform[i].numeric == 1 && isNaN(myform[i].value)) {
			errorList += '\n    -  '+myform[i].elementName+' should be a number'
		}
	}
	if(errorList) {
		errorPage =  "--------------------------------------------------------------------------------------------\t \n"	
		//errorPage =  "\n"	
		errorPage += "  FORM VALIDATION ALERT";
		errorPage +=  "\n--------------------------------------------------------------------------------------------\t\n"
		errorPage += errorList
		errorPage +=  "\n\n---------------------------------------------------------------------------------------------\t \n"
	}
	
	if(errorList) {
		alert(errorPage)
		return false;
	}
	
	return true;
	
}	

document.onmouseover = init;
document.onmouseout = init;
document.onclick = init;



