

// These two functions handle the image rollovers for the images thumbnails, based on arrays of
// image objects defined in each gallery js defintion files. Before swapping the image, they 
// compare the named image to the "currentDetail" variable. If it is the currently elected thumbnail, 
// they won't perform the image swap.

function thumbnail_rollOver(imgName) {
  if (document.images) {
  	if (imgName != ("print" + currentDetail)) { document.images[imgName].src = eval(imgName + "_on.src"); }
  }
}

function thumbnail_rollOut(imgName) {
  if (document.images) {
    if (imgName != ("print" + currentDetail)) { document.images[imgName].src = eval(imgName + "_off.src"); }
  }
}


// This function loads the new detial when the user clicks on a thumbnail image:
//   1. Swap out previously selected thubnail image for it's "off" version.
//   2. Update the 'currentDetail' variable to reflect newly selected detail.
//   3. Asemble the new HTML displaying image/text for newly selected detail.
//	 4. Replace the old detail with the new detail.
//	 5. Swap in the "on" version of the image thumbnail for newly selected thumbnail.

function loadPrintDetail(printNum) {

	// "Turn off" old thumbnail image
	var imgName = ("print" + currentDetail);
	document.images[imgName].src = eval(imgName + "_off.src"); 
	
	// Update to reflect thumbnail the user just clicked on.
	currentDetail = printNum;	
	
	// Need to set these variables in order to send to the pop-open script (can't do an eval() statement as an attribute delivered to the script because of the parentheses involved)
	printTitle = eval("print" + currentDetail + ".title");
	windowWidth = eval("print" + currentDetail + ".popOpen_width");
	windowHeight = eval("print" + currentDetail + ".popOpen_height");
	
	// build the HTML for the new detail
	var newHTML;
	
	//WIDTH=\"278\" HEIGHT=\"194\"
	newHTML = ( "<DIV STYLE=\"position:relative; width:278px; margin-right:-7px\"><IMG SRC=\"../images/prints/gallery" + galleryID + "/print"  + currentDetail + "_med.jpg\" ></DIV>");
	newHTML += ( "<H1>" + eval("print" + currentDetail + ".title") + "</H1>" );
	
	
	// Catch all for any additional content that falls out of the standard format ( Triptychs & Diptychs, etc)
	if (eval("print" + currentDetail + ".addInfo") != " ") { 
		newHTML += ( "<P>" + eval("print" + currentDetail + ".addInfo") + "</P>" );
	}
					
	// For each different offering of the print, go ahead and 
	for (count=0; count < eval("print" + currentDetail + ".totalOptions"); count++) {
		
		var currentOption = (count + 1);	
		
		
		newHTML += ("<DIV STYLE=\"position:relative; width:425px; height:2px; z-index:1; margin-right: -153px; margin-bottom: 8px; visibility: visible;\"><IMG SRC=\"../images/prints/divider.gif\" WIDTH=\"425\" HEIGHT=\"2\"></DIV>");
		
		newHTML += ( "<FORM ACTION=\"javascript:openOrderForm()\" METHOD=\"post\" NAME=\"orderForm" + currentOption + "\" ID=\"orderForm" + currentOption + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"GalleryID\" VALUE=\"" + galleryID + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"PrintID\" VALUE=\"" + currentDetail + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"Title\" VALUE=\"" + printTitle + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"Format\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".format") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"Width\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".width") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"Height\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".height") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"EditionSize\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".editionSize") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"Price\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".price") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"PriceFramed\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".priceFramed") + "\">" );
		newHTML += ( "<INPUT TYPE=\"hidden\" NAME=\"RecommendedFrame\" VALUE=\"" + eval("print" + currentDetail + ".option" + currentOption + ".recommendedFrame") + "\">" );
			
		newHTML += ( "<P><B>" );
		newHTML += ( eval("print" + currentDetail + ".option" + currentOption + ".height") + "\" x " + eval("print" + currentDetail + ".option" + currentOption + ".width") + "\" " );
		newHTML += ( eval("print" + currentDetail + ".option" + currentOption + ".format") + "</B><BR>" );
		newHTML += ( "$" + eval("print" + currentDetail + ".option" + currentOption + ".price") + " [$" + eval("print" + currentDetail + ".option" + currentOption + ".priceFramed") + " framed]<BR>"  );
		newHTML += ( eval("print" + currentDetail + ".option" + currentOption + ".editionSize") + " S\/N" );
		newHTML += ( "</P>" );
		
		// Display Frame Recommendations if reccomendations exist...
		if ( eval("print" + currentDetail + ".option" + currentOption + ".recommendedFrame") != " ") { 
			newHTML += ( "<H2>RECOMMENDED FRAME/MATTE:</H2>" );
			newHTML += ( "<P>" + eval("print" + currentDetail + ".option" + currentOption + ".recommendedFrame") + "</P>" );
		}
		
		newHTML += ( "<DIV CLASS=\"orderButton\"><A HREF=\"javascript:openOrderForm('" + currentOption + "');\"><IMG SRC=\"../images/shared/btn_order_off.gif\" WIDTH=\"93\" HEIGHT=\"24\" BORDER=\"0\"</A></DIV>");	
		
		newHTML += ( "</FORM>");		
		
	}
	
	// Display the new detail
	document.getElementById('detailColumn').innerHTML = newHTML;
	
	// If this is a "New Release", display the callout
	if ( eval("print" + currentDetail + ".newRelease") ) { 
		document.getElementById('newReleaseBug').style.display = 'block';
	}
	else {
		document.getElementById('newReleaseBug').style.display = 'none';
	}
	
	document.getElementById('detailColumn').innerHTML = newHTML;

	// Swap to the "on" state for the corresponding thumbnail image
	var imgName = ("print" + currentDetail);
	document.images[imgName].src = eval(imgName + "_on.src"); 
}



// Used to open and send from contents to Order Form window

function openOrderForm( selectedOption ) {
	
	var formID = eval(selectedOption);	
	
	var url = "order.php";
	url += "?";	
	url += ("galleryID=" + eval("document.orderForm" + formID + ".GalleryID.value"));
	url += ("&printID=" + eval("document.orderForm" + formID + ".PrintID.value"));
	url += ("&title=" + eval("document.orderForm" + formID + ".Title.value"));
	url += ("&format=" + eval("document.orderForm" + formID + ".Format.value"));
	url += ("&width=" + eval("document.orderForm" + formID + ".Width.value"));
	url += ("&height=" + eval("document.orderForm" + formID + ".Height.value"));
	url += ("&editionSize=" + eval("document.orderForm" + formID + ".EditionSize.value"));
	url += ("&price=" + eval("document.orderForm" + formID + ".Price.value"));
	url += ("&priceFramed=" + eval("document.orderForm" + formID + ".PriceFramed.value"));
	url += ("&recommendedFrame=" + eval("document.orderForm" + formID + ".RecommendedFrame.value"));

	popWin = window.open( url, '', 'width=625,height=520,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popWin.focus();

}
	

// This function dynamically creates and writes to a new pop-open window to display a larger version of the print detail image.

function openGalleryWindow(galleryID, printID, printName, winWidth, winHeight) {	
	galleryWin = window.open('', '' ,'toolbar=no,resize=yes,scrollbars=no,menubar=no,width=' + winWidth + ',height=' + winHeight);
	galleryWin.document.write("<HTML><HEAD><LINK HREF=\"/css/global.css\" REL=\"stylesheet\" TYPE=\"text/css\"></HEAD><BODY><IMG SRC='/images/prints/gallery" + galleryID + "/print"  + printID + "_lg.jpg'></BODY></HTML>");
	galleryWin.document.close();
}

