var colorOfInactiveTab = "#DDDDDD";
var colorOfActiveTab = "#EEEEEE";
var colorOfInactiveLink = "#999999";
var colorOfActiveLink = "#333333";
var dispWindow = null;

var daysofweek = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var colorCodingMid = new Array('FFFFFF', 'feb7b7', 'f5cba2', 'f4dd99', 'efee99', 'c5e7a1', 'a3e2a8', 'ace5cc', 'b9f5f5', 'b4e0fa', 'b1cdff', 'cebcf0', 'e7bad3', 'ffa0d3', 'ffd27a', 'ffff99', '90ff99', '7bdbff', 'cccccc', 'dbcccc', 'ccccdb', 'ccdbcc', 'dbdbcc', 'ccdbdb', 'd7ccd7');
				
				
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var isIE = browser == 'Microsoft Internet Explorer';

function mgOpenW(myURL,dsWinW,dsWinH,dsWinName) {
	var chasm = screen.availWidth;
	var mount = screen.availHeight;
	
	dispWindow = window.open(myURL,dsWinName,'width=' + dsWinW + ',height=' + dsWinH + ',left=' + ((chasm - dsWinW - 10) * .5) + ',top=' + ((mount - dsWinH - 30) * .5) + ',scrollbars=yes,resizable=yes');
	
	//return dispWindow;
}	

function toOrdinal(thisNum) {
	var n = thisNum % 100;
	var suff = ["th", "st", "nd", "rd", "th"]; // suff for suffix
	var ord= n<21?(n<4 ? suff[n]:suff[0]): (n%10>4 ? suff[0] : suff[n%10]);
	return thisNum + ord;
}
	
function mgTab(numTab){
	if (document.getElementById){
		for (lpTab=1; lpTab < numberOfTabs + 1; lpTab++){
			document.getElementById('tabContentBlock'+lpTab).style.display='none';
			document.getElementById('tabLink'+lpTab).style.background=colorOfInactiveTab;
			document.getElementById('tabLink'+lpTab).style.color=colorOfInactiveLink;
			document.getElementById('tabLink'+lpTab).style.borderBottomColor='#999999';
		}
		document.getElementById('tabContentBlock'+numTab).style.display='block';
		document.getElementById('tabLink'+numTab).style.background=colorOfActiveTab;
		document.getElementById('tabLink'+numTab).style.color=colorOfActiveLink;
		document.getElementById('tabLink'+numTab).style.borderBottomColor='transparent';
	}
}

function getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	var expiry = new Date(today.getTime() + 60 * 60 * 1000);
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + expiry.toGMTString()) +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function checkEmailAddress(sEmail) {
	var oRegExp = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g;
	if (oRegExp.test(sEmail)) {
		return true;
	} else {
		return false;
	}
}

function checkPhoneNumber(sPhone) {
	var oRegExp = /^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/;
	if (oRegExp.test(sPhone)) {
		return true;
	} else {
		return false;
	}
}

function checkAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = true ;
	}
}

function uncheckAll(field) {
	for (i = 0; i < field.length; i++) {
		field[i].checked = false ;
	}
}	

function mg_setfocus(aForm) {
	if( aForm.elements[0]!=null) {
		var i;
		var max = aForm.length;
		for( i = 0; i < max; i++ ) {
			if( aForm.elements[ i ].type != "hidden" &&
				!aForm.elements[ i ].disabled &&
				!aForm.elements[ i ].readOnly ) {
				aForm.elements[ i ].focus();
				break;
			}
		}
	}
}

function getClientHeight() {
	var h=0;
	if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientHeight) h=document.documentElement.clientHeight;
	else if(document.body && document.body.clientHeight) h=document.body.clientHeight;
	else {
		h=window.innerHeight;
		if(document.width>window.innerWidth) h-=16;
	}
	return h;
}

function getClientWidth() {
	var w=0;
	if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientWidth) w=document.documentElement.clientWidth;
	else if(document.body && document.body.clientWidth) w=document.body.clientWidth;
	else {
		w=window.innerWidth;
		if(document.height>window.innerHeight) w-=16;
	}
	return w;
}

function setOpacity(id, opacity) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

