if ( typeof hideAllMenus != 'undefined' )
{
document.onclick    = hideAllMenus;
}
var oLoginForm          = null;
var oMyAccountWindow    = null;
var oHelpWindow         = null;
var sVisibleTableStyle  = ( is_ie ) ? 'block' : 'table';
function init()
{
var oLoadingDiv = document.getElementById( 'div_loading' );
if ( oLoadingDiv != null )
{
oLoadingDiv.style.display  = 'none';
}
oLoginForm  = document.forms[ 'login' ];
if ( oLoginForm != null && ( window.location.href.indexOf('samples_screen_sized.jsp') == -1) )
{
oLoginForm.j_username.focus();
}
if ( typeof pageInit != 'undefined' )
{
pageInit();
}
if ( typeof menuInit != 'undefined' )
{
menuInit();
}
}
function returnFalse()
{
return false;
}
function getLeft( oSource )
{
var iReturnCoord = 0;
while ( oSource != null )
{
iReturnCoord += oSource.offsetLeft;
oSource = oSource.offsetParent;
}
return iReturnCoord;
}
function getTop( oSource )
{
var iReturnCoord = 0;
while ( oSource != null )
{
iReturnCoord += oSource.offsetTop;
oSource = oSource.offsetParent;
}
return iReturnCoord;
}
function debug( sMessage )
{
var oToday      = new Date();
var sTimestamp  = oToday.getHours() + ':' + oToday.getMinutes() + ':' + oToday.getSeconds();
var oDebugTextarea  = document.getElementById( 'textarea_debug' );
if ( oDebugTextarea == null )
{
var oNewTextarea    = document.createElement( 'TEXTAREA' );
oNewTextarea.id     = 'textarea_debug';
document.body.appendChild( oNewTextarea );
oDebugTextarea  = document.getElementById( 'textarea_debug' );
}
with ( oDebugTextarea.style )
{
display     = 'block';
width       = '175px';
height      = '454px';
position    = 'absolute';
left        = '785px';
fontFamily  = 'arial';
fontSize    = '11px';
top         = '71px';
}
oDebugTextarea.value    = sTimestamp + ' > ' + sMessage + '\n' + oDebugTextarea.value;
}
function debugProps( object )
{
for ( prop in object )
debug( 'object.' + prop + ' = \'' + eval('object.'+prop) + '\'' );
}
function deleteCookie( sName )
{
document.cookie = sName + '=; path=/; expires=Fri, 31 Dec 1999 23:59:59 GMT;';
}
function setCookie( sName, sValue )
{
document.cookie = sName + '=' + escape(sValue) + '; path=/';
}
function getCookie( sName )
{
var cookieVar       = document.cookie;
var cookieName      = sName + '=';
var cookieLength    = cookieVar.length;
var cookieBegin     = 0;
while ( cookieBegin < cookieLength )
{
var valueLength = cookieBegin + cookieName.length;
if ( cookieVar.substring(cookieBegin, valueLength) == cookieName )
{
var valueEnd    = cookieVar.indexOf( ';', valueLength );
if ( valueEnd == -1 )
valueEnd = cookieLength;
return unescape( cookieVar.substring(valueLength, valueEnd) );
}
cookieBegin = cookieVar.indexOf( ' ', cookieBegin ) + 1;
if (cookieBegin == 0)
break;
}
return null;
}
function swapImage( original, switched )
{
eval('document.getElementById("' + original + '").src = ' + switched + '.src;');
}
function doMyAccountPopUp()
{
oMyAccountWindow    = window.open( 'myaccount.jsp', 'myaccount', 'width=530,height=310,left=200,top=200,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=0' );
}
function doHelpPopUp( sHelpDocAnchor )
{
var sHelpUrl = 'help.jsp';
if ( sHelpDocAnchor != undefined && sHelpDocAnchor != '' )
{
sHelpUrl += sHelpDocAnchor;
}
oHelpWindow = window.open( sHelpUrl, 'help', 'width=550,height=500,left=200,top=200,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=0' );
}
function logout()
{
if ( confirm('Are you sure you wish to log out?\n\nIf you are in the middle of an order, you will\nhave to restart that order from the beginning.\n\n') )
{
doLogout();
window.location.href    = '/goview/';
}
}
function doLogout()
{
deleteCookie( COOKIENAME_LOGIN );
deleteCookie( COOKIENAME_LOGGEDINUSER );
deleteCookie( COOKIENAME_ENCRYPTEDCOOKIE );
deleteCookie( COOKIENAME_LOGINSOURCE );
deleteCookie( COOKIENAME_M25 );
deleteCookie( COOKIENAME_MEASUREMENTS );
deleteCookie( COOKIENAME_PRICES );
deleteCookie( COOKIENAME_ROYALTY );
}
function getUserProperty( sProperty )
{
var aArguments    = new Array();
var aValuePairs   = getCookie( COOKIENAME_LOGGEDINUSER ).split( '|' );
var sReturnValue  = '';
var bValueFound   = false;
for ( var iPair = 0; iPair < aValuePairs.length; iPair++ )
{
var sPair                       = aValuePairs[iPair]
var iFirstEquals                = sPair.indexOf( '=' );
aArguments[aArguments.length]   = sPair.substring( 0, iFirstEquals++ );
aArguments[aArguments.length]   = sPair.substr( iFirstEquals );
}
for (var iArg = 0; iArg < aArguments.length; iArg++)
{
if ( aArguments[iArg++] == sProperty && !bValueFound ) // Only get first instance
{
sReturnValue  = aArguments[iArg];
bValueFound   = true;
}
}
return sReturnValue; // Returns '' if not found
}