// START Functions added by Kurt Mattes for Merged Site UI 2005
function bolEnableFields(form,field)
{
	if((field.value) == "2")
	{		
		form.toDate.disabled = false;
		form.fromDate.disabled = false;
		form.toDate.style.backgroundColor = "White";
		form.fromDate.style.backgroundColor = "White";
	}
	if((field.value) == "1")
	{
		form.toDate.disabled = true;
		form.fromDate.disabled = true;
		form.toDate.style.backgroundColor = "Gray";
		form.fromDate.style.backgroundColor = "Gray";
	}
}

function checkRadio(form)
{
	form.DateRangeRadio.checked = true;
}



// Author: Sanjeevkumar Nair/Nurul
// Date: 30/04/2003 - 10/Nov/2003
// Description : The following code generates a HTML calender 
// on the client side and displays the selected date into the textbox control 
// in the parent page( page from where the control was invoded). 
//

// Customized call to the show_calender method (substitute for method overloading).
// This method is called from the parent page to invoke the calender control.
// Parmeters to be passed (str_target)= Document.FormName.TextBoxControlName (Eg. document.form1.textbox1). 
var arr_Holidays;
var arr_HolidayDates = new Array();
var Currentdate = new Date();
var CurrentMonth = Currentdate.getMonth();
var CurrentYear = Currentdate.getFullYear();
var UserDate;
var StartDate =""; 
var PreviousMonthDate="";
var NextMonthDate="";
var isDateInvalid = false;

function BolCurrentCalendar(str_target,img_path)
{
var isdisabled;

eval ("isdisabled="+str_target+".disabled;");
UserDate =  eval(str_target + ".value;");    
if(UserDate != "" && new Date(UserDate).toString().indexOf('NaN') >= 0)
{
alert('You have entered an invalid date.  Please reenter the date in mm/dd/yyyy format or use the calendar icon next to the date field.');
}
else
{
  if (isdisabled == false)
  {
      if (UserDate != "")
      {
        var CurUserDate = boldatestr(UserDate);
	    show_calendar(str_target,CurUserDate + "00:00:00" ,img_path);	
      }
      else
      {
       
        show_calendar(str_target,"",img_path);
      }
  }
}
}

//This function is used to load and display the calender html.
function show_calendar(str_target,str_datetime,img_path) {
    
    // Array containing months of the year.
    var arr_months = ["January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"];
    
    // Array containing days of the week. 
    var week_days = ["S", "M", "T", "W", "T", "F", "S"];
    
    // First day of the week.
    var n_weekstart = 0; // Day week starts from (normally 0 or 1).
   
    //Using for OMX
    var Tempdate = new Date(StartDate);
    Tempdate = new Date(Tempdate);
    Tempdate = Tempdate.setFullYear(Tempdate.getFullYear() - 1, Tempdate.getMonth(),Tempdate.getDate());
    Tempdate = new Date(Tempdate);    
    //End
    
    //Set the variable indicating valid date.
    isDateInvalid = false;
    
    // Setting the values required for navigation from current month to next month or year as the case may be.
    var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	if (isDateInvalid)
	dt_datetime = new Date();
    var dt_prev_month = new Date(dt_datetime);
    var dt_next_month = new Date(dt_datetime);

    if(isMonthEnd(dt_datetime)) 
    {
       
		SetPrevNextMonthDate(dt_datetime);
                if(dt_datetime.getMonth() == 0)
                {
  	            dt_prev_month.setFullYear(dt_datetime.getFullYear()-1, 11,PreviousMonthDate);
		    dt_next_month.setFullYear(dt_datetime.getFullYear(),dt_datetime.getMonth()+1,NextMonthDate);
                }
                else if (dt_datetime.getMonth() == 11)
                {
                    dt_prev_month.setFullYear(dt_datetime.getFullYear(), dt_datetime.getMonth()-1,PreviousMonthDate);
             	    dt_next_month.setFullYear(dt_datetime.getFullYear()+1,0,NextMonthDate);  
                }
                else
                {
		
		    dt_prev_month.setFullYear(dt_datetime.getFullYear(), dt_datetime.getMonth()-1,PreviousMonthDate);
		    dt_next_month.setFullYear(dt_datetime.getFullYear(),dt_datetime.getMonth()+1,NextMonthDate);
                }
		dt_prev_month = new Date(dt_prev_month);
		dt_next_month = new Date(dt_next_month);
          
    }
    else
    {
    	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
    	dt_next_month.setMonth(dt_datetime.getMonth()+1);
    }

    var dt_firstday = new Date(dt_datetime);
    dt_firstday.setDate(1);
    dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
    var dt_lastday = new Date(dt_next_month);
    dt_lastday.setDate(0);
  
    
    // Html generation.
    var str_buffer = new String (
        "<html>\n"+
        "<head>\n"+
        
        // Print calendar header.
        "<title>"+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</title>\n"+
        
        // Reg Expression to customise the date fromat to our date format.
        "<script>"+
        "function BolSetValue(target , value)"+
        "{"+
        "   var str1 = value.replace(/(^[^ ]+)([ ]*.+$)/,\"$1\");"+
        "   var str2 = str1.replace(/(^.{1,2})-(.{1,2})-(....$)/,\"$2/$1/$3\");"+
        "   target.value=str2; target.focus();"+
        "}"+
        "</script>"+
        
        // Stylesheet code exclusively used for this date control.
        "<STYLE TYPE=\"text/css\">"+
        "TD.NON {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#C0C0C0; font-weight :normal;}"+
        "TD.TOP {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#0000FF; font-weight :bold;}"+
        "TD.Some {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal;}"+
        "A.NOEVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}"+
        "A.NOEVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}"+
        "A.EVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}"+
        "A.EVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}"+
        "A.NORMAL:Link {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}"+
        "A.NORMAL:Visited {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}"+
        "</STYLE>"+
        "</head>\n"+
        
        // HTML page body starts here.
        "<body bgcolor=\"#FFFFFF\">\n"+
        "<table class=\"clsOTable\" cellpadding=\"2\" bordercolor=\"Gray\" cellspacing=\"0\" border=\"1\" align=\"center\">\n"+
        "<tr><td bgcolor=\"#FFFFFF\">\n"+
        "<table cellspacing=\"0\" cellpadding=\"1\" border=\"0\" bordercolor=\"Gray\" bgcolor=\"#FFFFFF\" align=\"center\" width=\"140\">\n"+
        "<tr>\n <td align='left' width=\"10\" height=\"18\" valign=\"middle\" bgcolor=\"Silver\"><a href=\"javascript:window.opener.show_calendar('"+
        str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+'00:00:00','"+img_path+"');\">"+
        "<img src=\""+img_path+"CalendarPrev.gif\" width=\"16\" height=\"16\" border=\"0\""+
        " alt=\"previous month\"></a></td>\n"+
        "   <td align =\"center\" bgcolor=\"Silver\" CLASS=\"SOME\" colspan=\"5\">"+
        arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</td>\n"+
        "   <td bgcolor=\"Silver\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
        +str_target+"', '"+dt2dtstr(dt_next_month)+"'+'00:00:00','"+img_path+"');\">"+
        "<img src=\""+img_path+"CalendarNext.gif\" width=\"16\" height=\"16\" border=\"0\""+
        " alt=\"next month\"></a></td>\n</tr>\n"
    );
    
    // Date object initialized.
    var dt_current_day = new Date(dt_firstday);
    
    
    // Print weekdays titles.
    str_buffer += "<tr>\n";
    for (var n=0; n<7; n++)
        str_buffer += " <td align='right' class =\"SOME\" width =\"18\" height=\"15\" Valign=\"bottom\">"+
        week_days[(n_weekstart+n)%7]+"</td>\n";
    
    // Print calendar table.
    str_buffer += "</tr>\n";
    while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
        dt_current_day.getMonth() == dt_firstday.getMonth()) {
        
        // Print row header.
        str_buffer += "<tr>\n";
        for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
                if (dt_current_day.getDate() == dt_datetime.getDate() && 
                    dt_current_day.getMonth() == dt_datetime.getMonth())

                    // Set color for the current date.
                    str_buffer += " <td bgcolor=\"GainsBoro\" align=\"right\">";
                    else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
                    
                    // Set color for Weekend days. 
                    str_buffer += " <td bgcolor=\"white\" align=\"right\">";
                else
                    // Set color for working days of current month.
                    str_buffer += " <td bgcolor=\"white\" align=\"right\">";
                
				if (dt_current_day.getMonth() == dt_datetime.getMonth())
                {     
                // Print days of current month.
		        if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
		        {
			       str_buffer += "<b><font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
		        }
		        else
		        {
		        if(StartDate != "")
			    {			   
			    StartDate.setHours(00,00,00,00);
			    if ((dt_current_day < StartDate) || (dt_current_day > Tempdate) || CheckIsHoliday(dt_current_day))
			    {			     
			      str_buffer += "<b><font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
			    }
			    else
			    {
				  str_buffer += "<b><a class='EVENT' href='#' onClick=\"javascript:BolSetValue(window.opener."+str_target+",'"+
				  dt2dtstr(dt_current_day)+ " 00:00:00'); window.close();\">";
				  str_buffer +=   "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\"></b>";
			    }
			 }
			 else
			 {
				 str_buffer += "<b><a class='EVENT' href='#' onClick=\"javascript:BolSetValue(window.opener."+str_target+",'"+
				 dt2dtstr(dt_current_day)+ " 00:00:00'); window.close();\">";
				 str_buffer +=   "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\"></b>";
			 }
                    }
                
                }
                else 
                {
			 if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
			 {
 			   str_buffer += "<b><font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
			 }            
			 else
			 {
			    if(StartDate != "")
			    {
			         StartDate.setHours(00,00,00,00);
			         if ((dt_current_day < StartDate) || (dt_current_day > Tempdate) || CheckIsHoliday(dt_current_day))
				{
				   str_buffer += "<b><font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				}
				else
				{
				   // Print days of other months.
				   str_buffer += "<a class='EVENT' href='#' onClick=\"javascript:BolSetValue(window.opener."+str_target+",'"+
				   dt2dtstr(dt_current_day)+ " 00:00:00'); window.close();\">"+
				   "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				}
			     }
			     else
			     {
				// Print days of other months.
				str_buffer += "<a class='EVENT' href='#' onClick=\"javascript:BolSetValue(window.opener."+str_target+",'"+
				dt2dtstr(dt_current_day)+ " 00:00:00'); window.close();\">"+
				"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";  
			     }
		          }
		}
                
                // To set days between 1 and 9 as 01 to 09 (only for the current month days).
                var dateStr="";
                //if (dt_current_day.getMonth() == dt_datetime.getMonth())
                //{
                    if(dt_current_day.getDate()<10)
                        dateStr = "0"+ dt_current_day.getDate().toString();
                    else
                        dateStr = dt_current_day.getDate().toString();  
                //}
                //else
                //  dateStr = dt_current_day.getDate().toString();  
                
               //if(dt_current_day.getMonth() == dt_prev_month.getMonth() || dt_current_day.getMonth() == dt_next_month.getMonth())
               //     dateStr = "";
            // Display the days into the page. 
            
            	if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
            	  str_buffer += dateStr+"</font></td>\n";
            	else
                 str_buffer += dateStr+"</font></a></td>\n";
               
                dt_current_day.setDate(dt_current_day.getDate()+1);
         
        }
        
        // Closing tags of the table row.
        str_buffer += "</tr>\n";
    }
    
    // Closing tags of the html page.
    str_buffer +=
        "</table>\n" +
        "</tr>\n</td>\n</table>\n" +
        "</body>\n" +
        "</html>\n";

    // Browser window settings.    
    var defaulturl = document.URL;
    var endindex = "";
    endindex = defaulturl.indexOf("/", defaulturl.indexOf("//",0)+2);
    if(endindex <=1)
    {
      defaulturl = "";
    }
    else
    {
      defaulturl = document.URL.substring(0,endindex);
    }
    
    var vWinCal = window.open(defaulturl, "Calendar", 
        "width=160,height=160,status=no,resizable=yes,top=200,left=200");
    vWinCal.opener = self;
    var calc_doc = vWinCal.document;
    calc_doc.write (str_buffer);
    calc_doc.close();
}

// Datetime parsing and formatting routimes.
function str2dt (str_datetime) {
    var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;    
    if (!re_date.exec(str_datetime))
    {
		isDateInvalid = true;
        return alert("Invalid Datetime format: "+ str_datetime);
    }
    return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}

// Function to convert the date type to string type in a required format.
function dt2dtstr (dt_datetime) 
{
    var dateStr="";
    var month = dt_datetime.getMonth()+1;
    var monthStr ="";
    if(dt_datetime.getDate()<10)
        dateStr = "0"+ dt_datetime.getDate().toString();
    else
        dateStr = dt_datetime.getDate().toString(); 
    if(month<10)
        monthStr = "0"+ month.toString();
    else 
        monthStr = month.toString();
    return (new String (dateStr+"-"+(monthStr)+"-"+dt_datetime.getFullYear()+" "));
}

function isMonthEnd(dt_current_date)
{
    dt_current_date = new Date(dt_current_date);
	var date = dt_current_date.getDate();
	var month = dt_current_date.getMonth();
	
	if(date == 31)
	{
	  if(month == 0 || month ==2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11)
	    return true;
	}	
	else if(date == 30)
	{
	 if(month == 3 || month == 2 || month == 5 || month == 8 || month == 10)
	    return true;
	}
	else if(date == 29 || date == 28)
	{
	  if(month == 1 || month == 2 || month == 0) return true;
	}
	return false;
}
function SetPrevNextMonthDate(current_date)
{
  var month = current_date.getMonth();
  var febdate = "";

 
  if(current_date.getFullYear()%4 == 0) febdate = 29; else febdate = 28;
 
  switch(month)
  {
	case 0:
	   PreviousMonthDate = 31;
	   NextMonthDate = febdate;
	   break;
	case 1:
	   PreviousMonthDate = 31;
	   NextMonthDate = 31;
	   break;
	case 2:
	   PreviousMonthDate = febdate;
	   NextMonthDate = 30;
	   break;
	case 3:
	   PreviousMonthDate = 31;
	   NextMonthDate = 31;
	   break;
	case 4:
		PreviousMonthDate = 30;
		NextMonthDate = 30;
		break;
	case 5:
	    PreviousMonthDate = 31;
	    NextMonthDate = 31;
	    break;
	case 6:
	    PreviousMonthDate = 30;
	    NextMonthDate = 31;
	    break;
	case 7:
	    PreviousMonthDate = 31;
	    NextMonthDate = 30;
	    break;
	case 8:
	    PreviousMonthDate = 31;
	    NextMonthDate = 31;
	    break;
	case 9:
		PreviousMonthDate = 30;
		NextMonthDate = 30;
		break;
	case 10:
	   PreviousMonthDate = 31;
	   NextMonthDate = 31;
	   break;
	case 11:
	   PreviousMonthDate = 30;
	   NextMonthDate = 31;
  }
}
// Function to convert the date time type to string type in a required format.
function dt2tmstr (dt_datetime) {
    return (new String (
            dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

//Function to check whether the current day is holiday or not
function IsHoliday(dt_today)
{
   
   for(i=0; i <arr_Holidays.length; i++)
   {
      if (dt_today == arr_Holidays[i])
            return true;
   }
   return false;
}

function SetHolidays(arr_Holidays)
{
  arr_HolidayDates = arr_Holidays
}


//Function to check is current date is holiday or not.
function CheckIsHoliday(dt_today_date)
{
  for(var i = 0; i< arr_HolidayDates.length; i++)
  {
     var dt_date = new Date(arr_HolidayDates[i]);
     if(dt_today_date.getMonth() == dt_date.getMonth() && dt_today_date.getDate() == dt_date.getDate() && dt_today_date.getFullYear() == dt_date.getFullYear())
     {
       return true;
     }
  }
  return false;
  
}

//Function to set the current month holidays
function SetMonthHolidays(dt_today)
{
   var k = 0;
   arr_Holidays = new Array();
   for(var i = 0; i< arr_HolidayDates.length; i++)
   {
     var dt_date = new Date(arr_HolidayDates[i]);
     if (dt_today.getMonth() == dt_date.getMonth() && dt_today.getFullYear() == dt_date.getFullYear())
     {
       arr_Holidays[k] = dt_date.getDate();
       k+=1;
     }
   }
}

function boldatestr(dt_datetime)
{
	var dateStr="";
	var month = new Date(dt_datetime).getMonth() + 1;
    var monthStr ="";
    if(new Date(dt_datetime).getDate()<10)
        dateStr = "0"+ new Date(dt_datetime).getDate().toString();
    else
        dateStr = new Date(dt_datetime).getDate().toString(); 
    if(month<10)
        monthStr = "0"+ month.toString();
    else 
        monthStr = month.toString();
    
    
    return (new String (dateStr+"-"+(monthStr)+"-"+new Date(dt_datetime).getFullYear()+" "));
}


isValid = true;


// Function to convert the date type to string type in a required format.
function bolSetFormat (dt_datetime) 
{
    var dateStr="";
    var month = dt_datetime.getMonth()+1;
    var monthStr ="";
    if(dt_datetime.getDate()<10)
        dateStr = "0"+ dt_datetime.getDate().toString();
    else
        dateStr = dt_datetime.getDate().toString(); 
    if(month<10)
        monthStr = "0"+ month.toString();
    else 
        monthStr = month.toString();
    return (new String (monthStr+"/"+(dateStr)+"/"+dt_datetime.getFullYear()+" "));
}





function bolSetFieldFocus(field){
if(field!=null){
if(field.type!="hidden")field.focus();
}
}

// END Functions added by Kurt Mattes for Merged Site UI 2005


/* Start GDS Changes
 * Modified by: Sanjeewa
 */
function bolGetCookie(p_CookieName)
{

}

function bolSetCookie(p_Name, p_Value)
{
  document.cookie = p_Name + "=" + escape (p_Value);
}

/* End GDS Changes
 */
function bolPopupURL(aURL){
var newWin=window.open(aURL,"bol","directories=0,height=480,width=578,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=yes");
var agt=navigator.userAgent.toLowerCase(); 
if(!(agt.indexOf("msie")!=-1 && (parseInt(agt.substr(agt.indexOf("msie")+5,1))==4))){
newWin.focus();
}
}
function bolPopupURL2(aURL){
var newWin=window.open(aURL,"bol","directories=0,height=480,width=578,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
var agt=navigator.userAgent.toLowerCase(); 
if(!(agt.indexOf("msie")!=-1 && (parseInt(agt.substr(agt.indexOf("msie")+5,1))==4))){
newWin.focus();
}
}
function bolPopupURLClose(aURL){
winArray[winArray.length] = window.open(aURL,"bol","directories=0,height=480,width=578,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=yes");
var agt=navigator.userAgent.toLowerCase(); 
}
function bolCloseChildren()
{
	for(i=0;i<winArray.length;i++)
	{
		// check if window wasn't already closed 
		if (winArray[i] && !winArray[i].closed) 
		{	
		  winArray[i].close();
		}		
	}
	winArray.length = 0;
}
function bolBillPayPopup(aURL){
var newWin=window.open(aURL,"bol","directories=0,height=280,width=463,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
var agt=navigator.userAgent.toLowerCase(); 
if(!(agt.indexOf("msie")!=-1 && (parseInt(agt.substr(agt.indexOf("msie")+5,1))==4))){
newWin.focus();
}
}
function bolAdPopupURL(aURL){
var leftOffset=0;
var topOffset=0;
var popupwidth=800;
var popupheight=400;
if(screen.width){
if(screen.width>popupwidth){
leftOffset=((screen.width-popupwidth)/2);
}  
}
var newWin=window.open(aURL,"bol",'directories=0,left='+leftOffset+',top='+topOffset+',screenx='+leftOffset+',screeny='+topOffset+',height='+popupheight+',location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=yes,width='+popupwidth);
var agt=navigator.userAgent.toLowerCase(); 
if(!(agt.indexOf("msie")!=-1&&(parseInt(agt.substr(agt.indexOf("msie")+5,1))==4))){
newWin.focus();
}
}
function bolTONWPopupURL(bolObj,aURL){
if(bolObj.selectedIndex!=0){
var leftOffset=50;
var topOffset=30;
var popupwidth=795;
var popupheight=475;
bolObj.selectedIndex = 0;
if(screen.width){	
if(screen.width>popupwidth){	
leftOffset=((screen.width-popupwidth)/2);
}  
}
var newWin=window.open(aURL,"ICMLayout",'directories=0,left='+leftOffset+',top='+topOffset+',screenx='+leftOffset+',screeny='+topOffset+',height='+popupheight+',width='+popupwidth+',location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
var agt=navigator.userAgent.toLowerCase(); 
if(!(agt.indexOf("msie")!=-1&&(parseInt(agt.substr(agt.indexOf("msie")+5,1))==4))){	
newWin.focus();	
}
}
}
function bolSelAct(bolObj,bolIdx,bolUseFirstOption){
var bolOffLink=bolObj.options[bolObj.selectedIndex].value;
if(bolUseFirstOption=="true" || (bolUseFirstOption==null && bolObj.selectedIndex!=0)){
if(bolOffLink!="VisaDNDLink" && bolOffLink != "UALMilesPlusLink" && bolOffLink != "SONYREWARDS"){
if(bolIdx=='' || bolOffLink.indexOf("AcctIndex=")==-1){
eval("top.location='"+bolObj.options[bolObj.selectedIndex].value+"'");
}else{
eval("top.location='"+bolObj.options[bolObj.selectedIndex].value+bolIdx+"'");
}
}else{
if (bolOffLink =="UALMilesPlusLink")
{
bolOffSiteLink('UAL Miles Plus','http://mileageplusvisa.ualmiles.com/');	
}
else if (bolOffLink == "SONYREWARDS")
{
bolOffSiteLink('Sony Rewards','http://www.sony.com/sonycard/');	
}
else
{
var bolBrandGoto = "";
if (document.bolForm["bolBrand" + bolIdx] != null)
{
bolBrandGoto = document.bolForm["bolBrand" + bolIdx].value;
}
else
{
var cookieVal = document.cookie;
if ( (cookieVal.indexOf("bolBrand=")) + 0 == -1 )
bolBrandGoto = "";
var temp = cookieVal.substring(cookieVal.indexOf("bolBrand=")+ 9, cookieVal.length);
var offset = temp.indexOf(";");
if (offset + 0 == -1)
{
offset = temp.length;
}
bolBrandGoto = unescape(temp.substring(0, offset));
}
switch(bolBrandGoto)
{
case "BA":
bolOffSiteLink('Visa','http://www.usa.visa.com/personal/shopping/visa_special_offers/First_USA_British_Airways.jsp');
break;
case "AMAZON":
bolOffSiteLink('Visa','https://usa.visa.com/specialOffers/FUSA_Amazon/offers.jsp');
break;
case "AOL":
bolOffSiteLink('Visa','http://usa.visa.com/specialOffers/AOLVisaOffers/offers.jsp');
break;
case "CMSFI":
bolOffSiteLink('Visa','http://usa.visa.com/specialOffers/CMS/offers.jsp');
break;
case "CMS":
bolOffSiteLink('Visa','http://usa.visa.com/specialOffers/CMS/offers.jsp');
break;
case "FROST":
bolOffSiteLink('Visa','http://usa.visa.com/specialOffers/CMS/offers.jsp');
break;
case "YAHOO":
bolOffSiteLink('Visa','http://usa.visa.com/specialOffers/Yahoo/offers.jsp');
break;
case "NETBANK":
bolOffSiteLink('Visa','https://www.usa.visa.com/specialOffers/NetBankVisaOffers/offers.jsp');
break;
default:
bolOffSiteLink('Visa','https://www.usa.visa.com/specialOffers/BankOne/offers.jsp');
break;
}
}
bolObj.selectedIndex=0;
}
}
}
function bolOffSiteLink(gotoName,gotoURL){  
gotoName = escape(gotoName);
gotoURL = escape(gotoURL); 
var OffSitePopUpURL;
var leftOffset=0;
var topOffset=0;    
OffSitePopUpURL="/bolOffSiteLink.aspx"; 
if(screen.width){
if(screen.width < 800){
leftOffset=60;
topOffset=90;
}else{
if(screen.width>=800&&screen.width<1024){
leftOffset=160;
topOffset=134;
}else{
if(screen.width>=1024){
leftOffset=272;
topOffset=250;
}
}
}
}
var loadURL=OffSitePopUpURL+'?gotoName='+gotoName+'&gotoURL='+gotoURL;
var webLinkWin=window.open(loadURL,"view",'width=480,height=295,left='+leftOffset+',top='+topOffset+',screenx='+leftOffset+',screeny='+topOffset+',resizable=no,scrollbars=yes,menubar=no');
webLinkWin.focus();
}
function printPage()
{
  var pr =  (window.print) ? 1 : 0;

  if (pr)	//Browser is Internet Explorer 5 or Netscape 4
    window.print()
  else		//Browser is not Internet Explorer 5 nor is it Netscape 4
    alert("Sorry, your browser doesn't support this feature.");
}

function bolClientSelectionListIsNotValid(list) {
  var itemSelected = list.selectedIndex;
  if (list.options[itemSelected].value == "") {
    list.focus();
    return true;
  }
  return false;
}
function bolStrip(string,sChar){
if((string==null)||(string=="")){
return "";
}
var startIndex=bolIndexOfFirstNotIn(sChar,string);
var endIndex=bolIndexOfLastNotIn(sChar,string);
if(startIndex==-1){
return "";
}
return string.substring(startIndex,endIndex+1);
}
function bolIndexOfFirstNotIn(okayChars,inString){
var i;
for(i=0;i<inString.length;i++){
var charm=inString.charAt(i);
if(okayChars.indexOf(charm)==-1){
return i;
}
}
return -1;
}
function bolIndexOfLastNotIn(okayChars, inString) {
var i;
for (i = inString.length - 1; i >= 0; i--) {
var charm = inString.charAt(i);
if (okayChars.indexOf(charm) == -1) {
return i;
}
}
return -1;
}
function bolIsNumeric(number) {
number = number + "";
return ((number.length > 0) && bolIsComposedOfChars("0123456789", number));
}
function bolIsLetter(aChar) {
return ((aChar >= "a") && (aChar <= "z")) || ((aChar >= "A") && (aChar <= "Z"));
}
function bolIsComposedOfChars(validChars, inString) {
return bolIndexOfFirstNotIn(validChars, inString) == -1;
}
function bolIsValidDateRangeValues(date1, date2) {
  if ((date1 == "") && (date2 == "") || (date1 != "") && (date2 != "")) {
    return true;
  }
}
function bolIsValidDateFormat(dateField) {
  var dateString = bolStrip(dateField.value, " ");
  var newValue = bolIsValidDateFormatString(dateString);
  if (newValue != "") {
    dateField.value = newValue;
    return true;
  }
  return false;
}
function bolIsValidNotFutureDate(dateField) {
  return bolIsValidDateCompare(dateField, "<=");
}
function bolIsValidDateRange(date1, date2) {
    if ((date1 == "") && (date2 == "")) {
        return true;
    }
    formattedDate1 = bolIsValidDateFormatString(date1);
    if (formattedDate1 == "") {
        return false;
    }
    formattedDate2 = bolIsValidDateFormatString(date2);
    if (formattedDate2 == "") {
        return false;
    }
    date1compare = bolDateCompareString(date1);
    date2compare = bolDateCompareString(date2);
    return (date1compare <= date2compare);
}
function bolIsValidDateFormatString(dateStr) {
    if (typeof (dateStr) == "undefined") {
        return "";
    }
    var dateLen = dateStr.length;
    if ((bolIsNumeric(dateStr)) && (dateLen == 8)) {
        dateStr = dateStr.substring(0, 2) + "/" + dateStr.substring(2, 4) + "/" + dateStr.substring(4, 8);
        dateLen = dateStr.length;
    }
    if ((bolIsNumeric(dateStr)) && (dateLen == 6)) {
        dateStr = dateStr.substring(0, 2) + "/" + dateStr.substring(2, 4) + "/" + dateStr.substring(4, 6);
        dateLen = dateStr.length;
    }
    if (bolIsNumeric(dateStr)) {
        return "";
    }
    var spacerIndex = bolIndexOfFirstNotIn("0123456789", dateStr);
    var spacerChar = dateStr.charAt(spacerIndex);
    if (bolIsLetter(spacerChar)) {
        return "";
    }
    var firstSpacer = dateStr.indexOf(spacerChar);
    var secondSpacer = dateStr.lastIndexOf(spacerChar);
    var monthStr = dateStr.substring(0, firstSpacer);
    var dayStr = dateStr.substring(firstSpacer + 1, secondSpacer);
    var yearStr = dateStr.substring(secondSpacer + 1, dateLen);
    if ((!bolIsNumeric(monthStr)) || (!bolIsNumeric(dayStr)) || (!bolIsNumeric(yearStr))) {
        return "";
    }
    if (monthStr.length == 1) {
        monthStr = "0" + monthStr;
    }
    if (dayStr.length == 1) {
        dayStr = "0" + dayStr;
    }
    var month = parseInt(monthStr, 10);
    var day = parseInt(dayStr, 10);
    var year = parseInt(yearStr, 10);
    if (yearStr.length == 4) {
       var century = parseInt(yearStr.substring(0,2), 10);
       if (century == 0) {
          return "";
       }
       var YearFirstDigit = parseInt(yearStr.substring(0,1), 10);
       if (YearFirstDigit == 0) {
		  return "";
	   }	  	
    }
    if (yearStr.length == 2) {
        if (year > 71) {
            yearStr = "19" + yearStr;
        } else {
            yearStr = "20" + yearStr;
        }
    }
    if ((monthStr.length != 2) || (dayStr.length != 2) || (yearStr.length != 4)) {
        return "";
    }
    var daysInMonth = new Array(12);
    daysInMonth[1] = 31;
    daysInMonth[2] = 28;
    daysInMonth[3] = 31;
    daysInMonth[4] = 30;
    daysInMonth[5] = 31;
    daysInMonth[6] = 30;
    daysInMonth[7] = 31;
    daysInMonth[8] = 31;
    daysInMonth[9] = 30;
    daysInMonth[10] = 31;
    daysInMonth[11] = 30;
    daysInMonth[12] = 31;
    if ((((year % 4) == 0) && ((year % 100) != 0)) || ((year % 400) == 0)) {
        daysInMonth[2] = 29;
    }
    if ((month < 1) || (month > 12)) {
        return "";
    }
    if ((day < 1) || (day > daysInMonth[month])) {
        return "";
    }
    return (monthStr + "/" + dayStr + "/" + yearStr);
}
function bolIsValidDateCompare(dateField, operator) {
  if (!bolIsValidDateFormat(dateField)) {
    return false;
  }
  var givenDate = bolDateCompareString(dateField.value);
  var today = bolDateCompareString(bolGetTodayAsmmddyyyy());
  return eval("\"" + givenDate + "\"" + operator + "\"" + today + "\"");
}
function bolDateCompareString(dateString) {
  var month = dateString.substring(0, 2);
  var day = dateString.substring(3, 5);
  var year = dateString.substring(6, 10);
  return year + month + day;
}
function bolGetTodayAsmmddyyyy() {
  var todayDate = new Date();
  var today = (todayDate.getMonth() + 1) + "/" + todayDate.getDate() + "/" + bolGetFullYear(todayDate);
  return (bolIsValidDateFormatString(today));
}
function bolGetFullYear(dateObj) {
  var year = parseInt(dateObj.getYear(), 10);
  if (year < 1000) {
    year += 1900;
  }
  return year;
}
var isValid = false;
function bolValidateForm(form)
{
  if (isValid)
  {
    document.onSamePage = "YES";
    if (confirm('You have already submitted this transaction.\n\nIf you have clicked the Stop button on your browser, click "OK".\n\nIf you have not clicked the Stop button, click "Cancel".\n'))
    {
      if (null == document.onSamePage)
      {
        return false;
      }
      else
      {
        isValid = false;
        form.IsKnownDuplicate.value = "YES";
      }
    }
    else
    {
      return false;
    }
  }
  if (form.AcctIndex.value == "")
  {
    if (bolClientSelectionListIsNotValid(form.accountIndex))
    {
      alert("Please select an account.");
      form.accountIndex.focus();
      return false;
    }
  }
  if (!bolIsValidDateRangeValues(form.fromDate.value, form.toDate.value))
  {
    alert("You must specify a beginning and ending date, or leave both dates blank.");
    form.fromDate.select();
    form.fromDate.focus();
    return false;
  }
  if ( (form.fromDate.value != "") && (form.fromDate.value != null) )
  {
    if (!bolIsValidDateFormat(form.fromDate))
    {
      alert("Please specify a valid date.");
      form.fromDate.select();
      form.fromDate.focus();
      return false;
    }
  }
  if ( (form.fromDate.value != "") && (form.fromDate.value != null) )
  {
    if (!bolIsValidNotFutureDate(form.fromDate))
    {
      alert("The Beginning Date may not be in the future.");
      form.fromDate.select();
      form.fromDate.focus();
      return false;
    }
  }
  if ( (form.toDate.value != "") && (form.toDate.value != null) )
  {
    if (!bolIsValidDateFormat(form.toDate))
    {
      alert("Please specify a valid date.");
      form.toDate.select();
      form.toDate.focus();
      return false;
    }
  }
  if ( (form.toDate.value != "") && (form.toDate.value != null) )
  {
    if (!bolIsValidNotFutureDate(form.toDate))
    {
      alert("The date may not be in the future.");
      form.toDate.select();
      form.toDate.focus();
      return false;
    }
  }
  if (!bolIsValidDateRange(form.fromDate.value, form.toDate.value))
  {
    alert("Enter a Beginning Date that is before the Ending Date.");
    form.fromDate.select();
    form.fromDate.focus();
    return false;
  }
  if (bolClientSelectionListIsNotValid(form.downloadType)) {
    alert("Please choose a valid download type.");
    form.downloadType.focus();
    return false;
  } 
  isValid = true;
  return true;
}
function bolDownloadActionAndFocusField(field)
{
  field.focus();
}
function bolSubmitDownloadForm()
{
  if (document.DownloadForm == null)
  {
    setTimeout("bolSubmitDownloadForm()", 100);
    return;
  }
  document.DownloadForm.submit();
}

function bolDownload()
{
setTimeout("bolSubmitDownloadForm()", 100);
bolSubmitDownloadForm()
{
 document.bolDownloadForm.submit();
}
}
