/////
// common js
d=document;

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function getParameter(paramName){
    paramName = paramName.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regExpStr = "[\\?&]"+paramName+"=([^&#]*)";
    var paramRegExp = new RegExp(regExpStr);
    var results = paramRegExp.exec(window.location.href);
    if (results == null){return("");}
    else{return(results[1]);}
}

function getWindowSize() {
  var w=0, h=0;
  if (typeof(window.innerWidth) == 'number'){//Non-IE
    w = window.innerWidth;
    h = window.innerHeight;
  }
  else if ( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ){//IE 6+ in 'standards compliant mode'
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
  }
  else if ( document.body && (document.body.clientWidth || document.body.clientHeight) ){//IE 4 compatible
    w = document.body.clientWidth;
    h = document.body.clientHeight;
  }
  return({"width":w,"height":h});
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function startScriptTimer(timerid){
if (!timerid){timerid="default";}
window["TimerStarted"+timerid]=new Date();
}

function queryScriptTimer(timerid,minsAndSecs){
if (!timerid){timerid="default";}
if (typeof(window["TimerStarted"+timerid])=="undefined"){return(-1)}
window["TimerEnded"+timerid]=new Date();
var timetaken = ((window["TimerStarted"+timerid]-window["TimerEnded"+timerid])/1000)
	if (minsAndSecs){
	var timeTaken=Math.floor(0-timetaken);
	var mins=Math.floor(timeTaken/60);
	var secs=timeTaken-(mins*60);
	if (secs<10){secs="0"+secs;}
	return([mins,secs])
	}
	else {
		return(0-timetaken)//seconds
	}
}

function toggle(id){
if ($(id).style.display!="none"){$(id).style.display="none"}
else ($(id).style.display="")
}

function show(args){
	for (i=0,j=arguments.length;i<j;i++){
	$(arguments[i]).style.display="inline";
	}
}

function hide(args){
	for (i=0,j=arguments.length;i<j;i++){
	$(arguments[i]).style.display="none";
	}
}

function getRandom(possibleValuesArr){
var random=Math.random();
var outNum=Math.round(random * possibleValuesArr.length) % possibleValuesArr.length;
return(possibleValuesArr[outNum])
}

function radioButtonChecker(formName,radioName){
var radioChoice = false;
var myRadio = document.forms[formName][radioName];
for (var counter = 0; counter < myRadio.length; counter++){
if (myRadio[counter].checked)
radioChoice = counter;
}

return (radioChoice);
}

var allPopups=0;
function popup(popName,popIntro,body,newPop,width,height){

if (!width){width=400;}
if (!height){height=400;}

	if (newPop || (!window["testwin"+popName+allPopups])){
	window["testwin"+popName+allPopups]=window.open("","testwin"+popName+allPopups,"height="+height+",width="+width+",status=no,toolbar=yes,menubar=no,location=no	,resizable=yes,scrollbars=yes")
	window["testwin"+popName+allPopups].document.write("<head><title>"+popName+"</title></head><body><h2>"+popName+" <a href='javascript:window.close()' style='text-decoration:none;'>(x)</a></h2><p><em>"+popIntro+"</em></p>")
	}

	window["testwin"+popName+allPopups].document.write("<p>"+body+"</p>")

}	

var quietMode;
function shout(a){
var shoutVarsText;

if (typeof(shoutVars)=="undefined"){shoutVarsText="";}

else {
shoutVarsText="\n";

	for (var i=0,j=shoutVars.length;i<j;i++){
		shoutVarsText+="\n"+shoutVars[i]+": "+window[shoutVars[i]];
	}
}

if (quietMode!=true){alert(a+shoutVarsText)}

return(shout);
}

function StringBuffer() {
var argc = arguments.length;
var argv = arguments;
this.str = "";
if (argc == 1) this.str = argv[0];
}
function _stringbuffer_append(str) {
this.str += str;
}
function _stringbuffer_toString() { return this.str; }
StringBuffer.prototype = new String();
StringBuffer.prototype.append = _stringbuffer_append;
StringBuffer.prototype.toString = _stringbuffer_toString;



//if (!confirm(THIS_FUNCTION)){return}


