/*  Functions */

function imgSwap(img, img2, imga, imgb)/*img is before, img2 is after*/
{

var after=document.getElementById('after');
var before=document.getElementById('before');

before.src=img;
document.getElementById('main').src=img2;
after.src=img2;



/*after.onclick=function(){mainSwap(img2);};*/
document.getElementById('after').onmouseover=function() {mainSwap(img2, img, imga, imgb, 'After', 'Before')};
document.getElementById('before').onmouseover=function() {mainSwap(img, img2, imgb, imga, 'Before', 'After')};
}

function mainSwap(img, img2, imga, imgb, title, title2)
{		
		
		document.getElementById('main').src=img;
		document.getElementById('main_link').href=imga;
		document.getElementById('main_link').title=title;
		
		document.getElementById('main_two').src=img2;
		document.getElementById('main_link_two').href=imgb;
		document.getElementById('main_link_two').title=title2;
		
		// set up all anchor elements with a "shadow" class to work with Shadowbox
    Shadowbox.setup("a.shadow");
		
}




	function swapHero(c, t, d, s, f) //Swaps out all Hero section Data from Scrollbar thumbnail image
	{

				
		/*Swap Out Variables*/
		var cost = c;
		var title =  t;
		var difficulty = d;
		var style = s;
		var diff = f;

	/*document.getElementById('cost').innerHTML = cost;
	document.getElementById('style').innerHTML = style;
	document.getElementById('difficulty').innerHTML = difficulty; */
	document.getElementById('dd').innerHTML = diff;
	
	}
	
	
	function addCount(lim)
	{
		var firstValue = document.getElementById('first');
		var lastValue = document.getElementById('last');
		
		
		var last = parseInt(lastValue.innerHTML);
		
		if((lim-last) < 5)
		{
			var num = lim - last;
		}
		else{
			num = 5;
		}
		
		
		firstValue.innerHTML = parseInt(firstValue.innerHTML) + 5;
		lastValue.innerHTML = parseInt(lastValue.innerHTML) + num;
		
		
		
		
	}
	
	function minusCount(lim)
	{
		var firstValue = document.getElementById('first');
		var lastValue = document.getElementById('last');
		
		var last = parseInt(lastValue.innerHTML);
		var first = parseInt(firstValue.innerHTML);
		
		if((lim-last) == 0)
		{
			var num = last-(first-1);
		}
		else{
			num = 5;
		}
		
		
		firstValue.innerHTML = parseInt(firstValue.innerHTML) - 5;
		lastValue.innerHTML = parseInt(lastValue.innerHTML) - num;
		
	
	
	}
	
	// Gallery to Facebook Album Linkage
	
	jQuery(document).ready( function($) {
		//* Hide Facebook link if onLoad has no href value
		var hasLink = $('.fb-album a').attr('href');
		if(!hasLink){ $('.fb-album').hide(); }
		
		$('#thumb_strip a').live( 'click', function (){
			var linkage =  $(this).attr('facebook');
			
			if(linkage){
				$('.fb-album').show();
				$('.fb-album a').attr('href', linkage);
			}
			else
			{
				$('.fb-album').hide();
			}
			
		});
		
	})
	
	// Facebook RSS feed modifications
	jQuery(document).ready( function ($)  {
		//Override the href to go to the Page's wall
		$('.fb-posts a').attr( 'href', 'http://www.facebook.com/pages/Sockeye-Homes/354669587883172');
		
		//Set the target attribute
		$('.fb-posts a').attr('target', '_blank');
	});
	
	
	//  Booking Calendar Modifications (deprecated)
	jQuery(document).ready( function ($) {
		/*
		// Add Instructions bekow ther calendar
		$('#calendar_booking1').append('<div>*Please click on the desired date above</div>');
		
		// Adjust the classes for cells that are pending onClick
		$('td.date2approve').live( 'click', function()
		{
			var tdClass = $(this).attr("class");
			tdClass = tdClass.split(" ");
			tdClass = tdClass[2].split("-");
			tdClass = tdClass[2]+"."+tdClass[1]+"."+tdClass[3];
			
			// Remove Class from previously selected day
			$('.datepick-current-day').removeClass('datepick-current-day');
			
			$(this).removeClass('date2approve');
			$(this).removeClass('datepick-unselectable');
			var html = $(this).html();
			$(this).html('<a>'+html+'</a>');
			$("#date_booking1").val(tdClass);
			$(this).addClass("datepick-current-day");
			$(this).addClass("reserved_days_count1");
			
			//Add class to submit
			$('input[type="button"]').addClass('dateSelected');
		});
		
			// Add class to submit so we know that a date has been selected
		$('td.datepick-days-cell').live( 'click', function(){
			
			$('input[type="button"]').addClass('dateSelected');
		});
		*/
		$('input[type="button"]').live( 'click', function(){
			
			setTimeout( function(){
			$('#submiting1>div').hide();
			$('#submiting1').html('Thank you, your request has been submitted.');
			$('html, body').animate({scrollTop:100}, 'slow');},
			6000);	
	      
		});
		/*
		
		$('.datepick-days-cell').click( function (){
			setTimeout( function (){
			$('select option.week').css('display', 'block');
			}, 1000);
		});
			
		$('.datepick-week-end-cell').click( function (){
			setTimeout( function (){
			$('select option.week').css('display', 'none');
			}, 1000);
		});
*/
		
	});
