// smartwebdesign.js - SmartWebDesign.com's JavaScript function library
// Utilizes components that are part of SmartWebDesign's Web Admin website management tool
// Copyright 2005-2007 SmartWebDesign, LLC All Rights Reserved


// **********************************************************
// General Functions
// Written Sep 2007 by Rich Andrews
// **********************************************************

// Check settings (originally from Flash Player Version Detection - Rev 1.5 below)
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;


// staticLoadScript(url) - load an external JS file
function staticLoadScript(scripturl) {
	if (scripturl != '') {  
   document.write('<script src="', scripturl, '" type="text/JavaScript"><\/script>');
  }
}



// **********************************************************
// Photo Album Display Code for Web Admin
// Written Sep 2007 by Rich Andrews
// **********************************************************

// Template settings and defaults - will be overriden by site defaults and album overrides

// ALBUM SUMMARY PAGE (lists all albums, their cover image, descriptions)
//var album_summary_hdr = '<table border=1><tr><td colspan=5><h2>Photo Albums</h2></td></tr><tr>';
//var album_summary_item = '<td><a href="{albumthumbnailURL}"><img src="{albumcoverimage}" border=0></a><br>{albumdescription}</td>';
//var album_summary_ftr = '</tr><tr><td align=left>{prevsummarypage_btn}</td><td colspan=3 align=center>{firstsummarypage_btn}</td><td align=right>{nextsummarypage_btn}</td></tr></table>';
//var album_numitems_persummarypage = 20;
//var album_numitems_persummaryrow = 5;
//var album_summaryrow_breakhtml = '</tr><tr>';
//var album_prevsummarypage_btn = '<a href="{prevpageURL}">Prev Page</A>';
//var album_nextsummarypage_btn = '<a href="{firstpageURL}">First Page</A>';
//var album_firstsummarypage_btn = '<a href="{nextpageURL}">Next Page</A>';

// ALBUM THUMBNAIL VIEW (lists thumbnails of photos in an album, their descriptions)
var album_thumbnailview_hdr = '<table width=90% align="center" cellspacing=0 cellpadding=0 border=0><tr><td colspan="3" class="pa_header" height=42><table width="100%"><tr><td class="pa_header2">&nbsp;&nbsp;{albumdescription}</td><td align="right">{viewalbumsummary_btn}&nbsp;&nbsp;</td></tr></table></td></tr><tr><td colspan=3><img src="images/blank.gif" height=10></td></tr><tr><td class="pa_left"><img src="images/b.gif" width="34" height="200"></td><td class="pa_body" width=100%><table cellspacing="5" cellpadding="5" align="center" width="95%"><tr>';
// <td colspan=5>{albumdescription}</td></tr>';
var album_thumbnailview_item = '<td class="pa_captiontext"><a href="{photoURL}"><img src="{photothumbnail}" border=0 class="pa_thumbnail"></a><br>{photodescription}</td>';
var album_thumbnailview_ftr = '</tr><tr><td align=left>{prevthumbnailpage_btn}</td><td colspan=3 align=center>{firstthumbnailpage_btn}</td><td align=right>{nextthumbnailpage_btn}</td></tr></table></td><td class="pa_right"><img src="images/b.gif" width="34" height="200"></td></tr></table><br><br>';
var album_numitems_perthumbnailpage = 10;
var album_numitems_perthumbnailrow = 5;
var album_thumbnailrow_breakhtml = '</tr><tr>';
var album_prevthumbnailpage_btn = '<a href="{prevpageURL}"><img src="images/pa_prevpage.jpg" alt="Previous Page" border="0"></A>';
var album_nextthumbnailpage_btn = '<a href="{nextpageURL}"><img src="images/pa_nextpage.jpg" alt="Next Page" border="0"></A>';
var album_firstthumbnailpage_btn = '<a href="{firstpageURL}"><img src="images/pa_firstpage.jpg" alt="First Page" border="0"></A>';
var album_viewalbumsummary_btn = '<a href="{albumsummaryURL}"><img src="images/pa_listalbums.jpg" alt="List Albums" border="0"></A>';

// ALBUM PHOTO VIEW (show one photo, full size, with navigation buttons)
var album_photoview_item = '<table width=90% align="center" cellspacing=0 cellpadding=0 border=0><tr><td class="pa_header" height=42>&nbsp;&nbsp;{photodescription}</td><td align="right" class="pa_header">{viewthumbnails_btn}&nbsp;&nbsp;</td></tr><tr><td><img src="images/blank.gif" height=10></td></tr></table><table width=90% align="center" cellspacing=0 cellpadding=0 border=0><tr><td class="pa_left" rowspan=2><img src="images/pa_left.jpg"></td><td width=100% align="center" class="pa_body"><br><img src="{photo}"></td><td class="pa_right" rowspan=2><img src="images/pa_right.jpg"></td></tr><tr><td align=left class="pa_body"><table width=90% align="center" cellspacing=5 cellpadding=5><tr><td>{prevphoto_btn}</td><td align=center>{firstphoto_btn}</td><td align=right>{nextphoto_btn}</td></tr></table></td></tr></table><br><br>';
var album_prevphoto_btn = '<a href="{prevpageURL}"><img src="images/pa_prevpage.jpg" alt="Previous Page" border="0"></A>';
var album_nextphoto_btn = '<a href="{nextpageURL}"><img src="images/pa_nextpage.jpg" alt="Next Page" border="0"></A>';
var album_firstphoto_btn = '<a href="{firstpageURL}"><img src="images/pa_firstpage.jpg" alt="First Page" border="0"></A>';
var album_viewthumbnails_btn = '<a href="{albumthumbnailURL}"><img src="images/pa_listthumbs.jpg" alt="Thumbnail View" border="0"></A>';

var album_datacount = 0;
var album_imgdata = new Array()  // This is a list of images when addressing an album, it is a list of album directories when addressing summary
var album_txtdata = new Array()
var album_name = '';
var album_description = '';

function album_loaddata(imgdata,txtdata) {
	album_imgdata[album_datacount] = imgdata;
	album_txtdata[album_datacount] = txtdata;
	album_datacount++;	
}

function album_showsummary() {

}

function album_showthumbnailview(divname,startingnum) {
	var outputstring = '';
	var tmpstr = album_thumbnailview_hdr;
	var tmpimageurl = '';
	var tmpbtn = '';
	outputstring = tmpstr;
	var currowcount = 0;
	numtoshow = startingnum + album_numitems_perthumbnailpage - 1;
	if (numtoshow > (album_datacount - 1)) {
		numtoshow = album_datacount - 1; 
	}
	for (var dataloop=startingnum; dataloop <= numtoshow; dataloop++) {
		currowcount++;
		if (currowcount > album_numitems_perthumbnailrow) {
			outputstring += album_thumbnailrow_breakhtml;
			currowcount = 1;
		}
		tmpstr = album_thumbnailview_item;
		tmpimageurl = album_imgdata[dataloop]
		tmpstr = tmpstr.replace("{photothumbnail}",tmpimageurl)
		tmpstr = tmpstr.replace("Full_","Thumb_")
		tmpstr = tmpstr.replace("{photodescription}",album_txtdata[dataloop])
		if (tmpimageurl.indexOf("Thumb_albumcover.jpg") > 0) {
			// Special case - this is a link to an album, not a photo
			tmpimageurl = "PhotoAlbum.aspx?album=" + tmpimageurl.replace("/Thumb_albumcover.jpg","")
			tmpstr = tmpstr.replace("{photoURL}",tmpimageurl)
		} else {
			tmpstr = tmpstr.replace("{photoURL}","javascript:album_showphoto('" + divname + "'," + (dataloop) + ");")
		}
		outputstring += tmpstr;
	}
	tmpstr = album_thumbnailview_ftr;
	outputstring += tmpstr;

	if (startingnum > 0) {
		tmpbtn = album_prevthumbnailpage_btn;
		tmpbtn = tmpbtn.replace("{prevpageURL}","javascript:album_showthumbnailview('" + divname + "'," + (startingnum - album_numitems_perthumbnailpage) + ");");
	} else {
		tmpbtn = '&nbsp;';
	}
	outputstring = outputstring.replace("{prevthumbnailpage_btn}",tmpbtn);
	if (startingnum > 0) {
		tmpbtn = album_firstthumbnailpage_btn;
		tmpbtn = tmpbtn.replace("{firstpageURL}","javascript:album_showthumbnailview('" + divname + "',0);");
	} else {
		tmpbtn = '&nbsp;';
	}
	outputstring = outputstring.replace("{firstthumbnailpage_btn}",tmpbtn);
	if (startingnum < (album_datacount - album_numitems_perthumbnailpage)) {
		tmpbtn = album_nextthumbnailpage_btn;
		tmpbtn = tmpbtn.replace("{nextpageURL}","javascript:album_showthumbnailview('" + divname + "'," + (startingnum + album_numitems_perthumbnailpage) + ");");
	} else {
		tmpbtn = '&nbsp;';
	}
	outputstring = outputstring.replace("{nextthumbnailpage_btn}",tmpbtn);

	tmpbtn = 	album_viewalbumsummary_btn;
	tmpbtn = tmpbtn.replace("{albumsummaryURL}","PhotoAlbum.aspx");
	outputstring = outputstring.replace("{viewalbumsummary_btn}",tmpbtn);

	outputstring = outputstring.replace("{albumname}",album_name)
	outputstring = outputstring.replace("{albumdescription}",album_description)
	
	document.getElementById(divname).innerHTML = outputstring;
}

function album_showphotoname(divname,currphotoname) {
	var tmpphotonum=0;
	for (var dataloop=0; dataloop < album_datacount; dataloop++) {
		if (album_imgdata[dataloop].toLowerCase().indexOf(currphotoname.toLowerCase()) > 0) {
			tmpphotonum = dataloop;
		}
	}
	album_showphoto(divname,tmpphotonum)
}

function album_showphoto(divname,currphotonum) {
//alert("curphotonum=" + currphotonum + "; album_datacount=" + album_datacount);
	var outputstring = '';
	var tmpstr = album_photoview_item;
	var tmpbtn = '';
	tmpstr = tmpstr.replace("{photo}",album_imgdata[currphotonum])
	tmpstr = tmpstr.replace("{photodescription}",album_txtdata[currphotonum])
	
	// Setup buttons
	tmpbtn = album_viewthumbnails_btn;
	tmpbtn = tmpbtn.replace("{albumthumbnailURL}","javascript:album_showthumbnailview('" + divname + "',0);");
	tmpstr = tmpstr.replace("{viewthumbnails_btn}",tmpbtn);
	
	if (currphotonum > 0) {
		tmpbtn = album_prevphoto_btn;
		tmpbtn = tmpbtn.replace("{prevpageURL}","javascript:album_showphoto('" + divname + "'," + (currphotonum - 1) + ");");
	} else {
		tmpbtn = '&nbsp;';
	}
	tmpstr = tmpstr.replace("{prevphoto_btn}",tmpbtn);
	if (currphotonum > 0) {
		tmpbtn = album_firstphoto_btn;
		tmpbtn = tmpbtn.replace("{firstpageURL}","javascript:album_showphoto('" + divname + "',0);");
	} else {
		tmpbtn = '&nbsp;';
	}
	tmpstr = tmpstr.replace("{firstphoto_btn}",tmpbtn);
	if (currphotonum < (album_datacount-1)) {
		tmpbtn = album_nextphoto_btn;
		tmpbtn = tmpbtn.replace("{nextpageURL}","javascript:album_showphoto('" + divname + "'," + (currphotonum + 1) + ");");
	} else {
		tmpbtn = '&nbsp;';
	}
	tmpstr = tmpstr.replace("{nextphoto_btn}",tmpbtn);
		
	outputstring += tmpstr;
	
	tmpbtn = 	album_viewalbumsummary_btn;
	tmpbtn = tmpbtn.replace("{albumsummaryURL}","PhotoAlbum.aspx");
	outputstring = outputstring.replace("{album_viewalbumsummary_btn}",tmpbtn);

	outputstring = outputstring.replace("{albumname}",album_name)
	outputstring = outputstring.replace("{albumdescription}",album_description)
	
	document.getElementById(divname).innerHTML = outputstring;
}

// album_data should be populated by Web Admin to include a full list of items to be presented (either albums or thumbnails or photos)

// Replaceables index/reference
// {photothumbnail}
// {photoURL}
// {photodescription}
// {prevpageURL}
// {nextpageURL}
// {photo}
// {albumname}
// {albumdescription}
// {albumcoverimage}
// {albumthumbnailURL}
// {albumsummaryURL}


// **********************************************************
// Item Rotator Code for Web Admin
// Written 2005 by Tim Jacobs
// **********************************************************

var rotatorid_ar = new Array();
var rotatorname_ar = new Array();
var rotatorthumb_ar = new Array()
var rotatorcurrent = 0;
var rotatortotal = 0;

function rotatorprev() { 
	rotatorcurrent = rotatorcurrent - 5; 
	if (rotatorcurrent < 0) {
		rotatorcurrent = rotatorcurrent + rotatortotal + 1;
		if (rotatorcurrent < 0)
			rotatorcurrent = 0;
	}
	rotatorload();
}

function rotatornext() { 
	rotatorcurrent = rotatorcurrent + 5; 
	if (rotatorcurrent > rotatortotal) {
		rotatorcurrent = rotatorcurrent - rotatortotal - 1;
		if (rotatorcurrent < 0)
			rotatorcurrent = 0;
	}
	rotatorload();
}

function rotatorcellcontents(itemnum) {
		if (itemnum > rotatortotal) {
			itemnum = itemnum - rotatortotal;
		}
		tmpstr = '';
		tmpstr = '<BR><a href="ListItem.aspx?ItemId=' + rotatorid_ar[itemnum] + '"  class=nav1><img src="' + rotatorthumb_ar[itemnum] + '" border=0 width=100 height=75><BR><BR>';
		tmpstr = tmpstr + rotatorname_ar[itemnum] + "</a>";
		tmpstr = tmpstr + '<br><BR><a href="ListItem.aspx?ItemId=' + rotatorid_ar[itemnum] + '"><img src="images/ClickForInfo.gif" border=0></a>';
		return tmpstr;
}

function rotatorload() {
	for (x=0;x<5;x++) {
		tmpx = rotatorcurrent+x;
		if (tmpx > rotatortotal) {
			tmpx = tmpx - rotatortotal;
		}
		if (rotatortotal >= x) {
		document.getElementById('rotator' + x).innerHTML  = rotatorcellcontents(rotatorcurrent+x);
		}
	}
}


// ***************************************************************************
// smartwebcollapsemenu.js (now integrated into smartwebdesign.js)
// Copyright 2007 SmartWebDesign, LLC All Rights Reserved
// This menu system works for IE and Firefox, and should show up fully expanded in Netscape
// For this to work, an additional file called smartwebcollapsesettings.js needs to exist in the site and be referenced in the Header

function MakeArray(num) {
	this.length = num+1;
	for (var swloop = 0; swloop<=num; swloop++) {
		this[swloop] = new Image();
	}
	return this;
}

function swmenu_msover(num) {
	if(navigator.userAgent.substring(0,9)>="Mozilla/3") {
		eval('swmenu'+num+'img.src = over['+num+'].src;');
	}
}

function swmenu_msout(num) {
	if(navigator.userAgent.substring(0,9)>="Mozilla/3") {
		eval('swmenu'+num+'img.src = standard['+num+'].src;');
	}
}

function swmenu_select(num) {
	for (var swloop=1; swloop <= swmenucount; swloop++) {
    		if ((swloop == num) || (swloop == swmenuopen)) {
    			// Selected menu item
    			var hascontent=0;
    			eval('hascontent=swmenu'+swloop+'sub.innerHTML.length;');
    			if (hascontent == 0) { // Special case, if no data is in sub-menu, keep it hidden
	    			eval('swmenu'+swloop+'sub.style.display=\'none\';');
	    		} else {
				eval('swmenu'+swloop+'sub.style.display=\'\'');
			}
	    		eval('swmenu'+swloop+'img.src = over['+swloop+'].src;');
    		} else {
    			// Unselected menu item
    			eval('swmenu'+swloop+'sub.style.display=\'none\';');
    			eval('swmenu'+swloop+'img.src = standard['+swloop+'].src;');
    		}
	}
}


// ***************************************************************************
// Show Flash Movie
// Need to check for flash version and not call this if no flash installed
// ***************************************************************************

function showFlash(flashURL,flashHeight,flashWidth,flashBgcolor,flashWmode,flashName,flashPlay) {
	document.write('<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" height="' + flashHeight + '" width="' + flashWidth + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
	document.write('<param value="13229" name="_cx" />');
	document.write('<param value="7938" name="_cy" />');
	document.write('<param value="" name="FlashVars" />');
	document.write('<param value="' + flashURL + '" name="Movie" />');
	document.write('<param value="' + flashURL + '" name="Src" />');
	document.write('<param value="' + flashWmode + '" name="WMode" />');
	document.write('<param value="-1" name="Play" />');
	document.write('<param value="-1" name="Loop" />');
	document.write('<param value="High" name="Quality" />');
	document.write('<param value="" name="SAlign" />');
	document.write('<param value="-1" name="Menu" />');
	document.write('<param value="" name="Base" />');
	document.write('<param value="" name="AllowScriptAccess" />');
	document.write('<param value="ShowAll" name="Scale" />');
	document.write('<param value="0" name="DeviceFont" />');
	document.write('<param value="0" name="EmbedMovie" />');
	document.write('<param value="' + flashBgcolor + '" name="BGColor" />');
	document.write('<param value="" name="SWRemote" />');
	document.write('<param value="" name="MovieData" />');
	document.write('<param value="1" name="SeamlessTabbing" />');
	document.write('<param value="0" name="Profile" />');
	document.write('<param value="" name="ProfileAddress" />');
	document.write('<param value="0" name="ProfilePort" />');
	document.write('<embed src="' + flashURL + '" quality="high" bgcolor="#' + flashBgcolor + '" width="' + flashWidth + '" height="' + flashHeight + '" WMode="' + flashWmode + '" name="' + flashName + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}



// ***************************************************************************
// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
// ***************************************************************************
// isIE, isWin, isOpera moved to top of this script for use in other functions

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


/******************************************************************************
* dhtmllib.js                                                                 *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://www.brainjar.com                                        *
* Last update: November 30, 1999.                                             *
*                                                                             *
* Provides basic functions for DHTML positioned elements which will work on   *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and  *
* up).                                                                        *
******************************************************************************/

// Determine browser.

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------

function hideLayer(layer) {

  if (isMinNS4)
    layer.visibility = "hide";
  if (isMinIE4)
    layer.style.visibility = "hidden";
}

function showLayer(layer) {

  if (isMinNS4)
    layer.visibility = "show";
  if (isMinIE4)
    layer.style.visibility = "visible";
}

function isVisible(layer) {

  if (isMinNS4 && layer.visibility == "show")
    return(true);
  if (isMinIE4 && layer.style.visibility == "visible")
    return(true);

  return(false);
}

//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------

function moveLayerTo(layer, x, y) {

  if (isMinNS4)
    layer.moveTo(x, y);
  if (isMinIE4) {
    layer.style.left = x;
    layer.style.top  = y;
  }
}

function moveLayerBy(layer, dx, dy) {

  if (isMinNS4)
    layer.moveBy(dx, dy);
  if (isMinIE4) {
    layer.style.pixelLeft += dx;
    layer.style.pixelTop  += dy;
  }
}

function getLeft(layer) {

  if (isMinNS4)
    return(layer.left);
  if (isMinIE4)
    return(layer.style.pixelLeft);
  return(-1);
}

function getTop(layer) {

  if (isMinNS4)
    return(layer.top);
  if (isMinIE4)
    return(layer.style.pixelTop);
  return(-1);
}

function getRight(layer) {

  if (isMinNS4)
    return(layer.left + getWidth(layer));
  if (isMinIE4)
    return(layer.style.pixelLeft + getWidth(layer));
  return(-1);
}

function getBottom(layer) {

  if (isMinNS4)
    return(layer.top + getHeight(layer));
  else if (isMinIE4)
    return(layer.style.pixelTop + getHeight(layer));
  return(-1);
}

function getPageLeft(layer) {

  if (isMinNS4)
    return(layer.pageX);
  if (isMinIE4)
    return(layer.offsetLeft);
  return(-1);
}

function getPageTop(layer) {

  if (isMinNS4)
    return(layer.pageY);
  if (isMinIE4)
    return(layer.offsetTop);
  return(-1);
}

function getWidth(layer) {

  if (isMinNS4) {
    if (layer.document.width)
      return(layer.document.width);
    else
      return(layer.clip.right - layer.clip.left);
  }
  if (isMinIE4) {
    if (layer.style.pixelWidth)
      return(layer.style.pixelWidth);
    else
      return(layer.clientWidth);
  }
  return(-1);
}

function getHeight(layer) {

  if (isMinNS4) {
    if (layer.document.height)
      return(layer.document.height);
    else
      return(layer.clip.bottom - layer.clip.top);
  }
  if (isMinIE4) {
    if (false && layer.style.pixelHeight)
      return(layer.style.pixelHeight);
    else
      return(layer.clientHeight);
  }
  return(-1);
}

function getzIndex(layer) {

  if (isMinNS4)
    return(layer.zIndex);
  if (isMinIE4)
    return(layer.style.zIndex);

  return(-1);
}

function setzIndex(layer, z) {

  if (isMinNS4)
    layer.zIndex = z;
  if (isMinIE4)
    layer.style.zIndex = z;
}

//-----------------------------------------------------------------------------
// Layer clipping.
//-----------------------------------------------------------------------------

function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) {

  if (isMinNS4) {
    layer.clip.left   = clipleft;
    layer.clip.top    = cliptop;
    layer.clip.right  = clipright;
    layer.clip.bottom = clipbottom;
  }
  if (isMinIE4)
    layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function getClipLeft(layer) {

  if (isMinNS4)
    return(layer.clip.left);
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return(0);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[3]);
  }
  return(-1);
}

function getClipTop(layer) {

  if (isMinNS4)
    return(layer.clip.top);
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return(0);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[0]);
  }
  return(-1);
}

function getClipRight(layer) {

  if (isMinNS4)
    return(layer.clip.right);
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return(layer.style.pixelWidth);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[1]);
  }
  return(-1);
}

function getClipBottom(layer) {

  if (isMinNS4)
    return(layer.clip.bottom);
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return(layer.style.pixelHeight);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[2]);
  }
  return(-1);
}

function getClipWidth(layer) {

  if (isMinNS4)
    return(layer.clip.width);
  if (isMinIE4) {
    var str = layer.style.clip;
    if (!str)
      return(layer.style.pixelWidth);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[1] - clip[3]);
  }
  return(-1);
}

function getClipHeight(layer) {

  if (isMinNS4)
    return(layer.clip.height);
  if (isMinIE4) {
    var str =  layer.style.clip;
    if (!str)
      return(layer.style.pixelHeight);
    var clip = getIEClipValues(layer.style.clip);
    return(clip[2] - clip[0]);
  }
  return(-1);
}

function getIEClipValues(str) {

  var clip = new Array();
  var i;

  // Parse out the clipping values for IE layers.

  i = str.indexOf("(");
  clip[0] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[1] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[2] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[3] = parseInt(str.substring(i + 1, str.length), 10);
  return(clip);
}

//-----------------------------------------------------------------------------
// Layer scrolling.
//-----------------------------------------------------------------------------

function scrollLayerTo(layer, x, y, bound) {

  var dx = getClipLeft(layer) - x;
  var dy = getClipTop(layer) - y;

  scrollLayerBy(layer, -dx, -dy, bound);
}

function scrollLayerBy(layer, dx, dy, bound) {

  var cl = getClipLeft(layer);
  var ct = getClipTop(layer);
  var cr = getClipRight(layer);
  var cb = getClipBottom(layer);

  if (bound) {
    if (cl + dx < 0)

      dx = -cl;

    else if (cr + dx > getWidth(layer))
      dx = getWidth(layer) - cr;
    if (ct + dy < 0)

      dy = -ct;

    else if (cb + dy > getHeight(layer))
      dy = getHeight(layer) - cb;
  }

  clipLayer(layer, cl + dx, ct + dy, cr + dx, cb + dy);
  moveLayerBy(layer, -dx, -dy);
}

//-----------------------------------------------------------------------------
// Layer background.
//-----------------------------------------------------------------------------

function setBgColor(layer, color) {

  if (isMinNS4)
    layer.bgColor = color;
  if (isMinIE4)
    layer.style.backgroundColor = color;
}

function setBgImage(layer, src) {

  if (isMinNS4)
    layer.background.src = src;
  if (isMinIE4)
    layer.style.backgroundImage = "url(" + src + ")";
}

//-----------------------------------------------------------------------------
// Layer utilities.
//-----------------------------------------------------------------------------

function getLayer(name) {

  if (isMinNS4)
    return findLayer(name, document);
  if (isMinIE4)
    return eval('document.all.' + name);

  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0) {
      layer = findLayer(name, layer.document);
      if (layer != null)
        return layer;
    }
  }

  return null;
}

//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------

function getWindowWidth() {

  if (isMinNS4)
    return(window.innerWidth);
  if (isMinIE4)
    return(document.body.clientWidth);
  return(-1);
}

function getWindowHeight() {

  if (isMinNS4)
    return(window.innerHeight);
  if (isMinIE4)
    return(document.body.clientHeight);
  return(-1);
}

function getPageWidth() {

  if (isMinNS4)
    return(document.width);
  if (isMinIE4)
    return(document.body.scrollWidth);
  return(-1);
}

function getPageHeight() {

  if (isMinNS4)
    return(document.height);
  if (isMinIE4)
    return(document.body.scrollHeight);
  return(-1);
}

function getPageScrollX() {

  if (isMinNS4)
    return(window.pageXOffset);
  if (isMinIE4)
    return(document.body.scrollLeft);
  return(-1);
}

function getPageScrollY() {

  if (isMinNS4)
    return(window.pageYOffset);
  if (isMinIE4)
    return(document.body.scrollTop);
  return(-1);
}


/******************************************************************************
* scroller.js                                                                 *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://www.brainjar.com                                        *
* Last update: December 1, 1999.                                              *
*                                                                             *
* Allows you to create scrolling displays on a page. Multiple scrollers can   *
* be defined, each with it's own parameters and list of items. Item text can  *
* include basic HTML tags, including links and images.                        *
* Note: requires dhtmllib.js.                                                 *
******************************************************************************/

//*****************************************************************************
// Scroller constructor.
//*****************************************************************************

function Scroller(x, y, width, height, border, padding) {

  this.x = x;
  this.y = y;
  this.width = width;
  this.height = height;
  this.border = border;
  this.padding = padding;

  this.items = new Array();
  this.created = false;

  // Set default colors.

  this.fgColor = "#000000";
  this.bgColor = "#ffffff";
  this.bdColor = "#000000";

  // Set default font.

  this.fontFace = "Arial,Helvetica";
  this.fontSize = "2";

  // Set default scroll timing values.

  this.speed = 50;
  this.pauseTime = 2000;

  // Define methods.

  this.setColors = scrollerSetColors;
  this.setFont = scrollerSetFont;
  this.setSpeed = scrollerSetSpeed;
  this.setPause = scrollersetPause;
  this.addItem = scrollerAddItem;
  this.create = scrollerCreate;
  this.show = scrollerShow;
  this.hide = scrollerHide;
  this.moveTo = scrollerMoveTo;
  this.moveBy = scrollerMoveBy;
  this.getzIndex = scrollerGetzIndex;
  this.setzIndex = scrollerSetzIndex;
  this.stop = scrollerStop;
  this.start = scrollerStart;
}

//*****************************************************************************
// Scroller methods.
//*****************************************************************************

function scrollerSetColors(fgcolor, bgcolor, bdcolor) {

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.fgColor = fgcolor;
  this.bgColor = bgcolor;
  this.bdColor = bdcolor;
}

function scrollerSetFont(face, size) {

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.fontFace = face;
  this.fontSize = size;
}

function scrollerSetSpeed(pps) {

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.speed = pps;
}

function scrollersetPause(ms) {

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.pauseTime = ms;
}

function scrollerAddItem(str) {

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.items[this.items.length] = str;
}

function scrollerCreate() {

  var start, end;
  var str;
  var i, j;
  var x, y;

  if (!isMinNS4 && !isMinIE4)
    return;

  // On first scroller, start interval timer.

  if (scrollerList.length == 0)
    setInterval('scrollerGo()', scrollerInterval);

  // Create the scroller only once.

  if (this.created) {
    alert("Scroller Error: Scroller has already been created.");
    return;
  }
  this.created = true;

  // Copy first item to the end of the list, this lets us scroll from the last
  // defined item to the first without jumping.

  this.items[this.items.length] = this.items[0];

  // Set up HTML code for item text.

  start = '<table border=0'
        + ' cellpadding=' + (this.padding + this.border)
        + ' cellspacing=0'
        + ' width=' + this.width
        + ' height=' + this.height + '>'
        + '<tr><td>'
        + '<font'
        + ' color="' + this.fgColor + '"'
        + ' face="' + this.fontFace + '"'
        + ' size=' + this.fontSize + '>';
  end   = '</font></td></tr></table>';

  // Build the layers.

  if (isMinNS4) {
    this.baseLayer = new Layer(this.width);
    this.scrollLayer = new Layer(this.width, this.baseLayer);
    this.scrollLayer.visibility = "inherit";
    this.itemLayers = new Array();
    for (i = 0; i < this.items.length; i++) {
      this.itemLayers[i] = new Layer(this.width, this.scrollLayer);
      this.itemLayers[i].document.open();
      this.itemLayers[i].document.writeln(start + this.items[i] + end);
      this.itemLayers[i].document.close();
      this.itemLayers[i].visibility = "inherit";
    }

    // Set background colors.

    setBgColor(this.baseLayer, this.bdColor);
    setBgColor(this.scrollLayer, this.bgColor);
  }

  if (isMinIE4) {
    i = scrollerList.length;
    str = '<div id="scroller' + i + '_baseLayer"'
        + ' style="position:absolute;'
        + ' background-color:' + this.bdColor + ';'
        + ' width:' + this.width + 'px;'
        + ' height:' + this.height + 'px;'
        + ' overflow:hidden;'
        + ' visibility:hidden;">\n'
        + '<div id="scroller' + i + '_scrollLayer"'
        + ' style="position:absolute;'
        + ' background-color: ' + this.bgColor + ';'
        + ' width:' + this.width + 'px;'
        + ' height:' + (this.height * this.items.length) + 'px;'
        + ' visibility:inherit;">\n';
    for (j = 0; j < this.items.length; j++) {
      str += '<div id="scroller' + i + '_itemLayers' + j + '"'
          +  ' style="position:absolute;'
          +  ' width:' + this.width + 'px;'
          +  ' height:' + this.height + 'px;'
          +  ' visibility:inherit;">\n'
          +  start + this.items[j] + end
          +  '</div>\n';
    }
    str += '</div>\n'
        +  '</div>\n';

    // Insert HTML code at end of page. For IE4, need to scroll window to
    // end of page, insert and scroll back to correct bug.

    if (!isMinIE5) {
      x = getPageScrollX();
      y = getPageScrollY();
      window.scrollTo(getPageWidth(), getPageHeight());
    }
    document.body.insertAdjacentHTML("beforeEnd", str);
    if (!isMinIE5)
      window.scrollTo(x, y);

    // Get handles to each layer.

    this.baseLayer = getLayer("scroller" + i + "_baseLayer");
    this.scrollLayer = getLayer("scroller" + i + "_scrollLayer");
    this.itemLayers = new Array();
    for (j = 0; j < this.items.length; j++)
      this.itemLayers[j] = getLayer("scroller" + i + "_itemLayers" + j);
  }

  // Position and clip base and scroll layers.

  moveLayerTo(this.baseLayer, this.x, this.y);
  clipLayer(this.baseLayer, 0, 0, this.width, this.height);
  moveLayerTo(this.scrollLayer, this.border, this.border);
  clipLayer(this.scrollLayer, 0, 0,
            this.width - 2 * this.border, this.height - 2 * this.border);

  // Position and clip each item layer.

  x = 0;
  y = 0;
  for (i = 0; i < this.items.length; i++) {
    moveLayerTo(this.itemLayers[i], x, y);
    clipLayer(this.itemLayers[i], 0, 0, this.width, this.height);
    y += this.height;
  }

  // Set up scrolling parameters.

  this.stopped = false;
  this.currentY = 0;
  this.stepY = this.speed / (1000 / scrollerInterval);
  this.stepY = Math.min(this.height, this.stepY);
  this.nextY = this.height;
  this.maxY = this.height * (this.items.length - 1);
  this.paused = true;
  this.counter = 0;

  // Add to global list.

  scrollerList[scrollerList.length] = this;

  // Display it.

  showLayer(this.baseLayer);
}

function scrollerShow() {

  if (this.created)
    showLayer(this.baseLayer);
}

function scrollerHide() {

  if (this.created)
    hideLayer(this.baseLayer);
}

function scrollerMoveTo(x, y) {

  if (this.created)
    moveLayerTo(this.baseLayer, x, y);
}

function scrollerMoveBy(dx, dy) {

  if (this.created)
    moveLayerBy(this.baseLayer, dx, dy);
}

function scrollerGetzIndex() {

  if (this.created)
    return(getzIndex(this.baseLayer));
  else
    return(0);
}

function scrollerSetzIndex(z) {

  if (this.created)
    setzIndex(this.baseLayer, z);
}

function scrollerStart() {

  this.stopped = false;
}

function scrollerStop() {

  this.stopped = true;
}

//*****************************************************************************
// Code for scrolling.
//*****************************************************************************

// An array is used to hold a pointer to each scroller that is defined. The
// scrollerGo() function runs at regular intervals and updates each scroller
// in this list.

var scrollerList     = new Array();
var scrollerInterval = 20;

function scrollerGo() {

  var i;

  // Update each scroller object in the list.

  for (i = 0; i < scrollerList.length; i++) {

    // If stopped, skip.

    if (scrollerList[i].stopped);

    // If paused, update counter.

    else if (scrollerList[i].paused) {
      scrollerList[i].counter += scrollerInterval;
      if (scrollerList[i].counter > scrollerList[i].pauseTime)
        scrollerList[i].paused = false;
    }

    // Scroll it.

    else {
      scrollerList[i].currentY += scrollerList[i].stepY;

      // Pause it if the next item has scrolled into view.

      if (scrollerList[i].currentY >= scrollerList[i].nextY) {
        scrollerList[i].paused = true;
        scrollerList[i].counter = 0;
        scrollerList[i].currentY = scrollerList[i].nextY;
        scrollerList[i].nextY += scrollerList[i].height;
      }

      // When we reach the end, start over.

      if (scrollerList[i].currentY >= scrollerList[i].maxY) {
        scrollerList[i].currentY -= scrollerList[i].maxY;
        scrollerList[i].nextY = scrollerList[i].height;
      }
      scrollLayerTo(scrollerList[i].scrollLayer,
                    0, Math.round(scrollerList[i].currentY),
                    false);
    }
  }
}

//*****************************************************************************
// Code to handle a window resize.
//*****************************************************************************

// These variables are used to determine if a resize event is a true one.
// Necessary due to a bug in older NS4 releases.

var origWidth;
var origHeight;

// Fix for resize bug.

if (isMinNS4) {
  origWidth  = window.innerWidth;
  origHeight = window.innerHeight;
}
window.onresize = scrollerReload;

function scrollerReload() {

  // Reload page in case of a browser resize. First make sure it's a true
  // resize.

  if (isMinNS4 && origWidth == window.innerWidth && origHeight == window.innerHeight)
    return;
  window.location.href = window.location.href;
}



function runmikescroll() {

  var layer;
  var mikex, mikey;

  // Locate placeholder layer so we can use it to position the scrollers.

  layer = getLayer("placeholder");
  mikex = getPageLeft(layer);
  mikey = getPageTop(layer);

  // Create the first scroller and position it.

  myScroller1.create();
  myScroller1.hide();
  myScroller1.moveTo(mikex, mikey);
  myScroller1.setzIndex(10);
  myScroller1.show();
}


var genRandNo     // Stores Generated random number.
var uslrn = 0;    // Stores User Selected Lower Range Number.
var usurn = 0;    // Stores User Selected Upper Range Number.

// The RandomNumberGenerator (RNG) with the function 
// 'NextRandomNumber()' and the function 
// 'RandomNumberGenerator()' is an implementation of 
// the Park-Miller algorithm. (See 'Random Number Generators: Good 
// Ones Are Hard to Find', by Stephen K. Park and Keith W. Miller, 
// Communications of the ACM, 31(10):1192-1201, 1988.) The JScript 
// version was written by David N. Smith of IBM's T. J. Watson 
// Research Center. Mr. Smith notes that his version has not been 
// subjected to the rigorous testing required of a mission-critical RNG.

// You might have noticed that JScript's Math object includes 
// a built-in random() method. The version presented here should 
// work as well as, if not better than, the built-in implementations, 
// and will work uniformly on all platforms.

function NextRandomNumber()  {
  var hi   = this.seed / this.Q;
  var lo   = this.seed % this.Q;
  var test = this.A * lo - this.R * hi;
  if (test > 0)
    this.seed = test;
  else
    this.seed = test + this.M;
  return (this.seed * this.oneOverM);
}

function RandomNumberGenerator() {
  var d = new Date();
  this.seed = 2345678901 +
    (d.getSeconds() * 0xFFFFFF) +
    (d.getMinutes() * 0xFFFF);
  this.A = 48271;
  this.M = 2147483647;
  this.Q = this.M / this.A;
  this.R = this.M % this.A;
  this.oneOverM = 1.0 / this.M;
  this.next = NextRandomNumber;
  return this;
}

function random(lrn, urn) {
  // Random LowerRange Number (lrn)
  // Random UpperRange Number (urn)
  // return Math.round((urn - lrn + 1) * rand.next() + lrn);
  return Math.floor((urn - lrn + 1) * rand.next() + lrn);
}

var rand = new RandomNumberGenerator();
genRandNo = random(uslrn, usurn);


