// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 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 = '';
	}


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Builds and loads URL including BV session info in query string
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function callBVPage(url, bvData, center) {
		if (! center) {center='';}
		if (lnArgLength > 1 && center != '') {
			lsAmper = "&";
		} else if (center != '' && lsQm == '') {
			lsAmper = "?";
		} else {
			lsAmper = "";
		}
		if (url.indexOf('.jsp') > -1) {
			server="http://www.csd.toshiba.com/cgi-bin/tais/";
		} else {
			server = "";
		}
		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();
//	year = 2001;
	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,'
	var detachWindow = window.open(url, 'detachWindow', opts);
	detachWindow.moveTo(100,100);
}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// return the HTML code for the  'Buy Online or Call' text
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function buyOnlineText(buyString, callString) {
	if (buyString == null) {
		buyString = 'Buy Online or Call Now!<br>1-800-316-0920';
	}
	if (buyString == '') {
		var lsHTMLBegin = '';
		var lsHTMLEnd = '';
	} else {
		var lsHTMLBegin = '\t<tr>\n\t\t<td width="150" colspan="3" align="middle" class="tosh800">\n\t\t\t';
		var lsHTMLEnd = '\n\t\t</td>\n\t</tr>\n';
	}
//	var boText = lsHTMLBegin + buyString + lsHTMLEnd;
	var boText = '';
	return boText;
}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Open a new window with the page defined in 'url'
// replaces 'BVSESSION' in url with BV session string if present
// Expands 'BV.' at beginning of URL into full path to TAIS IM
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function detachIt(url,w,h) {
	url = url.replace(/(\?|\&)BVSESSION/, (lsBVData != '') ? "$1" + lsBVData : '');	// replace BVSESSION with the BV session string if present
	url = url.replace(/^BV\./, 'http://www.csd.toshiba.com/cgi-bin/tais/');				// prepend URLs beginning in 'BV.' with base URL to TAIS BV
	opts = 'width=' + w + ',height=' + h;
	opts += ',toolbar=no,scrollbars=yes,status=no,menubar=no,resizable=yes,'
	var detachWindow = window.open('about:blank', 'detachWindow', opts);
	detachWindow.moveTo(100,100);
	detachWindow.location.href = url;
}


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

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