/* Fixed point dashboard + fpTools init */
var fpToolsPath = 'http://www.kiinto.com/experiments/javascript/dashboard/';
var dashboardScriptPath = 'http://www.kiinto.com/experiments/javascript/dashboard/';
var externalGoogleMaps = 'ABQIAAAALBeawp8SVKY56xh0Rf52phRcDr7xPfsTswNSAb4Z5396hC4ubRTO9MS7qSao__FgglM4pyWK_JHDpg';
var dashboardEnableDock = false;
var showInitStatus = false;
var dashboardDefaultWidgets = true;
var dashboardCookieControl = false;
var standaloneWidgets = true;



document.getElementsByClassName = function(tag, elemClass)
	{
	var elementsList = [];
	for(var i=0; i < document.getElementsByTagName(tag).length; i++)
		{
		if(document.getElementsByTagName(tag)[i].className == elemClass) elementsList.push(document.getElementsByTagName(tag)[i]);
		}
	return elementsList;
	}

showCase = [];
showCase = 
	{
	tempPos		: 0,
	scrollPos	: 0,

	change: function(elem, direction, orientation)
		{
		var promotions = document.getElementsByClassName("DIV", "promotionLarge");
		if(!direction) direction = 1;
		showCase.scrollPos+=direction;
		if(showCase.scrollPos >= promotions.length) showCase.scrollPos = 0;
		if(showCase.scrollPos < 0) showCase.scrollPos =  promotions.length-1;
		if(!orientation)
			{
			fpTools.animate.init({obj:elem, styleProperty: animate._x, startValue:(showCase.tempPos)*-720, endValue:(-720*showCase.scrollPos), iteration:5, speed:30})
			}
		else	{
			fpTools.animate.init({obj:elem, styleProperty: animate._y, startValue:(showCase.tempPos)*-720, endValue:(-720*showCase.scrollPos), iteration:5, speed:30})
			}
		showCase.tempPos = showCase.scrollPos;
		}
	}


function initAfterDashboard()
	{
	if(typeof(fixedPointAjaxFramework) != 'object')
		{
		setTimeout("initAfterDashboard()", 300);
		return false;
		}
	attachFPDStandaloneWidgets();
	}


function attachFPDStandaloneWidgets()
	{
	var widgets = document.getElementsByClassName("DIV", "FPDStandeloneWidget", true);
	for(var i=0; i < widgets.length; i++)
		{
		widgets[i].className = "FPDW"+widgets[i].title;
		if(widgets[i].getElementsByTagName("SPAN").length > 0)
			{
			fixedPointWindowControl.dashBoardWindow[widgets[i].title].params = widgets[i].getElementsByTagName("SPAN")[0].title;
			widgets[i].removeChild(widgets[i].firstChild);
			}
		fixedPointWindowControl.newStandaloneWidget(fixedPointWindowControl.dashBoardWindow[widgets[i].title], false, widgets[i]);
		}
	}







window.onload = function()
	{
	initAfterDashboard();
	findPopupLinks();
	}

function findPopupLinks()
	{
	var popups = document.getElementsByClassName("A", "moreInfo");
	for(var i=0; i < popups.length; i++)
		{
		popups[i].onclick = function()
			{
			var infoContainer = this.title;

			var popupsContainer = document.getElementsByClassName("DIV", "moreInfoContainer");
			popupsContainer[0].style.display = "block";

			var hideWindows = popupsContainer[0].getElementsByTagName("DIV");
			for(var x=0;x <hideWindows.length; x++)
				{
				if(hideWindows[x].className.indexOf('moreInfo') != -1) hideWindows[x].style.display = "none";
				}

			var popupsInfoContainer = document.getElementsByTagName("DIV");
			for(var j=0; j < popupsInfoContainer.length; j++)
				{
				if(popupsInfoContainer[j].className.indexOf(infoContainer) != -1) popupsInfoContainer[j].style.display = "block";
				}

			}
		}
	}

function closePopup(elem)
	{
	var popupsContainer = document.getElementsByClassName("DIV", "moreInfoContainer");
	popupsContainer[0].style.display = "none";
	}