
<!--

function isIE()
{
	if (document.all) return true;
	return false;
}

function getEl( id )
{
	return document.getElementById( id );
}

// because IE doesn't do document.getElementsByName()
function getElementsByTagAndName( tag, name )
{
	if (isIE())
		return getElementsByNameIE( tag, name );
	else
		return document.getElementsByName( name );
}

function getElementsByNameIE( tag, name )
{
	var elem = document.getElementsByTagName( tag );
	var arr = new Array();

	for (i = 0,iarr = 0; i < elem.length; i++)
	{
		att = elem[i].getAttribute( "name" );
		if (att == name)
		{
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}

function getTableRow( tableID, row )
{
	return document.getElementById( tableID ).rows.item( row );
}

function getTableCell( tableID, column, row )
{
	return getTableRow( tableID, row ).cells.item( column );
}

function getTableCellText( tableID, column, row )
{
	return getTableCell( tableID, column, row ).innerHTML;
}

function setTableCellText( tableID, column, row, text )
{
	getTableCell( tableID, column, row ).innerHTML = text;
}

function enableFormButtons( form )
{
	for (i=0; i<form.elements.length; i++)
	{
		e = form.elements[i];
		if (e.type == "submit") e.disabled = 0;
		if (e.type == "reset") e.disabled = 0;
		if (e.type == "button") e.disabled = 0;
	}
}

function useShipping( form )
{
	form.p_name.value = form.p_nametoship.value;
	form.p_address.value = form.p_addresstoship.value;
	form.p_city.value = form.p_citytoship.value;
	form.p_state.value = form.p_statetoship.value;
	form.p_zip.value = form.p_ziptoship.value;
	form.p_country.value = form.p_countrytoship.value;
}

function setSelectedOption( selectControl, optionValue )
{
	if (selectControl.options) for (var i=0; i<selectControl.options.length;i++)
		if (selectControl.options[i].value == optionValue)
		{
			selectControl.options[i].selected = true
			break
		}
}

function setSelectedOptionText( selectControl, optionText )
{
	if (selectControl.options) for (var i=0; i<selectControl.options.length;i++)
		if (selectControl.options[i].text == optionText)
		{
			selectControl.options[i].selected = true
			break
		}
}

function getSelectedOption( selectControl )
{
	if (selectControl.options) for (var i=0; i<selectControl.options.length;i++)
		if (selectControl.options[i].selected)
			return selectControl.options[i]
}

function getSelectedOptionText( selectControl )
{
	if (selectControl.options) for (var i=0; i<selectControl.options.length;i++)
		if (selectControl.options[i].selected)
			return selectControl.options[i].text
}

function getAjax()
{
	var ajax;

	if (typeof XMLHttpRequest != 'undefined')
	{
		try { ajax = new XMLHttpRequest(); }
		catch (e) { ajax = false; }
	}

	return ajax;
}

function doAjax( url, onreadystatechange )
{
	var ajax = getAjax();
	ajax.onreadystatechange = onreadystatechange;
	ajax.open( 'GET', url, true );
	ajax.send( null );
}



///////////////////////////////////


function cbSelectAll( form )
{
	for (i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].type == "checkbox") form.elements[i].checked = true;
	}
}

function cbSelectNone( form )
{
	for (i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].type == "checkbox") form.elements[i].checked = false;
	}
}

function showPopupMessage( e, description, width )
{
	popup = getEl( "popupDiv" );
	popup.style.visibility = "visible";
	popup.firstChild.data = description;
	if (isIE())
	{
		popup.style.left = document.body.scrollLeft + e.clientX + 10;
		popup.style.top = document.body.scrollTop + e.clientY - 30;
	}
	else
	{
		popup.style.left = pageXOffset + e.clientX + 10;
		popup.style.top = pageYOffset + e.clientY - 30;
	}

	if (width)
		popup.style.width = width;
	else
		popup.style.width = 300;
}

function showPopupMessageArray( e, lines )
{
	popup = getEl( "popupDivArray" );
	popup.style.visibility = "visible";

	for (i=0; i<lines.length; i++)
	{
		popup.appendChild( document.createTextNode( lines[i] ) );
		popup.appendChild( document.createElement( 'br' ) );
	}

	if (isIE())
	{
		popup.style.left = document.body.scrollLeft + e.clientX + 10;
		popup.style.top = document.body.scrollTop + e.clientY - lines.length * 10;
	}
	else
	{
		popup.style.left = pageXOffset + e.clientX + 10;
		popup.style.top = pageYOffset + e.clientY - lines.length * 10;
	}
	popup.style.width = 300;
}

function hidePopupMessage( e )
{
	popup = getEl( "popupDiv" );
	popup.style.visibility = "hidden";
}

function hidePopupMessageArray( e )
{
	popup = getEl( "popupDivArray" );
	popup.style.visibility = "hidden";

	while (popup.hasChildNodes())
	{
		popup.removeChild( popup.lastChild );
	}
}

function formatCurrency(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
			num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function sprintf()
{
	if (!arguments || arguments.length < 1 || !RegExp)
	{
		return;
	}
	var str = arguments[0];
	var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
	var a = b = [], numSubstitutions = 0, numMatches = 0;
	//while (a = re.exec(str))
	if (a = re.exec(str))
	{
		var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
		var pPrecision = a[5], pType = a[6], rightPart = a[7];

		//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);

		numMatches++;
		if (pType == '%')
		{
			subst = '%';
		}
		else
		{
			numSubstitutions++;
			if (numSubstitutions >= arguments.length)
			{
				alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
			}
			var param = arguments[numSubstitutions];
			var pad = '';
			if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
			else if (pPad) pad = pPad;
			var justifyRight = true;
			if (pJustify && pJustify === "-") justifyRight = false;
			var minLength = -1;
			if (pMinLength) minLength = parseInt(pMinLength);
			var precision = -1;
			if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
			var subst = param;
			if (pType == 'b') subst = parseInt(param).toString(2);
			else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
			else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
			else if (pType == 'u') subst = Math.abs(param);
			else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
			else if (pType == 'o') subst = parseInt(param).toString(8);
			else if (pType == 's') subst = param;
			else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
			else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
		}
		str = leftpart + subst + rightPart;
	}
	return str;
}

function objectToText( object, objectName, numSpaces )
{
	var text = '';

	text += '--------------' + objectName + '----------------------<br>';

	for (var i in object)
	{
		for (var j=0; j<numSpaces; j++) text += '&nbsp;';

		text += objectName + '.' + i + ' = ';
		if (
			objectName + '.' + i == 'document.body.innerHTML' ||
			objectName + '.' + i == 'document.body.outerHTML' ||
			objectName + '.' + i == 'document.body.innerText' ||
			objectName + '.' + i == 'document.body.outerText' ||
			objectName + '.' + i == 'document.body.textContent'
		)
			text += 'NOT PRINTED';
		else
			text += object[i];
		text += '<br>';
	}
	text += '<br>';

	return text;
}

function printObject( object, objectName, numSpaces )
{
	document.write( objectToText( object, objectName, numSpaces ) );
}

function printInfo()
{
	printObject( navigator, 'navigator', 0 );
	printObject( screen, 'screen', 0 );
	printObject( window, 'window', 0 );

	document.write( '--------------' + 'document' + '----------------------<br>' );
	for (var i in document)
	{
		document.write( 'document' + '.' + i + ' = ' );
		if (i != 'domConfig' && i != 'fileCreatedDate'&& i != 'mimeType'&& i != 'fileModifiedDate'&& i != 'fileSize')
			document.write( document[i] );
		document.write( '<br>' );
		//printObject( document[i], 'document' + '.' + i, 3 );
		//document.write( '<br>' );
	}

	printObject( document.body, 'document.body', 0 );
	printObject( document.body.style, 'document.body.style', 0 );

	document.write( '------------------------------------<br>' );
}


//-->



