var j = 0
var p = 0
var preLoad = new Array()
 
$(document).ready(function() {
	
   $("#allpics").dialog({
			autoOpen: false,
			height: 520,
			width: 660,
			modal: true,
			buttons: {
			"Close": function() {
					$( this ).dialog( "close" );
				}	
			}
			});

  p = Pic.length
  for (i = 0; i < p; i++){
     preLoad[i] = new Image()
     preLoad[i].src = Pic[i]
  }
  $('#totpics').html(p);
});

function next() {
    j = $('#pic').html() * 1
    if (j > (p-1)) j=0
    $('#SlideShow').hide("slide", { direction: "left" }, 1000);
	$('#SlideShow').attr('src', preLoad[j].src); 
    $('#pic').html(j+1)
}

function prev() {
    j = document.getElementById('pic').innerHTML * 1
    j = j -2
    if (j < (0)) j=p-1
    document.getElementById('SlideShow').src = preLoad[j].src
    document.getElementById('pic').innerHTML = j+1
}   


//$('#bg')
//    .animate({opacity: 0}, 'slow', function() {
//        $(this)
//            .css({'background-image': 'url(1.jpg)'})
//            .animate({opacity: 1});
//    });
