// JavaScript Document

function checkfooterLoc(){
//	alert('infucntion');
//	alert($(window).height());
/*
	if($(window).height() <= 700){
		// alert($(window).height());
		var newHeight = 0;
		newHeight = 62 + $('.sc_menu').height();
		
		
		 var cssObj = {
		  'margin-top' : newHeight+'px',
		  'position' : 'relative'
		}
		$('#footer ul').css(cssObj);
		$('#headerwrap').css('position','absolute');
//		alert('here');
	}	
*/
}
// window.onresize = function(event) {
//	alert('resized');
// }
$(document).ready(function(){
	checkfooterLoc();
	
//	$(window).resize(function() {
//		checkfooterLoc();
//	});

	if($('#slider li').length > 0){
		var maxWidth = 0;
		$('#slider li').each(function(index) {
			if($(this).width() > maxWidth){
				maxWidth = $(this).width();
			}
		});
		maxWidth = maxWidth + 10;
		$('#middlewrap').width(maxWidth);
	}
//	alert('gallery maxWidth: '+maxWidth);
  
	if($('.sc_menu .text').length > 0 && $('.sc_menu .text').height() < 540){
		// var midWrapHeight = $('.sc_menu .text').height() + 'px';
		var midWrapMargin = '-'+(parseInt($('.sc_menu .text').height() / 2))+'px';
	
	// $('#middlewrap').css('height',midWrapHeight);
	$('#middlewrap').css('marginTop',midWrapMargin);

	}

	var sliderli = new Array();
	var cHeight = $('#slider').height();
	sliderli = $('#slider li').each(function(index, value) { 
		var timg = $(this).find('img, iframe').height();
		var pTop = 0;
		pTop = (cHeight - timg)/2;
		$(this).css('top',pTop);
	});
	$("#slider li:last-child").click(function(event) {
		event.preventDefault();
	});
	$("a#next , #slider li img").click(function(event) {
		event.preventDefault();
		if($('#slider li.current').index() < ($('#slider li').length)-1){
  			$('#slider li.current').removeClass('current').next().fadeIn('normal').addClass('current');
		}
	});
	$("a#prev").click(function(event) {
	   event.preventDefault();
	   if($('#slider li.current').index()){
		   $('#slider li.current').removeClass('current').fadeOut('normal').prev().addClass('current');
	   }
	});
	
	
//	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

	var newconfig = {    
		 over: function(){alert('mouseover');}, // function = onMouseOver callback (REQUIRED)    
		 timeout: 5000, // number = milliseconds delay before onMouseOut    
		 out: function(){alert('mouseout');}// function = onMouseOut callback (REQUIRED)    
	};

/*	$("ul.children li").hoverIntent(function(newconfig) {
		// do Nothing
	}, function(newconfig){
		
		// alert('here');
		$(this).parent().stop().slideUp('slow'); 
		
//		$(this).parent().parent().slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
	});
*/	
	$("ul.sf-menu a").click(function(event) { //When trigger is clicked...
									 
									 
		if($(this).parent().parent().hasClass('sf-menu')){
			if($(this).siblings('ul').length){
				event.preventDefault();
			}
//			alert('top menu');
		}

		$(this).parent().siblings().find('ul').slideUp('slow');
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).siblings('ul').slideDown('fast').show(); //Drop down the subnav on click

		//Following events are applied to the trigger (Hover events for the trigger)
		});
	/*
	jQuery(function(){
			jQuery('ul.sf-menu').superfish();
	});
	*/
	
});
