// JavaScript Document
$j = jQuery.noConflict();

var isActive = false;

$j(function(){
		$j('#image_gallery ul li a').hover(
			function(){
				$j(this).children('.ig_overlay').show('fade','slow');
			},
			function(){
				$j(this).children('.ig_overlay').hide('fade','slow');
			}
		);
		
		$j('#image_gallery ul li a').hover(
			function(){
				$j(this).children('.ig_overlay_TK').show('fade','slow');
			},
			function(){
				$j(this).children('.ig_overlay_TK').hide('fade','slow');
			}
		);
		
		$j('#mastToggle a').hover(
			function(){
				if(! $j(this).hasClass('active'))
					$j(this).children('.mast_overlay').hide('fade','slow');
			},
			function(){
				if(! $j(this).hasClass('active'))
					$j(this).children('.mast_overlay').show('fade','slow');
			}
		);
		
		$j('a.video-link').hover(
			function(){
				$j(this).children('.video-overlay').show('fade','slow');
			},
			function(){
				$j(this).children('.video-overlay').hide('fade','fast');
			}
		);
		
		$j('#mastToggle a').click(function() {
			if (!isActive) {
				isActive = true;
				var rel = $j('#mastToggle .active').attr('rel');
				$j('a[rel="'+rel+'"]').children('.mast_overlay').show('fade','slow');
				$j('a[rel="'+rel+'"]').removeClass('active');
				var src = '#' + $j(this).attr('rel');
				
				$j(this).addClass('active');
				$j('#mastHead .active').hide('fade','slow', function(){
					$j('#mastHead .active').removeClass('active');
					$j(src).addClass('active');
					$j(src).show('fade','slow', function() {
						isActive = false;
					});
										
				}); }
			else {
				
				setTimeout( function(){
					var rel = $j('#mastToggle .active').attr('rel');
					$j('a[rel="'+rel+'"]').children('.mast_overlay').show('fade','slow');
					$j('a[rel="'+rel+'"]').removeClass('active');
					var src = '#' + $j(this).attr('rel');
					$j(this).addClass('active');
					$j('#mastHead .active').hide('fade','slow', function(){
						$j('#mastHead .active').removeClass('active');
						$j(src).addClass('active');
						$j(src).show('fade','slow');
								
					});
				}, 500);
			}
		
		});
});



$j(document).ready(function() {
	var ua = navigator.userAgent.toLowerCase();
	var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
	
	if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i))||(isAndroid)) {
					$j('a[rel^=shadowbox]').each(function() {
									$j(this).click(function() {
											setTimeout(scrollTo, 0, 0, 1);
									});
					}); //end:each
					$j('a[rel^=lightbox]').each(function() {
									$j(this).click(function() {
											setTimeout(scrollTo, 0, 0, 1);
									});
					}); //end:each
	} 
});







