// JavaScript Document

var my_imges=new Array();
var my_key='';
var length='';
var newImg = new Image();
var height=0; 
var width=0; 
var myval=0;
var my_donate=new Array();
var paypal;
var id;
var amount;
		
$(document).ready (function(){
							
   $('#greyblack_gal').css("position","fixed");
   $('#greyblack_gal').css("height",($(window).height()+ "px"));
   $('#greyblack_gal').css("width",($(window).width()+ "px"));
  
     

							
});

function hide_me_gal()
{
	$('#greyblack_gal').css('display','none');
	$('#imageborder_gal').css('display','none');
	
}
function show_graybox_gal(my_path)
{
	var img=$("#gal_gray_arr").val();
	$("#total_img1_gal").remove();
	my_imges=img.split(",");
	
	length=my_imges.length;
	my_key = array_key_gal(my_imges,my_path);
	
	
	$('#total_img_gal').append('<span id="total_img1_gal">'+length+'</span>');
	
	myval=my_key+1;
	$("#total_number_gal").remove();
	$('#cur_img_gal').append('<span id="total_number_gal">'+myval+'</span>');
	
	getImgSize_gal(my_path);
	
	
	
	$('#greyblack_gal').css('display','block');
	$('#image_window_gal').css('background-image','url('+my_path+')');
	
	$('#imageborder_gal').css('display','block');
	$('#image_window_gal').css('display','block');
	/*$('#imageborder').css("top","240px");
    $('#imageborder').css("left","362px");*/
	/*$('#imageborder').css("height",($(window).height() - $('#imageborder').height()) / 2+ "px");
   $('#imageborder').css("width",($(window).width() - $('#imageborder').width()) / 2+ "px"); set width=600 and height=500	
   
   */
   



	
		
}

newImg.onload = function(){
	
	/*if(width != 0 || height != 0)
	{
  $("#image_window").animate({"width":+width+"px"}, "slow");
  $("#image_window").animate({"height":+height+"px"}, "slow");
	}*/
};
function getImgSize_gal(imgSrc)
{


newImg.src = imgSrc;
height = newImg.height;
width = newImg.width;
var size='width:'+width+'height:'+height;


if(width != 0 || height != 0)
{
  
  //alert("width: "+width);
  //alert("height: "+height);
  $('#footer_gray_gal').css('display','block');
 
  $("#footer_gray_gal").animate({"width":+width+20+"px"}, "slow");
  $("#image_window_gal").animate({"width":+width+"px"}, "slow");
  $("#image_window_gal").animate({"height":+height+"px"}, "slow");
}

width=0;
height=0;

return width;
}

function array_key_gal(a, obj)
{
 
  for(var i = 0; i < a.length; i++) {
	 
    if(a[i] == obj){
		
		
      return i;
	  
	  
    }
  }
  
}

function previous_img_gal()
{

	
$('#image_window_gal').css('background-color','#FFF');
$('#image_window_gal').css('background-image','url(greybox/images/loading.gif)');
var my_val=my_imges[my_key];
var my_arkey=array_key_gal(my_imges, my_val);

my_arkey=my_arkey-1;



if(my_arkey == -1)
{
	my_arkey=length-1;
}
my_key=my_arkey;
myval=my_key+1;


$("#total_number_gal").remove();
$('#cur_img_gal').append('<span id="total_number_gal">'+myval+'</span>');

getImgSize_gal(my_imges[my_arkey]);


$('#image_window_gal').css('background-image','url('+my_imges[my_arkey]+')');	
}
function next_img_gal()
{
	
/*alert("next_img is called");
alert("my_arr:"+my_imges);
alert("my_key"+my_key);
alert("my_imges key"+my_imges[my_key]);*/

$('#image_window_gal').css('background-image','url(greybox/images/loading.gif)');
var my_val=my_imges[my_key];

/*alert("my_val;"+my_val);*/
var my_arkey=array_key_gal(my_imges, my_val);

/*alert(my_arkey);*/

var last_val=length;

my_arkey=my_arkey+1;
if(my_arkey == last_val)
{
  my_arkey=0;	
}
my_key=my_arkey;
myval=my_key+1;

	
	$("#total_number_gal").remove();
	
	$('#cur_img_gal').append('<span id="total_number_gal">'+myval+'</span>');

/*
alert("path:"+my_imges[my_arkey]);*/
getImgSize_gal(my_imges[my_arkey]);
//alert("next is work");

$('#image_window_gal').css('background-image','url('+my_imges[my_arkey]+')');

	
}


function dis_pre_gal(){$('.pre_div_gal').css('display','block');}
function out_pre_gal(){$('.pre_div_gal').css('display','none');}

function dis_next_gal(){ $('.next_div_gal').css('display','block');}
function out_next_gal(){$('.next_div_gal').css('display','none');}
