// quick pop window function
function pop(newURL,windowName,autowidth,autoheight) 
{
	return popWin(newURL,windowName,autowidth,autoheight,"yes","no");
}

// full pop window function
function popWin(newURL,windowName,autowidth,autoheight, scrollbars,resizable) 
{
	return window.open(newURL, windowName, "scrollbars=" + scrollbars + ",left=0,top=200,width=" + autowidth + ",height=" + autoheight + ",resizable=" + resizable);
}

// 2004-02-08  MN - Remember Me
function getCookie(name) {
   // use: getCookie("name");
   var lCookie = document.cookie;
   var index = lCookie.indexOf(name + "=");
   if(index == - 1) {
      return "";
   }
   index = lCookie.indexOf("=", index) + 1;
   // first character
   var endstr = lCookie.indexOf(";", index);
   if(endstr == - 1) {
      endstr = lCookie.length;
   }
   // last character
   return unescape(lCookie.substring(index, endstr));
}

function deleteCookie (name,path,domain) 
{ if (getCookie(name)) 
  { document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// Moves a select list element(s) to anthor select list
function moveModule(form, o_col, d_col, msg)
{

	if (form[o_col].length > 0)
	{
		for(i = form[o_col].length - 1; i >= 0; i--)
		{
			if(form[o_col].options[i].selected && form[o_col].options[i] != "")
			{
				d_sl = form[d_col].length;
			
				oText = form[o_col].options[i].text;
				oValue = form[o_col].options[i].value;
				form[o_col].options[i] = null;
				form[d_col].options[d_sl] = new Option (oText, oValue, false, false);

			} 

		}
	
		clearList(form, o_col);
		clearList(form, d_col);
	}
	else 
	{
		alert("Please select a " + msg + " first");
	}


}

// This function clears all selected elements in a select list
function clearList(form, list) {

    for (i = 0; i < form[list].length; i++) {
           form[list].options[i].selected = false;
    }

}

// This function selects all elements in a select list
function selectList(form, list) {

    for (i = 0; i < form[list].length; i++) {
        if(form[list].options[i].value != "")
           form[list].options[i].selected = true;
    }

}

// This function finds the index of a select list by passing in the value
function findIndex(form, id, listName) {
    for (i = 0; i < form[listName].length; i++) {
        if (id == form[listName].options[i].value)
            return i;
    }

    return 0;
}

// Trims the whitespaces from the begining and ends of the String inputed
function trim(a)
{
    return a.replace(/^\s+/,'').replace(/\s+$/,'');
}

function unescapeChars(str)
{
	return str.replace('&#039;', '\'');
}