// check if the browser is Navigator 3 or higher:
agent = navigator.userAgent;
browserVer = 2;
if (agent.substring(0,7) == "Mozilla")
{
    if (parseInt(agent.substring(8,9)) >= 3) {
          browserVer = 1;
     }
}

// preload universal images:

if(browserVer == 1){

oneon = new Image(100,28);
oneoff = new Image(100,28);

twoon = new Image(100,28);
twooff = new Image(100,28);

threeon = new Image(100,28);
threeoff = new Image(100,28);

fouron = new Image(100,28);
fouroff = new Image(100,28);

fiveon = new Image(100,28);
fiveoff = new Image(100,28);

sixon = new Image(100,28);
sixoff = new Image(100,28);

sevenon = new Image(118,112);
sevenoff = new Image(118,112);

eighton = new Image(110,33);
eightoff = new Image(110,33);

nineon = new Image(110,33);
nineoff = new Image(110,33);

tenon = new Image(110,33);
tenoff = new Image(110,33);

elevenon = new Image(110,33);
elevenoff = new Image(110,33);

twelveon = new Image(110,33);
twelveoff = new Image(110,33);

thirteenon = new Image(110,33);
thirteenoff = new Image(110,33);

fourteenon = new Image(151,59);
fourteenoff = new Image(151,59);

fifteenon = new Image(151,59);
fifteenoff = new Image(151,59);

sixteenon = new Image(151,59);
sixteenoff = new Image(151,59);

seventeenon = new Image(151,59);
seventeenoff = new Image(151,59);

eighteenon = new Image(151,59);
eighteenoff = new Image(151,59);

nineteenon = new Image(151,59);
nineteenoff = new Image(151,59);

twentyon = new Image(151,59);
twentyoff = new Image(151,59);

twentyoneon = new Image(151,59);
twentyoneoff = new Image(151,59);

twentytwoon = new Image(151,59);
twentytwooff = new Image(151,59);

twentythreeon = new Image(151,59);
twentythreeoff = new Image(151,59);

twentyfouron = new Image(151,59);
twentyfouroff = new Image(151,59);

twentyfiveon = new Image(151,59);
twentyfiveoff = new Image(151,59);

twentysixon = new Image(151,59);
twentysixoff = new Image(151,59);

twentysevenon = new Image(151,59);
twentysevenoff = new Image(151,59);

oneon.src = "images/0nav_zendo_on.gif";
oneoff.src = "images/0nav_zendo_off.gif";

twoon.src = "images/0nav_ecards_on.gif";
twooff.src = "images/0nav_ecards_off.gif";

threeon.src = "images/0nav_tips_on.gif";
threeoff.src = "images/0nav_tips_off.gif";

fouron.src = "images/0nav_posters_on.gif";
fouroff.src = "images/0nav_posters_off.gif";

fiveon.src = "images/0nav_ontheway_on.gif";
fiveoff.src = "images/0nav_ontheway_off.gif";

sixon.src = "images/0nav_legends_on.gif";
sixoff.src = "images/0nav_legends_off.gif";

sevenon.src = "images/box_artist_on.jpg";
sevenoff.src = "images/box_artist_off.jpg";

eighton.src = "images/0nav_vnext_on.gif";
eightoff.src = "images/0nav_vnext_off.gif";

nineon.src = "images/0nav_cart_on.gif";
nineoff.src = "images/0nav_cart_off.gif";

tenon.src = "images/0nav_next2_on.gif";
tenoff.src = "images/0nav_next2_off.gif";

elevenon.src = "images/0nav_next2_on.gif";
elevenoff.src = "images/0nav_next2_off.gif";

twelveon.src = "images/0nav_cart_on.gif";
twelveoff.src = "images/0nav_cart_off.gif";

thirteenon.src = "images/0nav_custom_on.gif";
thirteenoff.src = "images/0nav_custom_off.gif";

fourteenon.src = "images/1stamp_on.gif";
fourteenoff.src = "images/1stamp_off.gif";

fifteenon.src = "images/zafu_on.gif";
fifteenoff.src = "images/zafu_off.gif";

sixteenon.src = "images/box_artist_on.jpg";
sixteenoff.src = "images/box_artist_off.jpg";

seventeenon.src = "images/0nav_gifts_on.gif";
seventeenoff.src = "images/0nav_gifts_off.gif";

eighteenon.src = "images/0nav_viewcards_on.gif";
eighteenoff.src = "images/0nav_viewcards_off.gif";

nineteenon.src = "images/0nav_viewcalendar_on.gif";
nineteenoff.src = "images/0nav_viewcalendar_off.gif";

twentyon.src = "images/0nav_25_on.gif";
twentyoff.src = "images/0nav_25_off.gif";

twentyoneon.src = "images/0nav_50_on.gif";
twentyoneoff.src = "images/0nav_50_off.gif";

twentytwoon.src = "images/0nav_100_on.gif";
twentytwooff.src = "images/0nav_100_off.gif";

twentythreeon.src = "images/0nav_5_on.jpg";
twentythreeoff.src = "images/0nav_5_off.jpg";

twentyfouron.src = "images/0nav_10_on.jpg";
twentyfouroff.src = "images/0nav_10_off.jpg";

twentyfiveon.src = "images/0nav_15_on.jpg";
twentyfiveoff.src = "images/0nav_15_off.jpg";

twentysixon.src = "images/0nav_20_on.jpg";
twentysixoff.src = "images/0nav_20_off.jpg";

twentysevenon.src = "images/0nav_quote_on.gif";
twentysevenoff.src = "images/0nav_quote_off.gif";

}

function press(imgName) {
    if (document.images)
      document[imgName].src = eval(imgName + 'on.src');  
}
function release(imgName) {
  if (document.images)
    document[imgName].src = eval(imgName + 'off.src');  
}

//works with the next function to get date string
function getCorrectedYear(year) {
  year = year - 0;
  if (year < 70) return (2000 + year);
  if (year < 1900) return (1900 + year);
  return year;
}

//function to get client date
function grabCDate() {
	var lmod = new Date();
	var monthname;
	var lmonth = lmod.getMonth();
	if (lmonth == 0) monthname = "January";
	if (lmonth == 1) monthname = "February";
	if (lmonth == 2) monthname = "March";
	if (lmonth == 3) monthname = "April";
	if (lmonth == 4) monthname = "May";
	if (lmonth == 5) monthname = "June";
	if (lmonth == 6) monthname = "July";
	if (lmonth == 7) monthname = "August";
	if (lmonth == 8) monthname = "September";
	if (lmonth == 9) monthname = "October";
	if (lmonth == 10) monthname = "November";
	if (lmonth == 11) monthname = "December";

	var yearstr = getCorrectedYear(lmod.getYear());
	var outstr = monthname + " " + lmod.getDate() + ", " + yearstr;
	return outstr;
}

//open pop wait screen
function showPop(sLoc) {
	pWin = window.open(sLoc,"pWin", "height=2,width=2,status=0,menubar=0,location=0,resizable=0,titlebar=0,scrollbars=1,top=0,left=0");
	pWin.resizeTo (430, 480);
	pWin.moveTo (xPos, yPos);
}


//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();

//function for returning how many months in selected year
function MonthsInYear(WhichYear)
{	
  var MonthsInYear = 12;
  if (WhichYear != NowYear)	MonthsInYear = 12;
  if (WhichYear == NowYear)	MonthsInYear = NowMonth;
  return MonthsInYear;
}

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "April" || WhichMonth == "June" || WhichMonth == "September" || WhichMonth == "November") DaysInMonth = 30;
  if (WhichMonth == "February" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "February" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available months in a year
function ChangeOptionMonths(Which)
{
var monthArray =  new Array("('January','',true,true)",
	"('February')",
	"('March')",
	"('April')",
	"('May')",
	"('June')",
	"('July')",
	"('August')",
	"('September')",
	"('October')",
	"('November')",
	"('December')");
	
  MonthObject = eval("document.Form1." + Which + "Month");
  YearObject = eval("document.Form1." + Which + "Year");
  
  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;
  CurYearIndex = eval(YearObject.selectedIndex);
   
  MonthsForThisSelection = MonthsInYear(Year);
  CurrentMonthsInSelection = MonthObject.length;
  
  for (i=0; i<(CurrentMonthsInSelection); i++)
  {
    MonthObject.options[MonthObject.options.length - 1] = null
  }
  
  if (Year == [NowYear])
  {
  	for (i=0; i<=([NowMonth]); i++) {
		eval("MonthObject.options[i]=" + "new Option" + monthArray[i]);
		//eval("monthObject.options[i].=" + i;
	}
  }
  else
  {
  	for (i=0; i<(MonthsForThisSelection); i++)
    {
      eval("MonthObject.options[i]=" + "new Option" + monthArray[i]);
    }
  }
 
    if (MonthObject.selectedIndex < 0) MonthObject.selectedIndex == 0;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.Form1." + Which + "Day");
  MonthObject = eval("document.Form1." + Which + "Month");
  YearObject = eval("document.Form1." + Which + "Year");
  
  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;
  CurMonthIndex = eval(MonthObject.selectedIndex);
  CurYearIndex = eval(YearObject.selectedIndex);
  
  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  
  for (i=0; i<(CurrentDaysInSelection); i++)
  {
    DaysObject.options[DaysObject.options.length - 1] = null
  }
  
  if (CurMonthIndex == [NowMonth] && Year == [NowYear])
  {
  	for (i=0; i<([NowDay]); i++)
	{
	  NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
	}
  }
  else
  {
  	for (i=0; i<(DaysForThisSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
 
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to first day available
function SetToFirst(Which)
{
  DaysObject = eval("document.Form1." + Which + "Day");
  MonthObject = eval("document.Form1." + Which + "Month");
  YearObject = eval("document.Form1." + Which + "Year");

  MonthObject[0].selected = true;
  DaysObject[0].selected = true;
  YearObject[0].selected = true;
}
