var gap = 267;
var frameheight = 660;

$(window).scroll(function() {

		var scroll_position = window.pageYOffset;
		var page_height = document.body.clientHeight;
									   
		if (scroll_position >= gap && (page_height - scroll_position) > frameheight) {
			$("#MainColRight").css({
				"position": "fixed",
				"top": '20px',
				"margin-left" : '720px'
			});
		} 
		
		else if ((page_height - scroll_position) < frameheight) {
			$("#MainColRight").css({
				"position": "absolute",
				"top": page_height-frameheight-187,
				"margin-left" : '720px'
			});
		}
		
		else if (scroll_position < gap ) {
			$("#MainColRight").css({
				"position": "relative",
				"top" : 0,
				"margin-left" : '0px'
			});
		}
		
	});


$(function() {
	
	$("#1603110155").validate();
	$("#1874113193").validate();
	
	$('.customer img').mouseover(function() {
		$(this).animate({ "top": "-=10px"}, 100 );
	}).mouseout(function(){
		$(this).animate({ "top": "+=10px"}, 100 );
	});

	
	$('#MainCol .content').columnize({columns:2});
	
	
	$('#HomeSlideshow').cycle({ 
		fx: 'fade',
	    speed: 1000,
		timeout: 7000,
		pager:  '#SliderNav',
		pagerAnchorBuilder: function(idx, slide) { 
		        return '<a href="#"></a>'; 
		    }
	});
	$('#goto1').click(function() { 
	    $('#HomeSlideshow').cycle(0); 
	    return false; 
	});
	$('#goto2').click(function() { 
	    $('#HomeSlideshow').cycle(1); 
	    return false; 
	});
	$('#goto3').click(function() { 
	    $('#HomeSlideshow').cycle(2); 
	    return false; 
	});
	$('#goto4').click(function() { 
	    $('#HomeSlideshow').cycle(3); 
	    return false; 
	});
	$('#goto5').click(function() { 
	    $('#HomeSlideshow').cycle(4); 
	    return false; 
	});
	$('#goto6').click(function() { 
	    $('#HomeSlideshow').cycle(5); 
	    return false; 
	});
	
	$('#PhotoTourSlideShow').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 0, 
	    next:   '.next', 
	    prev:   '.prev' 
	});
});

$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
    $(pager).find('li').removeClass('activeLI')
        .filter('li:eq('+currSlideIndex+')').addClass('activeLI');
};


