$(document).ready(function() {

$('#newsletter input[type="text"]').focus(function() {
  this.value = '';
});
$('#newsletter input[type="text"]').blur(function() {
  if (this.value == '') this.value = (this.defaultValue ? this.defaultValue : '');
});


//Show Banner
$('.main_image .desc').show(); //Show Banner
$('.main_image .block').animate({ opacity: 0.85 }, 1 ); //Set Opacity

//Click and Hover events for thumbnail list
$('.image_thumb ul li:first').addClass('active');


// * Adds a class ‘last’ to the last li to let the rotator know when to return to the first
$('.image_thumb ul li:last').addClass('last');

$('.image_thumb ul li').dblclick(function(){
//Set Variables
var imgAlt = '';//$(this).find('img').attr('alt'); //Get Alt Tag of Image
var imgTitle = $(this).find('a').attr('alt'); //Get Main Image URL
var imgDesc = $(this).find('.block').html(); //Get HTML of block
var imgDescHeight = $('.main_image').find('.block').height(); //Calculate height of block

if ($(this).is('.active')) { //If it’s already active, then…
return false; // Don’t click through
} else {
//Animate the Teaser
$('.main_image .block').animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$('.main_image .block').html(imgDesc).animate({ opacity: 0.85, marginBottom: '0' }, 250 );
$('.main_image img').attr({ src: imgTitle , alt: imgAlt});
});
}

$('.image_thumb ul li').removeClass('active'); //Remove class of ‘active’ on all lists
$(this).addClass('active'); //add class of ‘active’ on this list only
return false;

}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});

//Toggle Teaser
$('a.collapse').dblclick(function(){
$('.main_image .block').slideToggle();
$('a.collapse').toggleClass('show');
});


// * if we are hovering over the image area, pause the clickNext function
// * by default, our new pauseClickNext variable is false
pauseClickNext = false;
$('.main_image').hover(
function () {
pauseClickNext = true;
},
function () {
pauseClickNext = false;
}
);


// * Define function to click the next li
// * notice that it checks for a class of ‘last’, we added that above
var clickNext = function(){
if(!pauseClickNext) {
/// find the next li after .active
var $next_li = $('li.active').next('li');
if($('li.active').hasClass('last') ){
$('.image_thumb ul li:first').trigger('dblclick');
} else {
$next_li.trigger('dblclick');
}
}
};


// * setTimeInterval to run clickNext
setInterval(clickNext, 3000);


$('#left').css('height', $('#right').css('height'));

});//Close Function



function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;













	var INTERVAL = 4000;
var slideshow_timer = null;
var is_sliding = null;
function slideShow()
{
is_sliding = true;
$.galleria.next();
is_sliding = false;
}

	$(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 : true, // 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
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
				if (is_sliding== null)
				{
					slideshow_timer = window.setInterval(slideShow, INTERVAL);
					is_sliding = false;
				} else if (!is_sliding)
				{
					window.clearInterval(slideshow_timer);
					slideshow_timer = null;
				}

			},
			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.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
	});

