function selectProd(sid,size)
{
	document.PO.size.value=size;
	document.PO.cat_ID.value=sid;
}

function checkAddToCart()
{
	var strProduct=getRadioValue(document.PO.product);
	if(!strProduct) {
		alert("Please select a size first.");
		return false;
	}

	return true;
}
function getRadioValue(radioObj) {
       if(!radioObj)
               return false;
       var radioLength = radioObj.length;
       if(radioLength == undefined)
               if(radioObj.checked)
                       return radioObj.value;
               else
                       return false;
       for(var i = 0; i < radioLength; i++) {
               if(radioObj[i].checked) {
                       return radioObj[i].value;
               }
       }
       return false;
}
//
// showFrames()
// Preloads images. Pleaces new image in frames then centers and displays.
//
function showFrames()
{
	// prep objects
	var strProduct=getRadioValue(document.PO.product);
	if(!strProduct) {
		alert("Please select a size first.");
		return false;
	}
	if(parseInt(document.PO.size.value)>=5) {
		alert("No frames available for this size.");
		return false;
	}
	
	/*
	var objOverlay = document.getElementById('framesoverlay');
	var objFrames = document.getElementById('frames');
	var objCaption = document.getElementById('framesCaption');
	var objContainer = document.getElementById('framesContainer');
	var objLoadingImage = document.getElementById('loadingFramesImage');
	var objFramesDetails = document.getElementById('framesDetails');
	var strProduct = 0;


	// strProduct is in the form of productid|size
	// we'll pass this along to the iframe for displaying frames
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();



		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (objLoadingImage) {	objLoadingImage.style.display = 'none'; }

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
		}

	
	// set height of Overlay to take up whole page and show
	objOverlay.style.width= (arrayPageSize[0] + 'px');
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	var lightboxTop = 100;
	var lightboxLeft = (arrayPageSize[0] / 2)-450;
	
	objFrames.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objFrames.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";

	objContainer.style.width='900px';
	objContainer.style.height='900px';
	objContainer.style.display = 'block';
	objFrames.style.display = 'block';
	objOverlay.style.display = 'block';
	*/
	window.location.href = '?view=frames&product='+strProduct;

}





//
// hideFrames()
//
function hideFrames()
{
	// get objects
	objOverlay = document.getElementById('framesoverlay');
	objFrames = document.getElementById('frames');

	// hide frames and overlay
	objOverlay.style.display = 'none';
	objFrames.style.display = 'none';

	// make select boxes visible
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}

}




//
// initFrames()
// Function runs on window load, going through link tags looking for rel="frames".
// These links receive onclick events that enable the frames display for their targets.
// The function also inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initFrames()
{
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','framesoverlay');
	objOverlay.onclick = function () {hideFrames(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '91';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	
	// create frames div, same note about styles as above
	var objFrames = document.createElement("div");
	objFrames.setAttribute('id','frames');
	objFrames.style.display = 'none';
	objFrames.style.position = 'absolute';
	objFrames.style.zIndex = '100';	
	objBody.insertBefore(objFrames, objOverlay.nextSibling);
	
	// create link
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Click to close');
	objLink.onclick = function () {hideFrames(); return false;}
	objFrames.appendChild(objLink);

	// create iframe here for frame choices
	var objContainer= document.createElement("iframe");
	objContainer.setAttribute('id','framesContainer');
	objContainer.style.top = '80';
	objContainer.style.display = 'none';
	objLink.appendChild(objContainer);
	
	// create details div, a container for the caption and keyboard message
	var objFramesDetails = document.createElement("div");
	objFramesDetails.setAttribute('id','framesDetails');
	objFrames.appendChild(objFramesDetails);

	// create caption
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','framesCaption');
	objCaption.style.display = 'none';
	objFramesDetails.appendChild(objCaption);

	// create keyboard message
	var objKeyboardMsg = document.createElement("div");
	objKeyboardMsg.setAttribute('id','frameskeyboardMsg');
	objKeyboardMsg.innerHTML = '<a href="#" onclick="hideFrames(); return false;">close</a>';
	objFramesDetails.appendChild(objKeyboardMsg);


}

addLoadEvent(initFrames);	// run initFrames onLoad