function isIE()
{
	ua = navigator.userAgent;
	if (ua.indexOf("MSIE")>=0)
	{ return true } else {return false}
}

function fadeInImages(){
    var images=document.getElementsByTagName("img");
	var blendcount=0;
    for (var i=0; i<images.length;i++){
        if (images[i].className=="fade_in"){
            setTimeout('opacity("'+images[i].id+'",0,100,1000);',blendcount*1000);
			blendcount++;
        }
    }
}

function changeImage(object,suffix,ext,folder){
    object.src="/images/"+folder+object.id+suffix+"."+ext;
}

jQuery(document).ready(function(){
	jQuery('a.zoom_image').each(function(i) {
		el=jQuery(this);
		el.tooltip({
			delay:0,
			track:true,
			showURL:false,
			bodyHandler:function(){
				 return '<img src="'+jQuery(this).attr("imgsrc")+'" />';
			}
		});
		el.attr("imgsrc",el.attr("href"));
		el.attr("href","javascript:void(0)");
	});
	if (jQuery('ul.slideshow').length>0) { 
		slideShow(10000);
	}
});


function slideShow(speed) {


	//append a LI item to the UL list for displaying caption

	//Set the opacity of all images to 0
	jQuery('ul.slideshow li').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	var items = jQuery('ul.slideshow li:not(.show,#slideshow-caption)');
	var itemscount= items.length;
	var first=jQuery(items.get(Math.round(Math.random()*(itemscount-1))));
	first.animate({opacity: 1.0});
	first.addClass('show');
	//var title=first.find('img').attr('title');
	//Get the caption of the first image from REL attribute and display it
	//jQuery('#slideshow-caption h3').html(title);
		
	//Display the caption
	//jQuery('#slideshow-caption').css({opacity: 0.7, bottom:0});
	
	//Call the gallery function to run the slideshow	
	var timer = setInterval('gallery()',speed);
	
	//pause the slideshow on mouse over
	jQuery('ul.slideshow').hover(
		function () {
			clearInterval(timer);	
		}, 	
		function () {
			timer = setInterval('gallery()',speed);			
		}
	);
	
}

function gallery() {


	//if no IMGs have the show class, grab the first image
	var current = (jQuery('ul.slideshow li.show')?  jQuery('ul.slideshow li.show') : jQuery('#ul.slideshow li:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var items = jQuery('ul.slideshow li:not(.show,#slideshow-caption)');
	var itemscount= items.length;
	var next=jQuery(items.get(Math.round(Math.random()*(itemscount-1))));
	
		
	//Get next image caption
	//var title = next.find('img').attr('title');	

	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
	
	//Hide the caption first, and then set and display the caption
	//jQuery('#slideshow-caption').animate({bottom:-40}, 300, function () {
			//Display the content
	//		jQuery('#slideshow-caption h3').html(title);					
	//});	

	//Hide the current image
	current.animate({opacity: 0.0}, 1000).removeClass('show');

}

function increaseFontSize(){
	document.body.style.fontSize=parseInt(document.body.style.fontSize)+1+"px";
}

function decreaseFontSize(){
	document.body.style.fontSize=parseInt(document.body.style.fontSize)-1+"px";
}
