function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

function $() 
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) 
	{
		var element = arguments[i];
		if (typeof element == 'string')
		{
			elementT = document.getElementById(element);
			if(elementT&&arguments.length==1) return elementT;
			else if(elementT) elements.push(element);
			else if(!elementT)
			{
				elementArr = getElementsByClassName(element);
				if(elementArr.length&&arguments.length==1) return elementArr;
				else if(elementArr.length) elements.splice(0,0,elementArr);
			}
		}
	}
	if(!elements.length) return null;
	return elements;
}

function swapClear(obj, defVal)
{
	if(obj.value==defVal) obj.value = "";
	else if(obj.value=="") obj.value = defVal;
}

function swapClearPWD(obj, defVal)
{
	if(obj.value==defVal)
	{
		var nObj = document.createElement("input");
		nObj.name = obj.name;
		nObj.id = "password_focus";
		nObj.className = obj.className;
		nObj.style.width = obj.style.width;
		if(obj.size) nObj.size=obj.size;

		nObj.type = "password";
		nObj.value="";
		obj.parentNode.replaceChild(nObj,obj);

		nObj.focus();
		nObj.onfocus = function(){swapClearPWD(nObj,'Password');}
		nObj.onblur = function(){swapClearPWDBlur(nObj,'Password');}
		setTimeout('$("password_focus").focus();',100);
	}

}

function swapClearPWDBlur(obj, defVal)
{
	if(obj.value=="")
	{ 
		var nObj = document.createElement("input");
		nObj.name = obj.name;
		nObj.id = obj.id;
		nObj.className = obj.className;
		nObj.style.width = obj.style.width;

		nObj.type = "text";
		nObj.value=defVal;
		obj.parentNode.replaceChild(nObj,obj);

		nObj.onfocus = function(){swapClearPWD(nObj,'Password');}
		nObj.onblur = function(){swapClearPWDBlur(nObj,'Password');}
	}
}

function passwordStrength(passText)
{
	var points=0;
	if(passText.length==0)
	{
		$("passText").innerHTML = "";
		return;
	}

	if(passText.length<=4) points--;
	if(passText.length>=6) points++;
	if(passText.match(/\d+/)) points++;
	if(passText.match(/[a-z]/)&&passText.match(/[A-Z]/)) points++;

	switch(points)
	{
		case -1: $("passText").style.color="#c64c25"; $("passText").innerHTML = " (VERY WEAK)"; break;
		case 0: $("passText").style.color="#ffa413"; $("passText").innerHTML = " (Weak)"; break;
		case 1: $("passText").style.color="#ffcd00"; $("passText").innerHTML = " (Medium)"; break;
		case 2: $("passText").style.color="#7aa1ba"; $("passText").innerHTML = " (Strong)"; break;
		case 3: $("passText").style.color="#7fc96b"; $("passText").innerHTML = " (Ultra-Strong)"; break;
	}	
}

function followLink(linkurl)
{
	window.location=linkurl;
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight);
	return arrayPageSize;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function showHideDiv(div)
{
	if($(div).style.display=="none") $(div).style.display="block";
	else $(div).style.display="none";
}
