$(function() { 
/* --------------------------------------------------------------------- */

	$(".mainImage > img.thumb").click(function (){
		var mainImage 	= $(this).parent().find("img.main");
		var thumbImage	= $(this);
		var oldMainImg	= mainImage.attr("src");
		
		mainImage.attr({ src: thumbImage.attr("src") });
		thumbImage.attr({ src: oldMainImg });
	});

	$(".mainImage > img.main").click(function (){
		var mainImageURL = $(this).parent().find("img.main").attr("src");
		window.open(mainImageURL);
	});

	if($(".ajaxRenewLoginSession").is("*")){
	  $("a.getSpecs").each(function (){
		var specsContainer 	= $(this).parent();
		var theKey 			= $(this).parent().find("span.productID").text();
		specsContainer.html("<br/><br/>Loading...<br/>");
		specsContainer.addClass("AJAXloading");		
		$.ajax({
		  type: "GET",
		  url: "/_project/_public/modules/eude/AJAXGetPriceBox.asp",
		  data: "theKey="+theKey+"&x="+Math.random(99999),
		  cache: false,
		  contentType: "text/html; charset=iso-8859-1",
		  error : function(data,string) {alert(string);},
		  success : function (data) {
			    specsContainer.html("");
			  	specsContainer.append(data);
				specsContainer.removeClass("AJAXloading");		
			  }
		})
	  });
	}else{
	  $("a.getSpecs").each(function (){$(this).remove();})
	}
	$("a.getDeliveries").each(function (){$(this).remove();})	
/*		
	$("td.productSpecs div.AJAXCloseBTN").click(function (){
		var specsContainer 	= $(this).parent();
		specsContainer.html("<br/><br/>Loading...<br/>");
		specsContainer.addClass("AJAXloading").css("background-color","#fff");
		specsContainer.html("");
		specsContainer.append(data);
		specsContainer.removeClass("AJAXloading");		
	});
*/

	$("a.getDeliveries").click(function (){
		var specsContainer 	= $(this).parent();
	
		specsContainer.html("<br/><br/>Loading...<br/>");
		specsContainer.addClass("AJAXloading");		
		$.ajax({
		  type: "GET",
		  url: "/_project/_public/modules/eude/AJAXGetDeliveryBox.asp",
		  data: "x="+Math.random(99999),
		  cache: false,
		  contentType: "text/html; charset=iso-8859-1",
		  error : function(data,string) {alert(string);},
		  success : function (data) {
			  	specsContainer.html("");
				specsContainer.append(data);
				specsContainer.removeClass("AJAXloading");		
			  }
		})
	});

/*	
	$("td.deliveryInfo a.AJAXCloseBTN").click(function (){
		var specsContainer 	= $(this).parent();
		specsContainer.html("<br/><br/>Loading...<br/>");
		specsContainer.addClass("AJAXloading").css("background-color","#fff");
		specsContainer.html("<a class='getDeliveries' href='javascript:;'>Planned shipments</a>");
		specsContainer.removeClass("AJAXloading");		
	});
*/

/* --------------------------------------------------------------------- */
});

