﻿
function resetVideoLinks(n)
{
	var linkList = document.getElementById("videodiv").getElementsByTagName("a");
 	for (i = 0; i < linkList.length; i++) 
 	{
      linkList[i].className = "style1";
  }
  n.className = "selected";
}



function init()
{
	var qs = new Querystring();
	if (qs.contains('pic')) swapBg(qs.get('pic'));
}


////////////////////////////////////////

function fitBg()
{
	
	 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
}

var bg = document.getElementById('bgimg');
var h = bg.offsetHeight;
var w = bg.offsetWidth;

if (h > myHeight)
{
	var ratio = myHeight / h;
	bg.style.width = w * ratio + 'px';
	bg.style.height = h * ratio + 'px';
	
}

var h = bg.offsetHeight;
var w = bg.offsetWidth;

if (w < myWidth)
{
	var ratio = myWidth / w;
	bg.style.width = w * ratio + 'px';
	bg.style.height = h * ratio + 'px';
}

var h = bg.offsetHeight;
var w = bg.offsetWidth;

if (h < myHeight)
{
	var ratio = myHeight / h;
	bg.style.width = w * ratio + 'px';
	bg.style.height = h * ratio + 'px';
}

//	bg.style.width = myWidth + 'px';
	//bg.style.height = myHeight + 'px';

bg.style.visibility = 'visible';

}

var currentPage = 1;

function showIndicator()
{
	for (var i=0; i<999; i++)
	{
		var a = document.getElementById('a_' + i);
		if (a != null)
		{
			a.className = "";
		} else if (i > 10) break;
	}
	var a = document.getElementById('a_' + currentPage);
	a.className = "cur";
}

function swapBg(num)
{
	var nextImg = document.getElementById('img_' + (num));
	if (nextImg != null)
	{
		var str = nextImg.src;
		if (document.getElementById('bgimg').src != str)
			document.getElementById('bgimg').src = str;
		currentPage = num;
	} else
			return;
	showIndicator();
	
}

function movePage(dir)
{
	swapBg(currentPage + dir);
}
showIndicator();
function init()
{
	currentPage = 1;
	showIndicator();
	fitBg();	
}



/*
function swapBg(num)
{
	document.getElementById('bgimg').src = kuvat[num];
}
*/