$(document).ready(function() {
 		$("#home-btn a").addClass('selected');
		$('#primary-navigation a').click(function () {
		$('#primary-navigation a').removeClass('selected');
		$(this).addClass('selected');
		current = $(this);
		$('#wrapper').scrollTo($(this).attr('href'), 800);		
		
		return false;
	});
	$(window).resize(function () {
		resizePanel();
	});
	
	loadmap();
	chooseStyle('home-theme', 60);
	$.backstretch("_includes/images/bg/ChristChurch4.jpg", {speed: 100});
	
	
	$('#home-btn a').click(function () {$.backstretch("_includes/images/bg/ChristChurch4.jpg", {speed: 100}),(chooseStyle('home-theme', 60)) });
    $('#projects-btn a').click(function () {$.backstretch("_includes/images/bg/ChristChurch3.jpg", {speed: 100}),(chooseStyle('projects-theme', 60)) });
    $('#practice-btn a').click(function () {$.backstretch("_includes/images/bg/ChristChurch2.jpg", {speed: 100}),(chooseStyle('practice-theme', 60)) });
    $('#contact-btn a').click(function () {$.backstretch("_includes/images/bg/ChristChurch1.jpg", {speed: 100}),(chooseStyle('contact-theme', 60)) });
    
  	var position = 0,
	images = [];

	$.backstretch(images[position], {speed: 400});
	setInterval(function() {
    if(position++ > images.length) position = 0;
    $("#backstretch img").attr("src", images[position]);
    $(window).trigger("resize");
}, 100);
	
	
});

function resizePanel() {
    width = $(window).width();
    height = $(window).height();
    mask_width = width * $('.item').length;
    $('#wrapper, .item').css({width: width, height: height});
    $('#mask').css({width: mask_width, height: height});
    $('#wrapper').scrollTo($('a.selected').attr('href'), 0);         
}

$(function(){ 
	$('input[title!=""]').hint();
	$('textarea[title!=""]').hint();
});
			
			
$(function(){ 
  $(".tabs").tabs({
		 fx: { opacity: 'toggle' }
		});		
  });
  
  
$(function(){ 
    jQuery('#nav-carousel, .pabgallery, .pabgallery2').jcarousel({
        scroll: 1
    });
}); 

$(function(){ 
	$("a.pabfancy").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'fade',
		'padding': 0,
		'showNavArrows' : true,
		'titlePosition' : 'inside',
		'overlayColor' : '#000',
		'overlayOpacity' : '0.6',
		'centerOnScroll' : true
	});
});


function loadmap(){

  var point = new google.maps.LatLng(53.494084,-2.512295);

  var myMapOptions = {
    zoom: 16,
    center: point,
    mapTypeId: google.maps.MapTypeId.SATELLITE,
    		    mapTypeControl: true,
    mapTypeControlOptions: {
      style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
    }

  };

  var map = new google.maps.Map(document.getElementById("map"),myMapOptions);

  var image = new google.maps.MarkerImage(
    '_includes/images/marker-images/image.png',
    new google.maps.Size(80,50),
    new google.maps.Point(0,0),
    new google.maps.Point(40,50)
  );

  var shadow = new google.maps.MarkerImage(
    '_includes/images/marker-images/shadow.png',
    new google.maps.Size(108,50),
    new google.maps.Point(0,0),
    new google.maps.Point(40,50)
  );

  var shape = {
    coord: [79,0,79,1,79,2,79,3,79,4,79,5,79,6,79,7,79,8,79,9,79,10,79,11,79,12,79,13,79,14,79,15,79,16,79,17,79,18,79,19,79,20,79,21,79,22,79,23,79,24,79,25,79,26,79,27,79,28,79,29,79,30,79,31,79,32,79,33,79,34,79,35,79,36,79,37,79,38,79,39,79,40,79,41,47,42,46,43,45,44,43,45,42,46,41,47,40,48,39,48,38,47,37,46,35,45,34,44,33,43,32,42,0,41,0,40,0,39,0,38,0,37,0,36,0,35,0,34,0,33,0,32,0,31,0,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0,79,0],
    type: 'poly'
  };

  var marker = new google.maps.Marker({
    draggable: false,
    raiseOnDrag: false,
    icon: image,
    shadow: shadow,
    shape: shape,
    map: map,
    position: point
  });

}





 
