

function validateQty(sFormName,sFieldName)
{
  var i = parseInt( document[sFormName][sFieldName].value );
  if( i>100 || i<0 ){
     alert( 'Please Enter a Quantity between 0 and 100' );
  }
}

var imgWin = 0;
function popImg( imgfile, w, h )
{
  if(imgWin && !imgWin.closed){ imgWin.close() }
  var popx, popy, strx, stry;
  popx = (screen.availWidth/2) - (w/2);
  popy = (screen.availHeight/2) - (h/2); /* why is this line commented out? - have put it back in now */
  //popy = 5;

  if(document.all) { strx='left'; stry='top'; } else { strx='screenX'; stry='screenY'; };
  imgWin = window.open( 'displayimage.asp?img='+imgfile+'&width='+w, '', 'width='+(w+40)+',height='+(h+40)+'toolbars=0,menubar=0,scrollbars=0,status=1,location=0,'+strx+'='+popx+','+stry+'='+popy ); 
}

var editWin = 0;
function popDetails( sURL, w, h)
{
  if(editWin && !editWin.closed){ editWin.close() }
  var popx, popy, strx, stry;
  popx = (screen.availWidth/2) - (w/2);
  popy = (screen.availHeight/2) - (h/2);
  //popy = 5;

  if(document.all) { strx='left'; stry='top'; } else { strx='screenX'; stry='screenY'; };
  editWin = window.open( sURL,'', 'toolbars=0,menubar=0,scrollbars=1,status=0,location=0,width='+w+',height='+h+','+strx+'='+popx+','+stry+'='+popy ); 
}





/*********** MENUS *************/



var bLoaded;

function getObj(id){
  if (document.getElementById){
    this.obj = document.getElementById(id);
    this.style = document.getElementById(id).style;
  }
  else if (document.all){
    this.obj = document.all[id];
    this.style = document.all[id].style;
  }
  else if (document.layers){
    this.obj = getObjNN4(document,id);
    this.style = this.obj;
  }
}

function getObjNN4(obj,id){
  var lyrs = obj.layers;
  var rtn;
  for (var i=0;i<lyrs.length;i++){
    if (lyrs[i].id == id){
      return lyrs[i];
    }else if(lyrs[i].document.layers.length){
      return getObjNN4(lyrs[i].document, id);
    }
  }
  return 0;
}

function setElementStyle(id, styleProperty, styleValue)
{
  if(bLoaded){
    var obj = new getObj(id);
    if (obj.obj && obj.style){
      obj.style[styleProperty] = styleValue;
    }
  }
}

function showElement(id){
 closeAllPop();
 setElementStyle( id, 'visibility', 'visible' );
}

function hideElement(id){
 setElementStyle( id, 'visibility', 'hidden' );
}


function bodyOnLoad() {
  bLoaded = true;
  hideElement('loading');
  initialisePopups();
}


function closeMe() {
	setElementStyle('refreshdiv', 'visibility', 'visible');
	window.opener.location.href = 'checkout.asp?action=summary';
	window.close();
}

function resizeMe(iWidth, iHeight) {
 if (top.outerWidth) {
	top.outerWidth = iWidth;
	top.outerHeight = iHeight;
   }
   else top.resizeTo(iWidth, iHeight);
}

function initialisePopups() {
	var oElements = document.getElementsByTagName('a');
	var iLoop, sDimensions;
	for(iLoop=0; iLoop < oElements.length; iLoop++) {
		if (oElements[iLoop].target.indexOf('_popup') >= 0) {
			oElements[iLoop].onclick = launchPopup;
			oElements[iLoop].onkeypress = launchPopup;
		}
	}
}

function launchPopup () {
	
	var iTop, iLeft, sTop, sLeft;
	var iWidth = this.getAttribute("popupwidth");
	var iHeight = this.getAttribute("popupheight");
	var sWidth = (iWidth != null) ? ',width=' + iWidth : '';
	var sHeight = (iHeight != null) ? ',height=' + iHeight : '';
	
	iLeft = (iWidth != null) ? (screen.availWidth / 2) - (iWidth / 2) : 0;
	iTop = (iHeight != null) ? (screen.availHeight / 2) - (iHeight / 2) : 0;

	if (document.all) { sLeft = 'left'; sTop = 'top'; } else { sLeft = 'screenX'; sTop = 'screenY'; }
		
	window.open(this.href, '', 'scrollbars=0,location=0,' + sLeft + '=' + iLeft + ',' + sTop + '=' + iTop + sWidth + sHeight);
	
	return false;
}

// For some reason, can't get this to work, not quite sure why! Am making use of an inline IE only script for the time being (inc_basket.asp)
function checkForInt(oEvent) {
	if (!oEvent) var oEvent = window.event;
	var iCode = (oEvent.which) ? oEvent.which : oEvent.keyCode;
	return (iCode <= 31 || (iCode >= 48 && iCode <= 57));
}