/*
 * 
 * @filename:  	taseda.js
 * @descrip:   	javascript object for The Franchiser
 * @date:  		7/6/2011
 *
*/


 <!-- jQuery Scripts -->
$(document).ready(function (){
	
	$('#next').hide();
	$('#prev').hide();
	
	$("#content").hover(function(){
		$("#next").fadeIn(),
		$("#prev").fadeIn();},
		function(){
		$("#next").fadeOut(),
		$('#prev').fadeOut();
			

});



$(document).ready(function(){
		var winheight = $(window).height();
		var conheight = $('#wrapper').height();
		var floatheight  = Math.ceil((winheight-conheight) / 2);
		
		$('#wrapper').css('margin-top', floatheight);

		$(window).bind("resize", function(){
		var winheight = $(window).height();
		var conheight = $('#wrapper').height();
		var floatheight  = Math.ceil((winheight-conheight) / 2);
		
		if (floatheight>=5){
		$('#wrapper').css('margin-top', floatheight);
		} else {
		$('#wrapper').css('margin-top', 5);
		}
		});
		});
						
						
	<!--  Width -->
	
	var accum_width = 0;
	$('#contentwrap').find('img').each(function() {
	   accum_width += $(this).outerWidth() +7;
	});
	
	$('#wrapscroll').width(accum_width);
	
	
	
	
	
	
	<!-- Stop Image Dragging -->
	$('img').bind('dragstart', function(event) { event.preventDefault(); });
	
	
	
	$('#access ul li').click(function(){
		$(this).children('ul').slideToggle();
});
	$('#access ul ul a').click(function(e){
		$('#access ul ul').slideUp();
		$('#content').fadeOut();
		var href = $(this).attr('href');  
		setTimeout(function() {window.location = href}, 500);
        return false;
});

	<!-- Swiping Events -->
	
	$('#contentwrap').bind('swipeleft', function(e) {
		$('#contentwrap').animate({scrollLeft: '+=1041'}, 'slow');
		e.stopImmediatePropagation();
		return false;
  } );  
	$('#contentwrap').bind( 'swiperight', function(e) {
		$('#contentwrap').animate({scrollLeft: '+=-1041'}, 'slow');
		e.stopImmediatePropagation();
		return false;
}); 

<!-- Prev/Next Buttons -->
		$('#next').click(function(){
			 $('#contentwrap').animate({scrollLeft: '+=1041'}, 'slow');
		});
		$('#prev').click(function(offRight){
			$('#contentwrap').animate({scrollLeft: '+=-1041'}, 'slow');
		});
		
		<!--  Disappearing arrows -->

	
	leftPos = $('#contentwrap').scrollLeft();
	
	if(leftPos<=0){
		$('#prev').css('opacity', 0);
	} 
	
	$('#contentwrap').scroll(function(){
		var leftPos = $('#contentwrap').scrollLeft();
		var wrapWidth = $('#wrapscroll').width();
			wrapWidth = wrapWidth-1041;
	
		if (leftPos>0){
				$('#prev').css('opacity', .6);}
		if(leftPos<=0){
			$('#prev').css('opacity', 0);} 
		
		if(leftPos <= wrapWidth){
			$('#next').css('opacity', .6);}
		
		if(leftPos == wrapWidth){
			$('#next').css('opacity', 0);					
		}
	});
		

$(document).ready(function(){
var wrapWidth = $('#wrapscroll').width();
if(wrapWidth == 772){
			$('#next').css('opacity', 0);					
}


});
	
		<!--  keyboard controls -->

		$(document).bind("keydown", function(e){
	if (e.keyCode == 39) { 
	   $('#contentwrap').animate({scrollLeft: '+=1041'}, 700, "easeInOutQuart");
	   return false;
		}
	});
	
	$(document).bind("keydown", function(e){
	if (e.keyCode == 37) { 
	   $('#contentwrap').animate({scrollLeft: '+=-1041'}, 700, "easeInOutQuart");
		e.stopImmediatePropagation()
	   return false;
		}
	});
	
	imgHeight = $('#contentwrap img').height();
	imgWidth = $('#contentwrap img').width();
	
});
