// ecatalogue.js

var needVersion = 6; // todo: verify minimum flash version compatible
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
var dhtmlUrl = "http://s7ondemand4.scene7.com/s7ondemand/brochure/dhtml_brochure.jsp?company=Signet&windowtitle=Ernest%20Jones%20-%20The%20Diamond%20and%20Watch%20Specialist&sku=";
var flashUrl = "http://s7ondemand4.scene7.com/s7ondemand/brochure/flash_brochure.jsp?company=Signet&windowtitle=Ernest%20Jones%20-%20The%20Diamond%20and%20Watch%20Specialist&sku=";
var fragConfig = "&config=";

if (plugin) {
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < words.length; ++i) {
		if (isNaN(parseInt(words[i])))
		continue;
		var pluginVersion = words[i]; 
	}
	var flashCanPlay = pluginVersion >= needVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\>\n'); //PJD: Stop IE4.5 Mac thinking we're starting a new scriptblock by splitting the tag
	document.write('on error resume next \n');
	document.write('flashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & needVersion)))\n');
	document.write('</SCR' + 'IPT\>\n');
}

function showCatalogue(ecat) {
	if (flashCanPlay) {
		openFlashVersion(ecat);
	} else {
		openDhtmlVersion(ecat);
	}
	return false;
}

function openFlashVersion(ecat) {
	var url = flashUrl + ecat + fragConfig + ecat;
	var properties = 'left=10,top=10,width=600,height=430,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	window.open(url, "", properties);
}

function openDhtmlVersion(ecat) {
	var url = dhtmlUrl + ecat + fragConfig + ecat;
	var properties = 'left=10,top=10,width=600,height=430,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	window.open(url, "", properties);
}
