// Copyright 2005 | Thierry Koblentz

// Obviously there is JS support so we can safely hide the DDs (page FAQ and Directions)
document.write('<style type="text/css">dd,.hideDD {left:-9999px;position:absolute}</style>');

// Obviously there is JS support so we can show and use the selectAll() function in showCart.asp
document.write('<style type="text/css">#hideJSbehavior {display:block !important}</style>');
// Serve the Styles Sheet to NN4
if (!document.getElementById) document.write('<link rel="stylesheet" type="text/css" href="css/nn4.css" />');

// Popup the link for the PDF file
function TJKpopAppPdf(){ // v1.0 | www.TJKDesign.com
	var zA=document.getElementsByTagName('a');
	for (var i=0;i<zA.length;i++){
//  This is if the href value contains the string ".pdf" or if the anchor contains the correct "type" attribute or if the file is stored in a PDF folder 
		if (zA[i].getAttribute('href') != null && (zA[i].getAttribute("type")=="application/pdf" || zA[i].getAttribute('href').toUpperCase().indexOf(".PDF") >= 0 || zA[i].getAttribute('href').toUpperCase().indexOf("PDF/") >= 0)){
//	This is to include a title attribute or attach a string to an existing title's value
		zA[i].title+=' (opens in new window)';
//	This is to include a class or attach one to an existing class' value
//		zA[i].className+=zA[i].className?' pdfFile':'pdfFile';
//	This spawns multiple windows, but works fine with popup blockers
		zA[i].target='_blank'; 
//	This open a unique window and brings it in front of the opener each time the user clicks on the link 
//		zA[i].onclick=function(){newWin=window.open(this.href,'TJKWin');if(window.focus){newWin.focus()} return false;}
		}
	}
}


// Open files inside BIGPIC folder in a custom popup window
function TJKpopFolder(){ // v1.0 | www.TJKDesign.com
	var e = document.getElementById('content');
	if (e){
		var a=e.getElementsByTagName('a');
		for (var i=0;i<a.length;i++){
			if (a[i].getAttribute('href') != null && a[i].getAttribute('href').toUpperCase().indexOf("BIGPIC") >= 0){
					a[i].className+=a[i].className?' outlink':'outlink';
					a[i].title+=' (opens in new window)';
					a[i].onclick=function(){newWin=window.open(this.href,'TJKWin','location=no,menubar=no,status=no,toolbar=no,width=530,height=400');if(window.focus){newWin.focus()} return false;}
			}
		}
	}
}

// Toggle the bestSellers UL in the left sidebar. In case there is no JS support or if there is a script error, the href value is set to bestSellers.asp 
function TJKtoggle(){ // v1.0 | www.TJKDesign.com
	var el= document.getElementById('bestSellers');
	var zH = document.getElementById('trigger');
	var a=zH.getElementsByTagName('a');
		el.className = '';
		a[0].title+='Find out about our Best Sellers';
		a[0].onclick=function(){if (el.className == 'show'){el.className=''}else{el.className='show'};return false;}
}

// From Simon Willison's Weblog
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
addLoadEvent(function(){if(document.getElementById)TJKpopFolder()});
addLoadEvent(function(){if(document.getElementById)TJKtoggle()});
addLoadEvent(function(){if(document.getElementById)TJKpopAppPdf()});