// Si la page apparaît dans une frame, on repasse dans la frame principale
//if (top.frames.length != 0) top.location.href = self.document.location.href;

// Détection du navigateur (enfin, presque)
var browser   = navigator.userAgent;
var isOpera   = (browser.indexOf("Opera") != -1);
var isIE      = (!isOpera && browser.indexOf("MSIE") != -1);
var isMozilla = (!isOpera && !isIE && browser.indexOf("Mozilla") != -1);

function formcdeSubmit() {
	
	document.formcde.submit();
	
}

function htmlentities (string) {
	quote_style = 'ENT_QUOTES';
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();    
    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    hash_map["'"] = '&#039;';    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
        return tmp_str;
}

// Donne le focus à l'élément dont l'ID est passé en paramètre
function giveFocus(theId) {
	document.getElementById(theId).focus();
}

// Tableau qui stocke les couleurs des boutons désactivés
// (Uniquement utile sous Opera qui ne désactive pas "visuellement" les boutons)
var saved_colors = new Array;

// Stocke la couleur de l'objet
function saveColor(itemId, color) {
	saved_colors[itemId] = color;
}

// Récupère la couleur de l'objet
function restoreColor(itemId) {
	if(typeof(saved_colors[itemId]) == "undefined") return "#000000";
	if(saved_colors[itemId] == "") return "#000000";
	return saved_colors[itemId];
}

// Désactive les éléments dont les ID sont passés en paramètres
function disableItem() {
	var items = disableItem.arguments;
	if(items.length == 0) return;
	for(var d=0; d<items.length; ++d) {
		if(document.getElementById(items[d]).disabled) continue;
		document.getElementById(items[d]).disabled = true;
		if(isOpera) {
			// Opera ne "montre" pas les boutons désactivés
			var el = document.getElementById(items[d])
			if(el.type == "button" || el.type == "reset" || el.type == "submit" || el.type == "file")
				saveColor(el.id, el.style.color);
				el.style.color = "#808080";
		}
	}
}

// Active les éléments dont les ID sont passés en paramètres
function enableItem() {
	var items = enableItem.arguments;
	if(items.length == 0) return;
	for(var d=0; d<items.length; ++d) {
		if(!document.getElementById(items[d]).disabled) continue;
		document.getElementById(items[d]).disabled = false;
		if(isOpera) {
			// Opera ne "montre" pas les boutons désactivés
			var el = document.getElementById(items[d])
			if(el.type == "button" || el.type == "reset" || el.type == "submit" || el.type == "file")
				el.style.color = restoreColor(el.id);
		}
	}
}

// Ouvre une nouvelle fenêtre pour afficher l'image imgFile, de dimension imgWidth x imgHeight
function myPopup(imgFile, imgWidth, imgHeight) {
	var imgLeft = (screen.width-imgWidth)/2;
	var imgTop  = (screen.height-imgHeight)/2;
	var wPopup  = window.open("", "_blank", "width="+imgWidth+", height="+imgHeight+", left="+imgLeft+", top="+imgTop);
	wPopup.document.write('<html><head><title>Cliquez dans cette fenêtre pour la fermer</title></head><body style="margin: 0px; padding: 0px;" onclick="window.close();"><img src="'+imgFile+'" alt="" title="Cliquez dans cette fenêtre pour la fermer" style="width: '+imgWidth+'; height: '+imgHeight+';" /></body></html>');
	wPopup.document.close();
	wPopup.focus();
}

function setcontact(elem) {
//	var contactno = document.getElementById('contactno')
//	var contactimg = document.getElementById('contactimg')
	
	var value = elem.value.split("-")
	
//	contactno.innerHTML=value[0] + '<img id="contactimg" src="images/country/' + value[1] + '.gif">';
//	contactimg.src='images/country/' + value[1] + '.gif';
	
	var p = document.getElementsByTagName('p');
	for(i=0;i<p.length;i++){
		if(p[i].id == 'contactno') {
			p[i].innerHTML = value[0] + '<img id="contactimg" src="/images/country/' + value[1] + '.gif">';
		}
	}
	
	SetCookieM('mnemo_pays',value[1],1);
	
	
}

function verifyauthorize(frm) {
	
	if(frm.card_no.value == '') {
		alert('Please enter your cc number.');
		return false;
	}
	
	return true;
	
}

jQuery(document).ready(function() {
		//alert(GetCookie('popup'));
		if(!GetCookie('popup')) {
			SqueezeBox.open('http://www.mazaldiamond.com/pebbles.popup.php', {handler:'iframe',size:{x:520,y:428}});
			setCookie('popup', 'true');
		}
		
		/*jQuery('a').click(function(){
			
			if(jQuery(this).attr('href').indexOf('cde') > -1)
				jQuery(this).attr('href', 'https://www.mazaldiamond.com/' + jQuery(this).attr('href'))
			
		})*/
		
		jQuery('a.slides2').click(function(){
		/*Cat 89*/
		
		jQuery('div.sections').hide();
		jQuery('div.' + jQuery(this).attr('rel')).show();
		
		});
		
//		jQuery('#reviewPaneTab').click(function(){
		/*Cat 89*/
		jQuery('#reviewPaneTab, div.latestreview').click(function(){
			jQuery('html, body').animate({
				scrollTop:877
				}, 2000);
	
   
			jQuery('#reviewPane').fadeIn("slow");
		
		
		});
		
		jQuery('.stay-tooltip-target').click(function(){
		/*Cat 89*/
		//alert('');
		jQuery('div.sections').hide();
		var slideid=jQuery(this).attr('id');
		var splitID=slideid.split('-');
		jQuery('div.' + splitID[2]).show();
		
		});
		
		
		
		jQuery('a.slides').click(function(){
		
		jQuery('div.sections').hide();
		
		jQuery('div.' + jQuery(this).attr('rel')).show()
			//alert(jQuery(this).attr('rel'))	;
		var imgSrc=jQuery(this).find('img').attr('src');
		var splitString=imgSrc.split('.');
		//alert(splitString[0]);
		var imageColorchr=splitString[0].substr(-1);
		//alert(imageColorchr);
		switch (imageColorchr)
			{
			case 'W':
					var mainimgTop=imgSrc.replace('W','Y');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageTop').attr('src', mainimgTop); 
					var mainimgBottom=imgSrc.replace('W','P');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageBottom').attr('src', mainimgBottom);
		    break;
			case 'P':
			  		var mainimgTop=imgSrc.replace('P','Y');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageTop').attr('src', mainimgTop); 
					var mainimgBottom=imgSrc.replace('P','W');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageBottom').attr('src', mainimgBottom);
			  break;
			case 'Y':
			 		 var mainimgTop=imgSrc.replace('Y','W');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageTop').attr('src', mainimgTop); 
					var mainimgBottom=imgSrc.replace('Y','P');
					jQuery('div.' + jQuery(this).attr('rel')).find('.mainimageBottom').attr('src', mainimgBottom);
			  break;
			default:
			  //document.write("I'm looking forward to this weekend!");
			}
		
		jQuery('div.' + jQuery(this).attr('rel')).find('.mainimage').attr('src', jQuery(this).find('img').attr('src'));
		//alert(mainimgTop);
		
		return false
		
	});
		
		jQuery('a.submenuHover').hover(function(){
			//alert(jQuery(this).attr('rel'))
		jQuery('div.submenu').hide();
		jQuery('div.submenuImages').hide();
		
		jQuery('div.' + jQuery(this).attr('rel')).show()
		});
		
		jQuery('a.menuImages').hover(function(){
			//alert(jQuery(this).attr('rel'))
		jQuery('div.submenuImages').hide();
		
		jQuery('#mainHeadermenuarea div.' + jQuery(this).attr('rel')).show()
		});
		
		jQuery('a.diamondsubLinks').hover(function(){
			//alert(jQuery(this).attr('rel'))
		jQuery('div.diamondsub').hide();
		
		
		jQuery('div.' + jQuery(this).attr('rel')).show()
		});
		
		
		jQuery('.stay-tooltip-content').hover(function(){
			//alert(jQuery(this).attr('rel'))
		jQuery('div.tooltip-content').hide();
		
		
		
		}); 
		
		
		jQuery('div.productDetailTab').click(function(){
			//alert(jQuery(this).attr('rel'))
		jQuery('div.productDescription').hide();
		jQuery('.bgColorDescription').css({backgroundColor: '#ffffff'});
		jQuery('.bgColorDetail').css({backgroundColor: '#F1EDEC'});
		jQuery('#arrowDetail').show();
		jQuery('#arrowDescription').hide();
		
		jQuery('div.productDetail').show();
		
		});
		
		jQuery('.productDescriptionTab').click(function(){
			//alert()
		jQuery('div.productDetail').hide();
		jQuery('.bgColorDescription').css({backgroundColor: '#F1EDEC'});
		jQuery('.bgColorDetail').css({backgroundColor: '#ffffff'});
		jQuery('#arrowDetail').hide();
		jQuery('#arrowDescription').show();
		jQuery('div.productDescription').show();
		
		});
		
/* Main slider js except three large images */		
	jQuery("div.thumb div").hover(function() {
	jQuery(this).css({'z-index' : '50000000'});
	jQuery(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-110px', 
			marginLeft: '-110px', 
			top: '95%', 
			left: '95%', 
			width: '120px', /* Increase height width if to large zoom here*/
			height: '120px',
			padding: '20px',
			position: 'absolute'
		}, 100);
	
	} , function() {
	jQuery(this).css({'z-index' : '0'});
	jQuery(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '70px', 
			height: '70px', 
			padding: '5px'
		}, 400);
});

/* The large 3 images js code*/
jQuery("div.thumb div.large").hover(function() {
	jQuery(this).css({'z-index' : '5'});
	jQuery(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-110px', 
			marginLeft: '-110px', 
			top: '55%', 
			left: '55%', 
			width: '190px', /* Increase height width if to large zoom here*/
			height: '180px',
			padding: '20px' 
		}, 100);
	
	} , function() {
	jQuery(this).css({'z-index' : '0'});
	jQuery(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '150px', 
			height: '140px', 
			padding: '5px'
		}, 400);
});
/* The bottom 2 small images js except large one*/	
	jQuery("ul.ZoomCategory li").hover(function() {
	jQuery(this).css({'z-index' : '5'});
	jQuery(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-110px', 
			marginLeft: '-110px', 
			top: '55%', 
			left: '55%', 
			width: '180px', /* Increase height width if to large zoom here*/
			height: '170px',
			padding: '20px' 
		}, 100);
	
	} , function() {
	jQuery(this).css({'z-index' : '0'});
	jQuery(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '128px', 
			height: '110px', 
			padding: '5px'
		}, 400);
});
/* Large bottom image js*/
jQuery("ul.ZoomCategory li.large").hover(function() {
	jQuery(this).css({'z-index' : '5'});
	jQuery(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-110px', 
			marginLeft: '-110px', 
			top: '35%', 
			left: '55%', 
			width: '222px', /* Increase height width if to large zoom here*/
			height: '262px',
			padding: '20px' 
		}, 100);
	
	} , function() {
	jQuery(this).css({'z-index' : '0'});
	jQuery(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '192px', 
			height: '232px', 
			padding: '5px'
		}, 400);
});
	
})
function addTabbgcolor()
{
jQuery('#menu li.onglet1').css("color","#292828");
}
function SubmenuHover(value) 
{
jQuery.ajax({
   type: "POST",
   url: "sub_menu_ajax.php",
   data: "catid="+value,
   success: function(msg){
    //alert( "Data Saved: " + msg );
	jQuery('#subMenuhtml').html(msg);
   }
 });
}
function hidemainDiv()
{
	
	jQuery('div.submenu').hide();
		jQuery('div.submenuImages').hide();
}
function chkstate(vale)
{
	
	if(vale==173)
	//jQuery('#showstate').show();
	document.getElementById("showstateval").style.display='block';
	else
	document.getElementById("showstateval").style.display='none';
	//jQuery('#showstate').hide();
	}
	
	function chkstatefront(vale)
{
	
	if(vale==173)
	jQuery('#showstate').show();
	//document.getElementById("showstateval").style.display='block';
	else
	//document.getElementById("showstateval").style.display='none';
	jQuery('#showstate').hide();
	}
	


function switchArticleImages(type,artid)
{
	if(type==162)
	{
		jQuery('div.priceSection').hide();		
		jQuery('div.platinum').show();	
	}
	else
	{
		jQuery('div.priceSection').hide();		
		jQuery('div.all').show();	
	}
	jQuery('div.sectionBottom'+artid).hide();	
	jQuery('div.'+type+artid).show();
	var linkhref = jQuery('div.'+type+artid+' a').attr('href');
	jQuery(".selectDiamondCls a").attr('href', linkhref);
}
function swapCatprices(price,url,divid,platPrice,platUrl)
{
	
//alert(price);	
	var val = jQuery('.'+divid+' input:radio[name=material]:checked').val();
	var linkValue = url;
		var pageURl= linkValue.replace("165",val);
	if(val==162)
	{
		jQuery('.'+divid+' .catPricesSwap').html(platPrice);
		
		
		jQuery('.'+divid+' .selectDiamond a').attr('href', pageURl);
	}
	else
	{
		jQuery('.'+divid+' .catPricesSwap').html(price);
		jQuery('.'+divid+' .selectDiamond a').attr('href', pageURl);
	}
	
	//alert(val);
	//if(val==162)
	//getPlatiniumPrices()

	
}
function switchArticleSizeprices(type,artid)
{
	
	//jQuery('div.'+artid+).show();
	var mainImgSrc = jQuery('.'+artid+' .'+type).attr("src");
	//alert(mainImgSrc);
	jQuery('.'+artid+' img.mainimage').attr('src', mainImgSrc);
	if(type==162)
	{
	//jQuery('div.'+artid+' div.mainTable '+'input:first').attr("checked","checked");
	var linkClass = jQuery('div.'+artid+' div.mainTable '+'input:checked').attr('class');
	var array = linkClass.split('::');
	jQuery('.'+artid+' .catPricesSwap').html(array[0]);

	var linkValue = jQuery('div.'+artid+' div.mainTable '+'input:checked').val();
	var pageURl= linkValue.replace("165",type);
	jQuery('.'+artid+' .selectDiamond a').attr('href', pageURl);

	}
	else
	{
		//jQuery('div.'+artid+' div.mainTable '+'input:first').attr("checked","checked");
		var linkPrice = jQuery('div.'+artid+' div.mainTable '+'input:checked').attr('id');
		var newprice = linkPrice.split('_');
		var linkValue = jQuery('div.'+artid+' div.mainTable '+'input:checked').val();
		//var array = linkClass.split('::');
		jQuery('.'+artid+' .catPricesSwap').html(newprice[1]);
		var pageURl= linkValue.replace("165",type);
		jQuery('.'+artid+' .selectDiamond a').attr('href', pageURl);
		
	}
	//alert(linkPrice+' '+artid);
}
function swapArticleImageOnload(artid)
{
				var stockimage = document.getElementById('ImgBig');
				var matValue = document.getElementById('lst_13').value;
				var imageSrcPathBig = '/configurations/www.mazaldiamond.com/images/produits/br/';
				var imageSrcPathsmall = '/configurations/www.mazaldiamond.com/images/produits/article/';
				var imgPink = document.getElementById('imagePink').value;
				var imgYellow = document.getElementById('imageYellow').value;
				var imgWhite = document.getElementById('imageWhite').value;
				
				
				if(matValue ==165 && imgYellow != '')
				{
					var yellowSrcsmall = imageSrcPathsmall+artid+'Y_Y.jpg';
					var yellowSrcbig = imageSrcPathBig+artid+'Y_Y.jpg';
					if (stockimage) stockimage.src = yellowSrcsmall; 
					jQuery('div.zoomer-wrapper-big').css('background', '');
					jQuery('div.zoomer-wrapper-big').css('background', yellowSrcsmall);
					jQuery('div.zoomer-wrapper-big img').attr('src', yellowSrcbig); 
					jQuery('#ImgDiamBig').attr('href', yellowSrcbig);
				}
				else if(matValue ==384 && imgWhite != '')
				{
					
					var yellowSrcsmall = imageSrcPathsmall+artid+'W_W.jpg';
					var yellowSrcbig = imageSrcPathBig+artid+'W_W.jpg';
					if (stockimage) stockimage.src = yellowSrcsmall; 
					jQuery('div.zoomer-wrapper-big').css('background', '');
					jQuery('div.zoomer-wrapper-big').css('background', yellowSrcsmall);
					jQuery('div.zoomer-wrapper-big img').attr('src', yellowSrcbig); 
					jQuery('#ImgDiamBig').attr('href', yellowSrcbig);
				}
				else if(matValue ==254 && imgPink != '')
				{
					
					var yellowSrcsmall = imageSrcPathsmall+artid+'P_P.jpg';
					var yellowSrcbig = imageSrcPathBig+artid+'P_P.jpg';
					if (stockimage) stockimage.src = yellowSrcsmall; 
					jQuery('div.zoomer-wrapper-big').css('background', '');
					jQuery('div.zoomer-wrapper-big').css('background', yellowSrcsmall);
					jQuery('div.zoomer-wrapper-big img').attr('src', yellowSrcbig); 
					jQuery('#ImgDiamBig').attr('href', yellowSrcbig);	
				}
				else if(matValue ==162 && imgWhite != '')
				{
					
					var yellowSrcsmall = imageSrcPathsmall+artid+'W_W.jpg';
					var yellowSrcbig = imageSrcPathBig+artid+'W_W.jpg';
					if (stockimage) stockimage.src = yellowSrcsmall; 
					jQuery('div.zoomer-wrapper-big').css('background', '');
					jQuery('div.zoomer-wrapper-big').css('background', yellowSrcsmall);
					jQuery('div.zoomer-wrapper-big img').attr('src', yellowSrcbig); 
					jQuery('#ImgDiamBig').attr('href', yellowSrcbig);
				}
					
}

function productPageFaqRedirect(val)
{
if(val=='EN')
document.location.href='/div-frequently-asked-questions-faq--frequently-asked-questions-faq--3-8.htm';
else if(val=='FR')
document.location.href='/div-questions-frA-quentes-faq--questions-frA-quentes-faq--3-8.htm';
}





