/*

	Filename             sitewide.js
	Detail               Site functionality
	Author:              thunder::tech inc.
	License:             CLIENT is defined as the owner of online property from which this file resides or this code is referenced in.
						 ADDITIONAL PARTY is defined as anyone other than thunder::tech or CLIENT.
						 No right is granted to ADDITIONAL PARTY to sell, distribute, modify or otherwise transfer the following source code without explicit written permission by CLIENT or thunder::tech.

*/

/*  ================================
     Sitewide JavaScript
    ================================ */

var CCon = {};

CCon.pageLoaded = function()
{
	$('#menu').children('a').mouseenter(CCon.menuRoll).mouseleave(CCon.menuRoll);
	CCon.snowFlakes = $('#flakes-area');
	CCon.snowCounter = 0;
	setInterval(CCon.snowFall, 40);
	$('.sparkle').each(CCon.sparkle);
	$('#flag').animate({height: 243},{duration: 2000});
	CCon.currentSponsorFold = 0;
	CCon.sponsorFolds = $('.sponsor-logo-fold');
	CCon.sponsorTimer = setInterval(CCon.scrollSponsors, 6000);
}

CCon.scrollSponsors = function()
{
	CCon.sponsorFolds.eq(CCon.currentSponsorFold).stop(true, false).slideUp(500);
	CCon.currentSponsorFold ++;
	if(CCon.currentSponsorFold >= CCon.sponsorFolds.length) CCon.currentSponsorFold = 0;
	CCon.sponsorFolds.eq(CCon.currentSponsorFold).stop(true, false).slideDown(500);
}

CCon.sparkle = function()
{
	var t = $(this);
	rx = parseInt(this.style.left) - 50 + (Math.random()*100);
	ry = parseInt(this.style.top) - 50 + (Math.random()*100);
	t.data('x', this.style.left).data('y',this.style.top);
	var from = {display: 'block', left: rx, top: ry};
	var towards = {left: t.data('x'),top: t.data('y')};
	if(!$.browser.msie) { from.opacity = 0; towards.opacity = 1; }
	t.css(from).animate(towards, {duration: 2000 * Math.random()});
	t.css({display: 'block'});
}

CCon.snowFall = function()
{
	if(CCon.snowCounter > 493) CCon.snowCounter = 0;
//	{ 493 × 529 }
	CCon.snowFlakes.css('backgroundPosition', CCon.snowCounter + 'px ' + (CCon.snowCounter * 1.07302) + 'px ');
	CCon.snowCounter += 1;
}

CCon.menuRoll = function(evt)
{
	if(evt.type=='mouseenter')
	{
		$(this).children('.menu-on').css({display:'block', opacity: 0}).stop(true, false).animate({opacity: 1}, {duration: 200});
	}
	else
	{
		$(this).children('.menu-on').stop(true, false).animate({opacity: 0}, {duration: 200});
	}
}

CCon.flashReplace = function()
{
	var so;
	so = new SWFObject("flash/swf1.swf", "swf-obj-1", "300", "250", "9", "");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.write("swf-holder-1");
}

$(CCon.pageLoaded);
