

var page_switch = function(service){
	// If requesting service header and is not currently
	if (service == 'service' && $('#ph_sales').css('top') == "-8px" ){
		// Phone Numbers
		$('#ph_sales').animate({top: '+=24px'});
		$('#ph_service').animate({top: '-=48px'});
		// Menus
		$('#bg_b2b').css({'z-index': '8'});
		$('#bg_bcc').css({'z-index': '9'});
		$('#bg_bcc').animate({top: '-=59px'},function(){ $('#bg_b2b').css({top: '59px'})});
	} else {
		// Only switch it needed
		if ( service != 'service' && $('#ph_sales').css('top') != "0px"){
			// Phone Numbers
			$('#ph_sales').animate({top: '-=24px'});
			$('#ph_service').animate({ top: '+=72px' })
			// Menus
			$('#bg_bcc').css({'z-index': '8'});
			$('#bg_b2b').css({'z-index': '9'});
			$('#bg_b2b').animate({top: '-=59px'},function(){ $('#bg_bcc').css({top: '59px'})});
		}
	}
};

var page_refresh = function(){ 
	$('.rotator').cycle({ fx: 'fade', shuffle: { top: -220, left: 40}, timeout: 3000});
	$('.carousel').galleria({
		history : false,
		clickNext : true,
		insert : '#gallery_large',
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				caption.css('display','none')	//.fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			}
	});
	// Solves AJAX Load issues
	if( $('.galleria').size() ){
		$.galleria.activate($('.galleria li:first img').attr('src'));
		$('.galleria li:first').addClass('active');
	}
	
}

$(document).ready(function(){
	page_refresh();
	
/*
	$('div.menu a').live('click',function(event){
		getPage($(this).attr('href'));
		// event.stopPropagation();
		event.preventDefault();
	});
	$('a.page').live('click',function(event){
		getPage($(this).attr('href'));
		event.stopPropagation();
		// event.preventDefault();
	});
*/
	// Make the Description link go to the detail rather than sort.
	$('.inv-desc td.inv-field-header').each(function(){
		$this = $(this);
		$layout = $this.parents('table.inv-item-layout');
		url = $layout.find('table.inv-item-pictures a:first').attr('href')
		$this.find('a').attr('href',url);
	});

});

Cufon.replace('.rockwell',{hover:true})('h1');
