
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
				
	for(var i=0; i<length; i++){
		current = elements[i];
		
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
				
	return returnElements;
}

function checkIfRequiredExists(element) {
	var result = false;
			
	if (element.indexOf(' ') > 0) {
		var tbl = element.split(' ');
		for (var j = 0; j < tbl.length; j++) { if (tbl[j] == 'required') { result = true } }
	
	} else {
		if (element == 'required') { result = true } 
	}
						
	return result;
}

function checkIfNumberExists(element) {
	var result = false;
			
	if (element.indexOf(' ') > 0) {
		var tbl = element.split(' ');
		for (var j = 0; j < tbl.length; j++) { if (tbl[j] == 'integer') { result = true } }
		
	} else {
		if (element == 'integer') { result = true }
	}
						
	return result;
}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
					
	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) { IsNumber = false; }
	}
			
	return IsNumber;
}

function emailCheck(emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
			
	var quotedUser="(\"[^\"]*\")"
			
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
			
	var matchArray=emailStr.match(emailPat)
				
	if (matchArray == null) { return false }
				
	var user=matchArray[1]
	var domain=matchArray[2]
			
	// See if "user" is valid 
	if (user.match(userPat)==null) { return false }
			
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) { 
		for (var i=1;i<=4;i++) { if (IPArray[i]>255) { return false } } 
		return true
	}
				
	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) { return false }
				
	/* Now we need to break up the domain to get a count of how many atoms it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
				
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { return false }
				
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	   return false
	}
				
	return true;
}

function scrollObject(main, width, height, direct, pause, speed) {
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.block = new Array();
  this.blockprev = this.offset = 0;
  this.blockcurr = 1;
  this.mouse = false;
  this.scroll = function() {
    if (!document.getElementById) return false;
    this.main = document.getElementById(this.main);
    while (this.main.firstChild) this.main.removeChild(this.main.firstChild);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    for (var x = 0; x < this.block.length; x++) {
      var table = document.createElement('table');
          table.cellPadding = table.cellSpacing = table.border = "0";
          table.style.position = "absolute";
          table.style.left = table.style.top = "0px";
          table.style.width = this.width + "px";
          table.style.height = this.height + "px";
          table.style.overflow = table.style.visibility = "hidden";
        var tbody = document.createElement('tbody');
          var tr = document.createElement('tr');
            var td = document.createElement('td');
                td.innerHTML = this.block[x];
              tr.appendChild(td);
            tbody.appendChild(tr);
          table.appendChild(tbody);
      this.main.appendChild(this.block[x] = table);
    }
    if (this.block.length > 1) {
      this.main.onmouseover = function() { self.mouse = true; }
      this.main.onmouseout = function() { self.mouse = false; }
      setInterval(function() {
        if (!self.offset && self.scrollLoop()) self.block[self.blockcurr].style.visibility = "visible";
      }, this.pause);
    } this.block[this.blockprev].style.visibility = "visible";
  }
  this.scrollLoop = function() {
    if (!this.offset) {
      if (this.mouse) return false;
      this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
    if (this.direct == "up" || this.direct == "down") {
      this.block[this.blockcurr].style.top = ((this.direct == "up") ? this.offset : -this.offset) + "px";
      this.block[this.blockprev].style.top = ((this.direct == "up") ? this.offset - this.height : this.height - this.offset) + "px";
    } else {
      this.block[this.blockcurr].style.left = ((this.direct == "left") ? this.offset : -this.offset) + "px";
      this.block[this.blockprev].style.left = ((this.direct == "left") ? this.offset - this.width : this.width - this.offset) + "px";
    }
    if (!this.offset) {
      this.block[this.blockprev].style.visibility = "hidden";
      this.blockprev = this.blockcurr;
      if (++this.blockcurr >= this.block.length) this.blockcurr = 0;
    } else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
  }
}
//
// function getElement(aID)
//    {
//        return (document.getElementById) ?
//            document.getElementById(aID) : document.all[aID];
//    }
//
//    function getIFrameDocument(aID){
//        var rv = null; 
//        var frame=getElement(aID);
//        // if contentDocument exists, W3C 
//
//      //compliant (e.g. Mozilla)
//      //alert('here');
//        if (frame.contentDocument)
//            rv = frame.contentDocument;
//        else // bad Internet Explorer  ;)
//            rv = document.frames[aID].document;
//        return rv;
//    }
//
//    function adjustMyFrameHeight()
//    { 
//        var frame = getElement("frame1");
//        var frameDoc = getIFrameDocument("frame1");
//	alert(frameDoc);
//        frame.height = frameDoc.body.offsetHeight;
//	alert(frame.height);
//    }


