function getParameter(vParam)
{
    vParam = vParam.toLowerCase();
    var query=this.location.search.substring(1);
    if (query.length > 0){
        var params=query.split("&");
        for (var i=0 ; i<params.length ; i++){
            var pos = params[i].indexOf("=");
            var name = (params[i].substring(0, pos)).toLowerCase();
            if (name == vParam) {
				return params[i].substring(pos + 1);
			}
        }
    }
    return "";
}

function checkEmailAddress(strValue) {
    var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9]{1,}[a-z0-9_\-\.]*)(\.[a-z]{2,4}(\.[a-z]{2}){0,2})$/i;
    return objRegExp.test(strValue);
}

function checkEmailList(emailList, nLimit) {
var sReturn;
	sReturn = "";

    if (emailList.charAt(emailList.length-1) == ",") {
        emailList = emailList.substr(0,emailList.length-1);
    }
    emailList = emailList.replace(/\s/g,"");
    var emailArray = emailList.split(",");
    if (emailArray.length > nLimit) {
      sReturn = "You have entered " + emailArray.length + " email addresses. Please limit your entries to " + nLimit + ".";
      return sReturn;
    }
    for (var i=0;i<emailArray.length;i++) {
      if (!checkEmailAddress(emailArray[i])) {
        sReturn += emailArray[i] + " is not valid email address. Please enter it again.";
        break;
      }
    }
    return sReturn;
}

function getWindowWidth(theWindow)
{
	var x;
	if (window.innerWidth) // all except Explorer
	{
		x = window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
	}
	return x;
}

function getWindowHeight(theWindow)
{
	var y;
	if (window.innerHeight) // all except Explorer
	{
		y = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		y = document.body.clientHeight;
	}
	return y;
}

function openNamedWindow(url, name, width, height)
{
  var newWindow2;
  newWindow2 = window.open(url, name,"width="+width+",height="+height+",toolbar=no,menubar=no,resizable=no,scrollbars=yes");
  newWindow2.focus();
}

function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}

function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}
