﻿var cal_events = [];

$(document).ready(function() {
	$("#ix-nav li").hover(
		function() { $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	$(".nav_stick").hover(
		function () {$(this).children("A").attr("class","on");},
		function () {$(this).children("A").attr("class","off");}
	);
	if (document.all) {
		$("#ix-nav li").hoverClass("sfHover");
	}
	if (document.getElementById("map_div")) {
		mapping.display();
	}
	$(function() {
        $('.photo a').lightBox();
    });
    $('#calendar').fullCalendar({
		header: {
			left: 'title',
			center: '',
			right:  'prev,next'
		},
		events: cal_events,
		height : 720,
		timeFormat: 'h:mm TT\n'
    });
    $('#coda-slider-1').codaSlider({
		dynamicArrows: false,
		autoHeight: false,
		dynamicTabs: false,
		firstPanelToLoad: 1,
		crossLinking: false
	});
	scrollerInit();
	heroInit();
});

			
			
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};
function txtHover(id,className) {
	document.getElementById(id).className=className;
}

/* Scroller Stuff */
	var total_scroll = 0;
	var scroll_start = 1;

	function scrollerInit() {
		if (document.getElementById("scroller")) {
			scrollerPop(1);
			document.getElementById("scroller").style.display = "block";
			document.getElementById("scroller").scrollLeft = 185;
		}
	}

	function scrollerPop(start) {
		var x = start;
		for (var i=2;i <= 6; i++) {
			if (document.getElementById("scroll_"+x)) {
				document.getElementById("spot_"+i).innerHTML = document.getElementById("scroll_"+x).innerHTML;
			}
			x++;
			if (x > total_scroll && total_scroll > 5) {
				x = 1;
			}
		}
		if (total_scroll > 5) {
			var spot_1 = start - 1;
			if (spot_1 == 0) {
				spot_1 = total_scroll;
			}
			var spot_7 = x;
			document.getElementById("spot_1").innerHTML = document.getElementById("scroll_"+spot_1).innerHTML;
			document.getElementById("spot_7").innerHTML = document.getElementById("scroll_"+spot_7).innerHTML;
		}
	}

	function scrollerMove(pos) {
		if (total_scroll > 5) {
			if (pos == 0) {
				scroll_start = scroll_start - 1;
				if (scroll_start == 0) {
					scroll_start = total_scroll;
				}
			} else {
				scroll_start = scroll_start + 1;
				if (scroll_start > total_scroll) {
					scroll_start = 1;
				}
			}
			$("#scroller").animate({scrollLeft:pos}, 400, 'swing', scrollDone);
		}
	}

	function scrollDone() {
		scrollerPop(scroll_start);
		document.getElementById("scroller").scrollLeft = 185;
	}

/* Hero Stuff */
	var total_hero = 0;
	var curr_hero = 1;
	
	function heroInit() {
		if (document.getElementById("hero_img")) {
			setCurrHero(curr_hero);
		}
	}
	
	
	function swapHero() {
		var next_hero = curr_hero+1;
		
		if (next_hero > total_hero) {
			next_hero = 1;
		}
		
		document.getElementById("hero_img_bak").innerHTML = document.getElementById("hero_img_"+next_hero).innerHTML;
		curr_hero = next_hero;
		
		document.getElementById("hero_txt").innerHTML = document.getElementById("hero_txt_"+curr_hero).innerHTML;
		//document.getElementById("hero_href").href = document.getElementById("hero_img_"+curr_hero).getAttribute("href");
		$("#hero_img").animate({opacity:0},1000,'linear',setCurrHero);
	}
	
	function setCurrHero() {
		document.getElementById("hero_img").innerHTML = document.getElementById("hero_img_"+curr_hero).innerHTML;
		document.getElementById("hero_txt").innerHTML = document.getElementById("hero_txt_"+curr_hero).innerHTML;
		//document.getElementById("hero_href").href = document.getElementById("hero_img_"+curr_hero).getAttribute("href");
		$("#hero_img").animate({opacity:1},10,'linear');
		setTimeout(swapHero,8000);
	}
	
mapping = {
	display : function() {
		var lat = '38.629211';
		var lng = '-121.071930';

		var latlng = new google.maps.LatLng(lat,lng);
		var myOptions = { 
			zoom: 12, 
			center: latlng, 
			mapTypeId: google.maps.MapTypeId.ROADMAP 
		}; 
		map = new google.maps.Map(document.getElementById("map_div"), myOptions); 
		
		var marker = new google.maps.Marker({ 
			position: latlng,
			map: map
		});
		
		var infowindow = new google.maps.InfoWindow({ 
			content: "<b style=\"font-size:15px;\">El Dorado Dance Academy</b><br /><span style=\"font-size:11px;\">3921 Sandstone Drive, Suite 4<br />El Dorado Hills, CA 95762<br /><br />" +
				"<a target=\"_blank\" href=\"http://maps.google.com/maps?q=El+Dorado+Dance+Academy+3921+Sandstone+Drive,+Suite+4,+El+Dorado+Hills,+CA+95762&hl=en&cd=1&ei=rdcuTN-TK5-uMtTW6MEJ&ie=UTF8&view=map&cid=6039100705946348567&iwloc=A&ved=0CEgQpQY&sa=X\">Get Directions</a></span>"
		}); 
		google.maps.event.addListener(marker, 'click', function() { 
			infowindow.open(map,marker); 
		});
		infowindow.open(map,marker);
	}
}


//{
//	title: 'All Day Event',
//	start: new Date(y, m, 1)
//},
//{
//	title: 'Long Event',
//	start: new Date(y, m, d-5),
//	end: new Date(y, m, d-2)
//},
//{
//	id: 999,
//	title: 'Repeating Event',
//	start: new Date(y, m, d-3, 16, 0),
//	allDay: false
//},
//{
//	id: 999,
//	title: 'Repeating Event',
//	start: new Date(y, m, d+4, 16, 0),
//	allDay: false
//},
//{
//	title: 'Meeting',
//	start: new Date(y, m, d, 10, 30),
//	allDay: false
//},
//{
//	title: 'Lunch',
//	start: new Date(y, m, d, 12, 0),
//	end: new Date(y, m, d, 14, 0),
//	allDay: false
//},
//{
//	title: 'Birthday Party',
//	start: new Date(y, m, d+1, 19, 0),
//	end: new Date(y, m, d+1, 22, 30),
//	allDay: false
//},
//editable: false,
//		events: [
//			{
//				title: 'Click for Google',
//				start: new Date(2010, 6, 5),
//				end: new Date(2010, 6, 8),
//				url: 'http://google.com/',
//				allDay : true
//			}
//		]
