/******************************************************************************
* xhuFonction.js
******************************************************************************/

function inputFocus(inputValue, inputId){
	if(inputValue == "Recherchez" && inputId == "fulltextField"){
		document.getElementById(inputId).value="";
	}else if(inputValue == "" && inputId == "fulltextField"){
		document.getElementById(inputId).value="Recherchez";
	}
}

function getImageProviderUrl()
{
	var extension = document.location.pathname;
	var pos = extension.lastIndexOf(".");
	extension = extension.substr(pos + 1).toLowerCase();
	if(extension == "aspx") {
		return "imageProvider.aspx";
	}
	return "imageProvider.asp";
}




$(function() {
	if (document.getElementById("zoomMainPicture") != null) {
		$('#zoomMainPicture').lightBox({ fixedNavigation: true });	
	}
	
    if (document.getElementById("xhuBasketNbProduct") != null) {
        if (Number(document.getElementById("xhuGshpGetBasketQuantityFlow").value) > 0) {
            document.getElementById("xhuBasketNbProduct").innerHTML = document.getElementById("xhuGshpGetBasketQuantityFlow").value + " articles dans mon panier valeur";
        } else {
            document.getElementById("xhuBasketNbProduct").innerHTML = document.getElementById("xhuGshpGetBasketQuantityFlow").value + " article dans mon panier valeur";
        }
		
		document.getElementById("xhuBasketProductsPrices").innerHTML = document.getElementById("xhuGshpGetBasketVatAmountFlow").value + " €";
    }
});



function changeSrcImg(oidProduct, widthImageProduct, dim) {
    var img = document.getElementById("productMainPicture");
    var elem = img.src.split('/');
    var flag = true;
    var reg1 = new RegExp(oidProduct.toString(), "g");
    if (img.src.match(reg1)) {
        flag = false;
    }

    if (flag == true) {
        var imgLoad = document.getElementById("gshpMainPicture");
        $(imgLoad).css({ background: "url(iso_icons/xhu_loading.gif) no-repeat scroll 50% 50% transparent" });
        $(img).css({ opacity: "0.5" });
        var newUrl = getImageProviderUrl() + "?private_image=" + oidProduct + '&ew=' + widthImageProduct + '&eh=0';
        $(img)
			.attr('src', newUrl)
			.load(function() {
			    $(img).fadeIn(5);
			    $(img).css({ opacity: "1.0" });
				if (dim == 1) {
					$(img).css({ height: "auto" });
					$(img).css({ width: "300px" });
				}
				if (dim == 2) {
					$(img).css({ width: "auto" });
					$(img).css({ height: "300px" });
				}
			    $(imgLoad).css({ background: "none #ffffff" });
			});

        var imgZoom = document.getElementById("zoomMainPicture");
        imgZoom.href = getImageProviderUrl() + "?private_image=" + oidProduct + '&ew=653&eh=0';
    }

}
