/// monthly_specs.js
//  v.12m - 
//  v.12w - email field added
//  v.19 for v.12z5
//  v.19b
//  v.21 version for 21 (re-design) based on v.19b
//  V.21b bug fixed : popup confirm stage (tellme and garage info)
//  v.21g2 - support of WWW domain JS/CSS/images added
//  v.21g2 - tax notice for MS and MS-mini
//  v.21m
//  v.21s4 -  further work on  monthly form First Last Name bug 
/*
'S e n d' button --> SendMonSpec() -> [ confirmMonSpecs() OR SubmitMonSpec() ]  -> doneMonSpecs()
                                        
*/
                                          
// XML_MONTHLYSPEC defined in index.php

var DEFAULT_CALL_TXT = "Specify your best time here";

var arrAllMonthlySpecials = Array(); // version 2: keeps all Titles/Subtitles/Specials

var arrMonthlySpecs = Array(); // old version, but also used in new for float
var arrMonthlyTitles = Array();
var arrAreaMonthSpecs = Array();

// keeps arrays of mon specs for the fetched areas, offset is corresponded to fetchedBounds offsets
var arrFetchedMonthSpecs = Array();

var arrCurrentMonthSpecs; // mon specs ids for the current area

var bMonSpecDisplay_mon = true; // keep state whether user open or hide MS win
var bMonSpecDisplay_day = false;

// keeps wether MS maximized
var bMaximizedMonthly = true;

// keep user info to fill monthly form
var userName = "";
var userNameL = "";
var userEmail = "";
var userPhone1 = "";
var userPhone2 = "";
var userPhone3 = "";
var userPhoneExt = "";

var userCall1 = true;
var userCall2 = true;
var userCall3 = true;
var userCall4 = true;

var userCallText = DEFAULT_CALL_TXT;


/////    Monthly Special Title object
function MonSpecTitle(id, descr)
{ //
this.id = id;
this.descr = descr;
this.subtitles = Array();
}

/////    Monthly Special SubTitle object
function MonSpecSubTitle(id, descr)
{ //
this.id = id;
this.descr = descr;
this.specials = Array();
}

/////    Monthly Special object
function MonSpec(id, rate, descr, descr2)
{ //
this.id = id;
this.rate = rate;
this.descr = descr;
this.descr2 = descr2;
//this.title_id = title_id;
}


////     parseXML_MonthlySpecs
function parseXML_MonthlySpecs(xmlDoc)
{
//alert("parseXML_Monthlpecs");
var ret_arrAreaMonSpec = Array();

var xmlMonSpecsElem = xmlDoc.documentElement.getElementsByTagName("MonthlySpecials")[0];

if(!xmlMonSpecsElem)return;

var xmlMonTitles = xmlMonSpecsElem.getElementsByTagName("MonthTitle");


     //// go through Titles 
     for(t=0 ; t < xmlMonTitles.length; t++)
     {
      
      var title_id = xmlMonTitles[t].getAttribute("id");
      var title_descr = xmlMonTitles[t].getAttribute("descr");
      
      
      arrMonthlyTitles[title_id] = title_descr;
      
     var xmlMonSpecs = xmlMonTitles[t].getElementsByTagName("MonthSpec");

     //// go through Monthly specs 
     for(s=0 ; s < xmlMonSpecs.length; s++)
     {
      var xmlMonSpec = xmlMonSpecs[s];
      
      var spec_id = xmlMonSpec.getAttribute("id");
      var rate = xmlMonSpec.getAttribute("rate");
      var descr = xmlMonSpec.getAttribute("descr");
      var descr2 = xmlMonSpec.getAttribute("descr2");
      
      
      var sort = xmlMonSpec.getAttribute("sort");
      
      arrMonthlySpecs[spec_id] = Array(rate, descr, descr2, sort, title_id);
      ret_arrAreaMonSpec[ret_arrAreaMonSpec.length] = spec_id;
     }

     } // end Titles

return ret_arrAreaMonSpec;
}

////     parseXML_MonthlySpecsVer2
function parseXML_MonthlySpecsVer2(xmlDoc)
{  // version 2  (Subtitles)

// MS_VERSION!=2 arrCurrentMonthSpecs arrFetchedMonthSpecs

//alert('parseXML_MonthlySpecsVer2');

var xmlMonSpecsElem = xmlDoc.documentElement.getElementsByTagName("MonthlySpecials")[0];

if(!xmlMonSpecsElem)return;

var xmlMonTitles = xmlMonSpecsElem.getElementsByTagName("MonthTitle");


     //// go through Titles 
     for(t=0 ; t < xmlMonTitles.length; t++)
     {
      
      var title_id = xmlMonTitles[t].getAttribute("id");
      var title_descr = xmlMonTitles[t].getAttribute("descr");
      
      arrAllMonthlySpecials[t] = new MonSpecTitle(title_id, title_descr);
      
      var xmlMonSubTitles = xmlMonTitles[t].getElementsByTagName("MonthSubTitle");
     
      //// go through Subtitles
      for(st=0 ; st < xmlMonSubTitles.length; st++)
      {

      var subtitle_id = xmlMonSubTitles[st].getAttribute("id");
      var subtitle_descr = xmlMonSubTitles[st].getAttribute("descr");
          
          arrAllMonthlySpecials[t].subtitles[st] =  
                new MonSpecSubTitle(subtitle_id, subtitle_descr);
     
          var xmlMonSpecs = xmlMonSubTitles[st].getElementsByTagName("MonthSpec");
     
          //// go through Monthly specs 
          for(s=0 ; s < xmlMonSpecs.length; s++)
          {
           loc_sp_arr = parseXML_MonthSpecElem(xmlMonSpecs[s]);
           var sp_id = loc_sp_arr[0];
           
          arrAllMonthlySpecials[t].subtitles[st].specials[s] =
           new MonSpec(loc_sp_arr[0], loc_sp_arr[1], loc_sp_arr[2], loc_sp_arr[3]);
          
          arrMonthlySpecs[sp_id] = Array(loc_sp_arr[1], loc_sp_arr[2], loc_sp_arr[3], 0, title_id); 
           
          }

     
      } // end SubTitles
     } // end Titles

//return ret_arrAreaMonSpec;
}


////     parseXML_MonthSpecElem
function parseXML_MonthSpecElem(xmlMonSpec)
{
      var spec_id = xmlMonSpec.getAttribute("id");
      var rate = xmlMonSpec.getAttribute("rate");
      var descr = xmlMonSpec.getAttribute("descr");
      var descr2 = xmlMonSpec.getAttribute("descr2");
     
      return Array(spec_id, rate, descr, descr2);

}



////     DisplayMonSpec
function DisplayMonSpec()
{ // positions Monthly Specials window on the map
  // displays and  populates the MS window

if(!parking_isMonthly && !MS_DISPLAY_DA)return; // not display for Daily, if MS_DISPLAY_DA not set

if(MS_VERSION==1 && arrCurrentMonthSpecs.length == 0)return;
if(MS_VERSION==2 && arrAllMonthlySpecials.length == 0)return;
  
   PositionExpWin("month_sp");
   
   PopulateMonSpec();
}



////     PopulateMonSpec
function PopulateMonSpec()
{ // combines contains and display it in MS window

GetElement("month_sp_sendbtn_inner").innerHTML = 'Send';
GetElement("month_sp_closebtn_inner").innerHTML =  'Close';
GetElement("month_sp_sendbtn").style.width = '84px';
GetElement("month_sp_closebtn").style.width = '84px';

GetElement("month_sp_closebtn").className = 'mb_btn';

if(MS_VERSION==2)
GetElement("month_sp_sendbtn").className = 'mb_btn';  /*_dis*/
else if(MS_VERSION==3)
GetElement("month_sp_sendbtn").className = 'mb_btn';

var strContents = '';

   //if(CITY_TAX)
   if(MS_TAX_NOTICE != "")
   strContents += '<center><span style="font-size:16px;color:#811010;padding-top:12px;">' + MS_TAX_NOTICE + '</span></center>';
  

 if(MS_VERSION==2)
 {
 var arrCont = combineContentsVer2();
 var addDispl = ' style="display:none;"';
 }
 else
 {
 var arrCont = combineContents();
 var addDispl = '';
 }

var strTableContents = arrCont[0];
var min_rate = arrCont[1];


 if(MS_VERSION==2)
 {
 strContents += '<div id="ms_instr" ' + 'style="">'+
                  flashContents_1 +
                  '</div>';
 }
 else
 {                 
 strContents += '<div id="ms_instr" ' + 'style="">'+
                  '1) Make One or More Choices Below<br>' +
                  '2) Enter Contact Information &amp; Click <span>Send</span>'  +
                  '</div>';                  
 }                 


strContents += '<table class="plain srch" cellspacing="0"><tr><td><img src="' + PATH_IMG + 'images/pop_yellow_tl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_tr.gif"></td></tr>';
strContents += '<tr><td></td><td><center>';

strContents += strTableContents;

strContents += '</center></td></td><td></tr>';
strContents += '<tr><td><img src="' + PATH_IMG + 'images/pop_yellow_bl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/pop_yellow_br.gif"></td></tr>';
strContents += '</table>';

strContents += '<div><img src="' + PATH_IMG + 'images/blank.gif" height="6px"></div>';


strContents += '<table id="ms_monfrm_area"' + addDispl + ' class="plain yellowff5" cellspacing="0"><tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_tl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_tr.gif"></td></tr>';


if(MS_VERSION==2)
strContents += '<tr id="contactTr" style="display:none;">';
else
strContents += '<tr>';

strContents += '<td></td><td class="contactme">';
strContents += '<input type="checkbox" name="monspec" value="0" checked>Contact Me About Other Deals</td><td></td></tr>';


strContents += '<tr><td></td><td>';
strContents += '<div id="month_sp_form"><center><table class="monthform" border="0" cellspacing="0" cellpadding="0" style="padding-top:2px;">';
strContents += '<tr><td style="width:80px;"><nobr>&nbsp;&nbsp;First Name:</nobr></td>';
strContents += '<td><input id="usrname" type="text" class="txt" value="' + userName + '" size="15"></td></tr>';

strContents += '<tr><td>&nbsp;&nbsp;Last Name:</td>';
strContents += '<td><input id="usrnamel" type="text" class="txt" value="' + userNameL + '" size="15"></td></tr>';

strContents += '<tr><td>&nbsp;&nbsp;Email: </td>';
strContents += '<td style="padding-right:0px;"><input id="usremail" type="text" class="txt" value="' + userEmail + '" style="width:187px;"></td></tr>';

strContents += '<tr><td style="padding-bottom:3px;">&nbsp;&nbsp;Phone:</td><td><nobr>';

strContents += 
'(<input type="text" class="txt" id="phone1" style="width:38px;" value="' + userPhone1 + '" size="2" MAXLENGTH="3"  onKeyUp="check_phone(this, 1);">)';
strContents += 
'&nbsp;<input type="text" class="txt" id="phone2" style="width:38px;" value="' + userPhone2 + '" size="2" MAXLENGTH="3" onKeyUp="check_phone(this, 2);">';
strContents += 
'-&nbsp;<input type="text" class="txt" style="width:43px;" id="phone3" value="' + userPhone3 + '" size="3" MAXLENGTH="4"  onKeyUp="check_phone(this, 3);">';
strContents += 
'&nbsp;ext.&nbsp;<input type="text" class="txt" id="phone4" value="' + userPhoneExt + '" style="width:53px;" size="4" MAXLENGTH="6">&nbsp;';
strContents += '</nobr></td></tr>';

strContents += '<tr><td colspan="2"><nobr style="color:#000!important;font-size:12px!important;font-weight:normal!important;">&nbsp;&nbsp;(Companies often ignore requests with fake phone nos.)</nobr></td></tr>';


strContents += '<tr><td colspan="2" style="padding-top:7px!important;">&nbsp;&nbsp;Best Time To Call:</td></tr>';



strContents += '<tr><td colspan="2" style="padding-bottom:3px;">';

strContents += '<center><table class="plain calltbl" cellspacing="0">';

strContents += '<tr><td><input type="checkbox" id="call1" ';
if(userCall1)strContents += 'checked';
strContents += '>&nbsp;Morning Mon-Fri</td>';
strContents += '<td><input type="checkbox" id="call3" ';
if(userCall3)strContents += 'checked';
strContents += '><nobr>&nbsp;Evening Mon-Fri</nobr></td></tr>';

strContents += '<tr><td><input type="checkbox" id="call2" ';
if(userCall2)strContents += 'checked';
strContents += '><nobr>&nbsp;Afternoon Mon-Fri</nobr></td>';

strContents += '<td><input type="checkbox" id="call4" ';
if(userCall4)strContents += 'checked';
strContents += '>&nbsp;Sat-Sun</td></tr>';

strContents += '<tr><td colspan="2">';
strContents += '<u>or</u>&nbsp;&nbsp;<input type="text" ';

if(userCallText==DEFAULT_CALL_TXT)strContents += 'class="callgray txt" ';

strContents += 'id="calltext" style="width:230px" onfocus="SetCallText(this);" value="'; 

strContents += userCallText;
strContents += '">'; 
strContents += '</td></tr>';
strContents += '</table></center>';

strContents += '</td></tr></table></center></div>';

strContents += '</td></td><td></tr>';
strContents += '<tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_bl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_br.gif"></td></tr>';
strContents += '</table>';



// set content
GetElement("month_sp_frame").innerHTML = strContents;

//if(MS_VERSION==1)
//min_rate = formatChargeNulls(min_rate);

    var contents_min = 'From $' + min_rate;
    
    if(MS_TAX_NOTICE != "")
    {
    if(MS_TAX_NOTICE.indexOf("Not")> -1)
    contents_min += '&nbsp;(+tax)';
    else
    contents_min += '&nbsp;(tax incl)';
    }

GetElement("month_sp_frame_min").innerHTML = contents_min;

bMonthFrmDisplayResult = false;

GetElement("month_sp").style.height = "";
  
b1st = 1;

 if(MS_VERSION==2)
  return arrAllMonthlySpecials.length;
 else
  return arrCurrentMonthSpecs.length;

}

var flashContents_1 = 'Click One or More <img src="' + PATH_IMG + 'images/plus21.gif" style="margin-bottom:-2px;"> Titles Below<br>To View Rates/Locations & Submit Inquiry';

var flashContents_2 = '1) Make One or More Choices Below<br>2) Enter Contact Information &amp; Click <span>Send<span>';


///////  combineContentsVer2
function combineContentsVer2()
{
// combines content of MS specials table
// different for old (version 1) and new (version 2)

 strContents = '<center>';
                  
 /*strContents += '<div id="flick11" class="flickon11" ' +
                  'style="margin:0px 1px 0px 1px;text-align:left;">'+
                  flashContents_1 +
                  '</div>'; */
                  

strContents += '<table id="monspctbl" class="monspctbl" style="/*border:1px solid #f00;*/" border="0" cellspacing="0" cellpadding="1">';

var min_rate = 999999;
var curr_title = 0;

for(t=0 ; t < arrAllMonthlySpecials.length; t++)
{
var min_title_rate = 999999;

var oTitle = arrAllMonthlySpecials[t];

var title_id = t;  // just id in arrAllMonthlySpecials array used for all elements Ids
var title_descr = oTitle.descr;
var arrSubtitles = oTitle.subtitles;

 
// title line
strContents += '<tr onClick="DisplaySpecRows(' + title_id + ');" onmouseover="this.className=\'mtitle mtitlesel\'" onmouseout="this.className=\'mtitle\'">';

strContents += '<td colspan="1" class="mtitle" style="padding-left:4px;padding-top:2px;">';

strContents += '<img id="img' + title_id + '" src="' + PATH_IMG + 'images/plus21.gif"></td>';

strContents += '<td class="mtitle" width="100%" style="color:#22506d;">&nbsp;&nbsp;' + title_descr;
         
strContents += '&nbsp;<span style="font-size:12px;">(from $<$$$' + title_id + '>)<span>';

         
strContents += '</td></tr><tr id="montr'+ title_id + '" ><td class="pad"></td><td>';

strContents += '<table border="0" cellspacing="0" cellpadding="1">';         


     /// subtitle 
     //for(var sub_id in arrSubtitles)
     for(st=0 ; st < arrSubtitles.length; st++)
     {
     
     var oSub = arrSubtitles[st];
     var subtitle_id = oSub.id; // 
     var sub_id = st; // just id in subtitles array used for all elements Ids
     var sub_descr = oSub.descr;
     var arrSpecs = oSub.specials;
     
     if(subtitle_id != 0)
     {
     strContents += '<tr><td colspan="2" class="mtitle" onClick="DisplaySpecRow(' + sub_id + ', \'s' + title_id + '_' + '\');" onmouseover="this.className=\'mtitle mtitlesel\'" onmouseout="this.className=\'mtitle\'">';
     
     strContents += '<img id="imgs' + title_id + '_' + sub_id + '" src="' + PATH_IMG + 'images/plus21.gif" style="margin-bottom:-1px;">';
     
     strContents += '&nbsp;&nbsp;' + sub_descr;         
              
     strContents += '</td></tr><tr id="montrs' + title_id + '_' + sub_id + '" style="display:none;"><td class="pad">&nbsp;</td><td>';     
     }
     else
     { // subtiyle id = 0, so it's 'root' sibtitle and no subtitle to display above specials
      
      strContents += '<tr id="montrs' + title_id + '_' + sub_id + '" style="display:none;">';
      strContents += '<td colspan="2" style="/*border:1px solid #0f0;*/">'; 
      strContents += '<img id="imgs' + + title_id + '_' + sub_id + '" src="' + PATH_IMG + 'images/plus21.gif" style="margin-bottom:-1px;display:none;">';
     }     
    
    
     // table for specials
     strContents += '<table border="0" cellspacing="0" cellpadding="0">';     
     
     /// Specials 
     //for(var spec_id in arrSpecs)
     for(s=0 ; s < arrSpecs.length; s++)
     {
     
     var oSpec = arrSpecs[s];
     var loc_rate = oSpec.rate;
     var loc_descr = oSpec.descr;
     var loc_spec_id = oSpec.id; // specials use Spec ID for elements Ids (and spec checkbox)
         
     loc_descr = loc_descr.replace(/&lt;/g, "<");
     loc_descr = loc_descr.replace(/&gt;/g, ">");          
          
     var loc_descr2 =  '<span id="monsp' + loc_spec_id + '" class="tax" style="display:none;"><nobr>' + 
                       oSpec.descr2 + '</nobr></span>';
          
     min_rate = Math.min(min_rate, loc_rate);
     min_title_rate = Math.min(min_title_rate, loc_rate);           
     
     
     strContents += 
     '<tr onmousemove="FloatMonth(' + loc_spec_id + ', 1);" onmouseout="FloatMonth(' + loc_spec_id + ', 0);"><td><input type="checkbox" class="check" name="monspec" value="' + loc_spec_id + '" onClick=""></td>';

     strContents += '<td id="monsptd' + loc_spec_id + '" ><nobr>$' + loc_rate; 
     
     if(CITY_TAX_APP)
     strContents += '<span class="tax">+tax</span>';
     
     strContents += ': ' + loc_descr + '</nobr>';
     
     strContents += loc_descr2 + '</td></tr>';
          
     strContents += loc_descr2;  

     }   
          
     strContents += '</table></td></tr>';     
     }


strContents = strContents.replace('<$$$' + title_id + '>', min_title_rate);

strContents += '</table></td></tr>';
          
}

strContents += '</table>';

return Array(strContents, min_rate);
}




///////  combineContents
function combineContents()
{
// combines content of MS specials table
// different for old (version 1) and new (version 2)

strContents = '<center>';
 /*
 strContents += '<div id="flick11" class="flickon11" ' +
                  'style="margin:0px 1px 0px 1px;text-align:left;">'+
                  '(1) Make One or More Choices Below<br>' +
                  '(2) Enter Contact Information &amp; Click "Send"'  +
                  '</div>';
 */

strContents += '<table id="monspctbl" class="monspctbl" border="0" cellspacing="0" cellpadding="1">';

var min_rate = 999999;
var curr_title = 0;

for(var n = 0; n < arrCurrentMonthSpecs.length; n++)
{

var loc_spec_id = arrCurrentMonthSpecs[n];
var loc_spec = arrMonthlySpecs[loc_spec_id];
var loc_title = loc_spec[4];

// insert title
if(curr_title != loc_title && MS_VERSION!=3)
{
// pervious table needed to be closed
if(curr_title != 0)
{
strContents += '</table></td></tr>';
}

curr_title = loc_title;

// title line
strContents += '<tr><td colspan="2" class="mtitle" onClick="DisplaySpecRow(' + loc_title + ');" onmouseover="this.className=\'mtitle mtitlesel\'" onmouseout="this.className=\'mtitle\'">';

strContents += '&nbsp;<img id="img' + loc_title + '" src="' + PATH_IMG + 'images/minus21.gif" style="margin-bottom:-1px;">';

strContents += '&nbsp;&nbsp;' + arrMonthlyTitles[loc_title];         
         
strContents += '</td></tr><tr id="montr'+ loc_title + '" ><td class="pad">&nbsp;</td><td>';

// specs container
strContents += '<table border="0" cellspacing="0" cellpadding="1" style="/*border:1px solid #f00;*/">';         
          
}



var loc_descr = loc_spec[1];
var loc_descr2 =  '<span id="monsp' + loc_spec_id + '" class="tax" style="display:none;"><nobr>' + loc_spec[2] + '</nobr></span>';

loc_descr = loc_descr.replace(/&lt;/g, "<");
loc_descr = loc_descr.replace(/&gt;/g, ">");

loc_rate = loc_spec[0];

min_rate = Math.min(min_rate, loc_rate); 

strContents += 
'<tr onmousemove="FloatMonth(' + loc_spec_id + ', 1);" onmouseout="FloatMonth(' + loc_spec_id + ', 0);"><td><input type="checkbox" class="check" name="monspec" value="' + loc_spec_id + '" onClick="/*DisplaySpecLines(' + loc_spec_id + ', this);*/"></td>';

strContents += '<td id="monsptd' + loc_spec_id + '" ><nobr>$' + loc_rate; 

if(CITY_TAX_APP)
strContents += '<span class="tax">+tax</span>';

strContents += ' ' + loc_descr + '</nobr>';

strContents += loc_descr2 + '</td></tr>';

}

if(MS_VERSION!=3)
strContents += '</table></td></tr>';


strContents += '</table>';

return Array(strContents, min_rate);
}



var bMonthFrmDisplayResult = false;

////     doneMonSpecs
function doneMonSpecs()
{

var strContents =  '';

strContents += '<table class="plain yellowff5" cellspacing="0"><tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_tl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_tr.gif"></td></tr>';
strContents += '<tr><td></td><td style="padding:7px 0;font-size:14px!important;"><center>';

strContents +=  "<center>Your request has been successfully submitted.<br>";

strContents += '<div id="flick11" class="flickon11" style="margin:0.5em 0;">' +
'<nobr>Please respond promptly to parking company voicemails.</nobr></div>';

strContents += 
'<table class="plain"><tr><td style="text-align:left;"><a href="javascript:;" onClick="window.open(\'/monthly\');return false;"  style="color:#0000b5">Click Here - Parking Companies Will Also Compete<br>' +
'For Your Business With Discounted Customized Bids</a></td></tr></table></b></center>';

strContents += '</center></td></td><td></tr>';
strContents += '<tr><td><img src="' + PATH_IMG + 'images/mon_frm_yel_bl.gif"></td>';
strContents += '<td width="100%"></td><td width="8"><img src="' + PATH_IMG + 'images/mon_frm_yel_br.gif"></td></tr>';
strContents += '</table>';


///
GetElement("month_sp_frame").innerHTML = strContents;

bMonthFrmDisplayResult = true;
        
GetElement("month_sp_closebtn_inner").innerHTML =  'No Thanks';

GetElement("month_sp_sendbtn").style.width = '84px';
GetElement("month_sp_closebtn").style.width = '84px';

GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61;

try
{
window.scrollTo(0, parseInt(GetElement("month_sp").style.top));
}
catch(e){};

}



////      check_phone
function  check_phone(obj, phone)
{ // forbid entering non-digit signs into number fields
          
          var contents = obj.value;
          var re = /[^0-9]/ig;
          //if(phone)re = /[^0-9 -]/ig;
          obj.value = contents.replace(re, "");
         
          if(phone)
          { // for phone fields, it move focus to next field
          // calc id

          var re = /([0-9]+)$/ig;
          var id_part = obj.id.replace(re, "");
          
          var letcount = 3;
          if(phone == 3) letcount = 4;
          
          if(obj.value.length == letcount)
          var newid = id_part + (parseInt(phone)+1);
          
          if(GetElement(newid))
          GetElement(newid).focus();
          }
          
          return true;

}


////      CloseMonWin
function  CloseMonWin()
{

if(GetElement("month_sp_closebtn").innerHTML.indexOf('Cancel Request')>=0)
{
bMonthFrmDisplayResult = true;
};

DisplayElem("month_sp", "none");
DisplayElem("month_float", "none");

}

///      DisplaySpecRow
function DisplaySpecRow(num, sub)
{// the function opens all specials for the certain subtitle (version 2) or title (version 1)
 // num is index of title/subtitle, sub is additional for id (version 2)


if(!sub)sub = '';

var oRow = GetElement("montr" + sub + num);
if(!oRow)return; 
 
 if(oRow.style.display == "none")
 {
 if(globJSBrowser=="Firefox" || globJSBrowser=="Chrome" || globJSBrowser=="Safari")
 oRow.style.display = "table-row";
 else
 oRow.style.display = "block";
 GetElement("img" + sub + num).src = PATH_IMG + "images/minus21.gif";
 viewType = 2;
 }
 else
 {
 oRow.style.display = "none";
 GetElement("img" + sub + num).src = PATH_IMG + "images/plus21.gif";
 }
 
GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61;

if(sub != '')
{
CheckSubtitles(sub, num);
viewType = CheckTitles();
setView(viewType);
}

GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61;
 
}
////     DisplaySpecRows
function DisplaySpecRows(num)
{ // MS function, version 2
  // the function opens all subtitles for the title
  // num  is title id in arrAllMonthlySpecials
     
var viewType = 0;
      
var oRow = GetElement("montr" + num);
if(!oRow)return; 
               
var expand = (GetElement("img"+ num).src.indexOf('plus') > -1);
    
if(expand)
{
     if(globJSBrowser=="Firefox" || globJSBrowser=="Chrome" || globJSBrowser=="Safari")
      var newDisplay = "table-row";
     else
      var newDisplay = "block";
      var newImg = PATH_IMG + "images/minus21.gif";
viewType = 2;      
}
else
{
var newDisplay = "none";
var newImg = PATH_IMG + "images/plus21.gif";

viewType = 1;
}
      
for(var subt in arrAllMonthlySpecials[num].subtitles)
{ 
 GetElement("montrs" + num + "_" + subt).style.display = newDisplay;
 GetElement("imgs" + num + "_" + subt).src = newImg;
}
 
GetElement("img" + num).src = newImg;

if(viewType == 1) viewType = CheckTitles();
setView(viewType);
                    
GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61; // 62

}

////     setView
function setView(viewType)
{ // version 2;
// set view for specials (1) if all closed; (2) if any open 

if(viewType == 1)
{
DisplayElem("ms_monfrm_area", "none");
GetElement("ms_instr").innerHTML = flashContents_1;
DisplayElem("contactTr",'none');
GetElement("month_sp_sendbtn").className = 'mb_btn_dis';
}

if(viewType == 2)
{
DisplayElem("ms_monfrm_area", "block");
GetElement("ms_instr").innerHTML = flashContents_2;

if(globJSBrowser=="Firefox" || globJSBrowser=="Chrome" || globJSBrowser=="Safari")
 DisplayElem("contactTr", 'table-row');
 else
 DisplayElem("contactTr", 'block');


GetElement("month_sp_sendbtn").className = 'mb_btn';
}

}


////     CheckTitles
function CheckTitles()
{ // check all of subtitles closed or some expanded
  // to set MS view

for(var t in arrAllMonthlySpecials)
{
     for(var st in arrAllMonthlySpecials[t].subtitles)
     {
     if(GetElement("imgs"+ t + "_" + st).src.indexOf('minus') > -1)
     return 2;
     }
}
return 1;
}


////     CheckSubtitles
function CheckSubtitles(sub, num)
{ // check whether all subtitles of the num title expanded/closed
  // num is subtitle id

//alert("CheckSubtitles " + sub + " " + num);

var t_id = sub.replace("s", "");
t_id = t_id.replace("_", "");

var allPlus = true;
var allMinus = true;

for(var subt in arrAllMonthlySpecials[t_id].subtitles)
{

if(GetElement("montr" +  sub + subt).style.display == 'none')
allMinus = false;
else
allPlus = false;
} 
                                                   
if(allMinus)
GetElement("img" + t_id).src = PATH_IMG + 'images/minus21.gif';
else if(allPlus)
GetElement("img" + t_id).src = PATH_IMG + 'images/plus21.gif';

}

 

////     DisplaySpecLines
function DisplaySpecLines(num, oCheck)
{
var oRow = GetElement("monsp" + num);
if(!oRow)return; 
 
  if(oCheck.checked)
  {
  oRow.style.display = "block";
  }
  else
  {
  oRow.style.display = "none";
  }

GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61; // 62
 
}



var b1st = 1;

////     SetMSDimentions
function SetMSDimentions()
{

if(b1st)
{ 
GetElement("monspctbl").style.width =
GetElement("monspctbl").offsetWidth;
} 


GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61; // 58 


b1st = 0;
}


/// create mini window
document.write('<table id="month_sp_min" class="exp_win_mini do_not_print_imp" cellspacing="0" ' +
' onClick="if(bMonthFrmDisplayResult)PopulateMonSpec();Expand(this);SetMSDimentions();"" style="display:none;" title="Click to open">' +
'<tr><td class="top" width="100%">Monthly Specials</td></tr>' +
'<tr><td  id="month_sp_frame_min" class="bottom"></td></tr>' +
'</table>');


var addStyle = '';

// create expanded window
///CreateMonthSpPopup("month_sp", "CloseMonWin();", 330);

CreateStandardPopup("month_sp", "CloseMonWin();", 330, 'SendMonSpecPop(0);');

document.getElementById("month_sp").style.zIndex = 3004;
document.getElementById("month_sp_head").innerHTML  = '<b>' + MS_WIN_HEADING + '</b>';
document.getElementById("month_sp_cont").innerHTML = '<div id="month_sp_frame"></div>';



////     OutputMonthlyForm
function OutputMonthlyForm(garid, isClick, place)
{ // the function  called from getDetailHTML (garagesX.js )
  // to display the form in garage popup on Monthly page


var isPartner = garages[garid].partner2;

var strAddId = "";
if(!isClick)strAddId = "f";

var strAddList = ""; // whether the form on list popup
if(place==3) strAddList = "l";

strAddId =  strAddList + strAddId;

strContents = '<div class="space" style="height:8px;"></div>';
strContents += '<div class="dotted_blue_dark" style="height:10px;"></div>';

strContents += '<center id="monthformpop' + strAddId + '"><table class="monthform" border="0" cellspacing="0" cellpadding="0">';

var loc_width = 172;

if(isPartner)
{strContents += '<tr><td colspan="4" style="padding-bottom:7px!important;"><center><input type="checkbox" id="tellme_pop' + strAddId + '" checked> Also Tell Me About Deals at Other Nearby Garages</center></td></tr>';
loc_width = 158;}
  
strContents += '<tr><td width=5%>&nbsp;</td><td style="width:90px;"><nobr>&nbsp;&nbsp;First Name:&nbsp;</nobr></td>';
strContents += '<td><input id="usrname_pop' + strAddId + '" type="text" class="txt" size="15" value="' + userName + '"></td><td width=5%>&nbsp;</td></tr>';

strContents += '<tr><td width=5%>&nbsp;</td><td><nobr>&nbsp;&nbsp;Last Name:&nbsp;</nobr></td>';
strContents += '<td><input id="usrnamel_pop' + strAddId + '" type="text" class="txt" size="15" value="' + userNameL + '"></td><td width=5%>&nbsp;</td></tr>';

strContents += '<tr><td width=5%>&nbsp;</td><td>&nbsp;&nbsp;Email:</td>';
strContents += '<td><input id="usremail_pop' + strAddId + '" type="text" class="txt style="width:' + loc_width + 'px;" value="' + userEmail + '"></td><td width=5%>&nbsp;</td></tr>';

strContents += '<tr><td width=5%>&nbsp;</td><td style="padding-bottom:3px;"><nobr>&nbsp;&nbsp;Phone:</td><td>';

strContents += 
'(<input type="text" id="phone_pop' + strAddId + '1" style="width:38px;" class="txt" value="' + userPhone1 + '" size="2" MAXLENGTH="3"  onKeyUp="check_phone(this, 1);">)';
strContents += 
'&nbsp;<input type="text" id="phone_pop' + strAddId + '2" style="width:38px;" class="txt" value="' + userPhone2 + '" size="2" MAXLENGTH="3" onKeyUp="check_phone(this, 2);">';
strContents += 
'-&nbsp;<input type="text" style="width:43px;" id="phone_pop' + strAddId + '3" class="txt" value="' + userPhone3 + '" size="3" MAXLENGTH="4"  onKeyUp="check_phone(this, 3);">';
strContents += 
'&nbsp;ext.&nbsp;<input type="text" id="phone_pop' + strAddId + '4" class="txt" value="' + userPhoneExt + '" style="width:53px;" size="4" MAXLENGTH="6">&nbsp;</nobr>';
strContents += '<input type="hidden" id="garage_pop' + strAddId + '" class="txt" value="' + garid + '"></td><td width=5%>&nbsp;</td></tr>';


strContents += '<tr><td width=5%>&nbsp;</td><td colspan="2"><nobr style="color:#000!important;font-size:12px!important;font-weight:normal!important;">&nbsp;&nbsp;(Companies often ignore requests with fake phone nos.)</nobr></td><td width=5%>&nbsp;</td></tr>';


strContents += '<tr><td width=5%>&nbsp;</td><td colspan="2" style="padding-top:7px!important;">&nbsp;&nbsp;Best Time To Call:</td><td width=5%>&nbsp;</td></tr>';

strContents += '<tr><td width=5%>&nbsp;</td><td></td><td>';


strContents += '<table class="plain calltbl" cellspacing="0">';

strContents += '<tr><td><input type="checkbox" id="call_pop' + strAddId + '1" ';
if(userCall1)strContents += 'checked';
strContents += '>&nbsp;Morning Mon-Fri</td>';

strContents += '<td><input type="checkbox" id="call_pop' + strAddId + '3" '; 
if(userCall3)strContents += 'checked';
strContents += '><nobr>&nbsp;Evening Mon-Fri</nobr></td></tr>';

strContents += '<tr><td><input type="checkbox" id="call_pop' + strAddId + '2" ';
if(userCall2)strContents += 'checked';
strContents += '><nobr>&nbsp;Afternoon Mon-Fri</nobr></td>';

strContents += '<td><input type="checkbox" id="call_pop' + strAddId + '4" ';
if(userCall4)strContents += 'checked';
strContents += '>&nbsp;Sat-Sun</td></tr>';

strContents += '<tr><td colspan="2"><nobr>';
strContents += '<u>or</u>&nbsp;&nbsp;<input ';

if(userCallText==DEFAULT_CALL_TXT)strContents += 'class="callgray txt" ';

strContents += ' id="calltext_pop' + strAddId + '" style="width:230px" onfocus="SetCallText(this);" value="' + userCallText + '">'; 

strContents += '</nobr></td></tr>';
strContents += '</table>';

strContents += '</td><td width=5%>&nbsp;</td></tr>';

strContents += '</table></center>';

//alert(strContents);

return strContents;

}


var globURL_start = null;
var globURL_call = null;
var globURL_pop = "";

////     SendMonSpecPop
function SendMonSpecPop(place)
{
// called when user click Send from garage MS or popup monthly form

//alert("SendMonSpecPop: place " + place);

var strAddList = ""; // whether the form on list popup
   
if(place==1 || place==2) strAddList = "_pop";
if(place==3) strAddList = "_popl";

      
if(place==0)
var sendMSbtn = document.getElementById("month_sp_sendbtn" + strAddList); 
else
var sendMSbtn = document.getElementById("sendms_btn" + strAddList);  /**/

if(sendMSbtn.className == "mb_btn_dis")return;

var fromConfirm =(sendMSbtn.innerHTML.indexOf('Confirm') > -1);


var fname = trim(document.getElementById("usrname" + strAddList).value);
var lname = trim(document.getElementById("usrnamel" + strAddList).value);
var email = trim(document.getElementById("usremail" + strAddList).value);

var fname_2 = trim(document.getElementById("usrname" + strAddList).value);
var lname_2 = trim(document.getElementById("usrnamel" + strAddList).value);
var email_2 = trim(document.getElementById("usremail" + strAddList).value);

var phone1 = trim(document.getElementById("phone" + strAddList + "1").value);
var phone2 = trim(document.getElementById("phone" + strAddList + "2").value);            
var phone3 = trim(document.getElementById("phone" + strAddList + "3").value);

var phone1_2 = trim(document.getElementById("phone" + strAddList + "1").value);
var phone2_2 = trim(document.getElementById("phone" + strAddList + "2").value);            
var phone3_2 = trim(document.getElementById("phone" + strAddList + "3").value);

var phone_ext = trim(document.getElementById("phone" + strAddList + "4").value);

     var str_specs = "";
     
     if(place == 0) // if MS
     {
               var col_checks = document.getElementsByName("monspec");
               
               for(var i=0; i<col_checks.length; i++)
               {
               if(col_checks[i].checked)
               str_specs += col_checks[i].value + " ";
               }
     
          if(
          str_specs == ""
          ||
          (MS_VERSION==2 && document.getElementById("contactTr").style.display == 'none')
          )
          {
          alert("Select Monthly Special!");
           return false; // not send the form
          }
     
     str_specs = "&ids=" + str_specs;
     }


   if(!fromConfirm)  // no call fields on confirm step
   {
    
    // Best Time to Call
   var call1 = 0; var call2 = 0;
   var call3 = 0; var call4 = 0;
   
   if(document.getElementById("call" + strAddList + "1").checked)call1 = 1; 
   if(document.getElementById("call" + strAddList + "2").checked)call2 = 1; 
   if(document.getElementById("call" + strAddList + "3").checked)call3 = 1; 
   if(document.getElementById("call" + strAddList + "4").checked)call4 = 1;
   
   var calltext = trim(document.getElementById("calltext" + strAddList).value);
   var calltxt = calltext;
    
   if(calltxt == DEFAULT_CALL_TXT)calltxt = "";
   
   var call = "&call=" + call1 + "_" + call2 + "_" + call3 + "_" + call4;
   calltxt = "&calltxt=" + escape(calltxt);

   }


 // save user info
 saveUserInfo(fname_2, lname_2, email_2, phone1_2, phone2_2, phone3_2, phone_ext, call1, call2, call3, call4, calltext);
  
  var checkStr = "";
  
  // checks names and phone fields filled
  if(fname == "")
  checkStr += "\nFirst Name";
 
  if(lname == "")
  checkStr += "\nLast Name";

  if(fname == "" || lname == "")
  {   
  jserror(7, place + " :s " + strAddList + 
  " :n " + document.getElementById("usrname" + strAddList).value + 
  " :nl " + document.getElementById("usrnamel" + strAddList).value); 
  }
  
  if(email == "")
  checkStr += "\nEmail";
  else if(email.indexOf("@") ==-1)
  checkStr += "\nEmail: invalid format"; 
 
 
  if(phone1 == ""
  || phone2 == ""
  || phone3 == ""
  )
  checkStr += "\nPhone";
 
    
  if(checkStr != "")
  {
  alert("Fields must be filled:" + checkStr);
  return false; // not send the form
  }
  


  var phone = "(" +  phone1 + ") " +  phone2  +  "-" + phone3;
  if(phone_ext!="")phone += " ext. " + phone_ext;
  
  
   ////////    info from pop
  
   if(!fromConfirm && place != 0) // if pop
   {
   str_tellme = '&tell=0';
   
   if(document.getElementById("tellme" + strAddList))
   if(document.getElementById("tellme" + strAddList).checked)
   str_tellme = '&tell=1';
   
   var gar_id = trim(document.getElementById("garage" + strAddList).value);
   str_gar_id = "&garid=" + gar_id;
   
   var chrg = garages[gar_id].getMonthlyRate(VEHICLE_REGULAR);
   addRate = "&rate=" + chrg;
   
   globURL_pop = str_gar_id +  addRate + str_tellme;
   
   }    

   if(place == 0)globURL_pop = '';

      var addDaMo = "";
         
      if(place == 0) // MS
      {
      if(parking_isMonthly)
        addDaMo = "&mod=monthly";
      else
        addDaMo = "&mod=daily";    
      }
      else     // pop
      {
      addDaMo = "&mod=monthlypop";
      }
      
       var url_start = XML_MONTHLYSPEC + "?fname=" + escape(fname) + 
                 "&lname=" + escape(lname) + 
                 "&email=" + escape(email) + 
                 "&phone=" + escape(phone) + 
                 globURL_pop + 
                 str_specs +
                 addDaMo;
                 
       //alert("url_start\n" + url_start);
       
       if(!fromConfirm)
       var url_call = call + calltxt;
  
       globURL_start = url_start;
      
       if(!fromConfirm)
       globURL_call = url_call;  
  
  
  if(userInfoNew && !fromConfirm)
  { // display Confirm only if user info updated
       
       if(place == 0)
       confirmMonSpecs();
       else
       confirmMonSpecsPop();

  }
  else
  {
       if(place == 0)
       SubmitMonSpec();
       else
       SubmitMonSpecPop();  
  }

}


////     SubmitMonSpec
function SubmitMonSpec()
{
// submits data to server after data confirm

     userInfoNew = false;
     
     var loc_url = globURL_start + globURL_call;
     
     var xmlDoc = getXML(loc_url, doneMonSpecs);
     
     globURL_start = globURL_call = null;
     
     bMonthFrmDisplayResult = true;
     
     GetElement("month_sp_sendbtn").className = 'mb_btn_dis';
     
     GetElement("month_sp_closebtn_inner").innerHTML = 
     'Close';
     
     

}

////     SubmitMonSpecPop
function SubmitMonSpecPop()
{
// submits data to server after data confirm
     
     userInfoNew = false;
    
     var loc_url = globURL_start + globURL_call;
     
    GetElement("debug_div").value = '/' + globURL_start + globURL_call;
    
    //alert("SubmitMonSpecPop\n" + loc_url); 
    
     var xmlDoc = getXML(loc_url, doneMonSpecsPop, true);
     
     globURL_start = globURL_call = null;
     globURL_pop = '';
     
     if(GetElement("sendms_btn_pop"))
     {
     //DisplayElem("sendms_btn_pop", "hidden");
     GetElement("sendms_btn_pop").className = 'mb_btn_dis';

     GetElement("close_btn_pop_inner").innerHTML = 
     'Close';
     }
     
     if(GetElement("sendms_btn_popl"))
     {
      //DisplayElem("sendms_btn_popl", "hidden");
     GetElement("sendms_btn_popl").className = 'mb_btn_dis';
      
     GetElement("close_btn_popl_inner").innerHTML = 
     'Close';
     }


}


////     doneMonSpecsPop
function doneMonSpecsPop()
{
// monthly request from garage popup done

//alert('doneMonSpecsPop');

var strContents1 = '<table><tr><td style="font-size:13px;"><center><span style="color:#000000;">Your request has been successfully submitted.</span></center>';

strContents1 += '<div id="flick';

var strContents2 = '" class="flickon12">' +
'Please respond promptly to parking company voicemails.</div></td></tr></table>';

if(GetElement("monthformpop"))
{
GetElement("sendms_btn_pop").className = 'mb_btn_dis';
GetElement("monthformpop").innerHTML = 
strContents1 + "12" + strContents2;
}

if(GetElement("monthformpopl"))
{
GetElement("sendms_btn_popl").className = 'mb_btn_dis';
GetElement("monthformpopl").innerHTML = 
strContents1 + "13" + strContents2 ;
}

} 

 ////     confirmMonSpecs
function confirmMonSpecs()
{
//

//alert("confirmMonSpecs");
 
var strContents = '<center>';

strContents += '<div style="color:#811010;font-size:14px;padding:5px 0;"><nobr>Please Confirm Accuracy of Contact Information</nobr></div>';

strContents += '<table class="monthform" cellspacing=0 style="margin-top:3px;color:#000000;">';

strContents += '<tr><td>Name:</td>';
strContents += '<td><input id="usrname" type="text" class="txt" name="usrname" value="' + userName + '" size="15">&nbsp;&nbsp;';

//strContents += '<tr><td>&nbsp;&nbsp;Last Name:</td>';
strContents += '<input id="usrnamel" type="text" class="txt" name="usrnamel" value="' + userNameL + '" size="15"></td></tr>';

strContents += '<tr><td>Email: </td>';
strContents += '<td style="padding-right:0px;"><input id="usremail" type="text" class="txt" name="usremail" value="' + userEmail + '" style="width:232px;"></td></tr>';

strContents += '<tr><td style="padding-bottom:3px;">Phone:&nbsp;&nbsp;</td>';

strContents += 
'<td>(<input type="text" class="txt" id="phone1" style="width:38px;" value="' + userPhone1 + '" size="2" MAXLENGTH="3"  onKeyUp="check_phone(this, 1);">)';
strContents += 
'&nbsp;<input type="text" class="txt" id="phone2" style="width:38px;" value="' + userPhone2 + '" size="2" MAXLENGTH="3" onKeyUp="check_phone(this, 2);">';
strContents += 
'-&nbsp;<input type="text" class="txt" style="width:43px;" id="phone3" value="' + userPhone3 + '" size="3" MAXLENGTH="4"  onKeyUp="check_phone(this, 3);">';
strContents += 
'&nbsp;ext.&nbsp;<input type="text" class="txt" id="phone4" value="' + userPhoneExt + '" style="width:53px;" size="4" MAXLENGTH="6">&nbsp;';
strContents += '</td></tr>';


strContents += '</table></div></center><br>';


GetElement("month_sp_form").innerHTML = 
strContents;

GetElement("month_sp_sendbtn").style.width = '124px';
GetElement("month_sp_closebtn").style.width = '124px';

GetElement("month_sp_sendbtn_inner").innerHTML = 
'Confirm';
GetElement("month_sp_closebtn_inner").innerHTML = 
'Cancel Request';
                 
// set MS height
GetElement("month_sp").style.height = 
parseInt(GetElement("month_sp_frame").offsetHeight) + 61; // 58

//alert(GetElement("month_sp").style.top);
/*try
{
window.scrollTo(0, parseInt(GetElement("month_sp").style.top));
}
catch(e){};
*/
}

////     confirmMonSpecsPop
function confirmMonSpecsPop()
{
//

//alert("confirmMonSpecsPop");
 
var strContents = '<div>'; 

strContents += '<div style="color:#811010;font-size:13px;padding-bottom:5px;"><nobr>Please Confirm Accuracy of Contact Information</nobr></div>';

strContents += '<table class="monthform" cellspacing=0 style="margin-top:3px;color:#000000;">';

strContents += '<tr><td>Name:</td>';
strContents += '<td><input type="text" class="txt" id="usrname_pop$ADD$" name="usrname_pop$ADD$" value="' + userName + '" size="15">&nbsp;&nbsp;';

strContents += '<input id="usrnamel_pop$ADD$" type="text" class="txt" name="usrnamel_pop$ADD$" value="' + userNameL + '" size="15"></td></tr>';

strContents += '<tr><td>Email: </td>';
strContents += '<td style="padding-right:3px;"><input id="usremail_pop$ADD$" type="text" class="txt" name="usremail_pop$ADD$" value="' + userEmail + '" style="width:100%;"></td></tr>';

strContents += '<tr><td style="padding-bottom:3px;">Phone:&nbsp;&nbsp;</td>';

strContents += 
'<td>(<input type="text" class="txt" id="phone_pop$ADD$1" style="width:38px;" value="' + userPhone1 + '" size="2" MAXLENGTH="3"  onKeyUp="check_phone(this, 1);">)';
strContents += 
'&nbsp;<input type="text" class="txt" id="phone_pop$ADD$2" style="width:38px;" value="' + userPhone2 + '" size="2" MAXLENGTH="3" onKeyUp="check_phone(this, 2);">';
strContents += 
'-&nbsp;<input type="text" class="txt" style="width:43px;" id="phone_pop$ADD$3" value="' + userPhone3 + '" size="3" MAXLENGTH="4"  onKeyUp="check_phone(this, 3);">';
strContents += 
'&nbsp;ext.&nbsp;<input type="text" class="txt" id="phone_pop$ADD$4" value="' + userPhoneExt + '" style="width:53px;" size="4" MAXLENGTH="6">&nbsp;';
strContents += '</td></tr>';


strContents += '</table></div>';

var strContents_0 = strContents.replace(/(\$ADD\$)/g, "");
var strContents_l = strContents.replace(/(\$ADD\$)/g, "l");

//alert(strContents_0 + "\n\n\n" + strContents_l);


if(GetElement("monthformpop"))
GetElement("monthformpop").innerHTML = 
strContents_0;

if(GetElement("monthformpopl"))
GetElement("monthformpopl").innerHTML = 
strContents_l;

if(GetElement("sendms_btn_pop"))
{
GetElement("sendms_btn_pop_inner").innerHTML = 
'Confirm';
GetElement("close_btn_pop_inner").innerHTML = 
'Cancel Request';
}

if(GetElement("sendms_btn_popl"))
{
GetElement("sendms_btn_popl_inner").innerHTML = 
'Confirm';
GetElement("close_btn_popl_inner").innerHTML = 
'Cancel Request';
}

}

var userInfoNew = false;

////     doneMonSpecsPop
function saveUserInfo(f_name, l_name, e_mail, phone_1, phone_2, phone_3, phone_ext, call1, call2, call3, call4, calltxt)
{

try
{

if(userName != f_name || userNameL != l_name || userEmail != e_mail
|| 
userPhone1 != phone_1 || 
userPhone2 != phone_2 ||  
userPhone3 != phone_3 ||  
userPhoneExt != phone_ext 
) userInfoNew = true;


// saves user info to fill mothly form next time
userName = f_name;
userNameL = l_name;
userEmail = e_mail;

userPhone1 = phone_1;
userPhone2 = phone_2;
userPhone3 = phone_3;
userPhoneExt = phone_ext;

//alert("call1 " + typeof(call1));

if(typeof(call1) != 'undefined')
{  // Confirm not include call flds
userCall1 = call1;
userCall2 = call2;
userCall3 = call3;
userCall4 = call4;
userCallText = calltxt;
}

// fill MS

if(bMonthFrmDisplayResult) return;

// set value to MS (if savinf is from pop/general

GetElement("usrname").value = f_name;
GetElement("usrnamel").value = l_name;

GetElement("usremail").value = e_mail;

GetElement("phone1").value = phone_1;
GetElement("phone2").value = phone_2;            
GetElement("phone3").value = phone_3;

GetElement("phone4").value = phone_ext;

if(typeof(call1) != 'undefined')
{ 
GetElement("call1").checked = call1;
GetElement("call2").checked = call2;
GetElement("call3").checked = call3;
GetElement("call4").checked = call4;

GetElement("calltext").value = calltxt;

if(calltxt != DEFAULT_CALL_TXT)
GetElement("calltext").className = '';
}


}
catch(e){jserror(6, e.description);};

}

// create floating
document.write(
'<table id="month_float" class="plain" cellspacing="0" style="display:none;">' +
'<tr><td><img src="' + PATH_IMG + 'images/month_float_tl.gif"></td>' +
'<td class="top" width="100%"></td>' +
'<td><img src="' + PATH_IMG + 'images/month_float_tr.gif"></td></tr>' +
'<tr><td class="top"></td><td id="month_float_top" class="top"></td><td class="top"></td></tr>' +
'<tr><td class="bottom"></td><td id="month_float_bottom" class="bottom"></td><td class="bottom"></td></tr>' +
'<tr><td><img src="' + PATH_IMG + 'images/month_float_bl.gif"></td>' +
'<td class="bottom" width="100%"></td>' +
'<td><img src="' + PATH_IMG + 'images/month_float_br.gif"></td></tr>' +
'</table>'
);


//       FloatMonth
function FloatMonth(month_id, bShow)
{ // floating element for 2nd, 3rd line of monthly special in MS

//alert(month_id + " " + bShow);

var oTD = GetElement("monsptd" + month_id);
var oFloat = GetElement("month_float");
//var oFloatTD = GetElement("month_float_td");

if(!bShow)
{
oTD.className = '';
oFloat.style.display = 'none';
return;
}


var loc_spec = arrMonthlySpecs[month_id];

var strContentsFloat_top = '<nobr>$' + loc_spec[0];
if(CITY_TAX_APP)
strContentsFloat_top += '<span class="tax">+tax</span>';

if(MS_VERSION==2)strContentsFloat_top += ':' ;

strContentsFloat_top += ' ' + loc_spec[1] + '</nobr>';

var strContentsFloat_bottom = "<nobr>"  + loc_spec[2] + "</nobr>";

GetElement("month_float_top").innerHTML  = strContentsFloat_top;
GetElement("month_float_bottom").innerHTML  = strContentsFloat_bottom;

oFloat.style.display = 'block';

var oInput = GetElement("monsp" + month_id);

var pos = getAbsolutePositionOf(oTD);


oFloat.style.left = parseInt(pos[0]) + 2;
oFloat.style.top = parseInt(pos[1]) + 20;

oTD.className = 'float_high';

//alert(strCont);

}



////     SetCallText
function SetCallText(oInput)
{
// set text for Best Time To Call
if(oInput.className.indexOf("callgray") >-1)
oInput.value = "";
oInput.className = "txt";
}

////     formatChargeNulls
function formatChargeNulls(str)
{
try{
str = String(str);
if(str.match(/\.\d$/))str += "0";
if(!str.match(/\./))str += ".00";
}catch(e) {}
return str;
}

