function ClickCounter( n ) {
	this.c = n;
	
	this.Tick = function() {
		this.c ++;
	}

	this.getTicks = function() {
		return this.c;
	}

	this.getMTicks = function() {
		return -this.c;
	}
}

//-----------------------------------------------------------------------------------------------------
function alarm( n ) {
	this.n = n;
	this.fired = false;
	
	this.fire = function() {
		this.fired = true;
	}
	
	this.wasFired = function() {
		return this.fired;
	}
}

//-----------------------------------------------------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0  
	window.open(theURL,winName,features);
  return false;
}
//-----------------------------------------------------------------------------------------------------


function large_sample(fn,w,h) {
	if ( w>0 && h>0 )
		MM_openBrWindow('popup.php?fn='+fn,'','scrollbars=no,width='+w+',height='+h+',top=0,screenY=0,left=0,screenX=0');
}	

//-----------------------------------------------------------------------------------------------------
function validate_email(strng, m1, m2, m3) {
	var error="";
	if (strng == "") {
		if ( m1 != '' )
	   		alert( m1 );
	   return false;
	}

    var emailFilter=/^.+@.+\....{2,3,4,5}$/;
    if (!(emailFilter.test(strng))) { 
		if ( m2 != '' )
    		alert( m2 );
		return false;
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\'\[\]]/
         if (strng.match(illegalChars)) {
			if ( m3 != '' )
		    	alert( m3 );
			return false;
       }
    }
return true;    
}
//-----------------------------------------------------------------------------------------------------

function getElementByName(element_name,element_tag) 
{
	var l = document.getElementsByTagName(element_tag);
	for ( var i = 0; i < l.length; i ++ )
		if ( l.item(i).name==element_name )
			return l.item(i);
	return undefined;
}

//-----------------------------------------------------------------------------------------------------

function getElementById(element_id) 
{
	if (document.getElementById) {
		return document.getElementById(element_id);
	}
	else if (document.all) {
		return document.all[element_id];
	}
	else if (document.layers) {
		return document.layers[element_id];
	} else {
		return undefined;
	}
}
//-----------------------------------------------------------------------------------------------------
function leftTrim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	return sString;
}
//-----------------------------------------------------------------------------------------------------
function rightTrim(sString) {
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//-----------------------------------------------------------------------------------------------------
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//-----------------------------------------------------------------------------------------------------
function abContainer(n) {
	this.cname = n;
	this.items = new Array();
	this.selectedItem = 0;
	
	this.addItem = function( itemId ) {
		var i = this.items.length;
		this.items[i] = itemId; 		
	}
}

//-----------------------------------------------------------------------------------------------------
function errorMessage( c, t ) {
	this.em_code = c;
	this.em_text = t;
}
//-----------------------------------------------------------------------------------------------------
function errorMessages() {
	this.e_messages = new Array();
	
	this.addErrorMessage = function( c, t ) {
		this.e_messages[this.e_messages.length] = new errorMessage( c, t );
	}
	
	this.findErrorMessage = function( c ) {
		em = '';
		for ( var i = 0; i < this.e_messages.length; i ++ ) {
			if ( this.e_messages[i].em_code == c ) {
				return this.e_messages[i].em_text;
			}
		}
		return '';
	}
}				
