$(function(){



$("img").load(function(evt){
      $(this).fadeIn(1000);
});

$(".image_thmb img").live("load",function () { $(this).fadeIn(); });
$("#big-img").load(function () { $("#big-img").fadeIn(); });
$("#more_image img").load(function () {$(this).fadeIn(); });
/*
$("#big-img").hide();
$("#more_image img").hide();
$("#more_image img").hide();
$(".image_thmb img").hide();
*/

/*
$("#more_image img").hide();

$("#big-img").load(function () {
$("#big-img").fadeIn();
});
*/



$("#src").hide();
$("#total").hide();

if($("#en_site").text()=='en'){
var images_gallery_folder="../img/gallery/pages/";	
var images_folder="../img/";	
}else{
var images_gallery_folder="../img/gallery/";
var images_folder="../img/";		
}



var number;
var total=$(".images_show_div div.img").length;

//alert(total);
var domain=$("#domain").text();
var cat=$("#image_thmb_cont1").attr("cat");
var cat_name=$("#image_thmb_cont1").attr("cat_name");

$("#over").hide();
$("#big-div-cont").hide();

//alert(images_gallery_folder);
//alert(total);

var window_height=$(document).height();


$("#over").css({"height":window_height+"px"});




$(".images_show_div div.img").live("click",function(){
//alert("s");
number=parseInt($(this).index())+1;
//alert(number);
$("#big-img").attr("src","");
$("#images_thumb").html("");

$("#big-div").show();
$("#big-div-cont").show();
$("#image-close").slideDown(500);



$("#image-code").text(" كـــــود : " + $(this).attr("code"));
$("#image-dim").text(" الأبعـــاد : " + $(this).attr("dim"));
$("#image-price").text(" السعــــر : " +$(this).attr("price"));

$("#big-img").attr("src","");
$("#big-img").attr("src",$(this).attr("src"));
$("#over").show();
//alert($(this).attr("src"));


$("#images_title").text($(this).attr("title"));

$("#images_thumb").load("load_more_gallery_photo_images.php",
{"table":$(this).attr("table"),"images":$(this).attr("images"),"title":$(this).attr("title"),"desc":$(this).attr("desc") },
function(data){
	

	

});

});		



$(".more_gallery_photo_image img").live("click",function(){
	
	
$("#big-img").attr("src","");
$("#big-img").attr("src",$(this).attr("image"));
	
});

   

$("#close").click(function(){
$("#big-div").hide(200);
$("#big-div-cont").hide();
$("#over").hide(200);

});	


$("#zoom").click(function(){
if($(this).attr("type")=="0"){
$("#big-img").css("min-width","100%");	
$("#big-img").attr("height","");	
$(this).attr("type","1");
$("#zoom").css("background","var(--black) url(../img/zoom_out.png) no-repeat scroll center center");
}else{
$("#big-img").css("min-width","");
$("#big-img").attr("height","100%");
$(this).attr("type","0");
$("#zoom").css("background","var(--black) url(../img/zoom_in.png) no-repeat scroll center center");

		
}	


});	





$("#image-prev").click(function(){


	
if (parseInt(number)>1 ){
number--;
//alert(number);
}else{

number=total;
//alert(total);
//alert(number);	
//number=total;
}
$("#big-img").attr("src","");
$("#images_thumb").html("");
$("#big-img").attr("src",images_folder+"empty.jpg");
img_src=$(".images_show_div div.img").eq(number-1).attr("src");
img_table=$(".images_show_div div.img").eq(number-1).attr("table");
img_images=$(".images_show_div div.img").eq(number-1).attr("images");
img_title=$(".images_show_div div.img").eq(number-1).attr("title");
img_desc=$(".images_show_div div.img").eq(number-1).attr("desc");
$("#mag_big").hide();
$("#big-img").attr("src",img_src);
$("#image-desc").text($(".images_show_div div.img").eq(number-1).attr("title"));
$("#image-code").text(" كـــــود : " + $(".images_show_div div.img").eq(number-1).attr("code"));
$("#image-dim").text(" الأبعـــاد : " + $(".images_show_div div.img").eq(number-1).attr("dim"));
$("#image-price").text(" السعــــر : " + $(".images_show_div div.img").eq(number-1).attr("price"));

$("#more_image").load("more_images_gallery_adv.php",{"table":img_table,"images":img_images},function(){

});



$("#images_title").text(img_title);

$("#images_thumb").load("load_more_gallery_photo_images.php",
{"table":img_table,"images":img_images,"title":img_title,"desc":img_desc },
function(data){
	

	

});






});	


$("#image-next").click(function(){
//alert(number);
//alert(total);
	
if (number<total ){
number++;
}else{
number=1;
}
$("#big-img").attr("src","");
$("#images_thumb").html("");
$("#big-img").attr("src",images_folder+"empty.jpg");
img_src=$(".images_show_div div.img").eq(number-1).attr("src");
img_table=$(".images_show_div div.img").eq(number-1).attr("table");
img_images=$(".images_show_div div.img").eq(number-1).attr("images");
img_title=$(".images_show_div div.img").eq(number-1).attr("title");
img_desc=$(".images_show_div div.img").eq(number-1).attr("desc");

$("#mag_big").hide();
$("#big-img").attr("src",img_src);
$("#image-desc").text($(".images_show_div div.img").eq(number-1).attr("title"));
$("#image-code").text(" كـــــود : " + $(".images_show_div div.img").eq(number-1).attr("code"));
$("#image-dim").text(" الأبعـــاد : " + $(".images_show_div div.img").eq(number-1).attr("dim"));
$("#image-price").text(" السعــــر : " + $(".images_show_div div.img").eq(number-1).attr("price"));




$("#images_title").text(img_title);

$("#images_thumb").load("load_more_gallery_photo_images.php",
{"table":img_table,"images":img_images,"title":img_title,"desc":img_desc },
function(data){
	
});


});


$(".more_img").live("click",function(){
	//alert("sad");
	
$("#big-img").attr("src",$(this).attr("src")); 
$("#more_image img").css("opacity","0.5");
$("#more_image img").css("filter","alpha(opacity=50)");

$(this).css("opacity","1");
$(this).css("filter","alpha(opacity=100)");

});





});


