var iarray = "";
var il = 0;
var ci = 0;

function callLightbox(target){
$("#lightbox").show();
var ustr = 'lightbox?id='+target;
$.get(ustr, function(data){				   
iarray = data.split('^');
il = iarray.length - 1;
ci=0;
/* alert(iarray[ci]); */
$(".lightimage").attr('src',iarray[ci]);



});
/* stuff goes here */
}

function prevImage(){
if(ci == 0){
ci = il-1;
}else{
ci = ci-1;
}
$(".lightimage").attr('src',iarray[ci]);
h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
e = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
var g = h - ($(".lightimage").height());
var f = 800 - ($(".lightimage").width());
$("#lbimage").css('top',g/2);
$("#lbimage").css('left',f/2);
}

function nextImage(){
if(ci == il-1){
ci = 0;
}else{
ci = ci + 1;
}
$(".lightimage").attr('src',iarray[ci]);
h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
e = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
var g = h - ($(".lightimage").height());
var f = 800 - ($(".lightimage").width());
$("#lbimage").css('top',g/2);
$("#lbimage").css('left',f/2);
}

$(".lightimage").bind('load',function(){
h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
d = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);
alert(d);
$(".lightimage").css('max-height', h*.8);
var g = h - ($(".lightimage").height());
var f = d - ($(".lightimage").width());
$("#lbimage").css('top',g/2);
$("#lbimage").css('left',f/2);
});

function closeLightbox(){
$("#lightbox").hide();
}
