
/* browser identification: */
var isIE4 = ( navigator.appVersion.indexOf( "MSIE" ) != -1 && parseFloat( navigator.appVersion ) >= 4 ) ? true : false;
var isNN4 = ( navigator.appName=='Netscape' && parseFloat( navigator.appVersion ) < 5 ) ? true : false;
var isNN6 = ( navigator.appName=='Netscape' && parseFloat( navigator.appVersion ) >= 5 ) ? true : false;
var is4Plus = ( isIE4 || isNN4 || isNN6 );
var fFullVer = parseFloat( navigator.appVersion.indexOf( "MSIE" ) != -1 ? navigator.appVersion.substr( navigator.appVersion.indexOf( "MSIE" ) + 5 ) : navigator.appVersion );
var children = new Array();

/* error handling, stop messages: */
/*function handlerWindowOnError()
{
	return true;
}
window.onError = handlerWindowOnError;*/

/* writes browser-dependent string to document: */
function writeBrowserDependent( szPrefix, szIE4, szNN4, szNN6, szSuffix, szOthers )
{  
	if( isIE4 )
	{
		document.write( szPrefix + szIE4 + szSuffix );
		return;
	}
	if( isNN4 )
	{  
		document.write( szPrefix + szNN4 + szSuffix );
		return;
	}
	if( isNN6 )
	{   
		document.write( szPrefix + szNN6 + szSuffix );
		return;
	}

	document.write( szPrefix + szOthers + szSuffix );
}

function openPopupWindow(url,width,height_ie,height_nn4,height_nn6,scrlbars,toolbar,menubar,resizable,location)
{

	if( !scrlbars )	
		scrlbars='no';	
	
	if( !toolbar )	
		toolbar='no';	

	if( !menubar )	
		menubar='no';
	
	if( !resizable )	
		resizable='no';	
	
	if( !location )
		location='no';

	if( !height_nn4 )	
		height_nn4=eval(height_ie);	
		
	if( !height_nn6 )	
	  	height_nn6=eval(height_nn4);	
		
	if( isIE4 )	
		height=eval(height_ie);	
	if( isNN4 )	
	  	height=eval(height_nn4);	
	if( isNN6 )	
	 	height=eval(height_nn6);	
		
	window.open(url,null,'width='+eval(width)+',height='+eval(height)+',status=yes,scrollbars='+scrlbars+',toolbar='+toolbar+',menubar='+menubar+',location='+location+',resizable='+resizable,false);
	return (false);
}



function openPopupWindowWithDependecy(url,width,height_ie,height_nn4,height_nn6,scrlbars,toolbar,menubar,resizable,location)
{

	if( !scrlbars )	
		scrlbars='no';	
	
	if( !toolbar )	
		toolbar='no';	

	if( !menubar )	
		menubar='no';
	
	if( !resizable )	
		resizable='no';	
	
	if( !location )
		location='no';

	if( !height_nn4 )	
		height_nn4=eval(height_ie);	
		
	if( !height_nn6 )	
	  	height_nn6=eval(height_nn4);	
		
	if( isIE4 )	
		height=eval(height_ie);	
	if( isNN4 )	
	  	height=eval(height_nn4);	
	if( isNN6 )	
	 	height=eval(height_nn6);	
		
	children[children.length] = window.open(url,name,'width='+eval(width)+',height='+eval(height)+',status=no,scrollbars='+scrlbars+',toolbar='+toolbar+',menubar='+menubar+',location='+location+',resizable='+resizable,false);
	return (false);
}


function closeChildren(){
	for(i=0;i<children.length;i++){
			children[i].close();		
	}
	children.length = 0;
}


function openPopupAdobeReader(url,width,height_ie,height_nn4,height_nn6,scrlbars,toolbar,menubar,resizable)
{

	if( !scrlbars )	
		scrlbars='yes';	
	
	if( !toolbar )	
		toolbar='yes';	

	if( !menubar )	
		menubar='yes';
	
	if( !resizable )	
		resizable='yes';	

	if( !height_nn4 )	
		height_nn4=eval(height_ie);	
		
	if( !height_nn6 )	
	  	height_nn6=eval(height_nn4);	
		
	if( isIE4 )	
		height=eval(height_ie);	
	if( isNN4 )	
	  	height=eval(height_nn4);	
	if( isNN6 )	
	 	height=eval(height_nn6);	
		
	window.open(url,'win1','width='+eval(width)+',height='+eval(height)+',status=yes,scrollbars='+scrlbars+',toolbar='+toolbar+',menubar='+menubar+',location=yes,resizable='+resizable,false);
	return (false);
}

function openPopupClickChat(url,width,height_ie,height_nn4,height_nn6,scrlbars,toolbar,menubar,resizable)
{

	if( !scrlbars )	
		scrlbars='yes';	
	
	if( !toolbar )	
		toolbar='no';	

	if( !menubar )	
		menubar='no';
	
	if( !resizable )	
		resizable='yes';	

	if( !height_nn4 )	
		height_nn4=eval(height_ie);	
		
	if( !height_nn6 )	
	  	height_nn6=eval(height_nn4);	
		
	if( isIE4 )	
		height=eval(height_ie);	
	if( isNN4 )	
	  	height=eval(height_nn4);	
	if( isNN6 )	
	 	height=eval(height_nn6);	
		
	window.open(url,'win2','width='+eval(width)+',height='+eval(height)+',status=no,scrollbars='+scrlbars+',toolbar='+toolbar+',menubar='+menubar+',location='+location+',resizable='+resizable,false);
	return (false);
}

function reLoad(url) 
{
	window.opener.location.href=url;
	window.close();
	return (false);
}
/* Tracker# 8194 */
function openPopupWindowPrintable()
{
	help_window=window.open('', 'help_window','toolbar=no,location=top,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=718,height=470,left=40,top=90'); 
	help_window.focus();
}

//***********************************************************************************
//*
//*  openScrollablePopupWindow
//*  Opens a popup window using the specified url, and defining the width and height
//*  of the window
//*  Inputs:  var url - the url to open
//*           var width - the width of the window in pixels
//*           var height - the height of the window in pixels
//*  Output:  None
//*
//************************************************************************************	
function openScrollablePopupWindow(url, width, height)
{
	window.open(url, "", "width=" + width + ",height=" + height + ",top=20,left=20,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=no");
}

function getDivHtml(divId, divTitle, title, authors, format, copyright, 
 lastUpdate, availability, price, shipping, baseUrlPath)
{
	var html = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
	html += "<head>\n\t<title>" + title + "</title>\n";
	var css1 = "\t<link href=\"" + baseUrlPath + "/css/styles.css\" rel=\"stylesheet\" type=\"text/css\"  media=\"screen, print\"  />\n";
	var css2 = "\t<link href=\"" + baseUrlPath + "/css/positioning.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen, print\" />\n";
	var css3 = "\t<link href=\"" + baseUrlPath + "/css/globalstyles.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen, print\" />\n";
	html += css1 + css2 + css3 + "</head>\n";
	html += "<body><div class=\"FloatLeft\">\n";
    html += "\t<img alt=\"\" src='" + baseUrlPath + "/images/logos/West.gif' />\n\t";
    html += "<div style=\"padding-left:10px\">\n\t<b>" + title + "</b><br />";
    if (authors.length > 0)
        html += "<b>" + authors + "</b>\n\t";
    if (format.length > 0)
        html += "<br /><small>" + format + "</small>\n\t";
    if (copyright.length > 0)
        html += "<br /><small>Copyright: " + copyright + "</small>\n\t";
    if (lastUpdate.length > 0)
        html += "<br /><small>Last Updated: " + lastUpdate + "</small>\n\t";
    if (availability.length > 0)
        html += "<br /><small>Availability: " + availability + "</small>\n\t";
    if (price.length > 0)
        html += "<br /><small>List Price: " + price + "</small>\n\t";
    if (shipping.length > 0)
        html += "<br /><small>Shipping: " + shipping + "</small>\n\t";
    html += "</div>\n";
    html += "\t<div style=\"padding-left:10px\"><small>" + divTitle + ":</small></div>\n\n";
    if (document.getElementById(divId) == null)
        var divContent = "Error: div tag '" + divId + "' not found.";
    else
        var divContent = document.getElementById(divId).innerHTML;
    divContent = divContent.replace('style="OVERFLOW: auto"','');
    html += divContent + "</div>\n</body>\n</html>";
    return html;
}

function printDiv(divId, divTitle, title, authors, format, copyright, 
 lastUpdate, availability, price, shipping, baseUrlPath)
{
    var width = 800;
    var height = 600;
    var left = Math.floor( (screen.width - width) / 2);
    var top = Math.floor( (screen.height - height) / 2);
	var html = getDivHtml(divId, divTitle, title, authors, format, copyright, lastUpdate, availability, price, shipping, baseUrlPath);
    var settings="toolbar=yes,resizable=yes,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,width=" + width + ",height=" + height + ";left=" + left + ";top=" + top + ";"; 
    var printDiv = window.open('', '', settings);
	printDiv.document.open("text/html");
    printDiv.document.write(html);
	printDiv.document.close();
	printDiv.print();
	printDiv.close();
}

function getFunnelDivHtml(divId, title, baseUrlPath)
{
	var html = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
	html += "<head>\n\t<title>" + title + "</title>\n";
	var css1 = "\t<link href=\"" + baseUrlPath + "/css/styles.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen, print\"  />\n";
	var css2 = "\t<link href=\"" + baseUrlPath + "/css/positioning.css\" rel=\"stylesheet\" type=\"text/css\"  media=\"screen, print\" />\n";
	var css3 = "\t<link href=\"" + baseUrlPath + "/css/globalstyles.css\" rel=\"stylesheet\" type=\"text/css\"  media=\"screen, print\" />\n";
	html += css1 + css2 + css3 + "</head>\n";
	html += "<body onclick=\"window.status='Read Only'; return false\" onmouseout=\"window.status='Read Only';\">\n";
    html += "\t<img alt=\"" + title + "\" src='" + baseUrlPath + "/images/logos/West.gif' />\n";
    if (document.getElementById(divId) == null)
        var divContent = "Error: div tag '" + divId + "' not found.";
    else
        var divContent = document.getElementById(divId).innerHTML;
    html += divContent + "\n</body>\n</html>";
    return html;
}
function printFunnel(divId, title, baseUrlPath)
{
    var width = 800;
    var height = 600;
    var left = Math.floor( (screen.width - width) / 2);
    var top = Math.floor( (screen.height - height) / 2);
	var html = getFunnelDivHtml(divId, title, baseUrlPath);
    var settings="toolbar=yes,resizable=yes,location=no,directories=no,menubar=no,status=yes,scrollbars=yes,width=" + width + ",height=" + height + ";left=" + left + ";top=" + top + ";"; 
    var printDiv = window.open('', '', settings);
	printDiv.document.open("text/html");
    printDiv.document.write(html);
	printDiv.document.close();
	printDiv.print();
	printDiv.close();
}




/* Browser friendly event handler */
function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    } else if (elm.attachEvent) {
        var result = elm.attachEvent('on' + evType, fn);
        return result;
    } else {
        elm['on' + evType] = fn;
    } 
}
