/*
	Standards Compliant Popup Script
	Author : Kevin Cannon
	http://www.multiblah.com
	Last Edited: 12.12.2004
	Version 1.0
	
	Searches through a document for links with the class popup.
	When clicked, this link will open in a popup window.
	This means you don't have to add javascript to your code, 
	and means the links continue to work, for search engines, 
	and browsers without javascript
	
*/


function initPopups() {

//alert("hello");

	if (!document.getElementById) return
	
	var aLinks = document.getElementsByTagName('a');

	for (var i = 0; i < aLinks.length; i++) {		
		if (aLinks[i].className == 'popup') {
			
			aLinks[i].onclick = function() {
				var url = this.href;
				openPopup(url);
				return false;
			}	
		}
	}
}

// popupWindow function
// This is where you set your specific height & width etc... for your popups.
function openPopup(url) {	
	window.open(url, 'popupwindow', 'width=400,height=300,scrollbars,resizable'); 
	return false;
}


// Piggy-back fucntion onto onLoad event ............................................
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(initPopups);



function popProducts() {	
	var url = "dir/all_cat_mini.htm";
	var tools="";
	var scrWidth = screen.availWidth;
	var scrHeight = screen.availHeight;
	var pageWidth = 500;
	var pageHeight = scrHeight - 30;
	var leftPos = scrWidth - pageWidth - 20;
	var scrnTop = 0;
	if (self.screenY) { scrnTop = self.screenY; }
	else {
	if (self.screenTop) { scrnTop = 0;}
	}
	
	self.moveTo(0,scrnTop); //move window to left so form not covered by pop-up
	tools = "resizable=yes,toolbar=no,location=no,scrollbars=yes,menubar=0,width="+pageWidth+",height="+pageHeight+",left="+leftPos+",top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
	return false;
}


// ----------------------------------------------
// Default search box text (thank you, Dunstan)
// ----------------------------------------------
 
// event handler
function addEventToObject(obj,evt,func) {
        var oldhandler = obj[evt];
        obj[evt] = (typeof obj[evt] != 'function') ? func : function(){oldhandler();func();};
}
 
// search box stuff
var Searchbox = {
        init : function()
               {
               var sBox = document.getElementById('comp');
               if (sBox)
                       {
                       addEventToObject(sBox,'onclick',Searchbox.click);
                       addEventToObject(sBox,'onblur',Searchbox.blur);
                       }       
               },
        click : function()
               {
               var sBox = document.getElementById('comp');
               if (sBox.value == 'e.g. mugs, pens, t-shirts')
                       {
                       sBox.value = '';
                       }
                },
        blur : function()
                {
               var sBox = document.getElementById('comp');
               if (sBox.value == '' || sBox.value == ' ') {sBox.value = 'e.g. mugs, pens, t-shirts';}
               }
        };
 
// add event onload
addEventToObject(window,'onload',Searchbox.init);



