//based on code from visionmonster.com
var o_navigator = navigator.userAgent.toLowerCase();
var isMacIE = (o_navigator.indexOf("msie 5")>-1&&o_navigator.indexOf("mac")>-1) ? 1 : 0;
var isPCIE = (o_navigator.indexOf("msie")>-1&&!isMacIE&&o_navigator.indexOf("opera")==-1) ? 1 : 0;
var isOpera = o_navigator.indexOf("opera")>-1 ? 1 : 0;
var mArray	= new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var dArray 	= new Array("Su","Mo","Tu","We","Th","Fr","Sa");
var datesArray 		= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var today 			= new Date();			//todays date
var cD 				= today.getDay();		//current day of week 0-6
var cT				= today.getDate();		//current day 1-31
var cM				= today.getMonth();		//current month 0-11
var cMDs 			= datesArray[cM];		//number of days in current month
var cY				= today.getFullYear();	//js method	not used here//current Year
var newT			= cT;					//cal selected date
var newM			= cM;					//cal selected month
var newY			= cY;					//cal selected year
var newDs			= cMDs;					//days for selected Month
var newD			= cD;					//day of week
var numCalendars	= 1;					//number of calendars you want to create
var calDirection	= "vertical";			//put "horizontal" or "vertical"
var calopen 		= 0;					//boolean set state of iframe "0" closed "1" open;
var o_windowparent  = top;					//set parent frame
var o_input 		= 0;
var o_month = 0; var o_date = 0;
var o_iframecal = 0;
var o_from;var o_to;var v_from;var v_to;
var d_makefrom=0; var d_maketo=0;var s_lang="us";
var o_currentDate = false;
var i_firstYear = cY; var i_firstMonth = cM;
var o_row = null;
var i_numcal = 0;
var o_calbody = 0; //where to write the calendar
var s_closecal = "<div class='calClose'><a href='#' onclick='top.closeCal();return false;'>close</a>Select a date:</div>";
var b_date331 = 0;
var a_input = 0;
var o_parent;
var s_inputtype = "object"; //for text input or select list input
var a_v_input = null; //calendar originating input fields
var from_input = null; //from input fields
var to_input = null; //to input fields
var calFormName;

var calType = "eventCal";
var inCat = "";

function findFirstDay(){
	firstDay = new Date();
	firstDay.setDate(1);
	firstDay.setMonth(newM);
	firstDay.setFullYear(newY);
	return firstDay.getDay();
}
function check331(d_date){
	i_date331 = Math.floor((d_date-today)/86400000);
	b_check331 = (i_date331>330) ? 1 : 0;
	return b_check331;
}
function vm_setupCal(){
	i_numcal = 0;
	vm_makeCal(cM);
}
function preventClose(evt){
	if(isOpera)evt.stopPropagation()
}

function ty_makeDate(which, addClass){
	d_makedate = new Date(newY,newM,which);
	b_date331 = check331(d_makedate);
	
	if((cT>which && cM == newM && cY == newY)||b_date331){
		s_makeDate = "<td class='calDateOff"+addClass+"'>";
		s_makeDate+= which;
	}else{
		if(d_makefrom||d_maketo){
			s_makeDate = ((d_makedate.toString()==d_makefrom.toString())||(d_makedate.toString()==d_maketo.toString())) ? "<td class='calDateSel"+addClass+"'>" : (d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom) ? "<td class='calDateRng"+addClass+"'>" : "<td class='calDate"+addClass+"'>";
		}else{
			s_makeDate = "<td class='calDate"+addClass+"'>";
		}
		
		if (calType == "eventCal"){
	        s_makeDate+= "<a href='/events/search?dt="+(newM+1)+"_"+which+"_"+newY+"&ed="+(newM+1)+"_"+which+"_"+newY+"&t="+inCat+"' class='calDateA'>";
	    }else{
		    s_makeDate+= "<a href='#' onclick='top.ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' class='calDateA'>";
		}
		s_makeDate+= which;
		s_makeDate+="</a>";
	
	}
	s_makeDate+="</td>\n";
	return s_makeDate;
}
function ty_maketr(what){
	s_tr = "<tr>\n";
	s_tr+= what;
	s_tr+= "</tr>\n";
	return s_tr;
}
function ty_changeMonths(which){
	i_numcal = 0;
	o_calbody.innerHTML ="";
	if(which < 1){
		which=11;
		newY--;
	}
	vm_makeCal(which);
}

function moveObjectX(e)
{
  var tempX = 0;	
  if (document.all) {
    tempX = event.clientX + document.body.scrollLeft;
  } else {
    tempX = e.pageX;
  }

  if (tempX < 0){tempX = 0}

return tempX;
}


function moveObjectY( e ) {


  var tempY = 0;
//  var offset = 5;

  if (document.all) {
    tempY = event.clientY + document.body.scrollTop;
  } else {
    tempY = e.pageY;
  }

  if (tempY < 0){tempY = 0}

  return tempY;
}

function vm_makeCal(whichMonth){
	o_cal= "";
	o_caltr="";o_caltd="";
	newM = whichMonth;
	if(newM < cM) newY = cY+1;
	if (newM>=12){
		newM=whichMonth-12;
		newY++;
	}
	//alert('test')
	if(i_numcal==0)i_firstMonth  = newM;
	newDs = datesArray[newM];
	//alert(newM);
	isLeap 	= (newY % 4 == 0 && (newY % 100 !=0 || newY % 400 ==0 )) ? 1:0
	if (newM==1) newDs=newDs+isLeap;
	newD = findFirstDay();
	countDay = newD;
	s_calclass = (calDirection=="vertical")? "calTableV" : "calTableH";
	o_cal+="<table month='"+newM+"' year='"+newY+"' cellpadding='0' cellspacing='0' border='0' class='"+s_calclass+"'>\n";
	/*
	o_caltr+= "<tr class='calRowHighlight'>\n";
	o_caltd+= "<td colspan='7' class='calLabel'>";
	o_caltd+= mArray[newM]+"&nbsp;"+newY;
	o_caltd+= "</td>";
	o_caltr+=o_caltd;
	o_caltr+="</tr>\n";
	o_cal+=o_caltr;
	o_caltd = "";
	o_caltr = "";
	*/
	/*
	for(i=0;i < dArray.length;i++){
		o_caltd+="<td class='calDayName'>";
		o_caltd+=dArray[i];
		o_caltd+="</td>\n";
	}*/
	o_caltr+= "<tr>\n";
	o_caltd+= "<td colspan='7' class='calRowDays'>";
	o_caltd+= "<img src='/images/layout/calendar/calendarDays.gif' style='display:block; ' />";
	o_caltd+= "</td>";
	o_caltr+=o_caltd;
	o_caltr+="</tr>\n";
	o_cal+=o_caltr;
	o_caltd = "";
	o_caltr="";
	
	o_caltr = ty_maketr(o_caltd);
	//o_cal+=o_caltr;
	o_caltd = "";
	i_calRows = 0;
	var caltdExtraClass="";
	for (d=1;d<=newDs;d++){
	    
		if(d==1){
		    for(bd=0;bd < newD;bd++){
		        switch(bd)
                    {
                    case 0:
                      caltdExtraClass = " calDateLeft"
                      break;    
                    case 6:
                      caltdExtraClass = " calDateRight"
                      break;
                    default:
                      caltdExtraClass = " calDateCenter"
                    }
                    (i_calRows<5)? caltdExtraClass += " calDateMiddle" : caltdExtraClass += " calDateBottom";
                    
		        o_caltd += "<td class='calDate"+caltdExtraClass+"'>&nbsp;</td>\n";
		    }
		}
		switch(countDay)
            {
            case 0:
              caltdExtraClass = " calDateLeft"
              break;    
            case 6:
              caltdExtraClass = " calDateRight"
              break;
            default:
              caltdExtraClass = " calDateCenter"
            }        
            (i_calRows<5)? caltdExtraClass += " calDateMiddle" : caltdExtraClass += " calDateBottom";
		o_caltd += ty_makeDate(d,caltdExtraClass);
		//alert(o_caltd);
		
		countDay++;
		if(countDay==7){
			countDay=0;
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;
			o_caltd = "";
			i_calRows++
		}
		if(d==newDs && countDay!=0){
		//alert(countDay);
			for (bd=countDay;bd < 7;bd++){
			    switch(bd)
                    {
                    case 0:
                      caltdExtraClass = " calDateLeft"
                      break;    
                    case 6:
                      caltdExtraClass = " calDateRight"
                      break;
                    default:
                      caltdExtraClass = " calDateCenter"
                    }
                    (i_calRows<5)? caltdExtraClass += " calDateMiddle" : caltdExtraClass += " calDateBottom";
			    o_caltd += "<td class='calDate"+caltdExtraClass+"'>&nbsp;</td>\n";
			    }
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;			
			o_caltd ="";
			i_calRows++
		}
	}
	if(i_calRows < 6){
		o_caltd = "";
		for(bd=0;bd < 7;bd++){
		    switch(bd)
                    {
                    case 0:
                      caltdExtraClass = " calDateLeft"
                      break;    
                    case 6:
                      caltdExtraClass = " calDateRight"
                      break;
                    default:
                      caltdExtraClass = " calDateCenter"
                    }
                    (i_calRows<5)? caltdExtraClass += " calDateMiddle" : caltdExtraClass += " calDateBottom";
		    o_caltd += "<td class='calDate"+caltdExtraClass+"'>&nbsp;</td>\n";
		    }
		o_caltr = ty_maketr(o_caltd);
		o_cal+= o_caltr;
	}
	//o_cal+="<tr><td colspan='7' style='text-align:left;'><div class='calMonthArea'>" + mArray[newM]+"&nbsp;"+newY + "</div></td></tr></table>";
	o_cal+="</table>";
	
	//o_calbody.innerHTML += (i_numcal==0) ? (newM==cM&&newY==cY) ? s_closecal+"<span class='calNavA'>&nbsp;</span>" : s_closecal+"<a href='#' onclick='top.ty_changeMonths("+i_firstMonth+"-1);top.preventClose(event);return false' class='calNavA'>previous month</a>" : "";
	var leftButton = (i_numcal==0) ? (newM==cM&&newY==cY) ? "" : "<a href='#' onclick='top.ty_changeMonths("+i_firstMonth+"-1);top.preventClose(event);return false' style='position:relative;'><img src='/images/layout/calendar/calendarMonthArrow_left.gif' /></a>" : "";
	var calHTML ="";
	calHTML += ""
	calHTML += o_cal;
	
	//alert(calHTML);
	i_numcal++;
	//if(i_numcal==numCalendars&&!(newM==cM-1)&&!b_date331)o_calbody.innerHTML+= "<a href='#' onclick='top.ty_changeMonths("+i_firstMonth+"+1);top.preventClose(event);return false;' class='calNavA'>next month</a>"
	var rightButton = "";
	if(i_numcal==numCalendars&&!(newM==cM-1)&&!b_date331) rightButton = "<a href='#' onclick='top.ty_changeMonths("+i_firstMonth+"+1);top.preventClose(event);return false;' style='position:relative;'><img src='/images/layout/calendar/calendarMonthArrow_right.gif' /></a>"
	calHTML += "<div class='calMonthArea'><img src='/images/layout/calendar/calendarMonthBG.png' style='position:absolute;' height='17' width='120' /><table cellpadding='0' cellspacing='0' border='0' style='position:relative;'><tr><td width='9'>"+leftButton+"</td><td width='102' style='text-align:center; vertical-align:top; padding-top:1px;'>" + mArray[newM]+"&nbsp;"+newY + "</td><td width='9'>"+rightButton+"</td></tr></table></div>"
	calHTML += "";
	//alert(calHTML);
	o_calbody.innerHTML=calHTML;
	//alert(o_calbody.innerHTML);
	if(i_numcal < numCalendars)vm_makeCal(newM+1);
	else if (i_firstMonth > newM){
		newY--;
	}
	
}
function ty_setDate(whatMonth,whatDate,whatTD,whatYear){
	o_currentDate = whatTD;
	o_currentDate.className = "calDateSel";
	//alert(a_v_input[0]);
	if(typeof(o_input)=="object"){
		o_input.value = (s_lang=="us") ? (whatMonth+1)+"/"+whatDate+"/"+whatYear : whatDate+"/"+(whatMonth+1)+"/"+whatYear;
	}else{
		top.document.getElementById(a_v_input[0]).value = whatMonth+1;
		top.document.getElementById(a_v_input[1]).value = whatDate;
		//alert(top.document.getElementById(a_v_input[1]).value);
		if (document.getElementById(a_v_input[2])){
			top.document.getElementById(a_v_input[2]).value = whatYear;
		}
		//if (top.document.getElementById(a_v_input[0]).value.length<2) top.document.getElementById(a_v_input[0]).value='0'+top.document.getElementById(a_v_input[0]).value;
		//if (top.document.getElementById(a_v_input[1]).value.length<2) top.document.getElementById(a_v_input[1]).value='0'+top.document.getElementById(a_v_input[1]).value;
		
		
		//set visible
		
		
		adjDate();
		
		document.getElementById(a_v_input[3]).value=document.getElementById(a_v_input[0]).value+" / "+document.getElementById(a_v_input[1]).value+" / "+document.getElementById(a_v_input[2]).value
  		//document.getElementById("toFullDate").value=document.getElementById(a_v_input[0]).value+"/"+document.getElementById(a_v_input[1]).value+"/"+document.getElementById(a_v_input[2]).value
  
	}
	closeCal();
}

function hideCalendar(){
	o_caldiv.style.display = "none";
	if(o_parent) o_parent.className = "cbrow";
}

function splitDate(s_input, s_mode){
	this.delimitor = (s_input.indexOf("/")>-1) ? "/" : (s_input.indexOf(".")>-1) ? "." : (s_input.indexOf("-")>-1) ? "-" : (s_input.indexOf(",")>-1) ? "," : "/";
	a_input = s_input.split(this.delimitor);
	//alert(s_input);
	this.date = -1;this.month = -1;this.year = -1;
	if(a_input.length==3&&!isNaN(a_input[0])&&!isNaN(a_input[1])&&!isNaN(a_input[2])){
		this.month = (s_mode=="us") ? parseInt(a_input[0],10) : parseInt(a_input[1],10);
		this.date = (s_mode=="us") ? parseInt(a_input[1],10) : parseInt(a_input[0],10);
		this.year = a_input[2];
		//alert(this.month);
		if(this.month>12||this.month<1)this.month=-1;
		if(this.date>31||this.month<1)this.date=-1;
		i_yrlength = this.year.toString().length;
		if(i_yrlength==2)this.year = "20"+this.year;//fix this in the next 96 years...
		if(i_yrlength<1||i_yrlength==3||this.year<cY)this.year=-1;
	}
}
var o_caldiv=0;var calopen=0;
var t_calcloser = null;
function buildDate(s_monthdate){
	a_monthdate = s_monthdate.split("|");
	bd_oMonth = document.getElementById(a_monthdate[0]);
	bd_oDate = document.getElementById(a_monthdate[1]);
	i_month = bd_oMonth.value; //+1;
	i_date = bd_oDate.value; //+1;
	s_date = "";
	s_date = i_month+"/"+i_date+"/";
	s_date+= (i_month < cM) ? cY+1 : cY;
	return s_date;
}

function makeEventCalendar(s_cal){
if(window.location.href.indexOf("/events/")!=-1){
    if(window.location.href.indexOf("theatre")!=-1){
        inCat="theatre";
    }else if(window.location.href.indexOf("music")!=-1){
        inCat="music";
    }else if(window.location.href.indexOf("dance")!=-1){
        inCat="dance";
    }else if(window.location.href.indexOf("museums")!=-1){
        inCat="museums";
    }else if(window.location.href.indexOf("visual-art")!=-1 || window.location.href.indexOf("visual_art")!=-1){
        inCat="visual_art";
    }else if(window.location.href.indexOf("science-nature")!=-1 || window.location.href.indexOf("science_nature")!=-1){
        inCat="science_nature";
    }else if(window.location.href.indexOf("film-literature")!=-1 || window.location.href.indexOf("film_literature")!=-1){
        inCat="film_literature";
    }else if(window.location.href.indexOf("poetry-literature")!=-1 || window.location.href.indexOf("poetry_literature")!=-1){
        inCat="poetry_literature";
    }else if(window.location.href.indexOf("film-video")!=-1 || window.location.href.indexOf("film_video")!=-1){
        inCat="film_video";
    }else if(window.location.href.indexOf("history-heritage")!=-1 || window.location.href.indexOf("history_heritage")!=-1){
        inCat="history_heritage";
    }else if(window.location.href.indexOf("sports")!=-1){
        inCat="sports";
    }else if(window.location.href.indexOf("kids-families")!=-1 || window.location.href.indexOf("kids_families")!=-1){
        inCat="kids_families";
    }else if(window.location.href.indexOf("festivals")!=-1){
        inCat="festivals";
    }else if(window.location.href.indexOf("free-events")!=-1 || window.location.href.indexOf("free_events")!=-1){
        inCat="free_events";
    }else{
        inCat="";
    }
}

    calType = "eventCal";
    o_calbody = document.getElementById(s_cal);
	o_calbody.innerHTML="";
	newY=cY;newM=cM;newD=cD;
	//alert(cM);
	vm_makeCal(cM);	
	
	
}

function makeCalendar(v_input,s_from,s_to,s_mode,s_cal){
	o_input = v_input;
	//alert(o_input.value);
	/*if(isPCIE){
		document.getElementById(s_cal).innerHTML="<iframe id=\"calframe\" src=\"javascript:'calendar'\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\"></iframe>"
		s_iecalcss = "<link rel='STYLESHEET' type='text/css' href='"+document.getElementById("calendarcss").href+"' />";
		o_califrame = document.getElementById("calframe")
		top.calframe.document.open();
		top.calframe.document.write("<html><head>"+s_iecalcss+"</head><body id='calbox' class='calendar'></body></html>");
		top.calframe.document.close();	
	}*/
	i_numcal = 0;
	//if(isPCIE)document.getElementById("calframe").className="calframe";
	//o_calbody = (isPCIE) ? top.calframe.document.getElementById(s_cal) : document.getElementById(s_cal);
	o_calbody = document.getElementById(s_cal);
	o_calbody.innerHTML="";
	o_udate = (typeof(o_input)=="object") ? new splitDate(o_input.value,'us') : new splitDate(buildDate(o_input),'us') ;
	a_from = s_from.split("|");
	v_from = (a_from.length==1) ? new splitDate(document.getElementById(s_from).value,s_mode) : new splitDate(buildDate(s_from),s_mode);
	a_to = s_to.split("|");
	//v_to = (a_to.length==2) ? new splitDate(buildDate(s_to),s_mode) : (document.getElementById(s_to)) ? new splitDate(document.getElementById(s_to).value,s_mode) : new splitDate("",s_mode);
	v_to = (a_to.length==1) ? new splitDate(document.getElementById(s_to).value,s_mode) : new splitDate(buildDate(s_to),s_mode);
	d_makefrom = (v_from.month!=-1) ? new Date(v_from.year,v_from.month-1,v_from.date) : 0;
	d_maketo = (v_to.month!=-1) ? new Date(v_to.year,v_to.month-1,v_to.date) : 0;
	
	//alert(d_makefrom + "  " + d_maketo);
	
	if(o_udate.month!=-1&&o_udate.year!=-1&&o_udate.date!=-1){
		newY=o_udate.year;
		newM=o_udate.month-1;
		newD=o_udate.date;
		vm_makeCal(o_udate.month-1);
	}else if(o_udate!=document.getElementById(s_from)&&d_makefrom){
		newY=v_from.year;
		newM=v_from.month-1;
		newD=v_from.date;
		vm_makeCal(v_from.month-1);
	}else if(o_udate!=document.getElementById(s_to)&&d_maketo){
		newY=v_to.year;
		newM=v_to.month-1;
		newD=v_to.date;
		vm_makeCal(v_to.month-1);	
	}else{
		newY=cY;newM=cM;newD=cD;
		vm_makeCal(cM);	
	}
}

function openCalRel(v_input,s_from,s_to,s_cal,s_parent,s_mode,s_caldir,s_class,e){
	// dynamically calculate the location of the div layer
	// then call the calendar and set the margin-top to this location
	// This will override the style sheet for margin-top.
	
	openCal(v_input,s_from,s_to,s_cal,s_parent,s_mode,s_caldir,s_class);	
}

function openCal(v_input,s_from,s_to,s_cal,s_parent,s_mode,s_caldir,s_class){
	calFormName = s_parent;
	if(o_parent) o_parent.className = "cbrow";//(s_inputtype=="object") ? "cbcalrow" : "cbrow"; 	
	clearTimeout(t_calcloser);
	s_inputtype = typeof(v_input);	
	//document.write('s_cal '+s_cal); 
	a_v_input = null;
	if(s_inputtype!="object") a_v_input = v_input.split("|");
	from_input = s_from.split("|");
	to_input = s_to.split("|");
	
	//document.getElementById(a_v_input[3]).style.backgroundColor='#FAF4DA';
	
	//document.write('a_v_input '+a_v_input); # frommonth, fromdate, etc.
	calopen = 0;
	o_caldiv = top.document.getElementById(s_cal);
	//alert(s_cal);
	//document.write('o_caldiv: '+typeof(o_caldiv)); # object
	o_caldiv.style.display = "block";
	//orig o_caldiv.className = "calboxon";
	o_caldiv.className = s_class;
	
	makeCalendar(v_input,s_from,s_to,s_mode,s_cal)
	//get objects
	o_inputright = (s_inputtype!="object") ?  document.getElementById(a_v_input[1]) : v_input;
	o_parent = document.getElementById(s_parent);
	o_cal = document.getElementById(s_cal);
	//o_parent.className+=" cbrowon";
	//i_calx = parseInt(o_inputright.offsetLeft)+parseInt(o_inputright.offsetWidth);
	//i_caly = parseInt(o_parent.offsetTop)+(parseInt(o_parent.offsetHeight)/2)-(parseInt(o_cal.offsetHeight)/2);
	//o_cal.style.top = (i_caly>0) ? i_caly+"px" : "0px";
	//o_cal.style.left = i_calx+"px";
	setTimeout("calopen = 1",500);	
}

function closeCal(){
//document.getElementById(a_v_input[3]).style.backgroundColor='#FFFFFF';
	if(o_caldiv&&calopen)t_calcloser = setTimeout("hideCalendar()",500);
	calopen=0;
}

// Moved from frontdoors.js
<!-- Adjustments for CB End Dates -->
 var b_stopBit = 0; // Setting to enable Date Increments
 
function adjDate(o_form) {

 if (b_stopBit == 0) {   
  // Set Variables
  var a_selectedForm;
  //var o_todays_date=new Date;  // Create new Date Object
  //var a_currentYear=o_todays_date.getFullYear(); // Get the current Year
  var indexParent = calFormName.indexOf('_');  	// get the index of "_" in the parent name
  var a_formPrefix = calFormName.substring(0,indexParent); // Obtain Prefix to use for element IDs
  var a_fromVal = document.getElementById(from_input[1]).value; // Form Value : From Date
  var a_fromMonth = document.getElementById(from_input[0]).value-1; // Form Value : From Month 
  var a_fromYear = document.getElementById(from_input[2]).value; // Form Value : From Year 
  var o_days = new Array(31, ((a_fromYear % 4 == 0 && a_fromYear % 100 != 0) || a_fromYear % 400 == 0 ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // Set the days for each month
  var a_dateDiff = 3; // Number of days to Increment
  
  
  
  // Check if they selected a date outside the Max Date
  if(a_fromVal > o_days[a_fromMonth]) {
   //document.getElementById(a_formPrefix+"_fromdate").options[eval(o_days[a_fromMonth] - 1)].selected=true; // Correct Date
   document.getElementById(from_input[1]).value=eval(o_days[a_fromMonth]); // Correct Date
   var a_fromVal = document.getElementById(from_input[1]).value; // Reset the from Date variable
  } 
  
  var o_selectedDate=new Date(a_fromYear,a_fromMonth,a_fromVal); // Create a Date Obj from dates selected
  var o_toDate = new Date(a_fromYear,a_fromMonth,parseInt(a_fromVal) + a_dateDiff);  //o_selectedDate.setDate(o_selectedDate.getDate() + a_dateDiff); // Increment the Date
 

  // Set the form fields
  
  
  //document.getElementById(a_formPrefix+"_tomonth").options[o_selectedDate.getMonth()].selected=true;
  //document.getElementById(a_formPrefix+"_todate").options[(o_selectedDate.getDate() - 1)].selected=true;
  //alert(a_formPrefix+"_tomonth");
  //alert(o_selectedDate.getMonth());
  //alert(o_selectedDate);
  //alert(a_fromVal + a_dateDiff);
  var new_toDate=o_toDate.getDate();
  var new_toMonth=o_toDate.getMonth()+1;
  var str_toDate=new_toDate.toString();
  var str_toMonth=new_toMonth.toString();
  //if (str_toDate.length<2) str_toDate='0'+str_toDate;
  //if (str_toMonth.length<2) str_toMonth='0'+str_toMonth;
  
  document.getElementById(to_input[1]).value=str_toDate;
  document.getElementById(to_input[0]).value=str_toMonth;
  document.getElementById(to_input[2]).value=o_toDate.getFullYear();
  //document.getElementById("fromFullDate").value=document.getElementById(a_formPrefix+"_frommonth").value+"/"+document.getElementById(a_formPrefix+"_fromdate").value+"/"+document.getElementById(a_formPrefix+"_fromyear").value
  document.getElementById(to_input[3]).value=document.getElementById(to_input[0]).value+" / "+document.getElementById(to_input[1]).value+" / "+document.getElementById(to_input[2]).value
  
  //alert(o_toDate.getFullYear());
 // alert(document.getElementById(a_formPrefix+"_tomonth").value+'/'+document.getElementById(a_formPrefix+"_todate").value);
  // Make sure all the Cannonball forms keep dates
/*  maintainState(document.getElementById(a_formPrefix+"_tomonth"));
  maintainState(document.getElementById(a_formPrefix+"_todate"));
  maintainState(document.getElementById(a_formPrefix+"_fromdate"));
  maintainState(document.getElementById(a_formPrefix+"_frommonth"));*/
  
  //Unset Variables
  var a_fromMonth;
  var a_fromVal;
  var a_currentYear;
  var selectedDate;
 }
}
function maintainState(o_input){
		a_bit = o_input.id.split("_");
		s_bit = a_bit[1];
		for(i=0;i<document.cbNav.nav.length;i++){
			a_formbit = document.cbNav.nav[i].value.split("form");
			s_formbit = a_formbit[1];
			o_formelement = document.getElementById(s_formbit+"_"+s_bit);	
			if(eval("document."+document.cbNav.nav[i].value)&&o_formelement!=o_input){
				if(o_formelement&&o_formelement!=o_input && o_input.type!="radio"){
					 if(o_formelement.type=="select-one" &&o_formelement.length>o_input.value)o_formelement.value=o_input.value 
					 else if(o_formelement.type==o_input.type)o_formelement.value=o_input.value;
				}else{
					a_input = eval("document."+document.cbNav.nav[i].value+"."+o_input.name);
					if(a_input) for(j=0;j<a_input.length;j++)if(a_input[j]!=o_input&&a_input[j].value==o_input.value)a_input[j].checked="checked";
				}
			}
		}
	}
// end of moved from frontdoors.js
// begin of moved from triggerParams.js
// No idea why we need this.  It doesn't do anything. lje - 03/04/2005 
function cppUrlPatch(s) {
	var translated = "";
	var i; 
	var found = 0;
	for(i = 0; (found = s.indexOf(':', found)) != -1; ) {
		translated += s.substring(i, found) + "|";
		i = found + 1;
		found++;
	}
	translated += s.substring(i, s.length);
	return translated;
}

var triggerParms = new Array();
// end of moved from triggerParams.js



//window.onclick=closeCal;
//window.document.onclick=closeCal;
