// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// This script provides basic common client-side functions for static HTML pages linked
// to and from Broadvision
// FUNCTIONS:
// 	ReadParse()
//		callBVPage(url,lsBVData,center)
//		showStatus(text)
//		showdate(['y' | blank]) if 'y' the 4-digit year is returned, else full verbose date string
//		detach(url,width,height,optional-parameter)
//		buyOnlineText(buyString, callString)	buyString is the 'buy online or call' text
//									callString is the number to call
//									if both are null, a default is provided
//
// last updated on 10-25-2000 by CDC
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set global array laArgs to contain a list of args passed to this page
// Set global string var lsBVData to contain the BV session and engine strings
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	laArgs = ReadParse(location.search);
	if (laArgs) {
		if (laArgs['BV_SessionID']) {
			lsBVData = 'BV_SessionID=' + laArgs['BV_SessionID'] + '&BV_EngineID=' + laArgs['BV_EngineID'];
		} else {
			lsBVData = '';
		}
		lsQm = '?';
		var lnArgLength = 0;
		for (var zz in laArgs) {	// laArgs.length doesn't appear to work with a hash
			lnArgLength++		// so create lnArgLength to do the same job - CDC 10-15-2K
		}
	} else {
//		alert("laArgs is blank");
		lsBVData = '';
		lsQm = '';
	}


/*	Used a more bulletproof version of this block (above) on 10-15-2000.  Delete this if all goes well
	in production
	if (laArgs) {
		lsBVData = 'BV_SessionID=' + laArgs['BV_SessionID'] + '&BV_EngineID=' + laArgs['BV_EngineID'];
		lsQm = '?';
	} else {
//		alert("laArgs is blank");
		lsBVData = '';
		lsQm = '';
	}
*/


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Builds and loads URL including BV session info in query string
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function callBVPage(url, bvData, center) {
		if (! center) {center='';}
			lsAmper = "";
			server = "";
		urlstr = server + url + lsQm + bvData + lsAmper + center;
//		alert(urlstr);
		location.href = urlstr;
		return;
	}

/*	commented on 10-15-2000.  Replaced by the newer version above.  Delete this one if all
	goes well in production
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Builds and loads URL including BV session info in query string
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function callBVPage(url, bvData, center) {
		if (! center) {center='';}
			lsAmper = "";
			server = "";
		alert('lsQm: ' + lsQm + '\nlsAmper: ' + lsAmper);
		urlstr = server + url + lsQm + bvData + lsAmper + center;
//		alert(urlstr);
		location.href = urlstr;
		return;
	}
*/

	
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Change the statusline display for onMouseOver event
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function showStatus(it) {
		status = it;
		return true;
	}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + ReadParse parses multiple getargs into an array and returns  +
// + the array (or false) to the caller.  Requires a non-blank    +
// + value, and that value must contain multiple name/value pairs +
// + separated by ampersands.  If blank or no ampersands, returns +
// + false.
// + Clark Christensen;  TAIS CSD eBusiness; 05-07-2000           +
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		function ReadParse(lsArgList) {
			if (lsArgList == '' | lsArgList.indexOf('&') < 0) {
				return false;
// if blank or no ampersand, return false
			}
			laInList = new Array();
			lnSize = lsArgList.length;
			if (lsArgList.indexOf('?') == 0) {
				lsList = lsArgList.substring(1,lnSize);
// strip the leading questionmark if present
			}
			laArgs = lsList.split('&');	// split the arg pairs into array laArgs
			for (i=0; i<laArgs.length; i++) {
				laSpl = laArgs[i].split('=');
				laInList[laSpl[0]] = laSpl[1];
// for each pair, split into laInList[name]=value
			}
		return laInList;
		}

		
// Initialize global variable 'value' with today's date text
function showdate(it) {
   today = new Date();
   day = today.getDate();
   year = today.getYear();
	if (year < 1980) {year = year + 1900;}
   month = today.getMonth() + 1;
   monthStr = new Array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
   dateString = monthStr[month] + ' ' + day + ', ' + year
	if (it == 'y') {
		return year;
	} else {
		return dateString;
	}
}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Open a new window with the page defined in 'it'
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function detach(it,w,h,prm) {
	if (it.indexOf('.jsp') > -1) {
		server = "http://www.csd.toshiba.com/cgi-bin/tais/";
	} else {
		server = "";
	}
	if (prm) {
		if (lsQm == '?')  {
			var lsAmper = '&';
		} else {
			var lsAmper = '?';
		}
	} else {
		prm = '';
		lsAmper = '';
	}
	url = server + it + lsQm + lsBVData + lsAmper + prm;
//	alert('Server: ' + server + '\nit: ' + it + '\nlsQm: ' + lsQm + '\nlsBVData: ' + lsBVData + '\nlsAmper: ' + lsAmper + '\nprm: ' + prm + '\nurl: ' + url);
	opts = 'width=' + w + ',height=' + h;
	opts += ',toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=yes,'
	window.open(url, 'detachWindow', opts);
}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// return the HTML code for the  'Buy Online or Call' text
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


function closeWindow()
{
	window.close();
}

function defstatus() {
	defaultStatus = "Document: Done"
}