/************************************************************************/

// JQuery on load
$(document).ready(function() {
		
	// We now manage the rollover state of some images
	// Let's chain all our events together:
	$('.imagehover').css('opacity',0.7).mouseover(function() {
		$(this).css('opacity',1)		
	}).mouseout(function() {
		$(this).css('opacity',0.7)		
	});
	
	// pull in reviews content
	var prodRef = document.getElementById('Ref').title;
	$("#ratings-frame").load("/reviews/review-summary.aspx?id=" + prodRef);
	$("#ratings-full").load("/reviews/filter_read_reviews.aspx?id=" + prodRef);

});
	
/************************************************************************/

/* For products WITH size/colour drop down lists */
function showStockMultiple()
	{
	
		/* document.getElementById("StockFrameDiv").style.display = "block"; */
		var prodRefParent = document.getElementById('Ref').title;
		var prodRef = "v_" + document.getElementById('Ref').title + "_1";
		var dropdownIndex = document.getElementById(prodRef).selectedIndex;
		var dropdownValue = document.getElementById(prodRef)[dropdownIndex].id;
		
		/*document.getElementById("StockFrame").src = "http://shop.packyourbags.com/stock/stock.aspx?id=" + dropdownValue;*/
		
		if(document.getElementById(prodRef)[dropdownIndex].value == "nothing")
			{
				
				document.getElementById("stock-default").style.display = "block";
				window.parent.document.getElementById("BuyDiv").style.display = "block";
				try 
					{
					window.parent.document.getElementById("quantity-no-sizes").style.display = "block";
					}
				catch(err)
					{
					}
					
				try 
					{
					window.parent.document.getElementById("quantity-with-sizes").style.display = "block";
					}
				catch(err)
					{
					}
			
			}
		else
			{
				document.getElementById("stock-default").style.display = "none";
			}
		
		var w = document.getElementById("StockFrame");
		w.contentWindow.location.replace("http://shop.packyourbags.com/stock/stock.aspx?id=" + dropdownValue + "&parent=" + prodRefParent);

	}

/************************************************************************/

/* For single choice products - changing to querystring on stock.aspx to show whether a product is in stock */
function showStockSingle()
	{
		/*try
			{*/
			var CyberTillRef = document.getElementById('Ref').title;
			
			var w = document.getElementById("StockFrame");
			w.contentWindow.location.replace("http://shop.packyourbags.com/stock/stock.aspx?id=" + CyberTillRef);
			/*}
		catch(err)
			{
			}*/
	}
	
/************************************************************************/

/* Validation for drop down lists when adding to basket */	
function AddToBasketValidation()
	{
		
		// when there is two size/colours drop down
		
			try 
				{
					
					var prodRef2 = "v_" + document.getElementById('Ref').title + "_2"
					var dropdownIndex2 = document.getElementById(prodRef2).selectedIndex;
					var dropdownValue2 = document.getElementById(prodRef2)[dropdownIndex2].value;
					
					var prodRef = "v_" + document.getElementById('Ref').title + "_1"
					var dropdownIndex = document.getElementById(prodRef).selectedIndex;
					var dropdownValue = document.getElementById(prodRef)[dropdownIndex].value;
					
					if (dropdownValue == "nothing" || dropdownValue2 == "nothing")
						{
							alert("Please select a size and/or colour before adding to basket");
							return false;
						}
						
				}
			catch(err)
				{
				}
						
		// when there is one size/colour drop down
						
			try 
				{
					
					var prodRef = "v_" + document.getElementById('Ref').title + "_1"
					var dropdownIndex = document.getElementById(prodRef).selectedIndex;
					var dropdownValue = document.getElementById(prodRef)[dropdownIndex].value;
					
					if (dropdownValue == "nothing")
						{
							alert("Please select a size and/or colour before adding to basket");
							return false;
						}
						
				}
			catch(err)
				{
				}

	}

/************************************************************************/

function ShowReviewsFrame() {
	var ProdId = document.getElementById('Ref').title;
	var ReviewsFrame = document.getElementById("reviews-summary-iframe");
	ReviewsFrame.contentWindow.location.replace("/reviews/review-summary.aspx?id=" + ProdId);
}

/************************************************************************/