/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10)
}

/* for other browsers */
window.onload = init;

/* Golbal scoped vars */

/* dom loaded call */
function init() {
// quit if this function has already been called
	if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
	arguments.callee.done = true;
// kill the timer
	if (_timer) clearInterval(_timer);
	
  /* Clear inputs */
  inputs = document.getElementsByTagName('input') ;
  for (i = 0; i < inputs.length; i++) {
    if (inputs[i].getAttribute('value')) {
      inputs[i].onfocus = clearIt ;
    }
  }
  
}

/* page functions */
function clearIt() {
  if ((this.value == this.getAttribute('value')) && (this.getAttribute('type') == 'text')) {
    this.value = '' ;
  }
}
function toggleQuickNav() {
  var quickNav = getChild(document.getElementById('quickNavMenu')) ;
  quickNav.style.display = (quickNav.style.display == 'block' ? 'none' : 'block') ;
}
function toggle() {
  smlImg = getChild(this) ;
  smlSrc = smlImg.src ;
  lrgSrc = smlSrc.substring(0,smlSrc.lastIndexOf('.')) + ".thumb?w=260&h=260";
  ProductImage.src = lrgSrc
}
function open() {
  smlImg = getChild(this) ;
  smlSrc = smlImg.src ;
  lrgSrc = smlSrc.substring(0,smlSrc.lastIndexOf('.')) + '.thumb?w=400&amp;h=400';
  ShowPopup(lrgSrc,lrgSrc,440,420,true);
  return false;
}


/* common methods */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function getChild(startParent) {
  EndChild = startParent.firstChild ;
  while(EndChild.nodeType != 1){
    EndChild = EndChild.nextSibling ;
  }
  return EndChild;
}