function PopupPic(URL)
{
	h=400;
	w=400;
	window.open(URL,'Title','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,top='+Math.floor(screen.height/2-h/2)+',left='+Math.floor(screen.width/2-w/2)+',resizable=0,width='+w+',height='+h);
}
/////////////
/* Rotator */
/////////////
var imageRotatorImage = 0;
var valuesArrayImage = [];
//Display this function when json finish
function initialImage()
{
	if(jQuery("#home-banner").length == 1)
	{
		imageRotatorImage = 0;
		if(isNaN(imageRotatorImage))
		{
			imageRotatorImage = 0;
		}
		else
		{
			imageRotatorImage = (imageRotatorImage+1)%(valuesArrayImage.length);				
		}
		//Display 2 Images in front end			
		jQuery('#home-banner').prepend('<img src="'+valuesArrayImage[(imageRotatorImage+1)%valuesArrayImage.length]+'" alt=""/>');
		$intervalid = setInterval( "rotateImage()", 15000/2 );
	}
	
}

function rotateImage()
{
	var images = jQuery();
	
	jQuery('#home-banner img:last').fadeOut(8000/2, function()
	{
		jQuery(this).remove();
	});

	imageRotatorImage = (imageRotatorImage+1)%(valuesArrayImage.length);
	
	jQuery('#home-banner').prepend('<img src="'+valuesArrayImage[(imageRotatorImage+1)%(valuesArrayImage.length)]+'" alt=""/>');
}

jQuery(function()
{
	//Scrollbar
	if(jQuery('#pane').length != "")
	{
		jQuery('#pane').jScrollPane();
	}
});
jQuery(document).ready(function() {

	jQuery('#sidebar ul').addClass("home-spotlight");
	jQuery('#sidebar ul li:first').addClass("first");
	jQuery('#sidebar ul li:last').addClass("last");
	
	//Navigation
	//jQuery("ul#navigation li:first a").attr("class","first");
	//jQuery("ul#navigation li:last").attr("class","last");
	
	
	//get image from JSON	
	jQuery.getJSON(
			"/json-request-image.php",
			function(data){
				jQuery.each(data.userdata, function(i,user){
					valuesArrayImage[i] = user.rotated_image;					
				});
				//call initialImage function to display in front end from javascript	
				initialImage();

			}
		);
});

