
(function($){
$(document).ready(function(){			
	$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
	$('ul.gallery_demo').galleria({
			history   : false, // activates the history object for bookmarking, back-button etc.
			clickNext : false, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
		    onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				image.css('display','none').fadeIn(500);
				caption.css('display','none').show("slow");
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(100,0.8);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title',thumb.attr('title'));			
				if(thumb.attr('onclick')!=null)
				{
					image.css('cursor','pointer').fadeIn(1000);
					thumb.css('cursor','pointer');					
					var arVersion = navigator.appVersion.split("MSIE")
					var version = parseFloat(arVersion[1])					
					if(version>5 && version < 8)
					{
						urltmp = thumb.attr('onclick');
						document.getElementById("main_image").onclick = urltmp;						 
					}else
					{
						image.attr('onclick',thumb.attr('onclick')) ;
					}
				}
				
			},	
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.8';
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(500);	
				
			}				
  	 		}); 
				var i=0;
				var galleryactive = 0;
				function autoslide()
				{	
					
					if(i>=1 && galleryactive==0)
					{			
						$.galleria.next();				
					}
					i++;
					setTimeout(autoslide,5000);			
					
				}		
					document.getElementById("slidemain").onmouseover = function()
					{			  
						galleryactive = 1;
			// alert(i);
					}
					document.getElementById("slidemain").onmouseout = function()
					{			
						galleryactive = 0;
					}
				
			
			function loadIMG()
			{
				if(loadFlg==1)
				{
					autoslide();
				}else
				{
					setTimeout(loadIMG,5000);	
				}
			}
			loadIMG();			
});
})(jQuery);
function opensite(url)
{
		window.open(url);	
}