﻿// main frames page frame border colors

var LO_MainFrameBorderColor	= '#34487E';

// BODY Selector
var LO_BodyBGColor			= 'Window';
var LO_BodyFont				= 'tahoma';
var LO_FontSize				= '8pt';
var LO_FontColor			= '#000000';
var LO_TextOverFlow			= 'ellipsis';

// Menu Body
var LO_MenuBorder			= '2px outset';
var LO_MenuBGColor			= '#D4D0C8';
var LO_MenuFont				= 'tahoma';
var LO_MenuFontSize			= '8pt';
var LO_MenuFontColor		= '#000000';

// menu attributes
var LO_MenuButtonBorderOn	= '1px outset';
var LO_MenuButtonBorderOff	= '1px solid lightsteelblue';

var LO_MenuImgBackgroundColor = 'lightsteelblue';
var LO_MenuImgFilter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#99FFFFFF', EndColorStr='#00FFFFFF')";

var LO_MenuCheckBorder = '2px inset';
var LO_MenuCheckBGColor = 'lightsteelblue';

// menu mouseover
var LO_MO_MenuBGColor		= 'navy';
var LO_MO_MenuFont			= 'tahoma';
var LO_MO_MenuFontSize		= '8pt';
var LO_MO_MenuFontColor		= '#ffffff';

// menu divider
var LO_MenuDivBGColor		= 'lightslategray';
var LO_MenuDivBorder		= '1pt inset';
var LO_MenuDivWidth			= '100%';
var LO_MenuDivHeight		= '1px';

// list highlighting colors
var LO_ListHighlightBackgroundColor	=	'lightsteelblue';
var LO_ListHighlightColor	=	'#000000';
var LO_ListUnHighlightBackgroundColor	=	'#F1F5FA';
var LO_ListUnHighlightColor	=	'#000000';

var LO_MenuCheckBorder = '2px inset';
var LO_MenuCheckBGColor = '#6600FF';

var refreshInteval = 20;
var refreshValue = refreshInteval;
var timerID = null;
var timerRunning = false;
var SHours = eval(getCookie("serverhour"));
var SMinutes = eval(getCookie("serverminute"));
var SSeconds = eval(getCookie("serversecond"));
var SMonths = eval(getCookie("servermonth"));

var oPopup = window.createPopup();
	oPopup.document.body.style.border = LO_MenuBorder;
	oPopup.document.body.style.backgroundColor = LO_MenuBGColor;
	
function progress(x,y) {  
   refreshValue = refreshInteval;
   if(window.self.dialogTop) {
      vtop = parseInt(Replace(window.self.dialogTop,"px",""))+(parseInt(Replace(window.self.dialogHeight,"px",""))-389)/2;
      vleft = parseInt(Replace(window.self.dialogLeft,"px",""))+(parseInt(Replace(window.self.dialogWidth,"px",""))-512)/2;
   }
   else {
      vtop = (top.screen.availHeight-100)/2;
      vleft = (top.screen.availWidth-300)/2;
   }
   if(x) {
      vtop = x;
      vleft = y;
      alert(vtop +","+ vleft);
   }
   s="<table border=0 cellPadding=0 cellSpacing=0 width=300 height=90>"+
     "<tr>"+
     "<td  width=20% height=100% valign=middle align=right>"+
     "<img src='/images/gif/search1.gif' border=0 align=absmiddle>&nbsp;"+
     "</td>"+
     "<td  width=80% height=100% valign=middle align=center>"+
     "<font face='Arial' size=2><b><span id=msgbox>Searching...</span></b></font><font face='Tahoma' size=2><b><span id=elapse></span></b></font>"+
     "</td>"+
     "</tr>"+
     "</table>";
	oPopup.document.body.innerHTML = s; 
	oPopup.show(vleft, vtop, 300, 90, document.getElementById("helpDiv") );
}
	
function processing(x,y) {  
   refreshValue = refreshInteval;
   if(window.self.dialogTop) {
      vtop = parseInt(Replace(window.self.dialogTop,"px",""))+(parseInt(Replace(window.self.dialogHeight,"px",""))-389)/2;
      vleft = parseInt(Replace(window.self.dialogLeft,"px",""))+(parseInt(Replace(window.self.dialogWidth,"px",""))-512)/2;
   }
   else {
      vtop = (top.screen.availHeight-100)/2;
      vleft = (top.screen.availWidth-300)/2;
   }
   if(x) {
      vtop = x;
      vleft = y;
      alert(vtop +","+ vleft);
   }
   s="<table border=0 cellPadding=0 cellSpacing=0 width=300 height=90>"+
     "<tr>"+
     "<td  width=20% height=100% valign=middle align=right>"+
     "<img src='/images/gif/search1.gif' border=0 align=absmiddle>&nbsp;"+
     "</td>"+
     "<td  width=80% height=100% valign=middle align=center>"+
     "<font face='Arial' size=2><b><span id=msgbox>Searching...</span></b></font><font face='Tahoma' size=2><b><span id=elapse></span></b></font>"+
     "</td>"+
     "</tr>"+
     "</table>";
	oPopup.document.body.innerHTML = s; 
    startclock();
	oPopup.show(vleft, vtop, 300, 90, document.getElementById("helpDiv") );
}


var tmpnow = new Date();
var ohours = SHours;
var ominutes = SMinutes;

if(tmpnow.getHours() - SHours < 0){
   houroffset = tmpnow.getHours() - SHours + 24;
}   
else {
   houroffset = tmpnow.getHours() - SHours;
}   

if(tmpnow.getMinutes() - SMinutes < 0){
   minoffset = tmpnow.getMinutes() - SMinutes + 60;
   houroffset = houroffset - 1;
}   
else {
   minoffset = tmpnow.getMinutes() - SMinutes;
}   

if(tmpnow.getSeconds() - SSeconds < 0){
   secondoffset = tmpnow.getSeconds() - SSeconds + 60;
   minoffset = minoffset - 1;
}   
else {
   secondoffset = tmpnow.getSeconds() - SSeconds;
}   

function stopclock(){
   if(timerRunning)
      clearTimeout(timerID);
      timerRunning = false;
} 

function startclock(){
   stopclock();
   showtime();
}

function showtime(){
  var now = new Date();
  if(now.getSeconds() - secondoffset < 0) {
      seconds = (60 - secondoffset) + now.getSeconds();
      if (seconds == 60) seconds = 0;
  }
  else
  {       
    seconds = now.getSeconds() - secondoffset;
    if (seconds == 60) seconds = 0;
  }
  if (seconds==0)
  {
    if  (now.getMinutes() - minoffset < 0)
    {
       minutes = (60 - minoffset) + now.getMinutes();
       if (minutes == 60) minutes = 0;
       ominutes = minutes;
    }
    else
    {       
       minutes = now.getMinutes() - minoffset;
       if (minutes == 60) minutes = 0;
       ominutes = minutes;
    }
  }
  else
  {
    minutes = ominutes;
    ominutes = minutes;
  }

  if (minutes==0)
  {
    if  (now.getHours() - houroffset < 0)
    {
       Webhours = (24 - houroffset) + now.getHours();
       if (Webhours == 24) Webhours = 0;
       ohours = Webhours;
    }
    else
    {       
       Webhours = now.getHours() - houroffset;
       if (Webhours == 24) Webhours = 0;
       ohours = Webhours;
    }
  }
  else
  {
    Webhours = ohours;
    ohours = Webhours;
  }
  var elaphour
  elaphour = (SMonths>=4 && SMonths<=10) ? 15 : 16;
 
  refreshValue = refreshValue - 1;
  mm = parseInt(refreshValue / 60) ;
  mm = ((mm < 10) ? "0" : "") + mm ;
  ss = refreshValue - (mm*60);
  ss = ((ss < 10) ? "0" : "") + ss ;
  if(document.getElementById("refreshSpan")!=null){
     var refreshObj = document.getElementById("refreshSpan");   	
  }
  else if(oPopup.document.getElementById("elapse")!=null){
     var refreshObj = oPopup.document.getElementById("elapse");   	
  }

  if(refreshObj)
     refreshObj.innerHTML = mm+":"+ss;   	
  
  if(refreshValue == 0) {
     stopclock();
     if(refreshObj)
        refreshObj.innerHTML = "Busy!";   
  }
  else {
     timerID = setTimeout("showtime()",1000);
     timerRunning = true;
  }
}

function chknum(obj,  isInt) {
   pcsstr = Replace(obj.value,",","");
   
   if(pcsstr.length > 0) {
       flag = isNaN(pcsstr);
       if(flag == true) {
          obj.focus();
          alert("This field must be numeric value!");          
          return(false);
       }
       if(isInt==true) {
            if(pcsstr.indexOf(".")>-1) {
            obj.value = pcsstr.substr(0,pcsstr.indexOf("."));
                  obj.focus();
              alert("This field must be integer value!");          
              return(false);
         }
       }
   }
   else {
        obj.value = "0";
   }
   return(true);
}

function pickDate(sender,fullyear) {
     strDate = alltrim(sender.value);
    if(fullyear==true)
       window.showModalDialog("/fullcalendar.asp?date="+strDate,sender,"status:no;scroll:no;dialogWidth:220px;dialogHeight:240px;center:yes")   
    else
       window.showModalDialog("/calendar.asp?date="+strDate,sender,"status:no;scroll:no;dialogWidth:220px;dialogHeight:240px;center:yes");                              
}

function USAdate(vdate,DateCode) 
{
   try
   {
      var aryDate = vdate.split("/");
      if(Datecode==13) {
         vdate = aryDate[1]+"/"+aryDate[0]+"/"+aryDate[2];
      }
      return(vdate);
   }
   catch(errorObject)
   {
      var msg = "Error number: " + (errorObject.number & 0xffff) + "\n"+
                'Source: <%=Request.ServerVariables("URL")%>\n' +
                "Name: " + errorObject.name + "\n"+
                "Message: " + errorObject.message + "\n"+
                "Description: " + errorObject.description + "\n";
      alert(msg);      
   }              
}

function Replace(sstr,ostr,nstr) {
    if(sstr) {
       vpos = sstr.indexOf(ostr);
       vit = sstr;
       while(vpos>=0) {
          vit = vit.replace(ostr ,nstr);        
          vpos = vit.indexOf(ostr);          
       }
       return(vit);
    }
    else
       return("");
} 
 
function round(number,X) {
    X = (!X ? 2 : X);              
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function formatnumber(pnumber,decimals) 
{  
  //var vnumber = Replace(pnumber,",","");
  var vnumber = pnumber;
  var flag = isNaN(vnumber);
  if(flag == false) {
     if(vnumber.length>0) {
        vnumber = round(parseFloat(vnumber),decimals).toString();
        if(vnumber.lastIndexOf(".")==-1) vnumber = vnumber + ".";
        dot = vnumber.lastIndexOf(".");
        adot = (vnumber.length - 1 - dot);
        for(k=decimals;k>adot;k--) vnumber = vnumber + "0";
     }
  }
  return vnumber;  
} 
 
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}
	
    if(tmpNumStr.lastIndexOf(".")==-1 && decimalNum>0) tmpNumStr= tmpNumStr+ ".";
    if(decimalNum>0) {
       dot = tmpNumStr.lastIndexOf(".");
       adot = (tmpNumStr.length - 1 - dot);
       for(k=decimalNum;k>adot;k--) {
           tmpNumStr += "0";
       }
    }

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}

function alltrim(inputString) 
{
   if(typeof inputString != "string") { return inputString; }
   
   var retValue = inputString; 
      
   var ch = retValue.substr(retValue.length-1, 1);   
   
   while (escape(ch) == "%A0" || escape(ch) == "%20") {        
      retValue = retValue.substr(0,retValue.length-1);
      ch = retValue.substr(retValue.length-1, 1);      
   }
   ch = retValue.substr(0,1);   
   while (escape(ch) == "%A0" || escape(ch) == "%20") {        
      retValue = retValue.substr(1,retValue.length-1);
      ch = retValue.substr(0, 1);      
   }
   return retValue;
} 

String.prototype.trim = function () {return this.replace(/^\s+|\s+$/g, "");}

function focusNum(numObj){
   if((numObj.value).length>0) {
      if(parseFloat(numObj.value)==0) {
         numObj.value="";
      }
   }
}

function StrReplace(sstr,ostr,nstr) {
    vpos = sstr.indexOf(ostr);
    vit = sstr;
    do {
       vit = vit.replace(ostr,nstr);        
       vpos = vit.indexOf(ostr);
    } while(vpos >= 0);
    dstr = vit;
    return dstr;
} 

function setCookie(theName,theValue,theDay)
{
	if ((theName != null) && (theValue != null))
	{
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";	
		//if (theDay != null)
		//{
		//	theDay = eval(theDay);	
		//	setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
			setDay = new Date();
			setDay.setTime(setDay.getTime()+(1*1000*60*60*24));
			expDay = setDay.toGMTString();
		//}
		document.cookie = theName + "="+escape(theValue)+";expires="+expDay;
		return true;
	}
	return false;
}

function deleteCookie(theName)
{
	document.cookie = theName + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
	return true;
}

function getCookie(theName)
{
	theName += "=";	
	theCookie = document.cookie+";";	
	start = theCookie.indexOf(theName);	
	if (start != -1)
	{
		end = theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start+theName.length,end));
	}
	return false;
}

function viewCookie(CookieName)
{
	getValue = getCookie(CookieName);
	alert(CookieName+"="+getValue);
}

// 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;
		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;height:16px;width:16px" 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;
		//case "imaged_button": alert('<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[2] +'  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] + ".ajaxHttp");
         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;}

var menu = new Array();

var iWidth = screen.availWidth;
var menuWidth = 300;
var menuHeight = 16;
function menuIcon(itemWidth, itemName, itemClass, itemUrl, urlTarget, imageUrl, imageWidth, imageHeight, imageHSpace, imageVSpace, itemText, hasSubMenu, subMenuName){
	this.name = itemName;
	this.itemClass = itemClass;
	this.url = itemUrl;
	this.target = urlTarget || null;
	this.imageUrl = imageUrl;
	this.imageWidth = imageWidth;
	this.imageHeight = imageHeight;
	this.imageHSpace = imageHSpace;
	this.imageVSpace = imageVSpace;
	this.itemText = itemText;
	this.hasSubMenu = hasSubMenu;
	this.subMenuName = subMenuName;
	this.createItem = function(){
  	     return '<table id="' + this.name +'" width="'+itemWidth+'" height="100%" cellpadding="0" cellspacing="0" border="0"><tr>'+ 
	            '<td width="'+itemWidth+'" height="100%" valign="middle" align=center onclick="if(!'+ this.name +'.disabled) {' + this.url + 
  	            '} else {alert(&quot;Access Denied!&quot;)} " class="menuButton" style="behavior:url(../css/NormalButtonBehavior.htc);" id="' + this.name +'Table">' + 
		        '<span align="absmiddle"><img id="'+ this.name +'Image" align="absmiddle" SRC="' + this.imageUrl + '" border="0" alt="' + this.itemText + '" lowsrc="../images/spacer.gif">&nbsp;</span>'+
	            '<span align="absmiddle"><b>'+this.itemText+'</b></span>' + 
	            (this.hasSubMenu ? '</td>'+			       		             
	            '<td width="12" height="100%" class="menuButton" id="' + this.name +'TableArrow" onclick="' + 
	            this.subMenuName + 
	            'Function()" style="behavior:url(../css/NormalButtonBehavior.htc);width:12px;margin:0px;padding:0px;overflow:hidden;">'+
	            '<img src="/images/MinArrow.gif" border="0" alt="" />' : '') + '</td>'+
	            '<td width="10">&nbsp;</td>' + 	            
	            '</tr></table>';	            
	}
	menu.push(this);
}
var iDividers=0;
function divider(){
	this.dividerID = iDividers++;
	this.name = "div"
	this.createItem = function(){return '<div id="Divider'+this.dividerID+'" style="display:inline;border:1px inset;height:100%;width:2px;"></div>&nbsp;';}
	menu.push(this);
}

function doPickCustno(qryObj) {
   var now = new Date();
   vtime='y'+now.getFullYear()+now.getMonth()+now.getDate()+now.getHours()+now.getSeconds();
   window.showModalDialog("../ProjectPub/picker/pickCustno.asp?time="+vtime,qryObj,"status:no;scroll:no;dialogWidth:640px;dialogHeight:480px;center:yes");               
}

function getCountryDate(dateStr, cocode) {
    try {
        if (dateStr.length == 0) return (new Date());
        dateAry = dateStr.split("/");
//        if (cocode == "BBIAU" || cocode == "BBIUK" || cocode == "BBINZ") {
//            yy = dateAry[2];
//            var yyyy = "20" + yy;
//            var mm = dateAry[1];
//            mm = parseInt(mm) - 1;
//            var dd = dateAry[0];
//            alert(cocode+"  D/M/Y = " + dd + "/" + mm + "/" + yyyy);
//        }
//        else {
            yy = dateAry[2];
            var yyyy = "20" + yy;
            var mm = dateAry[0];
            mm = parseInt(mm) - 1;
            var dd = dateAry[1];
            //alert(cocode+"  M/D/Y = " + mm + "/" + dd + "/" + yyyy);
//        }
         return (new Date(yyyy, mm, dd));
    }
    catch (errorObject) {
        var msg = "Error number: " + (errorObject.number & 0xffff) + "\n" +
                'Source: <%=Request.ServerVariables("URL")%>\n' +
                "Name: " + errorObject.name + "\n" +
                "Message: " + errorObject.message + "\n" +
                "Description: " + errorObject.description + "\n";
        alert(msg);
    }
}

function ValidateDate(DateFrom, DateTo, DiffDays, dbname) {
    try {
        var FromDate = getCountryDate(DateFrom, dbname);
        var ToDate = getCountryDate(DateTo, dbname);
        //alert(FromDate + " " + ToDate);

        var one_day = 1000 * 60 * 60 * 24;
        var days = Math.ceil((ToDate.getTime() - FromDate.getTime()) / (one_day));
        if (days > DiffDays) {
            return (false);
        }
        return (true);
    }
    catch (errorObject) {
        var msg = "Error number: " + (errorObject.number & 0xffff) + "\n" +
                'Source: <%=Request.ServerVariables("URL")%>\n' +
                "Name: " + errorObject.name + "\n" +
                "Message: " + errorObject.message + "\n" +
                "Description: " + errorObject.description + "\n";
        alert(msg);
        return (false);
    }
}


