// JavaScript Document

$(document).ready(function(){
	initLightBox();	
	if(!hasFlash){
		$('body').addClass('noflash');
		$('#nav').appendTo('#noflash_nav');
		$('#nine-months').parent().load('/ninemonths.html', function() {
			showNineMonth();
		});
	}
});

$(document).ready(function(){
	$(".clearClick").each(function(i,elem){
		$(elem).focus(function(){
			if($(this).val() == $(this).attr("rel"))
				$(this).val("");
		});
		$(elem).blur(function(){
			if($(this).val() == "")
				$(this).val($(this).attr("rel"));
		});
	});
	
});

function isIE(version){
	var browser = getBrowser();
	if(browser['name'] == "ie"){
		if(version != null && parseInt(version)){
			return (browser['version'] == version) ? true : false;
		}else{
			return true;
		}
	}else{
		return false;
	}
}

function initLightBox(){
	//var imgPrev = (isIE(6)) ? '/images/photo_prev.gif' : '/images/photo_prev.png';
	//var imgNext = (isIE(6)) ? '/images/photo_next.gif' : '/images/photo_next.png';
	var imgPrev = '/images/lightbox-btn-prev.gif';
	var imgNext = '/images/lightbox-btn-next.gif';
	$(function() {
		$("a[rel='lightbox']").lightBox({
			imageLoading: '/images/lightbox-ico-loading.gif',
			imageBtnClose: '/images/lightbox-btn-close.gif',
			imageBtnPrev: imgPrev,
			imageBtnNext: imgNext,
			fixedNavigation: true
		});
	});
}

function showFBHeader() {
	if($('#facebook_fanbox_wrapper').is(':visible')){
		$('#facebook_fanbox_wrapper').stop().clearQueue().slideUp(400);
	}else{
		$('#facebook_fanbox_wrapper').stop().clearQueue().slideDown(400);
	}
}


var arrayNumber = 0;
var nineMonth = Array("monthtext0","monthtext1","monthtext2","monthtext3",
					"monthtext4","monthtext5","monthtext6","monthtext7",
					"monthtext8","monthtext9","monthtext10","monthtext11",
					"monthtext12","monthtext13","monthtext14","monthtext15",
					"monthtext16","monthtext17","monthtext18","monthtext19",
					"monthtext20","monthtext21","monthtext22","monthtext23",
					"monthtext24","monthtext25"
		);
var nineMonths = Array(0, 8, 11, 14, 16, 18, 20, 21, 22, 23);
function showNineMonth() {	
		$('#btnNext').click(function() {
			$('.' + nineMonth[arrayNumber]).fadeOut("fast");
			arrayNumber++;
			showNextMonth();
			return false;
		});
		
		$('#btnPrev').click(function() {
			$('.' + nineMonth[arrayNumber]).fadeOut("fast");
			arrayNumber--;
			showNextMonth();
			return false;
		});
		
		$('#nine_nav a').click(function() {
			var num = $(this).attr("rel");
			$('.' + nineMonth[arrayNumber]).fadeOut("fast");
			arrayNumber = nineMonths[num];
			
			$('.' + nineMonth[nineMonths[num]]).fadeIn("fast");
			
			return false;
		});
		
		
	}

function showNextMonth() {
	
	if(arrayNumber == nineMonth.length) {
		arrayNumber = 0;
	} else if(arrayNumber < 0) {
		arrayNumber = nineMonth.length - 1;
	}
	
	$('.' + nineMonth[arrayNumber]).fadeIn("fast");
	return false;
}



