function showPopUpLoading(){
    $j.blockUI({ message: $j('#ajaxaddtocartL') });
	nohide = true;
	$j("#ajaxaddtocart_popup_loading").className="ajaxaddtocart_popup_loading_show";
	$j("#ajaxaddtocart_popup_loading").show();
    $j("#ajaxaddtocart").hide();
}

function hidePopUpLoading(){
	$j("#ajaxaddtocart_popup_loading").className="ajaxaddtocart_popup_loading_hide";
	$j("#ajaxaddtocart_popup_loading").hide();
    $j("#ajaxaddtocartL").hide();

}

function showPopUp(){
    $j("#ajaxaddtocartL").hide();
	nohide = false;

    showAllNormal();
	appear('ajaxaddtocart_popup');
	duree = confirmation_seconds();
	t();
}

function showError(err){
	appear('ajaxaddtocart_popup_error');
	$j("#ajaxaddtocart_error").html(err);
}

function hidePopUp(){
	fade('ajaxaddtocart_popup');
    $j("#ajaxaddtocart_popup_options").hide();
    $j("#ajaxaddtocart_popup_options_in").html('');
}


function showPopUpOptions(){
	nohide = true;
	appear('ajaxaddtocart_popup_options');		
}

function hidePopUpOptions(){
	$j('#ajaxaddtocart_popup_options').hide();
}

function showPopUpRedirecting(){
	nohide = false;
	appear('ajaxaddtocart_popup_redirecting');
}

function showLoginPopUp(){
	appear('ajaxaddtocart_popup_login');
	window.setLocation($j("#easyajaxproduct_linkurl").attr("value")+'/customer/account/login/');
}

function showAll(){
		$j("#ajaxaddtocartL").removeClass("ajaxaddtocart_hide");
		$j("#ajaxaddtocartL").addClass("ajaxaddtocart_show");
		$j("#ajaxaddtocartL").css("left",((width()/2) - 150) + "px");
		$j("#ajaxaddtocartL").css("top",((height()/2) - 25) + "px");
		$j("#ajaxaddtocartL").show();

		showPopUpLoading();
}

function showAllNormal(){

        $j("#ajaxaddtocartL").hide();
        $j("#ajaxaddtocart_popup_loading").hide();

		$j("#ajaxaddtocart").removeClass("ajaxaddtocart_hide");
		$j("#ajaxaddtocart").addClass("ajaxaddtocart_show");
		$j("#ajaxaddtocart").css("left",((width()/2) - 150) + "px");
		$j("#ajaxaddtocart").css("top",((height()/2) - 25) + "px");

		$j("#ajaxaddtocart").show();
}

function hideAll(){
	if(nohide == false){
		duree = -1;
		hidePopUp();
		fade('ajaxaddtocart');
	}else{
		hidePopUp();
        fade('ajaxaddtocart');
	}
}

function t()
{
    s=duree;
    if(s == -1){
    	s=0;
    }
    else if(s == 0)
    {
        hideAll();
    }
    else
    {
    	$j("#compteur").html("<small>This popup will close in "+s+" second(s)</small>");
	    duree=duree-1;
	    window.setTimeout("t();",999);
    }
}

function imageZoom(url, id){
	if (cart_zoom_enabled()){
		arr_images = url.split('#');
		arr_images_index = 0;
		z=$j("#imagezoom"+id);
		z.show();
	}
}

function imageZoomNext(id){
	if (cart_zoom_enabled()){
		if(arr_images_index + 1 == arr_images.length){
			arr_images_index = 0;
		}else{
			arr_images_index = arr_images_index + 1;
		}
		z=$j("#imagezoom"+id);
		z.html('<img style="width:100%" src="'+arr_images[arr_images_index]+'" />');
	}
}
function imageZoomPrevious(id){
	if (cart_zoom_enabled()){
		if(arr_images_index == 0){
			arr_images_index = arr_images.length - 1;
		}else{
			arr_images_index = arr_images_index - 1;
		}
		z=$j("#imagezoom"+id);
		z.html('<img style="width:100%" src="'+arr_images[arr_images_index]+'" />');
	}
}
function imageZoomKill(id){
	if (cart_zoom_enabled()){
		z=$j("#imagezoom"+id);
		z.hide();
	}
}
