String.prototype.toParameters = function(s,vs){
	var sep = "&";
	var valsep = "=";
	
	if(s)	{
		sep = s;
		valsep = vs;
		}

	var par = {}
	var prop = this.split(sep);
					
	for(var i=0;i<prop.length;i++)
		{
		var cprop = prop[i].split(valsep);
		if(cprop.length>=2)
			{
			var param = cprop.shift();
			par[param] = cprop.join("=");
			}
		}
	return par;
	}

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 = 
	{
	showcase	: false,
	tempPos		: 0,
	scrollPos	: 0,

	change: function(elem, caseData, direction, orientation)
		{
		if(!direction) direction = 1;
		showCase.showcase = caseData;		
		showCase.scrollPos+=direction;
		if(showCase.scrollPos >= elem.getElementsByTagName("IMG").length) showCase.scrollPos = 0;
		if(showCase.scrollPos < 0) showCase.scrollPos =  elem.getElementsByTagName("IMG").length-1;
		var counterContainer = document.getElementsByClassName('span', 'scrollCounter');
		counterContainer[0].innerHTML = (showCase.scrollPos+1) + "/" +elem.getElementsByTagName("IMG").length;
		if(!orientation)
			{
			fpTools.animate.init({obj: elem, styleProperty: animate._x, startValue:(showCase.tempPos)*-800, endValue:(-800*showCase.scrollPos), iteration:5, speed:30});
			}
		else	{
			fpTools.animate.init(elem, animate._y, (showCase.tempPos)*-280, (-280*showCase.scrollPos), 10, 30)
			}
		showCase.tempPos = showCase.scrollPos;
		}
	}

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

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

	fpTools.animate.init({obj: $(dashboardContainer.id), styleProperty: animate._y, startValue:0, endValue:fixedPointUiControl.screenHeight, iteration:1, speed:30});

	var hideDashboard = document.createElement("A");
	hideDashboard.href = "#";
	hideDashboard.className = "hideDashboard";
	hideDashboard.onclick = function() {openDashboard(false); return false;}
	$(dashboardContainer.id).appendChild(hideDashboard);
	insertContactDetails();

	document.getElementsByClassName("LI", "dashboard")[0].lastChild.appendChild(document.createTextNode("show dashboard"));
//	animateDashboardLink();
	}

function animateDashboardLink(fadeIn)
	{
	var targetElem = document.getElementsByClassName("LI", "dashboard")[0];
	if(!fadeIn) animate.init({obj: targetElem, styleProperty: animate._alpha, startValue:100, endValue:50, iteration: 30, speed:30, init: 'animateDashboardLink(0)'});
	else animate.init({obj: targetElem, styleProperty: animate._alpha, startValue:50, endValue:100, iteration: 30, speed:30, init: 'animateDashboardLink()'});
	}

function insertContactDetails()
	{
	var emailAddress = 'pyry'+'@'+'kiinto'+'.'+'com';
	var emailLink = document.createElement("A");
	emailLink.setAttribute("HREF", 'mailto:'+emailAddress);
	emailLink.appendChild(document.createTextNode(emailAddress));
	$("contactInformation").appendChild(emailLink);
	}


function openDashboard(show)
	{
	if(show){
		if(parseInt($(dashboardContainer.id).style.zIndex) < 0) $(dashboardContainer.id).style.zIndex = "+9999";
		fpTools.animate.init({obj: $(dashboardContainer.id), styleProperty: animate._y, startValue:fixedPointUiControl.screenHeight, endValue:0, iteration:3, speed:30});
		}

	else	{
		fpTools.animate.init({obj: $(dashboardContainer.id), styleProperty: animate._y, startValue:0, endValue:fixedPointUiControl.screenHeight, iteration:3, speed:30});
		}
	}


function attachLinks()
	{
	var ajaxContainer = document.getElementsByClassName("DIV", "content")[0];
	var navigationLinks = document.getElementsByClassName("DIV", "header")[0].getElementsByTagName("a");

	for (var i=0; i<navigationLinks.length;i++)
		{
		if(navigationLinks[i].className == 'dashboard') {}
		else
			{
			navigationLinks[i].onclick = function()
				{
				var navigationLinksTemp = document.getElementsByClassName("DIV", "header")[0].getElementsByTagName("a");
				for (var i=0; i<navigationLinksTemp.length;i++)
					{
					navigationLinksTemp[i].className = "";
					}
				this.className = "selected";
	
				pageLocation = this.getAttribute("title");
	
				ajaxContainer.innerHTML = '<div class="loadBgr"><span>Loading...</span></div>';
	
				fixedPointAjaxFramework.addToLine({content: 'content_'+pageLocation+'.php', target:ajaxContainer, onscreen:true, runafter:false});
				return false;
				}
			}
		}
	}