var currentThumbId = 0;

var isNS = 0;
var isIE = 0;
    if( navigator.appName.indexOf('Netscape') != -1 ) 
      { isNS = 1; }
else if( navigator.appName.indexOf('Microsoft') != -1 ) 
      { isIE = 1; }

function changeImg(title, thumbid) {
  document.images.mainImg.src = '/shirts/'+title;
  if( currentThumbId ) { document.getElementById(currentThumbId).style.borderColor = 'white'; }
  document.getElementById(thumbid).style.borderColor = '#0099ff';
  currentThumbId = thumbid;
  return false;
}

function fitBoxes() {

  var boxNum = 0;
  var boxHeight = new Number();
  var adjust = 0;
  if(isIE) { adjust = 0; } else { adjust = 0; }

//deal with the sidebar (same calculations, just different object id 
    outerBox = document.getElementById('sidebar');
    lowerBox = document.getElementById('sidebarbot');
    boxHeight = outerBox.offsetHeight;
    boxHeight = boxHeight - 40;
    boxHeight = boxHeight % 17;
    boxHeight = 17 - Number(boxHeight) + Number(adjust);
    outerBox.style.height = (outerBox.offsetHeight + boxHeight)+"px";
    lowerBox.style.top = boxHeight+"px"; 

try {
  while (typeof(document.getElementById('topbox'+boxNum)) != 'undefined') {
    outerBox = document.getElementById('topbox'+boxNum);
    lowerBox = document.getElementById('box'+boxNum);

    boxHeight = outerBox.offsetHeight;
    boxHeight = boxHeight - 40;
    boxHeight = boxHeight % 17;
    boxHeight = 17 - Number(boxHeight) + Number(adjust);
    outerBox.style.height = (outerBox.offsetHeight + boxHeight)+"px";
    lowerBox.style.top = boxHeight+"px";
    boxNum++;
  }
}
finally { return true; }
}



var popupWindow=null;
function popup(mypage,myname,w,h,t,l){
settings='width='+ w + ',height='+ h + ',top=' + t + ',left=' + l + ',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
popupWindow=window.open(mypage,myname,settings);

}
/***************************************************
####################################################

#  these functions aren't being used at present

####################################################
##################################################*/

function randomPins() {
return true;
  var pins = getElementsByClassName(document, "*", "left");
  for(var i = 0; i < pins.length; i++) 
    { pins[i].style.background = "url('/images/pin-tl.php?i="+i+"')" ; }
  var pins = getElementsByClassName(document, "img", "right");
  for(var i = 0; i < pins.length; i++) 
    { pins[i].style.background = "url('/images/pin-tl.php?i="+i+"')" ; }
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}


