
 
  var s=screen.width;
  var res1 = "";
  var res = "";
  if(s<801){res1 = "800/";}
  if(s<1279){res = "1280/";}
  if (document.documentElement.clientWidth>1279){wid=1280;}
  else {wid=1024;}
  var afiliate = unescape(parent.window.location.search);
  var afiliatestring = "?"
  var beginPositionAfiliate = afiliate.indexOf(afiliatestring)
  var afiliate1 =(afiliate.substring(beginPositionAfiliate+4,beginPositionAfiliate+1))
  var afiliate2 =((afiliate.substring(beginPositionAfiliate+4,beginPositionAfiliate))+'_NE');
  if (afiliate2=='_NE')afiliate2 = "?cd0_NE"
  if ((afiliate2.length < 2)||(afiliate2==null)){afiliate2="?cd0"}
  
  var appVer = navigator.appVersion.toLowerCase();
  var agt = navigator.userAgent.toLowerCase();
  var doc = document.location;
  var addr = document.location.href;
  
  var goo = (addr.indexOf('goo')!=-1)?true:false;
  var rep = (addr.indexOf('rep')!=-1)?true:false;
  
  var mac = ((appVer.indexOf("mac")!=-1)||(appVer.indexOf("ppc")!=-1))?true:false;
  var saf = (appVer.indexOf("safari")!=-1)?true:false;
  var is_gecko = ((!saf)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
  var moz = (agt.indexOf("mozilla/5")!=-1&&agt.indexOf("compatible")==-1&&agt.indexOf('opera')==-1&&is_gecko&&((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")))?true:false;
  var ope = (agt.indexOf("opera")!=-1)?true:false;
  var iePos  = appVer.indexOf('msie');
  var is_ie = ((iePos!=-1)&&!ope&&!saf)?true:false;
  var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_gecko) && (navigator.vendor=="Firebird"))?true:false;
  var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_gecko) && (agt.indexOf('firefox')!=-1))?true:false;
  if(is_fx){var vers = agt.split("firefox/"); fx_ver = vers[1];}// fx_ver*=1;}
  var net = (agt.indexOf("mozilla")!=-1&&agt.indexOf("compatible")==-1&&!ope&&!moz&&!saf&&!is_fx)?true:false;
  //
  var ios = ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) ?true:false; 
  //
  
  //set Netscape variables dependent on version no.
  var newNet = (net&&agt.indexOf('netscape/8')!=-1)?true:false;
  var oldNet = (net&&is_major<8&&is_minor<8)?true:false;
 

  
  //language
  if(net||saf||moz||is_fx){language = navigator.language}
  else{language = navigator.browserLanguage}
  var fr = (language.indexOf('fr')==0)?true:false;
  //	if(fr){document.location.replace('http://www.cooldiamonds.com/site_francais/cd_1024newfr/cd_1024newfr.html'+afiliate2);}
  //if(fr){document.location.replace('http://www.cooldiamonds.fr');}
  //if(ios){organisePage(country,lang1,s);}
  function getInternetExplorerVersion() {

    var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
}
return rv;
}

 
  function organisePage(country,lang1,s)
  { 
  var ver = getInternetExplorerVersion();
  var agt1 = navigator.userAgent.toLowerCase();
  var shopLocation="../../../../jstock/web/en/diamond-rings.jsp";
  var msieVer8="false";
  if((agt1.indexOf('msie')!=-1)&&(ver<9)){var msieVer8="true";}
  
 if (lang1=="ENG"){if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/en/diamond-rings.jsp"}
 else{shopLocation="../../../../jstock/v5/web/eng/diamond-rings.jsp";}
 }
 
 if (lang1=="ESP"){if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/es/diamond-rings.jsp";}
 else{shopLocation="../../../../jstock/v5/web/esp/diamond-rings.jsp";}
 }
 if (lang1=="FR"){if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/fr/bagues-diamant.jsp";}
                   else{shopLocation="../../../../jstock/v5/web/fr/diamondRingsFr.jsp";}
				   }
 if (lang1=="DUT"){
	 if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/nl/diamond-rings.jsp"}
	 else {shopLocation="../../../../jstock/v5/web/dut/diamond-rings.jsp";}
 }
 if (lang1=="PL"){
	 if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/pl/diamond-rings.jsp"}
	 else {shopLocation="../../../../jstock/v5/web/pl/diamond-rings.jsp";}
 }
 if (lang1=="GER"){
	 if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/ge/diamantringe.jsp"}
	 else {shopLocation="../../../../jstock/v5/web/ger/diamantringe.jsp";}
 }
 if (lang1=="FI"){
	 if((agt1.indexOf('msie')!=-1)&&(ver<8)){shopLocation="../../../../jstock/web/en/diamond-rings.jsp"}
	 else {shopLocation="../../../../jstock/v5/web/fi/diamond-rings.jsp";}
 }
  var addr = document.location.href;
	var imgRef="";
	var imgRef3="-";
	
	if(addr.indexOf('imgRef=')!=-1){
		var addr2 = addr.split('imgRef=');
		if(addr2[1]){
			if(addr2[1].length>=5){
				var imgRef5 = addr2[1].split("&");//x,x&'googleTaGs'
				var imgRef4 = imgRef5[0];//xx,xx
			}
			else{
				var imgRef4 = addr2[1];
			}
			if(imgRef4.indexOf(",")!=-1){
				var imgRef3 = imgRef4;//xx,xx     
				var imgRef2 = imgRef3.split(",");
				var imgRef = imgRef2[0]+imgRef2[1];//xx
				//make sure only changes front page picture if we have an existing pic on the server
				if (imgRef=="017"||imgRef=="10"||imgRef=="20"||imgRef=="30"||imgRef=="60"){}
				else{imgRef="";}
			}
		}
	}

	
  location.href = shopLocation+afiliate2+"&imgRef="+imgRef3+"&mac="+mac+"&saf="+saf+"&is_gecko="+is_gecko+"&moz="+moz+"&ope="+ope+"&is_ie="+is_ie+"&is_fb="+is_fb+"&is_fx="+is_fx+"&is_ios="+ios+"&net="+net+"&country="+country+"&lang="+lang1+"&curr="+curr+"&screenWidth="+wid+"&phone="+escape(phone)+"&email="+email+"&currTxt="+currTxt+"&msieVer8="+msieVer8;
  }
 function changePicture()
 
 {
	 var addr = document.location.href;
	var imgRef="";
	var imgRef3="-";
	
	if(addr.indexOf('imgRef=')!=-1){
		var addr2 = addr.split('imgRef=');
		if(addr2[1]){
			if(addr2[1].length>=5){
				var imgRef5 = addr2[1].split("&");//x,x&'googleTaGs'
				var imgRef4 = imgRef5[0];//xx,xx
			}
			else{
				var imgRef4 = addr2[1];
			}
			if(imgRef4.indexOf(",")!=-1){
				var imgRef3 = imgRef4;//xx,xx     
				var imgRef2 = imgRef3.split(",");
				var imgRef = imgRef2[0]+imgRef2[1];//xx
				
				//make sure only changes front page picture if we have an existing pic on the server
				if (imgRef=="017"||imgRef=="10"||imgRef=="20"||imgRef=="30"||imgRef=="60"){}
				else{imgRef="";}
			
			}
		}}
	 window.document.body.style.backgroundImage="none"; 
	 var url1="../../../../jstock/v5/web/pictures/"+lang1.toLowerCase()+"/frontPageWide"+country+imgRef+".jpg";
	 document.body.style.backgroundImage='url("'+url1+'")';
	 }
function moveAbout(){
	var addr = document.location.href;
	var imgRef="";
	var imgRef3="-";
	
	if(addr.indexOf('imgRef=')!=-1){
		var addr2 = addr.split('imgRef=');
		if(addr2[1]){
			if(addr2[1].length>=5){
				var imgRef5 = addr2[1].split("&");//x,x&'googleTaGs'
				var imgRef4 = imgRef5[0];//xx,xx
			}
			else{
				var imgRef4 = addr2[1];
			}
			if(imgRef4.indexOf(",")!=-1){
				var imgRef3 = imgRef4;//xx,xx     
				var imgRef2 = imgRef3.split(",");
				var imgRef = imgRef2[0]+imgRef2[1];//xx
				//make sure only changes front page picture if we have an existing pic on the server
				if (imgRef=="017"||imgRef=="10"||imgRef=="20"||imgRef=="30"||imgRef=="60"){}
				else{imgRef="";}
				
			}
		}}
	if(document.documentElement.clientWidth/document.documentElement.clientHeight>1.55){changePicture();}
else{var url2="../../../../jstock/v5/web/pictures/"+lang1.toLowerCase()+"/frontPage"+country+imgRef+".jpg";
	document.body.style.backgroundImage='url("'+url2+'")';}
var fRes="7px";
	var topPos="95%";
	if(document.documentElement.clientWidth>600 ){fRes="8px";}
	if(document.documentElement.clientWidth>700 ){fRes="9px";}
	if(document.documentElement.clientWidth>850 ){fRes="10px";}
	if(document.documentElement.clientWidth>1050 ){fRes="11px";}
	if(document.documentElement.clientWidth>1100 ){fRes="12px";}
	if(document.documentElement.clientWidth>1200 ){fRes="14px";}
	
	
	if(document.documentElement.clientWidth/document.documentElement.clientHeight>1.47||599>document.documentElement.clientWidth){
	document.getElementById('footerLinkAbout').style.visibility="hidden";
	document.getElementById('footerLinkTerms').style.visibility="hidden";
	document.getElementById('footerLinkInfo').style.visibility="hidden";
	document.getElementById('footerLinkPress').style.visibility="hidden";
	document.getElementById('footerLinkContact').style.visibility="hidden";
	if(document.getElementById('engagementRings')){document.getElementById('engagementRings').style.visibility="hidden";
	document.getElementById('hattonGardensShowRoom').style.visibility="hidden";
	}}
	
	else {
	document.getElementById('footerLinkAbout').style.visibility="visible";
	document.getElementById('footerLinkTerms').style.visibility="visible";
	document.getElementById('footerLinkInfo').style.visibility="visible";
	document.getElementById('footerLinkPress').style.visibility="visible";
	document.getElementById('footerLinkContact').style.visibility="visible";
	if(document.getElementById('engagementRings')){document.getElementById('engagementRings').style.visibility="visible";
	document.getElementById('hattonGardensShowRoom').style.visibility="visible";}}
	document.body.style.fontSize=fRes;
	document.getElementById('transP').style.height=topPos;
	document.getElementById('footerLinkAbout').style.top=topPos;
	document.getElementById('footerLinkTerms').style.top=topPos;
	document.getElementById('footerLinkInfo').style.top=topPos;
	document.getElementById('footerLinkPress').style.top=topPos;
	document.getElementById('footerLinkContact').style.top=topPos;
	}
	
	(function(){
 
/**
CONFIGURATION:
Define the size of our background image
*/
var bgImageSize = {
width: 640,
height: 492
};
 
/*END CONFIGURATION */
 
/**
Detect support for CSS background-size. No need for any more javascript if background-size is supported.
*/
if ((function(){
var el = document.createElement('div'),
bs = 'backgroundSize',
ubs= bs.charAt(0).toUpperCase() + bs.substr(1),
props= [bs, 'Webkit' + ubs, 'Moz' + ubs, 'O' + ubs];
 
for ( var i in props ) {
if ( el.style[props[i]] !== undefined ) {
return true;
}
}
return false;
}())) {
return;
};

 
/**
We also want to leave IE6 and below out in the cold with this
*/
if ( false /*@cc_on || @_jscript_version < 5.7 @*/ ) {
return;
}
 
/**
If we've gotten here, we don't have background-size support,
so we'll have to mimic it with Javascript.
Let's set up some variables
*/
var elBody,
imageID= 'expando',
tallClass= 'tall',
wideClass= 'wide',
elBgImage, elWrapper, img, url, imgAR,
 
/**
Since we're not relying on a library, we'll need some utility functions
First, basic cross browser event adders
*/
addEvent = function(el, evnt, func) {
if (el.addEventListener) {
el.addEventListener(evnt, func, false);
} else if (el.attachEvent) {
return el.attachEvent("on" + evnt, func);
} else {
el['on' + evnt] = func;
}
},
 
domLoaded = function(callback) {
/* Internet Explorer */
/*@cc_on
@if (@_win32 || @_win64)
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
document.getElementById('ieScriptLoad').onreadystatechange = function() {
if (this.readyState == 'complete') {
callback();
}
};
@end @*/
/* Mozilla, Chrome, Opera */
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', callback, false);
}
/* Safari, iCab, Konqueror */
if (/KHTML|WebKit|iCab/i.test(navigator.userAgent)) {
var DOMLoadTimer = setInterval(function () {
if (/loaded|complete/i.test(document.readyState)) {
callback();
clearInterval(DOMLoadTimer);
}
}, 10);
}
},
 
/**
Next, a way to properly get the computed style of an element

*/
getStyle = function(el, css){
var strValue = "";
if (document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(el, "").getPropertyValue(css);
}
else if (el.currentStyle){
css = css.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
strValue = el.currentStyle[css];
}
return strValue;
},
 
/**
Finally, some element class manipulation functions
*/
classRegex = function(cls) {
return new RegExp('(\\s|^)'+cls+'(\\s|$)');
},
 
hasClass = function(el, cls) {
return el.className.match(classRegex(cls));
},
 
addClass = function(el, cls) {
if ( ! hasClass(el, cls)) {
el.className += ' ' + cls;
}
},
 
removeClass = function(el, cls) {
if (hasClass(el, cls)) {
el.className = el.className.replace(classRegex(cls), '');
}
},
 
/*
Now we can move on with the core functionality of Flexibackground
*/
initialize = function() {
 
// No need for any of this if the screen isn't bigger than the background image
if (screen.availWidth <= bgImageSize.width && screen.availHeight <= bgImageSize.height) {
return;
}
 
// Grab elements we'll reference throughout
elBody= document.getElementsByTagName('body')[0];
 
// Parse out the URL of the background image and drop out if we don't have one
url = getStyle(elBody, 'backgroundImage').replace(/^url\(("|')?|("|')?\);?$/g, '') || false;
if (!url || url === "none" || url === "") {
return;
}
 
// Get the aspect ratio of the image
imgAR = bgImageSize.width / bgImageSize.height;
 
// Create a new image element
elBgImage = document.createElement('img');
elBgImage.src = url;
elBgImage.id = imageID;
 
// Create a wrapper and append the image to it.
// The wrapper ensures we don't get scrollbars.
elWrapper = document.createElement('div');
elWrapper.style.overflow= 'hidden';
elWrapper.style.width= '100%';
elWrapper.style.height= '100%';
elWrapper.style.zIndex= '-1';
 
elWrapper.appendChild(elBgImage);
elBody.appendChild(elWrapper);
 
// Fix the wrapper into position
elWrapper.style.position= 'fixed';
elWrapper.style.top= 0;
elWrapper.style.left= 0;

// Set up a resize listener to add/remove classes from the body 
addEvent(window, 'resize', resizeAction);

// Set it up by triggering a resize
resizeAction();
 
},
 
/**
Set up the action that happens on resize
*/
resizeAction = function() {
var win = {
height: window.innerHeight || document.documentElement.clientHeight,
width: window.innerWidth || document.documentElement.clientWidth
},
 
// The current aspect ratio of the window
winAR = win.width / win.height;
 
// Determine if we need to show the image and whether it needs to stretch tall or wide
if (win.width < bgImageSize.width && win.height < bgImageSize.height) {
removeClass(elBody, wideClass);
removeClass(elBody, tallClass);
} else if (winAR < imgAR) {
removeClass(elBody, wideClass);
addClass(elBody, tallClass);
// Center the image
elBgImage.style.left = Math.min(((win.width - bgImageSize.width) / 2), 0);
} else if (winAR > imgAR) {
addClass(elBody, wideClass);
removeClass(elBody, tallClass);
elBgImage.style.left = 0;
}
};
 
// When the document is ready, run this thing.
domLoaded(initialize);
 
})();

