

$(document).ready( function () {
	// contact page jquery hax
	// This is to place the text on the right hand side to the middle vertically
	$("#contact_form input[name='f_name_'], #contact_form input[name='f_email_']").after("<div class='req'>*</div>");
	
	var contact_w_height = $('#contactus').height();
	var contact_t_height = $('#contactus #contact_text').height();
	var offset = (contact_w_height - contact_t_height) /2 ;
	$('#contactus #contact_text').css({'position' : 'relative', 'top' : offset });
	
	// This is to calculate how big the UL tag should be
	
});
$(window).load( function () {
	//alert('document loaded');
	//alert('dude');
	var lis = $('#thumbwindow ul li');
	var walker = 0;
	var pagewalker = 0;
	var pagenum = 0;
	var numitems = 0;
	var ix = 0;
	lis.each( function () {
		var cw = $(this).outerWidth(true);
		walker += cw;
		$(this).data('index',ix);
		if((cw + pagewalker) > 850) {
			pagenum++;
			pagewalker = cw;
			$(this).attr('page', pagenum);
			$(this).data('index', ix);
			numitems = 0;
			ix++;
		} else {
			//none of these should be changed, at all
			pagewalker += cw;
			numitems++;
			$(this).attr('page', pagenum);
			$(this).data('index', ix);
			ix++;
		}		
	});
	
	//alert(walker);
	$('#thumbwindow ul').data('page',0);
	$('#thumbwindow .slid ul').width(walker);
	//alert(walker);
	$('.navileft').hide();
	if(walker < 850) {
		$('.naviright').hide();
	}

	$('.navileft').click(function () {
		var navinum = $('#thumbwindow ul').data('page');
		$('#thumbwindow ul').data('page',(navinum-1));
		
		//alert('navinum: '+navinum);
		
		var d1 = $('#thumbwindow').offset().left;
		var d2id = '#thumbwindow ul li[page="'+(navinum-1)+'"]:first';
		//alert(d2id);
		var d2 = $(d2id).offset().left;
		//alert('d2 = '+d2)
		var distance = d1-d2;
		//alert(d2-d1);
		//alert(distance);
	
		$('#thumbwindow ul').animate({
			left: '+='+distance		
		}, 250, function () {
			$('.naviright').show();
			//alert($('#thumbwindow ul').position().left);
			if($('#thumbwindow ul').position().left > -30 ) {
				$('.navileft').hide();		
			}
			var navinum = $('#thumbwindow ul').data('page');
			
			
		});
	});
	
	
	$('.naviright').click(function () {
		var navinum = $('#thumbwindow ul').data('page');
		$('#thumbwindow ul').data('page',(navinum+1));
		
		var d1 = $('#thumbwindow').offset().left;
		var d2id = '#thumbwindow ul li[page="'+(navinum+1)+'"]:first';
		
		//alert('navinum: '+navinum);
		//alert(d2id);
		var d2 = $(d2id).offset().left;
		var distance = d2-d1;
		//alert(d2-d1);
		//alert(distance);
		
		$('#thumbwindow ul').animate({
			left: '-='+distance
		
		}, 250, function () {
			$('.navileft').show();
			//alert($('#thumbwindow ul').position().left);
			if(($('#thumbwindow ul').position().left + $('#thumbwindow ul').outerWidth()) < 850 ) {
				$('.naviright').hide();
				
			}
			
			
		});
	});
	
	var minheight = $(window).height();
	var actualheight = $("body").height(); //+$("#footer_area").height()
	if (actualheight < minheight) {
		//alert('true, the actualheight ('+actualheight+') is bigger than the minheight ('+minheight+'), therefore it\'s all wrong... :(');
		$("body").css('height',minheight);
		$("#footer_area").css({'position':'absolute','bottom':'0'});
	}
	
	$('#orbitz').orbit({
	     animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
	     animationSpeed: 1000,                // how fast animtions are
	     timer: true, 			 // true or false to have the timer
	     advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
	     pauseOnHover: true, 		 // if you hover pauses the slider
	     startClockOnMouseOut: false, 	 // if clock should start on MouseOut
	     startClockOnMouseOutAfter: 0, 	 // how long after MouseOut should the timer start again
	     directionalNav: false, 		 // manual advancing directional navs
	     captions: true, 			 // do you want captions?
	     captionAnimation: 'fade', 		 // fade, slideOpen, none
	     captionAnimationSpeed: 100, 	 // if so how quickly should they animate in
	     bullets: false,			 // true or false to activate the bullet navigation
	     bulletThumbs: true,		 // thumbnails for the bullets
	     bulletThumbLocation: 'images/thumbz',		 // location from this file where thumbs will be
	     afterSlideChange: function(){} 	 // empty function 
	});
	
	
	$('#galleryz').orbit({
	     animation: 'horizontal-slide',                  // fade, horizontal-slide, vertical-slide, horizontal-push
 	     animationSpeed: 1900,                // how fast animtions are
 	     timer: true, 			 // true or false to have the timer
 	     advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
 	     pauseOnHover: true, 		 // if you hover pauses the slider
 	     startClockOnMouseOut: true, 	 // if clock should start on MouseOut
 	     startClockOnMouseOutAfter: 0, 	 // how long after MouseOut should the timer start again
 	     directionalNav: true, 		 // manual advancing directional navs
// 	     captions: true, 			 // do you want captions?
// 	     captionAnimation: 'fade', 		 // fade, slideOpen, none
// 	     captionAnimationSpeed: 1000, 	 // if so how quickly should they animate in
// 	     bullets: true,			 // true or false to activate the bullet navigation
// 	     bulletThumbs: true,		 // thumbnails for the bullets
// 	     bulletThumbLocation: '',		 // location from this file where thumbs will be
		 dc: true,
 	     afterSlideChange: function(){} 	 // empty function 
 
	});
	
});

$(function() {
	$('input[name="f_date_of_event_"]').datepicker({showAnim: 'drop'});		
});
