/*make outside pages open in separate window*/
$(function(){
	$('a[rel="external"]').live("click" ,function(){
		window.open(this.href);
		return false;
	});
});
/*load fancybox*/
$(document).ready(function() {
	if ($('body').is('.gallery')) {
		$("a[rel=bookmark]").fancybox({
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'titlePosition' : 'over',
			'overlayColor' : '#ffffff',
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	}
});
/*easy input hover*/
$(document).ready(function(){
	$("#send").hover(function() {
		$(this).attr("src","images/send_button_over.gif");
	}, function() {
		$(this).attr("src","images/send_button.gif");
	});
	$("#submit").hover(function() {
		$(this).attr("src","images/submit_button_over.gif");
	}, function() {
		$(this).attr("src","images/submit_button.gif");
	});
});
/*create a map*/
var map;
function initialize(){
	var myLatlng = new google.maps.LatLng(41.798021,-86.237638);
	// sets the center of the map to the varible "LatLong" that contains the coordinates
	var myOptions = {
		zoom: 12,
		// Zoom level for initial map. Valild vaues range form 0 to 20
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
		// sets the type of map to be displayed
		// HYBRID - displays a transparent layer of major streets on satellite images
		// ROADMAP - displays a normal street map 
		// SATELLITE - displays satellite images
		// TERRAIN - displays maps with physical features such as terrain
	}
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	var marker = new google.maps.Marker({
		position: new google.maps.LatLng(41.798021,-86.237638),
		// sent the geographic position for the marker
		map: map, 
		//  puts the marker on the specified map 
		title:"1605 Bell Road, Niles, MI  49120"
		// text that will display when the mouse cursor hovers over the marker
	});
}
$(document).ready(function() {
	if ($('body').is('.contact')) {
		initialize();
	}
});
/*slideshow*/
function slideSwitch(){
	var $active = $("#slideshow a.active");
	if ( $active.length == 0 ) $active = $("#slideshow a:last");
	if ( $active.next().length ){
		var $next = $active.next();
	}else{
		var $next = $("#slideshow a:first");
	}
	$active.addClass("last-active");
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
		$active.removeClass("active last-active");
	});
}
var slideId = null;
$(function() {
	animId = setInterval( "slideSwitch()", 8000 );
});
