// GLOBAL view variables
var MESSAGELISTING = 0;
var CALENDARWEEKVIEW = 1
var CALENDARMONTHVIEW = 2;
var ADDRESSBOOK = 3;
var OPTIONS = 4;

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_opera = (agt.indexOf("opera") != -1);
var is_nav  = ((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1)&&(agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav&&(is_major == 2));
var is_nav3 = (is_nav&&(is_major == 3));
var is_nav4 = (is_nav&& (is_major == 4));
var is_nav4up = (is_nav&&(is_major >= 4));
var is_navonly = (is_nav&&((agt.indexOf(";nav") != -1)||(agt.indexOf("; nav") != -1)));
var is_nav6 = (is_nav&&(is_major == 5));
var is_nav6up = (is_nav&&(is_major >= 5));
// use is_ie5up to detect IE5
var is_ie   = (agt.indexOf("msie") != -1 && !is_opera && !is_nav);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) && (agt.indexOf("msie 5.5")==-1)&& (agt.indexOf("msie 6.0")==-1) && (agt.indexOf("msie 6.5")==-1));
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var is_ie55 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5")!=-1) );
var is_ie55up  = (is_ie  && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6  = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0")!=-1) );

function check_escape(sFolderName){if(sFolderName.indexOf('%23')!=-1){return sFolderName;}return escape(sFolderName);}

function Mesg(Msg){
StatusMsg();
if (Msg.length == 0){return;}
alert(Msg);
}

function StatusMsg(){try{if(document.getElementById('StatusMesg').innerHTML.length > 0){window.status = document.getElementById('StatusMesg').innerHTML;}}catch(Exception){}}

function Post(field, value){
	document.forms[0].action += '&' + field + '=' + (value != null ? value : 'Yes');
	if (typeof(Validate) == 'undefined' || Validate()){document.forms[0].submit();}
}

function Get(field, value){
	var url = document.forms[0].action += '&' + field + '=' + (value != null ? value : 'Yes');
	document.location = url;
}

function SetOption(name, value){
	var i = 0;
	var docForm = document.forms[0];
	var formLength = i = docForm.length;
	while(i--){if (docForm.elements[i].name == name){var element = docForm.elements[i];break;}}
	if (element == null){return;}
	switch(element.type){
	case 'checkbox': element.checked = (element.value == value);break;
	case 'radio': i = formLength;while(i--){if (docForm.elements[i].name == name && docForm.elements[i].value == value){	docForm.elements[i].checked = true;}}break;
	case 'select-one': i = element.length;while(i--){if(element.options[i].value.toLowerCase() == value.toLowerCase()){element.selectedIndex = i;}}break;
	case 'select-multiple':	i = element.length;while(i--){if(element.options[i].value.toLowerCase() == value.toLowerCase()){element.options[i].selected = true;}}break;
	case 'text': element.value = value;break;
	case 'hidden':element.value = value;break;
	}
}
var DIVIDER = 0; var TOGGLE = 1; var TRASH = 2; var IMAGED_BUTTON = 3; var DEFAULT = 4;
function buildMenu(menuID,arrayOfMenuItems){
	var output = [];
		output.push('<table id="'+menuID+'" style="background-color:'+LO_MenuBGColor+';" cellspacing="0" cellpadding="0">');
	var arMenuLength = arrayOfMenuItems.length;
	var aEl = null;
	for(var i = 0;i<arMenuLength;i++){
		aEl = arrayOfMenuItems[i];
		switch(aEl[0]){
		case "divider": output.push('<tr><td colspan="2"><div style="border-top:'+LO_MenuDivBorder+';width:'+LO_MenuDivWidth+';height:'+LO_MenuDivHeight+';background-color:'+LO_MenuDivBGColor+';height:1px;"><img src="'+theme+'/spacer.gif" width="1" height="1" alt=""></div></td></tr>');break;
		case "toggleSwitch": output.push('<tr><td style="background-color:'+LO_MenuImgBackgroundColor +';filter:'+LO_MenuImgFilter+';width:20;height:20;text-align: center;" onclick="'+aEl[2]+'"><img id="'+aEl[1]+'Check" '+'src="'+theme+'/checkmark.gif" style="display:none;"></td>'+'<td style="font-family:'+LO_MenuFont+';font-size:'+LO_MenuFontSize +';color:'+LO_MenuFontColor+';padding-right:2px;padding-left:2px;" nowrap onmouseover="this.style.cursor=\'default\';'+'this.style.background=\''+LO_MO_MenuBGColor+'\';this.style.color = \''+LO_MO_MenuFontColor+'\';" onmouseout="this.style.background=\''+LO_MenuBGColor+'\';this.style.color = \''+LO_MenuFontColor+'\';" onclick="' + aEl[2]+'">'+ aEl[3] +'&nbsp;</td></tr>');break;
		case "trash": output.push('<tr><td id="emptyTrashIcon" style="background-color:'+LO_MenuImgBackgroundColor +	';filter:'+LO_MenuImgFilter +';font-size:'+LO_MenuFontSize +';font-family:'+LO_MenuFont +';height:20px;"><img style="margin:2px;" src="' + aEl[1] + '" onclick="' + aEl[2] + '" /></td><td id="emptyTrash" style="font-family:' + LO_MenuFont +';font-size:' + LO_MenuFontSize +';color:' + LO_MenuFontColor +';padding-right:2px;padding-left:2px;" nowrap onmouseover="this.style.cursor=\'default\'' +';this.style.background=\'' + LO_MO_MenuBGColor +'\';this.style.color = \'' + LO_MO_MenuFontColor +'\';" onmouseout="this.style.background=\'' + LO_MenuBGColor +'\';this.style.color = \'' + LO_MenuFontColor + '\';" onclick="' + aEl[2] +'">'+ aEl[3] +'&nbsp;</td></tr>');break;
		case "imaged_button": output.push('<tr><td style="background-color:'+LO_MenuImgBackgroundColor +';filter:' + LO_MenuImgFilter +';font-size:' + LO_MenuFontSize +';font-family:'+LO_MenuFont +';height:20px;width:20px;" id="'+aEl[4] +'Icon"><img style="margin:2px;" src="' + aEl[1] + '" onclick="' + aEl[2] + '" /></td><td style="font-family:' + LO_MenuFont +';font-size:'+LO_MenuFontSize +';color:'+LO_MenuFontColor +';height:20px;padding-right:2px;padding-left:2px;" nowrap onmouseover="this.style.cursor=\'default\'' +';this.style.background=\''+ LO_MO_MenuBGColor +'\';this.style.color = \''+LO_MO_MenuFontColor +'\';"  onmouseout="this.style.background=\''+LO_MenuBGColor +'\';this.style.color = \''+LO_MenuFontColor +'\';" onclick="' + aEl[2] +'" ID="'+aEl[4] +'">'+ aEl[3] +'&nbsp;</td></tr>');break;
		default: output.push('<tr><td style="background-color:'+LO_MenuImgBackgroundColor +';filter:' + LO_MenuImgFilter +';font-size:' + LO_MenuFontSize +';font-family:'+LO_MenuFont +';height:20px;width:20px;">&nbsp;</td><td style="font-family:' + LO_MenuFont +';font-size:'+LO_MenuFontSize +';color:'+LO_MenuFontColor +';height:20px;padding-right:2px;padding-left:2px;" nowrap="nowrap" onmouseover="this.style.cursor=\'default\'' +';this.style.background=\''+ LO_MO_MenuBGColor +'\';this.style.color = \''+LO_MO_MenuFontColor +'\';"  onmouseout="this.style.background=\''+LO_MenuBGColor +'\';this.style.color = \''+LO_MenuFontColor +'\';" onclick="' + aEl[1] +'" ID="'+aEl[3] +'">'+ aEl[2] +'&nbsp;</td></tr>');break;
		}
	}
	output.push('</table>');
	return output.join('');
}
function getControlPrefix() {
   if (getControlPrefix.prefix){return getControlPrefix.prefix;}
   var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
   var o, o2, i;
	i = 4;
   while(i--){
      try {
         // try to create the objects
         o = new ActiveXObject(prefixes[i] + ".XmlHttp");
         o2 = new ActiveXObject(prefixes[i] + ".XmlDom");
         return getControlPrefix.prefix = prefixes[i];
      }catch (ex) {};
   }
	throw new Error("Could not find an installed XML parser");
}
function SelectAll() {
	MsgSelected.length = 0;
	var docForm = document.forms[0];
	var formLength = i = document.forms[0].elements.length;
	var e = null;
	while(i--){e=docForm.elements[i];if(e.name == 'Number'){e.checked=true;highlight(e.value);MsgSelected.push(e.value);}}
}
function SetCookie(cookieName, cookieValue){document.cookie = cookieName + "=" + cookieValue +";expires=" + new Date(2020,12,31);}
function GetCookie(cookieName){var aCookie = document.cookie.split("; ");var i = aCookie.length;while(i--){var aFolderOpen = aCookie[i].split("=");if (cookieName == aFolderOpen[0]){return (aFolderOpen[1]);}}return null;}
function setFocus(field){document.forms[0][field].focus();}
function Print(url) {window.open(url,'Print','height=400,width=600,scrollbars=yes,status=yes,resizable=1,toolbar=yes,menubar=yes');}
function Source(url) {window.open(url,'Source','height=400,width=600,scrollbars=yes,status=yes,resizable=1,toolbar=yes,menubar=yes');}
function openWin(url, winName, width, height, features){
	var w = top.document.body.clientWidth;
	var h = top.document.body.clientHeight;
	var popW = width, popH = height;
	var leftPos = (w>800?(w-popW)/1.48:0);
	var topPos = (h>640?(h-popH)/1.42:0);
	var hWin = window.open(url, winName+(features=='compose' ? top.composeWindowCount++ : ''),'directories=no,location=no,menubar=no,status=no,scrollbars='+(features=='yes'||features=='compose'?'yes':'no')+',resizable='+(features=='yes'||features=='compose'?'yes':'no')+',titlebars=no,toolbar=no,width=' + width + ',height=' + height+ ',screenX=' + topPos + ',screenY=' + leftPos+',top=' + topPos + ',left=' + leftPos);
		hWin.focus();
	if(!hWin.opener){hWin.opener = window;}
}
if(is_ie55up && (typeof(detectKeyStrokes) != 'undefined' && detectKeyStrokes))
{
try{top.writeToDebugLog('LOGGING KEY STROKES');}catch(exception){}
document.onkeydown=microsoftKeyDown;
document.onkeyup=microsoftKeyUp;
document.onhelp=openHelp;
}
var prefix = '';
function microsoftKeyDown() {
	var we = window.event;
	prefix = (we.shiftKey?'s':'')+(we.ctrlKey?'c':'')+(we.altKey?'a':'');
	var pk = prefix+we.keyCode;
	document.selection.empty();
	switch(pk){
	case 'c85': top.keyStroke(top.UNREAD);break;
	case 'c78': top.keyStroke(top.COMPOSE);break;
	case '38': top.keyStroke(top.PREVIOUS_MSG);break;
	case '188': top.keyStroke(top.PREVIOUS_MSG);break;
	case '40': top.keyStroke(top.NEXT_MSG);break;
	case '190': top.keyStroke(top.NEXT_MSG);break;
	case '46': top.keyStroke(top.DELETE);break;
	case 'c65': window.event.returnValue = top.keyStroke(top.SELECT_ALL);return false;break;
	case 'c81': top.keyStroke(top.MARK_AS_READ);break;
	default: window.event.returnValue=true;break;
	}
	window.event.returnValue=true;
}
function microsoftKeyUp(){
var we = window.event;
prefix = (we.shiftKey?'s':'')+(we.ctrlKey?'c':'')+(we.altKey?'a':'');
var pk = prefix+we.keyCode;
document.selection.empty();
try{top.writeToDebugLog('KEYUP > ' + pk);}catch(exception){}
prefix = '';
}
function openHelp(){if(opener){return;}else{top.openHelp();}return false;}