// -----------------------------------------------------------------------------
// Javascript Copyright ©2010 Sage internet Solutions
// Developed by Alan Pugh
// http://www.sageinternet.com/
// -----------------------------------------------------------------------------


// -----------------------------------------------------------------------------
// Redefine changeProductPhotoView in order to hijack the call for MagicZoom Updates
// -----------------------------------------------------------------------------
var changeProductPhotoViewOrig = changeProductPhotoView;
changeProductPhotoView = function(profile,profileList) {
	changeProductPhotoViewOrig(profile,profileList);
	var zoom = document.getElementById("mzLink"); //get the reference to our zoom object
	//debugit("zoom.href = " + zoom.href, true);
	//debugit("zoom.rel = " + zoom.rel);
	//debugit("zoom.firstChild.src = " + zoom.firstChild.src);
	//debugit("zoom.firstChild.pbsrc = " + zoom.firstChild.pbsrc); // Nitrosell PopBox Source
	zoom.href = getProductImageSource("large"+profile);
	//debugit("zoom.href = " + zoom.href, true);

	// refresh ALL zooms on the page
	MagicZoomPlus.refresh();
}


// -----------------------------------------------------------------------------
// Redefine updateProductSelection in order to hijack the call for MagicZoom Updates
// updateProductSelection is called by populateSelect() when the colour dropdown changes
// -----------------------------------------------------------------------------
var updateProductSelectionOrig = updateProductSelection;
updateProductSelection = function(profile,profileList) {
	updateProductSelectionOrig();
	var zoom = document.getElementById("mzLink"); //get the reference to our zoom object
	zoom.href = getProductImageSource("large");
	MagicZoomPlus.refresh();
}



var debugit = function (str, blnClear){
try{
	var pnlDebug = document.getElementById('pnlDebug');
	if(typeof pnlDebug != "undefined"){

		if(blnClear === true || blnClear === 1){
			pnlDebug.innerHTML = "pnlDebug";
		}

		//pnlDebug.innerHTML = str + '<br>' + pnlDebug.innerHTML;
		pnlDebug.innerHTML =pnlDebug.innerHTML + '<br>' +  str;
	}
	else{
		alert("debugit(" + str + ")\n"  + "Error: pnlDebug is undefined");
	}
}
catch (e){
	alert("debugit(" + str + ")\n"  + "Error: " + e.description + "\nLine: " + e.line);
}
};
