// JavaScript Document

//function ajax load image with preloader
function load_image(myimg,mydesc,myalt) {
//alert(mydesc);
		$('#picholder').html('<p><img src="http://wp.carte-blanche.org/wp-content/themes/carte_blanche/ui/imgs/ajax-loader.gif" width="16" height="16" /></p>')
        var img = new Image();
		var $anchor = $('<a href="'+myalt+'"class="thickbox"></a>');
        $(img).load(function () {
            $(this).hide();
			$('#picholder').html('');
            $('#picholder').append(this);
			$('#picholder').append('<p>'+mydesc+'</p>');
            $(this).fadeIn();
			if(myalt!=0) { $(this).wrap($anchor); }
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', myimg);


}



$(document).ready(function()
{

$('hr').replaceWith('<div class="hr">~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~</div>');

$('#mycarousel').jcarousel();

//catalog images loading
$("#mycarousel li a").click(function(){

	var src = $(this).attr("href");
	var desc = $(this).attr("title");
	var alt = $(this).attr("alt");
	//$("#cm span").removeClass("select");
	//$(this).addClass("select");	
	load_image(src,desc,alt);
	return false;

  });
  
  
//catalog images loading
$("#glist li a").click(function(){

	var src = $(this).attr("href");
	var desc = $(this).attr("title");
	$("#glist li a").removeClass("active");
	$(this).addClass("active");	
	load_image(src,desc,0);
	return false;

  });


$("#lastp").prev("p").addClass("finalp");


});


