/*

	commercial.js
	JavaScript and jQuery for Oak Island - SHANNNONWARE COMMERCIAL
	August 7, 2010
	Copyright (c) 2010 Shannon Ware. All Rights Reserved
	
	// using jQuery.js
	
*/

var pageWidth = $(window).width();
var pageHeight = $(window).height();
var heightIndex;
var contentHeight;
var textLanguageLinkPadding;
var headerOneSize = "64px";	/* not working */
var scrollingTextHeight;
var sectionLinkHeight; 
var sectionLinkPadding;
var topLinkHeight;
var topLinkAnchorPadding;

	/* heightIndex: 0 = normal page; 1 = narrow page */

if (pageHeight < 600) heightIndex = 1;
else heightIndex = 0; 

var centreClosedTop = Math.floor(pageHeight/2) + "px";
var centreClosedLeft = Math.floor(pageWidth/2) + "px";
var centreOpenLeft = Math.floor((pageWidth - 800)/2) + "px";
var centreOpenTop;

/*
	DISPLAY INDEX
	0	Spalsh page
	1	Irish Welcokme
	2 	Japanese Welcome
	3	English Welcome
*/
var displayIndex = 0;
		
if (heightIndex == 0) { 
	centreOpenTop = Math.floor((pageHeight - 600)/2) + "px"; 
	contentHeight = 600;
	textLanguageLinkPadding = "30px";
	headerOneSize = "144px";
	scrollingTextHeight = "494px";
	sectionLinkHeight = "30px"; /* basically, meaningless. See the next sectionLinkPadding */
	sectionLinkPadding = "26px 0px"; //"16px 0px";
	topLinkHeight = "300px";
	topLinkAnchorPadding = "196px 2px";
}
else { 
	centreOpenTop = Math.floor((pageHeight - 400)/2) + "px"; 
	contentHeight = 400;
	textLanguageLinkPadding = "0px";
	headerOneSize = "104px";
	scrollingTextHeight = "290px";
	sectionLinkHeight = "20px"; //28px";  /* basically, meaningless. See the next sectionLinkPadding */
	sectionLinkPadding = "14px 0px"; //"10px 0px";
	topLinkHeight = "288px";
	topLinkAnchorPadding = "93px 2px";
}

function glTest(a, b) {
	alert ('commercial.js test at '+new Date().toString()+'; a: '+a.toString()+'; b: '+b.toString());	
}

function hideTopLink () {
	$("#topLinkDiv").css({ height : topLinkHeight }).animate({ width : '0px' }, "fast");
	$("#topLinkAnchor").css({ padding : topLinkAnchorPadding }).animate({ width : '0px' }, "fast");
	$("#topLinkImage").animate({ width : '0px' }, "fast");
}

function showTopLink () {
	$("#topLinkDiv").animate({ width : '30px' }, "slow");
	$("#topLinkAnchor").animate({ width : '24px' }, "fast");
	$("#topLinkImage").animate({ width : '20px' }, "fast");
}

// LET THE jQUERY BEGIN!

$(function() {
	// Good to begin again
	//glTest(centreTop, centreLeft);
	//alert('Page height: '+pageHeight+'; page width: '+pageWidth+'; centreClosedTop: '+centreClosedTop+'; centreClosedLeft: '+centreClosedLeft);
	$("#content").css({ top: centreClosedTop, left: centreClosedLeft }).animate({ 
		width: 800,
		height: contentHeight,
		top: centreOpenTop,
		left: centreOpenLeft
	}, 200, function(){ 
		//alert('centreOpenTop: '+centreOpenTop+'; centreOpenLeft: '+centreOpenLeft);	
		$(".languageLink").css({ padding: textLanguageLinkPadding });
	});
	$(".contentTypeLink").click(function() {
		$(".sectionContent").not("#welcomeSection").hide();
		$(".languageLink").slideUp("slow");
		$(".clickToEnter").slideUp("slow");
		$("#irishFlagImage").attr("src", "irishFlagNarrow.png");
		$("#japaneseFlagImage").attr("src", "japaneseFlagNarrow.png");
		$("#englishFlagImage").attr("src", "englishFlagNarrow.png");
		$(".flagLink").css({ padding : "0px 15px" });
		$("h1").css({ margin : "-16px 0px" });
		$("#scrollingText").css({ height : scrollingTextHeight });
		$("#section").css({ height : topLinkHeight });
		$(".sectionLink").css({ height : sectionLinkHeight, padding : sectionLinkPadding });
		$("#flagLinks").css({ padding : "0px" });
		hideTopLink();
		/*
		$("#topLinkDiv").css({ height : topLinkHeight }).animate({ width : '0px' }, "fast");
		$("#topLinkAnchor").css({ padding : topLinkAnchorPadding }).animate({ width : '0px' }, "fast");
		$("#topLinkImage").animate({ width : '0px' }, "fast");
		*/
	});
	$(".sectionLink").click(function() {
		showTopLink();
		/*
		$("#topLinkDiv").animate({ width : '30px' }, "slow");
		$("#topLinkAnchor").animate({ width : '24px' }, "fast");
		$("#topLinkImage").animate({ width : '20px' }, "fast");
		*/
		//$("#welcomeSection").css({border : "1px solid red"}).slideUp("slow");		
	});
	$("#topLinkAnchor").click(function () {
		//alert('Attractons Section');
		$("#welcomeSection").slideDown("slow");
		$(".sectionContent").not("#welcomeSection").slideUp("slow");
		hideTopLink();
	});
	$("#sectionAttractions").click(function () {
		//alert('Attractons Section');
		$("#attractionsSection").slideDown("slow");
		$(".sectionContent").not("#attractionsSection").slideUp("slow");
	});
	$("#sectionLodging").click(function () {
		//alert('Attractons Section');
		$("#lodgingSection").slideDown("slow");
		$(".sectionContent").not("#lodgingSection").slideUp("slow");
	});
	$("#sectionTransit").click(function () {
		//alert('Attractons Section');
		$("#transitSection").slideDown("slow");
		$(".sectionContent").not("#transitSection").slideUp("slow");
	});
	$("#sectionDining").click(function () {
		//alert('Attractons Section');
		$("#diningSection").slideDown("slow");
		$(".sectionContent").not("#diningSection").slideUp("slow");
	});
	$("#sectionEntertainment").click(function () {
		//alert('Attractons Section');
		$("#entertainmentSection").slideDown("slow");
		$(".sectionContent").not("#entertainmentSection").slideUp("slow");
	});
	$("#sectionAboutUs").click(function () {
		//alert('Attractons Section');
		$("#aboutUsSection").slideDown("slow");
		$(".sectionContent").not("#aboutUsSection").slideUp("slow");
	});

	// DIAGNOSTIC
	//alert('Page height: '+pageHeight+'; page width: '+pageWidth+'; heightIndex: '+heightIndex+'; contentHeight: '+contentHeight);
});

