// JavaScript Document
var currentProduct = "marleyArmChair";
var isPanelOpen = false;

///////////code for header slideshow

		//$('#coin-slider').coinslider({ width: 1024, height: 570, navigation: false, delay: 5000, links : false, effect: 'straight' });
		function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
	
//////////////////////////////////end of code


//////////code for the navigation scroll down
	$('#scrollDown').hide();
		///////////code to open panel
		$('#productsLink').click(scrollDown);
		function scrollDown(){
			if(!isPanelOpen){
			$('#scrollDown').slideDown('slow');
			isPanelOpen = true;
			};
		
		};
		
		$('#scrollDown').mouseleave(scrollUp);
		$('.buttons').mouseover(scrollUp);
		$('aside').mouseover(scrollUp);
		function scrollUp(){
			if(isPanelOpen){
			$('#scrollDown').slideUp('slow');
			isPanelOpen = false;
			};
		
		};
///////////////////////////////////////////////////////end of scroll down code

//code for the chairs_sub page
$('#marleyArmChair_sub').click(linkToMarleyArmChair);
$('#marleyStackingChair_sub').click(linkToMarleyStackingChair);
$('#marleySideChair_sub').click(linkToMarleySideChair);
$('#oceanStackingChair_sub').click(linkToOceanStack);
$('#kiffFoldableChair_sub').click(linkToFoldable);
$('#kiffFoldableSide_sub').click(linkToFoldableSide);
$('#marleyBarChair_sub').click(linkToMarleyBar);



function linkToMarleyArmChair(){
	$.cookie('itemSelected','marleyArmChair');
	window.location = 'teak_chairs.html'
};

function linkToMarleyStackingChair(){
	$.cookie('itemSelected','marleyStackingChair');
	window.location = 'teak_chairs.html'
};


function linkToMarleySideChair(){
	$.cookie('itemSelected','marleySideChair');
	window.location = 'teak_chairs.html'
};

function linkToOceanStack(){
	$.cookie('itemSelected','oceanStack');
	window.location = 'teak_chairs.html'
};
function linkToFoldable(){
	$.cookie('itemSelected','foldableChair');
	window.location = 'teak_chairs.html'
};
function linkToFoldableSide(){
	$.cookie('itemSelected','foldableChairSide');
	window.location = 'teak_chairs.html'
};
function linkToMarleyBar(){
	$.cookie('itemSelected','marleyBar');
	window.location = 'teak_chairs.html'
};

////////////////////////////////////////////////////////end of sub chairs

//code for the benches_sub page
$('#4ftMarley_sub').click(linkToMarley4);
$('#5ftMarley_sub').click(linkToMarley5);
$('#6ftMarley_sub').click(linkToMarley6);
$('#4ftOval_sub').click(linkToOval4);
$('#5ftOval_sub').click(linkToOval5);
$('#4ftBackless_sub').click(linkToBackless4);
$('#5ftBackless_sub').click(linkToBackless5);
$('#6ftBackless_sub').click(linkToBackless6);



function linkToMarley4(){
	$.cookie('itemSelected','4ftMarley');
	window.location = 'teak_benches.html'
};

function linkToMarley5(){
	$.cookie('itemSelected','5ftMarley');
	window.location = 'teak_benches.html'
};


function linkToMarley6(){
	$.cookie('itemSelected','6ftMarley');
	window.location = 'teak_benches.html'
};

function linkToOval4(){
	$.cookie('itemSelected','4ftOval');
	window.location = 'teak_benches.html'
};

function linkToOval5(){
	$.cookie('itemSelected','5ftOval');
	window.location = 'teak_benches.html'
};

function linkToBackless4(){
	$.cookie('itemSelected','4FtBackless');
	window.location = 'teak_benches.html'
};

function linkToBackless5(){
	$.cookie('itemSelected','5FtBackless');
	window.location = 'teak_benches.html'
};
function linkToBackless6(){
	$.cookie('itemSelected','6FtBackless');
	window.location = 'teak_benches.html'
};



/////////////////////////////////////end of benches sub

//code for the table_sub page
$('#9ftOval_sub').click(linkTo9ftOval);

$('#9ftRect_sub').click(linkTo9ftRect);
$('#6ftOval_sub').click(linkTo6ftOvalT);
$('#6ftRect_sub').click(linkTo6ftRect);
$('#79farm_sub').click(linkTo79Farm);
$('#95farm_sub').click(linkTo95farm);

$('#5ftRound_sub').click(linkTo5ftRound);
$('#4ftRound_sub').click(linkTo4ftRound);
$('#47InchRound_sub').click(linkTo47Foldable);




function linkTo9ftOval(){
	$.cookie('itemSelected','9ftOval');
	window.location = 'teak_tables.html'
};




function linkTo9ftRect(){
	$.cookie('itemSelected','9ftRect');
	window.location = 'teak_tables.html'
};

function linkTo6ftOvalT(){
	$.cookie('itemSelected','6ftOvalT');
	window.location = 'teak_tables.html'
};

function linkTo6ftRect(){
	$.cookie('itemSelected','6ftRect');
	window.location = 'teak_tables.html'
};
function linkTo79Farm(){
	$.cookie('itemSelected','79farm');
	window.location = 'teak_tables.html'
};
function linkTo95farm(){
	$.cookie('itemSelected','95farm');
	window.location = 'teak_tables.html'
};

function linkTo5ftRound(){
	$.cookie('itemSelected','5ftRound');
	window.location = 'teak_tables.html'
};
function linkTo4ftRound(){
	$.cookie('itemSelected','4ftRound');
	window.location = 'teak_tables.html'
};
function linkTo47Foldable(){
	$.cookie('itemSelected','foldable');
	window.location = 'teak_tables.html'
};





//code for the lounger_sub page
$('#chairWfootstool_sub').click(linkToChairWithFoot);
$('#madison_sub').click(linkToMadison);
$('#steamer_sub').click(linkToSteamer);
$('#lazy_sub').click(linkToLazy);



function linkToChairWithFoot(){
	$.cookie('itemSelected','chairWithFoot');
	window.location = 'teak_loungers.html'
};




function linkToMadison(){
	$.cookie('itemSelected','madisonLounger');
	window.location = 'teak_loungers.html'
};

function linkToSteamer(){
	$.cookie('itemSelected','steamer');
	window.location = 'teak_loungers.html'
};

function linkToLazy(){
	$.cookie('itemSelected','lazy');
	window.location = 'teak_loungers.html'
};


//code for the occasional table sub page
$('#squareTable_sub').click(linkToSquareTable);
$('#coffeeTable_sub').click(linkToCoffeeTable);
$('#round_sub').click(linkToRoundTable);
$('#largeRound_sub').click(linkToLargeRound);


function linkToSquareTable(){
	$.cookie('itemSelected','squareTable');
	window.location = 'teak_oTables.html'
};

function linkToCoffeeTable(){
	$.cookie('itemSelected','coffeeTable');
	window.location = 'teak_oTables.html'
};

function linkToRoundTable(){
	$.cookie('itemSelected','roundTable');
	window.location = 'teak_oTables.html'
};

function linkToLargeRound(){
	$.cookie('itemSelected','largeRound');
	window.location = 'teak_oTables.html'
};




///function to animate to selected item

function moveToSelectedItem(){
	
	var selected = $.cookie('itemSelected');
	
	
	if(selected == '4ftMarley' || selected == 'marleyArmChair' || selected == '9ftOval' || selected == 'chairWithFoot' || selected == "squareTable" ){
		item1();
		$.cookie('itemSelected',null);
		
	}else if(selected == '5ftMarley' || selected == 'marleyStackingChair' || selected == '9ftRect' || selected == 'madisonLounger' || selected == 'coffeeTable' ){
		item2();
		$.cookie('itemSelected',null);
	}else if(selected == '6ftMarley' || selected == 'marleySideChair' || selected == '6ftOvalT' || selected == 'steamer' || selected == 'roundTable' ){
		item3();
		$.cookie('itemSelected',null);
	}else if(selected == '4ftOval'|| selected == 'oceanStack' || selected == '6ftRect' || selected == 'lazy' || selected == 'largeRound'  ){
		item4();
		$.cookie('itemSelected',null);
	}else if(selected == '5ftOval' || selected == 'foldableChair' || selected == '79farm'){
		item5();
		$.cookie('itemSelected',null);
	}else if(selected == '4FtBackless' || selected == 'foldableChairSide' || selected == '95farm'  ){
		item6();
		$.cookie('itemSelected',null);
	}else if(selected == '5FtBackless' || selected == 'marleyBar' || selected == '5ftRound'){
		item7();
		$.cookie('itemSelected',null);
	}else if(selected == '6FtBackless' || selected == '4ftRound'){
		item8();
		$.cookie('itemSelected',null);
	}else if(selected == 'foldable'){
		item9();
		$.cookie('itemSelected',null);
	}
	
	
	
};

moveToSelectedItem();


/////////////////////////////////////////////////end of function for selected item
		
	
		
		
////code for chairPage
	
		 
		//button events
		$('#marleyArmChair').click(item1);
		$('#marleyStackingChair').click(item2);
		$('#marleySideChair').click(item3);
		$('#oceanStackingChair').click(item4);
		$('#kiffaWideFoldable').click(item5);
		$('#kiffaWideFoldable_side').click(item6);
		$('#marleyBarChair').click(item7);
		
		
////code for bench page
	
		 
		//button events
		$('#4ftMarleyBench').click(item1);
		$('#5ftMarleyBench').click(item2);
		$('#6ftMarleyBench').click(item3);
		$('#4ftOval').click(item4);
		$('#5ftOval').click(item5);
		$('#4ftBackless').click(item6);
		$('#5ftBackless').click(item7);
		$('#6ftBackless').click(item8);
		
////code for table page
	
		 
		//button events
		$('#9ftOval').click(item1);
		$('#9ftRect').click(item2);
		$('#6ftOvalT').click(item3);
		$('#6ftRect').click(item4);
		$('#79Farm').click(item5);
		$('#95Farm').click(item6);
		$('#5ftRound').click(item7);
		$('#4ftRound').click(item8);
		$('#foldable').click(item9);
		
		
		
		$('#chairWfootStool').click(item1);
		$('#madison').click(item2);
		$('#steamliner').click(item3);
		$('#lazyChair').click(item4);
		
		

////code for occasional tables page
	
		 
		//button events
		
		$('#squareTable').click(item1);
		$('#coffeeTable').click(item2);
		$('#roundTable').click(item3);
		$('#largeRound').click(item4);
		
		
		///event handlers
		
		function item1(){
		
		
			$("#TopContainer").animate({"left": "-0px"}, "slow");
			
		
		currentProduct = 'marleyArmChair';
        
		
		
		
	    };/////end of marleyBench4
		
		
		function item2(){
		
		
			$("#TopContainer").animate({"left": "-935px"}, "slow");
		
		currentProduct = 'marleyStackingChair';
        
		
		
	    };/////end of marleyBench5
		
		
		
		function item3(){
		
		
			$("#TopContainer").animate({"left": "-1860"}, "slow");
	
		
		currentProduct = 'marleySideChair';
        
		
		
	    };/////end of marleyBench6
		
		
		
		function item4(){
		
		
	
			$("#TopContainer").animate({"left": "-2780px"}, "slow");
		
		
		currentProduct = 'oceanStackingChair';
        
		
		
	    };/////end of oval4
		
		
		
		function item5(){
		
		
		
			$("#TopContainer").animate({"left": "-3700"}, "slow");
		
		
		
		currentProduct = 'kiffaWideFoldable';
        
		
		
	    };/////end of oval5
		
		
		
		
		
		function item6(){
		
		
		
			$("#TopContainer").animate({"left": "-4612px"}, "slow");
		
		
		
		
		currentProduct = 'kiffaWideFoldable_side';
        
		
		
	    };/////end of backless4
		
		
		
		
		function item7(){
		
			
			$("#TopContainer").animate({"left": "-5552px"}, "slow");
		
		
		
		currentProduct = 'marleyBarChair';
        
		
		
	    };/////end of backless4
		
		
		function item8(){
		
			
			$("#TopContainer").animate({"left": "-6490px"}, "slow");
		
		
		
		currentProduct = 'marleyBarChair';
        
		
		
	    };/////end of backless6
		
		function item9(){
		
			
			$("#TopContainer").animate({"left": "-7405px"}, "slow");
		
		
		
		currentProduct = 'marleyBarChair';
        
		
		
	    };/////end of backless6
		
		
		function item10(){
		
			
			$("#TopContainer").animate({"left": "-8310px"}, "slow");
		
		
		
		currentProduct = 'marleyBarChair';
        
		
		
	    };/////end of backless6
		
		function item11(){
		
			
			$("#TopContainer").animate({"left": "-9240px"}, "slow");
		
		
		
		currentProduct = 'marleyBarChair';
        
		
		
	    };/////end of backless6
		
		
		
		//google analytics
		

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-23723605-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


		
		
	



	
	
	
	
		
