// set this to true for military time:
var military = true;

var am = true;
var dividervisible = false;

function rand(start, end)
{
 var range = end-start;
 var out = parseInt(parseFloat(Math.random()*range+start));
 if (out==end) out--;
 return (out);
}

// result: Thu Sep 11 2003 01:17:55 GMT-0700

function setflashclock() {
	var rightnow = new Date();
	var ie = navigator.appName.indexOf("Microsoft") != -1; 
	var clockmovie = (ie ? window.homeembed :  window.document.homeembed); 
	clockmovie.SetVariable ("fulldate", rightnow);
	setTimeout ("setflashclock();", 500);
}

var rightnow = new Date();
var dayte = rightnow.getDate();
var month = rightnow.getMonth();
var day = rightnow.getDay();
var fullyear = rightnow.getFullYear();
var hours = rightnow.getHours();
var minutes = rightnow.getMinutes();
var seconds = rightnow.getSeconds();

 if (hours >= 12) am = false;

 if (military) clockmovie.TGotoFrame ("/ampm", 2);	// blank am/pm
 else
 {
  hours %= 12;
  if (hours==0) hours=12;
  if (am) clockmovie.TGotoFrame ("/ampm", 0);	// am frame
  else clockmovie.TGotoFrame ("/ampm", 1);	// pm frame
 }

 clockmovie.TGotoFrame ("/hour1", parseInt(hours/10));
 clockmovie.TGotoFrame ("/hour2", hours%10);
 clockmovie.TGotoFrame ("/minute1", parseInt(minutes/10));
 clockmovie.TGotoFrame ("/minute2", minutes%10);
 clockmovie.TGotoFrame ("/second1", parseInt(seconds/10));
 clockmovie.TGotoFrame ("/second2", seconds%10);

 if (dividervisible) clockmovie.TGotoFrame ("/colon", 1);
 else clockmovie.TGotoFrame ("/colon", 0);
 dividervisible = !dividervisible;


MaxCartItems = 75;

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
	   if (document.cookie.substring(i, j) == arg)
     return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);  // This cookie is history
  var cval = GetCookie (name);
  if (cval != null)
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function AddItem(ID,Sdesc,Price,Qty,Weight,Availability)
{
	if (Qty <= 0) 
	{
		rc = alert('The Quantity must be greater than 0');
		return false;
	}

	if (confirm('Adding ' +Qty+ ': "' +Sdesc+ '" to the shopping cart')) 
	{
		for(NumItems = 0; NumItems<=MaxCartItems; NumItems++)
		{
			if(NumItems == MaxCartItems)
			{

alert('Maximum of '+MaxCartItems+' different items can fit in the shopping cart, please go to the Checkout Counter and submit your order.  Then empty your cart and shop some more later.');
			}
			else
			{
				CookieName = 'Cart' +NumItems;
				CookieValue = GetCookie(CookieName);
				if(CookieValue == null)
				{
					CookieValue = "["+ID+"œ"+Sdesc+"®"+Price+"Ô"+Qty+"ê"+Weight+"Ù"+Availability+"]";
					SetCookie(CookieName,CookieValue);
					break;
				}
			}
		}
	}
	return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*
Script Name: Simple Javascript Browser/OS detection
Authors: Harald Hope, Tapio Markula, Websites: http://techpatterns.com/
http://www.nic.fi/~tapio1/Teaching/index1.php3
Script Source URI: http://techpatterns.com/downloads/javascript_browser_detection.php
Version 2.0.2
Copyright (C) 29 June 2007

This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt

*/

/*************************************************************
Light version, use for basic browser detection only. Use our
http://techpatterns.com/downloads/javascript_browser_detection.txt script for more
complex javascript browser detection.

Remember, always use method or object testing as your first choice, for example, if ( dom ) { statement; };

Let me know if you find an error or a failure to properly detect, or if there
is a relevant browser that has special needs for detection at our tech forum:
http://techpatterns.com/forums/forum-11.html
The main script is separated from the initial netscape 4 detection due to certain bugs in
netscape 4 when it comes to unknown things like d.getElementById. The variable declarations
of course are made first to make sure that all the variables are global through the page, 
otherwise a javascript error will occur because you are trying to use an undeclared variable.

We test for basic browser type (ie, op, or moz/netscape > 6)..

For more in depth discussion of css and browser issues go to:
http://www.nic.fi/~tapio1/Teaching/DynamicMenusb.php#detections
http://www.nic.fi/~tapio1/Teaching/FAQ.php3

***************************************************************/

/**************************************************************
Lite version, tests only for main types and browsers out there, 
this will cover you in almost all normal situations out there.
***************************************************************/

var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

d = document;
n = navigator;
na = n.appVersion;
nua = n.userAgent;
win = ( na.indexOf( 'Win' ) != -1 );
mac = ( na.indexOf( 'Mac' ) != -1 );
lin = ( nua.indexOf( 'Linux' ) != -1 );

if ( !d.layers ){
	dom = ( d.getElementById );
	op = ( nua.indexOf( 'Opera' ) != -1 );
	konq = ( nua.indexOf( 'Konqueror' ) != -1 );
	saf = ( nua.indexOf( 'Safari' ) != -1 );
	moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
	ie = ( d.all && !op );
	ie4 = ( ie && !dom );

	/*
	ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
	Opera will register true in this test if set to identify as IE 5
	*/

	ie5x = ( d.all && dom );
	ie5mac = ( mac && ie5x );
	ie5xwin = ( win && ie5x );
}

/********************************************************
here is a sample use of the browser detector, it would load a browser specific stylesheet for certain unsupported or improperly supported mac ie 5 css styles. The depth variable is used so that the javascript library file can be used from anywhere in the website, you simply insert the depth of the file like this, 
...
 <head>
 <title>Browser information Page</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <link rel = "stylesheet" type = "text/css" href = "/css/main.css" />
 <script type = "text/javascript" src = "/js/browser_detection.js"> </script>
 <script type = "text/javascript> browser_css( '/'); </script>
 </head>

in the head of the web page after the js file is loaded.
Or if you are always referring your site to the root, you wouldn't need that
 and could delete the depth variable and just use the absolute path to the root.
********************************************************/

/********************************************************
function browser_css() {
	if ( ie5mac ) {
		document.write('<link rel = "stylesheet" type = "text\/css" href = "css/ucare_layers_moz.css" />');
	}
	else if ( document.layers ){
		document.write('<link rel = "stylesheet" type = "text\/css" href = "css/ucare_layers_moz.css" />');
	}
	else if ( ie4 ){
		document.write('<link rel = "stylesheet" type = "text\/css" href = "css/ucare_layers_moz.css" />');
	}
	else if ( moz ){
		document.write('<link rel = "stylesheet" type = "text\/css" href = "css/ucare_layers_moz.css" />');
	}
	else {
		document.write('<link rel = "stylesheet" type = "text\/css" href = "css/ucare_layers_moz.css" />');
	}
}
********************************************************/
