/*  =========================================================================================================
	YarnMarket, LLC Routines 																				=
	====================================================================================================== */

/*  @name		dispLarge 										.
	@author		Andrew Penhorwood based on code by Ted Johnson	.
	@created													.
	@purpose	displays a large version of a product image    */
function dispLargeImage(sImage, nWidth, nHeight, sTitle) {	
	var URL = '/support/largeImage.cfm?image=' + sImage + '&width=' + nWidth + '&height=' + nHeight + '&title=' + sTitle;
	var windowName = 'Image' + genRandom() + nWidth;
    var features   = 'width=' + nWidth + ',height=' + nHeight + ',location=no,menubar=no,scrollbars=auto,status=no,toolbar=no,resizable=no,top=10,left=10';

    window.open(URL, windowName, features);
}

/*  @name		genRandom 										.
	@author		Andrew Penhorwood								.
	@created													.
	@purpose	generate a random number 					   */
function genRandom() {
	var nRandom = Math.random();
	nRandom = nRandom * 10000;
	nRandom = Math.ceil(nRandom);
	return nRandom;
}

/*  @name		popUp	 										.
	@author		Andrew Penhorwood based on code by Ted Johnson	.
	@created													.
	@purpose	displays a popUp window 					   */
function popUp(URL, windowName, nWidth, nHeight) {	
    var sFeatures   = 'width=' + nWidth + ',height=' + nHeight + ',location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,top=10,left=10';

    window.open(URL, windowName, sFeatures);
}
/*  @name		doSelect 										.
	@author		Andrew Penhorwood based on code by Ted Johnson	.
	@created													.
	@purpose	                        					   */
function doSelect(ID,nOption)
{
	var oPicLarge = document.getElementById("picLarge_"+ID);
	var oPicThumb = document.getElementById("picThumb_"+ID);
	var oSel = document.getElementById("sel_"+ID);
	var aLarge = eval('aLarge_'+ID);
	var aThumb = eval('aThumb_'+ID);

	oSel.options[nOption].selected = true;

	if(aLarge[nOption] == "-none-")
	{ alert("No image available for this color."); }
	else
	{
		oPicThumb.src   = aThumb[nOption];
		oPicLarge.value = aLarge[nOption];
	}
}
/*  @name		doChangeImage	 								.
	@author		Andrew Penhorwood based on code by Ted Johnson	.
	@created													.
	@purpose	              								   */
function doChangeImage(ID)
{
	var oPicLarge = document.getElementById("picLarge_"+ID);
	var oPicThumb = document.getElementById("picThumb_"+ID);
	var oSel = document.getElementById("sel_"+ID);
	var nOption = oSel.selectedIndex;

	var aLarge = eval('aLarge_'+ID);
	var aThumb = eval('aThumb_'+ID);
	
	if(aLarge[nOption] == "-none-")
	{ alert("No image available for this color."); }
	else
	{
		oPicThumb.src   = aThumb[nOption];
		oPicLarge.value = aLarge[nOption];
	}
}

