jQuery.extend( jQuery.easing,
{
	
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	}
	
});


$(function(){
	$(window).load(function(){
		$('#tag').animate({'left':'-67px'}, 1000);
		setTimeout('$("#tag").toggleClass("tagback")', 2500);
	});
	
	$('#header_content a').hover(function(){
		$(this).css({'opacity':'0.7'});
	}, function(){
		$(this).css({'opacity':'1'});
	});
	$('#pano_nav_bg').css({'opacity':'0.6'});
	$('#pano_nav li:first-child').addClass('current');
	$('#pano_nav li').each(function(){
		$(this).hover(function(){
			$(this).css({'background-color': '#fff'});
		},function(){
			$(this).removeAttr('style');
		});
	});
	$('#pano_nav li').click(function(){
		$('#pano_nav li').each(function(){
			$(this).removeClass('current');
		});
		$(this).addClass('current');
	});
	$('#scroll_left').click(function(){
		var left = parseInt($('#scroller ul').css('left'));
		move = left + 144;
		if(move <= 0)
			$('#scroller ul').animate({'left': move+'px'}, 200, 'easeInOutSine');
		else
			$('#scroller ul').animate({'left': '0px'}, 200, 'easeInOutSine');
	});
	$('#scroll_right').click(function(){
		var width = parseInt($('#scroller ul').css('width')) - 864;
		var left = parseInt($('#scroller ul').css('left'));
		move = left - 864;
		if(move >= -(width))
			$('#scroller ul').animate({'left': move+'px'}, 300, 'easeInOutSine');
		else
			$('#scroller ul').animate({'left': '-'+width+'px'}, 200);
	});
	$('a.youtube').click(function(){
		$.fancybox({
			'transitionIn' : 'elastic',
			'easingIn' :'swing',
			'transitionOut'	: 'elastic',
			'easingOut' : 'swing',
			'titleShow' : true,
			'overlayOpacity' : 0.6,
			'overlayColor' : '#000',
			'padding' : 10,
			'scrolling' : 'no',
			'centerOnScroll' : true,
			'hideOnContentClick': false,
			'hideOnOverlayClick': true,
			'showCloseButton': true,
			'autoScale' : false,
			'title' : this.title,
			'width' : 853,
			'height' : 505,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		return false;
	});
	$('a.map').fancybox({
		'transitionIn' : 'elastic',
		'easingIn' :'swing',
		'transitionOut'	: 'elastic',
		'easingOut' : 'swing',
		'titleShow' : true,
		'overlayOpacity' : 0.6,
		'overlayColor' : '#000',
		'padding' : 10,
		'scrolling' : 'no',
		'centerOnScroll' : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': true,
		'showCloseButton': true,
		'type': 'iframe',
		'width': 750,
		'height': 500,
		'autoScale': false
	});
	$('a.walkscore').fancybox({
		'transitionIn' : 'elastic',
		'easingIn' :'swing',
		'transitionOut'	: 'elastic',
		'easingOut' : 'swing',
		'titleShow' : true,
		'overlayOpacity' : 0.6,
		'overlayColor' : '#000',
		'padding' : 10,
		'scrolling' : 'no',
		'centerOnScroll' : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': true,
		'showCloseButton': true,
		'type': 'iframe',
		'width': 750,
		'height': 286,
		'autoScale': false
	});
	$('a.fancybox').fancybox({
		'transitionIn' : 'elastic',
		'easingIn' :'swing',
		'transitionOut'	: 'elastic',
		'easingOut' : 'swing',
		'titleShow' : true,
		'overlayOpacity' : 0.6,
		'overlayColor' : '#000',
		'padding' : 10,
		'scrolling' : 'no',
		'centerOnScroll' : true,
		'hideOnContentClick': false,
		'hideOnOverlayClick': true,
		'showCloseButton': true,
		'autoScale': true
	});
	$('#contact_form').submit(function(){
		var valid = true;
		$('#contact_form input.req').each(function(){
			if($(this).val() == ''){
				$(this).css({'border':'2px solid red', 'padding': '2px 1px'});
				valid = false;
			}else{
				$(this).removeAttr('style');
			}
		});
		$('#contact_form textarea.req').each(function(){
			if($(this).val() == ''){
				$(this).css({'border':'2px solid red'});
				valid = false;
			}else{
				$(this).removeAttr('style');
			}
		});
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if(!filter.test($('#contact_form #email').val())){
			$('#contact_form #email').css({'border':'2px solid red', 'padding': '2px 1px'});
			valid = false;
		}else{
			$(this).removeAttr('style');
		}
		if(valid){
			$('#error').html('');
		}else{
			$('#error').html('<strong>There appears to be one or more errors in the highlighted fields.<br>Please check the form and try again.</strong>');
		}
		return valid;
	});
});
function changePano(tour, pano){
	document.getElementById('flashcontent').innerHTML='';
	if(pano == tour+"_2")
		pano = "pano2";
	else if(pano == tour+"_3")
		pano = "pano3";
	else if(pano == tour+"_4")
		pano = "pano4";
	else if(pano == tour+"_5")
		pano = "pano5";
	else if(pano == tour+"_6")
		pano = "pano6";
	else if(pano == tour+"_7")
		pano = "pano7";
	else if(pano == tour+"_8")
		pano = "pano8";
	else if(pano == tour+"_9")
		pano = "pano9";
	else if(pano == tour+"_a")
		pano = "panoa";
	else pano = "pano1";
	
	var so = new SWFObject("files/pano.swf", pano, "908", "420", "9", "#282828"); 
	so.addVariable("xml_file","files/flashParams.xml");
	so.addVariable("redirect", window.location);
	so.addVariable("panoName",tour+"/"+pano);
	so.addParam("allowFullScreen","true");
	so.addParam("allowScriptAccess","sameDomain");
	so.addParam("wmode","transparent");
	so.write("flashcontent");
}

$(document).ready(function() {
	$('#tag').click(function() {
				window.location = "http://www.cotala.com/";});
			});




