
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function start_hide()
{
	document.write('<!--');
}

function end_hide()
{
	document.write('-->');
}

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,width=200, height=370, menubar=0,scrollbars=0,resizable=0,left=200,top=200");

}

function openUrl(theURL, winName, width, height)
{
	if(!width) width = 800;
	if(!height) height = 600;

	//winName = 'Dialog ';
  	features='width=' + width + ',height=' + height + ',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,top=0,left=0';
	msgWindow = window.open(theURL, winName, features);
	msgWindow.focus();
}

function closeAndReload()
{
	opener.window.focus();
	opener.window.location.reload();
	self.close();
	return false;
}

function closeAndReloadAttachments()
{
	opener.window.showAttachments();
	opener.window.focus();
	window.setTimeout('self.close()', 2000);
	return false;
}



function showAttachments()
{
	var articleID = document.getElementById("articleID").value;
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", "/admin/newsletter/archive/attachments.php?articleID="+ articleID, true);
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
            	var divAttachments = document.getElementById("divAttachments");
    			divAttachments.innerHTML = oXmlHttp.responseText;
            } else {
                //statusText is not always accurate
            }
        }
    };
    oXmlHttp.send(null);
}


function removeAttachment(attachmentID, confirmText)
{
	if(!confirm(confirmText))
	{
		return false;
	}

    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get", "/admin/newsletter/archive/delete_attachment.php?attachmentID=" + attachmentID, true);
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                showAttachments();
            } else {
                //statusText is not always accurate
                //alert('could not remove attachment');
            }
        }
    };
    oXmlHttp.send(null);
    return false;
}

function closeAndSubmit()
{
	opener.window.forms[0].submit();
	opener.window.focus();
	self.close();
	return false;
}

function closeWindow()
{
	opener.window.focus();
	self.close();
	return false;
}

function disableForm(theform)
{
  if (document.all || document.getElementById)
  {
    for (i = 0; i < theform.length; i++)
    {
      var tempobj = theform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
      tempobj.disabled = true;
    }
    return true;
  }
}

function tarkista_taytetyt()
{
	for (i=0; i<tarkista_taytetyt.arguments.length; i++)
	{
		if (!document.getElementById(tarkista_taytetyt.arguments[i]).value!='')
		{
			alert(tarkista_taytetyt.arguments[i] + ' puuttuu!');
			document.getElementById(tarkista_taytetyt.arguments[i]).focus();
			return false;
		}
	}
	return true;
}


function CheckFormFilled()
{
	for (i=1; i<CheckFormFilled.arguments.length; i++)
	{
		if (!document.getElementById(CheckFormFilled.arguments[i]).value!='')
		{
			errorBox(CheckFormFilled.arguments[i] + ' ' +CheckFormFilled.arguments[0]);
			document.getElementById(CheckFormFilled.arguments[i]).focus();
			return false;
		}
	}
	return true;
}


function CheckFormFilled2()
{
	var erStr = '';
	for (i=1; i<CheckFormFilled2.arguments.length; i++)
	{
		if (!document.getElementById(CheckFormFilled2.arguments[i]).value!='')
		{
			//alert(CheckFormFilled2.arguments[i] + ' ' +CheckFormFilled2.arguments[0] + '<br>');
			erStr = erStr + CheckFormFilled2.arguments[i] + ' ' +CheckFormFilled2.arguments[0] + "\n";
		}
	}

	if(erStr != '')
	{
		alert(erStr);
		return false;
	}
	return true;
}


function openFullScreen(url)
{
	fs = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0, menubar=0,scrollbars=0,resizable=0,left=0,top=0");
	fs.resizeTo(fs.screen.availWidth, fs.screen.availHeight);
}


function showScreen()
{
	var blurscreen = document.getElementById('blurscreen');
	blurscreen.setAttribute('class', 'displayNone');
	blurscreen.setAttribute('className', 'displayNone');

	var info = document.getElementById('info');
	info.setAttribute('class', 'displayNone');
	info.setAttribute('className', 'displayNone');

}




function InfoBox()
{
	this.setData = setData;
	this.addButton = addButton;
	this.showInfoBox = showInfoBox;
	this.setAlert = setAlert;
	this.setInfo = setInfo;
	this.addInputText = addInputText;

	var txtCaption = document.getElementById('infoboxData');
	var infoButtons = document.getElementById('infoButtons');
	var infoImg = document.getElementById('infoImg');

	var SwapImgNumber = 200;

	infoButtons.innerHTML = '';

	function setData(usrCaption)
	{
		txtCaption.innerHTML = usrCaption;
	}

	function addButton(butCaption, callBackFunc)
	{
		//infoButtons.innerHTML = infoButtons.innerHTML + '<input type="submit" value="' + butCaption +'" onclick="' + callBackFunc + '">&nbsp;';
		//infoButtons.innerHTML = infoButtons.innerHTML + '<a onclick="' + callBackFunc + '" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'Image' + SwapImgNumber +'\',\'\',\'/images/'+butCaption+'_over.jpg\',1)"><img src="/images/'+butCaption+'.jpg" name="Image' + SwapImgNumber +'" width="113" height="56" border="0" id="Image' + SwapImgNumber +'" /></a>';
		infoButtons.innerHTML = infoButtons.innerHTML + '<span onclick="' + callBackFunc + '" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'Image' + SwapImgNumber +'\',\'\',\'/images/'+butCaption+'_over.jpg\',1)"><img src="/images/'+butCaption+'.jpg" name="Image' + SwapImgNumber +'" width="113" height="56" border="0" id="Image' + SwapImgNumber +'" style="cursor:pointer;" /></span>';
		SwapImgNumber++;
		//alert(butCaption);
	}

	function addInputText(butCaption)
	{
		//infoButtons.innerHTML = infoButtons.innerHTML + '<input type="submit" value="' + butCaption +'" onclick="' + callBackFunc + '">&nbsp;';
		txtCaption.innerHTML = txtCaption.innerHTML + '<br>' + butCaption + '<input type="text" id="infoBoxInputText" class="textfieldi">';
		SwapImgNumber++;
		//alert(butCaption);
	}

	function showInfoBox()
	{
		var blurscreen = document.getElementById('blurscreen');
		blurscreen.setAttribute('class', 'blurscreen');
		blurscreen.setAttribute('className', 'blurscreen');

		/*
		//var pageSize = getDocumentSize();	// contrib by jr 20.06.2007
		var pageSize = getPageSize();
		var pageScroll = getPageScroll();

		var x = pageSize[0]+pageScroll[0];
		var y = pageSize[1]+pageScroll[1];

		//blurscreen.style.width = x + 'px';
		//blurscreen.style.height = x + 'px';

		//alert(blurscreen.style.height);
		*/

		var info = document.getElementById('info');
		info.setAttribute('class', 'info');
		info.setAttribute('className', 'info');

		var textField = document.getElementById('infoBoxInputText');	// contrib by jr 12.06.2007
		if (textField) textField.focus();
	}

	function setAlert()
	{
		infoImg.src = "/images/alert.jpg";
	}

	function setInfo()
	{
		infoImg.src = "/images/info.jpg";
	}
}

/*
function getWindowSize() {
	var dimensions = Array(2);
	dimensions['width']		= 0;
	dimensions['height']	= 0;
	if (typeof(window.innerWidth ) == 'number' ) {
		dimensions['width']		= window.innerWidth;
		dimensions['height']	= window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		dimensions['width']		= document.documentElement.clientWidth;
		dimensions['height']	= document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		dimensions['width']		= document.body.clientWidth;
		dimensions['height']	= document.body.clientHeight;
	}
	return dimensions;
}

function getDocumentSize(){
	var dimensions = Array(2);
	dimensions['width']		= 0;
	dimensions['height']	= 0;


	if (window.innerHeight && window.scrollMaxY) {
		dimensions['height']	= window.innerHeight+window.scrollMaxY;
		dimensions['width']		= window.innerWidth+window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		dimensions['height']	= document.body.scrollHeight;
		dimensions['width']		= document.body.scrollWidth;
	} else if (document.body) {
		dimensions['height']	= document.body.offsetHeight+document.body.offsetTop;
		dimensions['width']		= document.body.offsetWidth+document.body.offsetLeft;

		alert(dimensions['height']);
  	}
	return dimensions;
}


function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

	arrayPageScroll = new Array(xScroll,yScroll)
	return arrayPageScroll;
}

function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}
*/


function apu()
{
	var infobox = new InfoBox();
	infobox.setAlert();
	infobox.setData('Oletko aivan varma?');
	infobox.addButton('peruuta', 'alert(\'EN\');');
	infobox.addButton('ok', 'alert(\'OLEN\');');

	infobox.showInfoBox();
}
function showAlertScreen()
{
	//alert('alert');
	apu();

	var blurscreen = document.getElementById('blurscreen');
	blurscreen.setAttribute('class', 'blurscreen');
	blurscreen.setAttribute('className', 'blurscreen');

	var info = document.getElementById('info');
	info.setAttribute('class', 'info');
	info.setAttribute('className', 'info');
}

function setActiveTab(tabNum)
{
	var curTab;
	var curFormPage;
	for(i=1;i<11;i++)
	{
		curTab = document.getElementById('form_tab_'+i);
		curFormPage = document.getElementById('form_page_'+i);
		if(curTab && curFormPage)
		{
			if(i == tabNum)
			{
				curTab.setAttribute('class', 'adminFormTabActive');
				curTab.setAttribute('className', 'adminFormTabActive');
				curFormPage.setAttribute('class', 'displayAll');
				curFormPage.setAttribute('className', 'displayAll');
			}
			else
			{
				curTab.setAttribute('class', 'adminFormTab');
				curTab.setAttribute('className', 'adminFormTab');
				curFormPage.setAttribute('class', 'displayNone');
				curFormPage.setAttribute('className', 'displayNone');
			}
		}

	}
}

function leftNaviHide()
{
	var leftNaviArrow = document.getElementById('leftNaviArrow');
	if(leftNaviArrow.src.indexOf('arrow_up.png') == -1)
	{
		leftNaviHide2();
		new Effect.Move('left_navi_hidden', 0, 200, {duration:1, fps:25, from:0.0, to:1.0});
		leftNaviArrow.src = leftNaviArrow.src.replace('arrow_down.png', 'arrow_up.png');
	}
	else
	{
		new Effect.Move('left_navi_hidden', 0, -200, {duration:1, fps:25, from:0.0, to:1.0});
		leftNaviArrow.src = leftNaviArrow.src.replace('arrow_up.png', 'arrow_down.png');
		window.setTimeout('leftNaviHide2()', 1000);
	}

}


function leftNaviHide2()
{
	//alert('hidden');
	var left_navi_hidden = document.getElementById('left_navi_hidden');
	if(left_navi_hidden.getAttribute('class') != 'displayNone')
	{
		left_navi_hidden.setAttribute('class', 'displayNone');
		left_navi_hidden.setAttribute('className', 'displayNone');
	}
	else
	{
		left_navi_hidden.setAttribute('class', 'displayAll');
		left_navi_hidden.setAttribute('className', 'displayAll');
	}
}

function confirmation(capt, URLobj)
{
	/*
	var infobox = new InfoBox();
	infobox.setData(capt);
	infobox.addButton('peruuta', 'showScreen()');
	if(URLobj) infobox.addButton('ok', 'window.location = \'' + URLobj.href + '\'');

	infobox.showInfoBox();
	return false;
	*/

	var infobox = new InfoBox();
	infobox.setData(capt);
	infobox.addButton('peruuta', 'showScreen()');

	if (typeof(URLobj) == 'string')
	{
		//alert(URLobj);
		infobox.addButton('ok', URLobj);// + ' showScreen();');
	}
	else if(URLobj) infobox.addButton('ok', 'window.location = \'' + URLobj.href + '\'');

	infobox.showInfoBox();
	return false;
}

function errorBox(capt, URLobj)
{
	var infobox = new InfoBox();
	infobox.setAlert();
	infobox.setData(capt);
	infobox.addButton('ok', 'showScreen()');
	if(URLobj) infobox.addButton('ok', 'window.location = \'' + URLobj.href + '\'');

	infobox.showInfoBox();
	return false;
}

function forwardDialog(capt, forwardTo)
{
	var infobox = new InfoBox();
	infobox.setData(capt);
	infobox.setInfo();
	//infobox.addButton('ok', 'showScreen()');
	if(forwardTo) infobox.addButton('ok', 'window.location = \'' + forwardTo + '\'');

	infobox.showInfoBox();
	return false;
}

function textBox(capt, divToSetVal)
{
	var infobox = new InfoBox();
	infobox.setData(capt);
	infobox.addButton('peruuta', 'showScreen()');
	if(divToSetVal) infobox.addButton('ok', '');

	infobox.showInfoBox();
	return false;
}

/***** FORM **/
function saveForm(theID)
{
	if(is_defined('SpawEngine'))
	{
		//alert('Spawengine found');
		SpawEngine.updateFields();
	}

	var infobox = new InfoBox();
	infobox.setInfo();
	infobox.setData('Tietoja tallennetaan...');
	infobox.showInfoBox();

	var formData = document.getElementById(theID);

	new Ajax.Updater('popUpInfo', formData.action, {asynchronous:true, encoding:'UTF-8', parameters:Form.serialize(theID), onComplete:formSaved, onFailure:formSaveFailure, evalScripts:true});
}

function formSaveFailure()
{
	var infobox = new InfoBox();
	infobox.setAlert();
	infobox.setData('Tietojen tallennus epäonnistui. Yritä hetken kuluttua uudelleen.');
	//infobox.addButton('peruuta', '');
	infobox.addButton('ok', 'showScreen()');

	infobox.showInfoBox();
}

function formSaved()
{
	var saveSuccessful = document.getElementById('popUpInfo');

	var infobox = new InfoBox();

	if(saveSuccessful.innerHTML == 1)
	{
		infobox.setInfo();
		infobox.setData('Tietojen tallennus onnistui');
		infobox.addButton('ok', 'showScreen()');

		infobox.showInfoBox();

	}
	else
	{
		infobox.setAlert();
		infobox.setData('Tietojen tallennus epäonnistui');
		infobox.addButton('ok', 'showScreen()');

		infobox.showInfoBox();
	}
}
/***  */

function textboxdemo()
{
	var textboxdemo = document.getElementById('textboxdemo');
	var infobox = new InfoBox();

	infobox.setInfo();
	infobox.setData('Tietojen muokkaus');
	infobox.addInputText('Tekstikenttä:');
	infobox.addButton('ok', 'settextboxdemo()');

	infobox.showInfoBox();

}
function settextboxdemo()
{
	var infoBoxInputText = document.getElementById('infoBoxInputText');
	var textboxdemo = document.getElementById('textboxdemo');
	textboxdemo.innerHTML = infoBoxInputText.value;
	showScreen();
}




function setPublished(handlerScript, dbItemID, imgPublished, parameters)
{
	if (!parameters) parameters = '';
	new Ajax.Updater('popUpInfo', handlerScript+'.php?id='+dbItemID+parameters, {asynchronous:true, evalScripts:true});

	if(imgPublished.src.indexOf('x.png') == -1) //not x.png --> x.png
	{
		imgPublished.src = imgPublished.src.replace('y.png', 'x.png');
	}
	else
	{
		imgPublished.src = imgPublished.src.replace('x.png', 'y.png');
	}

}


function setPublishedRequest(handlerScript, dbItemID, imgPublished, parameters)
{
	if (!parameters) parameters = '';
	new Ajax.Request(handlerScript+'.php?id='+dbItemID+parameters, {asynchronous:true});

	if(imgPublished.src.indexOf('x.png') == -1) //not x.png --> x.png
	{
		imgPublished.src = imgPublished.src.replace('y.png', 'x.png');
	}
	else
	{
		imgPublished.src = imgPublished.src.replace('x.png', 'y.png');
	}

}



function is_defined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function addToCart( theID )
{
	var formData = document.getElementById(theID);

	new Ajax.Updater('shoppingCart', formData.action, {asynchronous:true, encoding:'UTF-8', parameters:Form.serialize(theID), evalScripts:true});
	//new Ajax.Updater('shoppingCart', '/ostoskori/ajax/true/lisaa/'+pubID, {asynchronous:true, evalScripts:true});
	return false;
}


function orderDetails(toActive)
{
	//alert(toActive);
	var pakolliset = document.getElementById('pakolliset');
	pakolliset.setAttribute('class', 'displayTableCell');
	pakolliset.setAttribute('className', 'displayTableCell');

	var asiakasryhma = document.getElementById('asiakasryhma');
	asiakasryhma.setAttribute('class', 'displayNone');
	asiakasryhma.setAttribute('className', 'displayNone');

	var newState = (toActive == 'yksityisTiedot') ? 'displayTableCell' : 'displayNone';
	var formPart = document.getElementById('yksityisTiedot');

	formPart.setAttribute('class', newState);
	formPart.setAttribute('className', newState);

	var newState = (toActive == 'yritysTiedot') ? 'displayTableCell' : 'displayNone';
	var formPart = document.getElementById('yritysTiedot');

	formPart.setAttribute('class', newState);
	formPart.setAttribute('className', newState);

	var newState = (toActive == 'oppilaitosTiedot') ? 'displayTableCell' : 'displayNone';
	var formPart = document.getElementById('oppilaitosTiedot');

	formPart.setAttribute('class', newState);
	formPart.setAttribute('className', newState);
}

function authorDetails(toActive)
{
	//alert(toActive);
	var newState;
	var detailPart;
	var detailLink;
	var activeFound = false;

	for(i=1;i<9;i++)
	{
		newState = (toActive == i) ? 'bigfont' : 'displayNone';
		activeFound = (toActive == i);
		detailPart = document.getElementById('kirjailijaTiedot_'+i);
		detailPart.setAttribute('class', newState);
		detailPart.setAttribute('className', newState);


		newState = (toActive == i) ? 'selected' : '';
		detailLink = document.getElementById('detLink_'+i);
		if(detailLink)
		{
			detailLink.setAttribute('class', newState);
			detailLink.setAttribute('className', newState);
		}
	}

	return false;
	return activeFound;
}

function bookDetails(toActive)
{
	//alert(toActive);
	var newState;
	var detailPart;
	//var detailLink;
	var activeFound = false;

	for(i=1;i<9;i++)
	{
		newState = (toActive == i) ? 'leipa_gray' : 'displayNone';
		activeFound = (toActive == i);
		detailPart = document.getElementById('kirjaTiedot_'+i);
		detailPart.setAttribute('class', newState);
		detailPart.setAttribute('className', newState);


		/*newState = (toActive == i) ? 'selected' : '';
		detailLink = document.getElementById('detLink_'+i);
		if(detailLink)
		{
			detailLink.setAttribute('class', newState);
			detailLink.setAttribute('className', newState);
		}*/
	}

	return false;
	return activeFound;
}

function bookDetailsOppi(toActive)
{
	//alert(toActive);
	var newState;
	var detailPart;
	//var detailLink;
	var activeFound = false;

	for(i=1;i<3;i++)
	{
		newState = (toActive == i) ? 'leipa_gray' : 'displayNone';
		activeFound = (toActive == i);
		detailPart = document.getElementById('kirjaTiedot_'+i);
		detailPart.setAttribute('class', newState);
		detailPart.setAttribute('className', newState);


		/*newState = (toActive == i) ? 'selected' : '';
		detailLink = document.getElementById('detLink_'+i);
		if(detailLink)
		{
			detailLink.setAttribute('class', newState);
			detailLink.setAttribute('className', newState);
		}*/
	}

	return false;
	return activeFound;
}

function showLeftSubNavi()
{
	detailPart = document.getElementById('leftNaviSub');
	detailPart.setAttribute('class', '');
	detailPart.setAttribute('className', '');
	detailPart = document.getElementById('leftNaviSubLink');
	detailPart.setAttribute('class', '');
	detailPart.setAttribute('className', '');
}

function getActiveForm()
{
	//alert(toActive);
	var formPart = document.getElementById('yksityisTiedot');
	if(formPart.getAttribute('class') != 'displayNone')
	return 'yksityisTiedot';

	var formPart = document.getElementById('yritysTiedot');
	if(formPart.getAttribute('class') != 'displayNone')
	return 'yritysTiedot';

	var formPart = document.getElementById('oppilaitosTiedot');
	if(formPart.getAttribute('class') != 'displayNone')
	return 'oppilaitosTiedot';

	return 'yksityisTiedot';
}

function requestServerTime()
{
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get", "/admin/servertime.php", true);
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                displayServerTime(oXmlHttp.responseText);
            } else {
                //statusText is not always accurate
            }
        }
    };
    showServerTime();
    oXmlHttp.send(null);
}

function showServerTime()
{
	window.setTimeout('requestServerTime()', 30000);
}

function startClock()
{
	requestServerTime();
	showServerTime();
}

function displayServerTime(sText)
{
    //var divServerTime = document.getElementById("divServerTime");
    //if (is_defined(divServerTime))
    //divServerTime.innerHTML = sText;

    document.getElementById('divServerTime').innerHTML = sText;
}

function updateExtraFile(fileID)
{
	new Ajax.Updater('extraFile', 'the_file.php?edu_extra_fileID='+fileID, {asynchronous:true, evalScripts:true});
}

function CheckLectures()
{
	var selected_box;
	var box;
	var div;

	selected_box = document.getElementById('lecture_check_'+CheckLectures.arguments[0]);

	for (i=1; i<CheckLectures.arguments.length; i++)
	{
		box = document.getElementById('lecture_check_'+CheckLectures.arguments[i]);
		if (!box) continue;
		div = document.getElementById('lecture_'+CheckLectures.arguments[i]);
		if (!div) continue;
		if (CheckLectures.arguments[i] == CheckLectures.arguments[0]) continue;
		if (selected_box.checked)
		{
			box.disabled=true;
			div.setAttribute('class', 'lecture lectureDisabled');
			div.setAttribute('className', 'lecture lectureDisabled');
		}
		else
		{
			box.disabled=false;
			div.setAttribute('class', 'lecture lectureEnabled');
			div.setAttribute('className', 'lecture lectureEnabled');
		}
	}
}

function CheckBooks()
{
	var check_y;
	var check_n;

	for (i=1; i<CheckBooks.arguments.length; i++)
	{
		check_y = document.getElementById(CheckBooks.arguments[i]+'_y');
		check_n = document.getElementById(CheckBooks.arguments[i]+'_n');

		if (check_y.checked != true && check_n.checked != true)
		{
			alert(CheckBooks.arguments[0]);
			return false;
		}
	}
	return true;
}

function checkOrderForm()
{
	var activeForm = getActiveForm();
	var erStr = '';

	if(activeForm == 'yksityisTiedot')
	{
		if (!document.getElementById("Etunimi").value!='')
		{
			erStr = erStr + 'Etunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("Sukunimi").value!='')
		{
			erStr = erStr + 'Sukunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("Toimitusosoite").value!='')
		{
			erStr = erStr + 'Toimitusosoite puuttuu.' + "\n";
		}

		if (!document.getElementById("Postinumero").value!='')
		{
			erStr = erStr + 'Postinumero puuttuu.' + "\n";
		}

		if(!checkPostinumero(document.getElementById("Postinumero").value))
		{
			erStr = erStr + 'Tarkista postinumero.' + "\n";
		}

		if (!document.getElementById("Postitoimipaikka").value!='')
		{
			erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
		}

		if (document.getElementById("Email") && document.getElementById("Salasana"))
		{
			if(!document.getElementById("Email").value!='')	erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("downloadable_product"))
		{
			if(!document.getElementById("Email").value!='')	erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("Salasana") && !document.getElementById("Salasana").value!='')
		{
			erStr = erStr + 'Salasana puuttuu.' + "\n";
		}

		if (document.getElementById("Vahvista_salasana") && !document.getElementById("Vahvista_salasana").value!='')
		{
			erStr = erStr + 'Salasanan vahvistus puuttuu.' + "\n";
		}

		if(document.getElementById("Salasana") && document.getElementById("Vahvista_salasana"))
		{
			if(document.getElementById("Salasana").value != document.getElementById("Vahvista_salasana").value)
			{
				erStr = erStr + 'Tarkista salasanat.' + "\n";
			}
		}

		if(document.getElementById("ehdot"))
		{
			if(document.getElementById('ehdot').checked==false)
			{
				erStr = erStr + 'Ehdot tulee hyväksyä.' + "\n";
			}
		}
	}

	if(activeForm == 'yritysTiedot')
	{
		if (!document.getElementById("companyName").value!='')
		{
			erStr = erStr + 'Yrityksen nimi puuttuu.' + "\n";
		}

		/*if (!document.getElementById("companyBusinessID").value!='')
		{
			erStr = erStr + 'LY-tunnus puuttuu.' + "\n";
		}*/

		if (!document.getElementById("1firstName").value!='')
		{
			erStr = erStr + 'Tilaajan etunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("1lastName").value!='')
		{
			erStr = erStr + 'Tilaajan sukunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("1billingAddress").value!='')
		{
			erStr = erStr + 'Laskutusosoite puuttuu.' + "\n";
		}

		if (!document.getElementById("1billingPostalCode").value!='')
		{
			erStr = erStr + 'Postinumero puuttuu.' + "\n";
		}
		if(!checkPostinumero(document.getElementById("1billingPostalCode").value))
		{
			erStr = erStr + 'Tarkista postinumero.' + "\n";
		}

		if (!document.getElementById("1billingCity").value!='')
		{
			erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
		}

		if (document.getElementById("downloadable_product"))
		{
			if(!document.getElementById("1email").value!='')	erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("1email") && document.getElementById("1password"))
		{
			if(!document.getElementById("1email").value!='') erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("1password") && !document.getElementById("1password").value!='')
		{
			erStr = erStr + 'Salasana puuttuu.' + "\n";
		}

		if (document.getElementById("1password2") && !document.getElementById("1password2").value!='')
		{
			erStr = erStr + 'Salasanan vahvistus puuttuu.' + "\n";
		}

		if(document.getElementById("1password") && document.getElementById("1password2"))
		{
			if(document.getElementById("1password").value != document.getElementById("1password2").value)
			{
				erStr = erStr + 'Tarkista salasanat.' + "\n";
			}
		}
		if(document.getElementById("1ehdot"))
		{
			if(document.getElementById('1ehdot').checked==false)
			{
				erStr = erStr + 'Ehdot tulee hyväksyä.' + "\n";
			}
		}
	}

	if(activeForm == 'oppilaitosTiedot')
	{
		if (!document.getElementById("schoolName").value!='')
		{
			erStr = erStr + 'Oppilaitoksen nimi puuttuu.' + "\n";
		}

		if (!document.getElementById("schoolCity").value!='')
		{
			erStr = erStr + 'Kunta puuttuu.' + "\n";
		}

		if (!document.getElementById("2firstName").value!='')
		{
			erStr = erStr + 'Tilaajan etunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("2lastName").value!='')
		{
			erStr = erStr + 'Tilaajan sukunimi puuttuu.' + "\n";
		}

		if (!document.getElementById("2billingAddress").value!='')
		{
			erStr = erStr + 'Laskutusosoite puuttuu.' + "\n";
		}

		if (!document.getElementById("2billingPostalCode").value!='')
		{
			erStr = erStr + 'Postinumero puuttuu.' + "\n";
		}
		if(!checkPostinumero(document.getElementById("2billingPostalCode").value))
		{
			erStr = erStr + 'Tarkista postinumero.' + "\n";
		}

		if (!document.getElementById("2billingCity").value!='')
		{
			erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
		}

		if (document.getElementById("downloadable_product"))
		{
			if(!document.getElementById("2email").value!='')	erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("2email") && document.getElementById("2password"))
		{
			if(!document.getElementById("2email").value!='') erStr = erStr + 'Email puuttuu.' + "\n";
		}

		if (document.getElementById("2password") && !document.getElementById("2password").value!='')
		{
			erStr = erStr + 'Salasana puuttuu.' + "\n";
		}

		if (document.getElementById("2password2") && !document.getElementById("2password2").value!='')
		{
			erStr = erStr + 'Salasanan vahvistus puuttuu.' + "\n";
		}

		if(document.getElementById("2password") && document.getElementById("2password2"))
		{
			if(document.getElementById("2password").value != document.getElementById("2password2").value)
			{
				erStr = erStr + 'Tarkista salasanat.' + "\n";
			}
		}
		if(document.getElementById("2ehdot"))
		{
			if(document.getElementById('2ehdot').checked==false)
			{
				erStr = erStr + 'Ehdot tulee hyväksyä.' + "\n";
			}
		}
	}
	if(erStr != '')
	{
		alert(erStr);
		return false;
	}
	return true;
}

function checkLahjakorttiForm()
{
	var erStr = '';

	if (!document.getElementById("kpl").value!='')
	{
		erStr = erStr + 'Kappalemäärä puuttuu.' + "\n";
	}

	if (!document.getElementById("companyName").value!='')
	{
		erStr = erStr + 'Yrityksen nimi puuttuu.' + "\n";
	}

	if (!document.getElementById("1firstName").value!='')
	{
		erStr = erStr + 'Tilaajan etunimi puuttuu.' + "\n";
	}

	if (!document.getElementById("1lastName").value!='')
	{
		erStr = erStr + 'Tilaajan sukunimi puuttuu.' + "\n";
	}

	if (!document.getElementById("1billingAddress").value!='')
	{
		erStr = erStr + 'Laskutusosoite puuttuu.' + "\n";
	}

	if (!document.getElementById("1billingPostalCode").value!='')
	{
		erStr = erStr + 'Postinumero puuttuu.' + "\n";
	}

	if (!document.getElementById("1billingCity").value!='')
	{
		erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
	}



	if(erStr != '')
	{
		alert(erStr);
		return false;
	}

	return true;
}


function updateCartStatus()
{
	var cartLocked = document.getElementById("cartLocked");
	//alert('Janne testaa. Cart status update.' + cartLocked.innerHTML);
	if(cartLocked)
	{
		new Ajax.Updater('cartLocked', '/cartStatus.php', {asynchronous:true, evalScripts:true});
	}
	//alert('Janne testaa2. Cart status update.' + cartLocked.innerHTML);

	return;
}

function checkCartStatus()
{
	var cartLocked2 = document.getElementById("cartLocked");

	if(cartLocked2)
	{
		if(cartLocked2.innerHTML == '1')
		{
			//alert('Ostokori on lukittu!');
			return true;
		}
		else
		{
			var urlToGo;
			var cartOppi = document.getElementById("cartOppi");

			if(cartOppi) urlToGo = '/ostoskori/kassa/oppi/1/kassa.php';
			else urlToGo = '/ostoskori/kassa/kassa.php';

			alert('Ostoskoria on muokattu. Maksutapahtuma keskeytetään.');
			window.location =  urlToGo;
			return false;
		}
	}
}

function cartCheck()
{
	updateCartStatus();
	window.setTimeout('cartCheck()', 5000);
	window.setTimeout('checkCartStatus()', 2500);
}

function esikatsele(url)
{
	var erStr = '';

	var osoite1 = document.getElementById("osoite1");
	var osoite2 = document.getElementById("osoite2");
	var osoite3 = document.getElementById("osoite3");

	var nimi = document.getElementById("nimi");
	var email = document.getElementById("email");
	var viesti = document.getElementById("viesti");

	if(!osoite1 || !nimi || !email || !viesti) return;

	if(tarkistaEsikatselu())
	openUrl(url+'osoite1/'+URLEncode(osoite1.value)+'/osoite2/'+URLEncode(osoite2.value)+'/osoite3/'+URLEncode(osoite3.value)+'/nimi/'+URLEncode(nimi.value)+'/email/'+URLEncode(email.value)+'/viesti/'+URLEncode(viesti.value));
}

function tarkistaEsikatselu()
{
	var erStr = '';

	var osoite1 = document.getElementById("osoite1");
	var osoite2 = document.getElementById("osoite2");
	var osoite3 = document.getElementById("osoite3");

	var nimi = document.getElementById("nimi");
	var email = document.getElementById("email");
	var viesti = document.getElementById("viesti");

	if(!osoite1 || !nimi || !email || !viesti) return;

	if(osoite1.value=='')
	{
		erStr = erStr + 'Osoite 1 puuttuu.' + "\n";
	}
	if(nimi.value=='')
	{
		erStr = erStr + 'Oma nimesi puuttuu.' + "\n";
	}
	if(email.value=='')
	{
		erStr = erStr + 'Sähköpostiosoitteesi puuttuu.' + "\n";
	}
	if(viesti.value=='')
	{
		erStr = erStr + 'Viesti puuttuu.' + "\n";
	}

	if(erStr)
	{
		alert(erStr);
		return false;
	}

	return true;
}

function tarkistaKKlomake()
{
	var erStr = '';

	var etunimi = document.getElementById("etunimi");
	var sukunimi = document.getElementById("sukunimi");
	var osoite = document.getElementById("osoite");
	var postinumero = document.getElementById("postinumero");
	var ptoimipaikka = document.getElementById("ptoimipaikka");


	if(!etunimi || !sukunimi || !osoite || !postinumero || !ptoimipaikka) return;

	if(etunimi.value=='')
	{
		erStr = erStr + 'Etunimi puuttuu.' + "\n";
	}
	if(sukunimi.value=='')
	{
		erStr = erStr + 'Sukunimi puuttuu.' + "\n";
	}
	if(osoite.value=='')
	{
		erStr = erStr + 'Osoite puuttuu.' + "\n";
	}
	if(postinumero.value=='')
	{
		erStr = erStr + 'Postinumero puuttuu.' + "\n";
	}
	if(ptoimipaikka.value=='')
	{
		erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
	}

	var cb_checked = false;
	for(i=1;i<7;i++)
	{
		var cb = document.getElementById("checkbox"+i);
		if(cb && cb.checked) cb_checked = true;
	}

	if(cb_checked==false)
	{
		erStr = erStr + '"Kuulin Tammen kultaiset kirjat -sarjasta" -valinta puuttuu.' + "\n";
	}

	if(erStr)
	{
		alert(erStr);
		return false;
	}

	return true;
}

function tarkistaKKlomake2()
{
	var erStr = '';

	var etunimi = document.getElementById("etunimi");
	var sukunimi = document.getElementById("sukunimi");
	var osoite = document.getElementById("osoite");
	var postinumero = document.getElementById("postinumero");
	var ptoimipaikka = document.getElementById("ptoimipaikka");
	var etunimi2 = document.getElementById("saaja_etunimi");
	var sukunimi2 = document.getElementById("saaja_sukunimi");
	var syntvuosi = document.getElementById("year2");
	var nimi3 = document.getElementById("nimi3");
	var osoite3 = document.getElementById("osoite3");
	var postinumero3 = document.getElementById("postinumero3");
	var ptoimipaikka3 = document.getElementById("ptoimipaikka3");


	if(!etunimi || !sukunimi || !osoite || !postinumero || !ptoimipaikka) return;

	if(etunimi.value=='')
	{
		erStr = erStr + 'Etunimi puuttuu.' + "\n";
	}
	if(sukunimi.value=='')
	{
		erStr = erStr + 'Sukunimi puuttuu.' + "\n";
	}
	if(osoite.value=='')
	{
		erStr = erStr + 'Osoite puuttuu.' + "\n";
	}
	if(postinumero.value=='')
	{
		erStr = erStr + 'Postinumero puuttuu.' + "\n";
	}
	if(ptoimipaikka.value=='')
	{
		erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
	}

	if(etunimi2.value=='')
	{
		erStr = erStr + 'Lapsen/saajan etunimi puuttuu.' + "\n";
	}
	if(sukunimi2.value=='')
	{
		erStr = erStr + 'Lapsen/saajan sukunimi puuttuu.' + "\n";
	}
	if(syntvuosi.value=='')
	{
		erStr = erStr + 'Lapsen/saajan syntymäaika puuttuu.' + "\n";
	}


	if(nimi3.value=='')
	{
		erStr = erStr + 'Suosittelijan nimi puuttuu.' + "\n";
	}
	if(osoite3.value=='')
	{
		erStr = erStr + 'Suosittelijan osoite puuttuu.' + "\n";
	}
	if(postinumero3.value=='')
	{
		erStr = erStr + 'Suosittelijan postinumero puuttuu.' + "\n";
	}
	if(ptoimipaikka3.value=='')
	{
		erStr = erStr + 'Suosittelijan postitoimipaikka puuttuu.' + "\n";
	}


	/*var cb_checked = false;
	for(i=1;i<7;i++)
	{
		var cb = document.getElementById("checkbox"+i);
		if(cb && cb.checked) cb_checked = true;
	}

	if(cb_checked==false)
	{
		erStr = erStr + '"Kuulin Tammen kultaiset kirjat -sarjasta" -valinta puuttuu.' + "\n";
	}*/

	if(erStr)
	{
		alert(erStr);
		return false;
	}

	return true;
}
function tarkistaTildalomake()
{
	var erStr = '';

	var etunimi = document.getElementById("etunimi");
	var sukunimi = document.getElementById("sukunimi");
	var osoite = document.getElementById("osoite");
	var postinumero = document.getElementById("postinumero");
	var ptoimipaikka = document.getElementById("ptoimipaikka");


	if(!etunimi || !sukunimi || !osoite || !postinumero || !ptoimipaikka) return;

	if(etunimi.value=='')
	{
		erStr = erStr + 'Etunimi puuttuu.' + "\n";
	}
	if(sukunimi.value=='')
	{
		erStr = erStr + 'Sukunimi puuttuu.' + "\n";
	}
	if(osoite.value=='')
	{
		erStr = erStr + 'Osoite puuttuu.' + "\n";
	}
	if(postinumero.value=='')
	{
		erStr = erStr + 'Postinumero puuttuu.' + "\n";
	}
	if(ptoimipaikka.value=='')
	{
		erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
	}


	if(erStr)
	{
		alert(erStr);
		return false;
	}

	return true;
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function reloadFlashBanner(bid)
{
	opener.window.focus();
	opener.window.location = '/admin/flash_banners/flash_banners_edit.php?flash_bannerID='+bid+'&tab=2';
	self.close();
	return false;
}

function reloadAdsBanner(aid)
{
	opener.window.focus();
	opener.window.location = '/admin/ads/ads_edit.php?adID='+aid;
	self.close();
	return false;
}

function reloadPresentation(aid)
{
	opener.window.focus();
	opener.window.location = '/admin/oppi/presentation/presentation_edit.php?presentationID='+aid;
	self.close();
	return false;
}

function SetItemDimensions(height, width, item_id)
{
  	if (height) document.getElementById(item_id).height=height;
  	if (width) document.getElementById(item_id).width=width;
}


function opkv_paataso(selVal, apuID)
{
	//alert('/oppi/tuotetiedot/sarja.php?taso='+selVal);
	new Ajax.Updater('sarja'+apuID, '/oppi/tuotetiedot/sarja.php?taso='+selVal+'&id='+apuID, {asynchronous:true, evalScripts:true});
}

function opkv_sarja(selVal, apuID)
{
	//alert('/oppi/tuotetiedot/kirja.php?taso='+document.getElementById('paataso'+apuID).value+'&sarja='+selVal);
	new Ajax.Updater('kirja'+apuID, '/oppi/tuotetiedot/kirja.php?taso='+document.getElementById('paataso'+apuID).value+'&sarja='+selVal+'&id='+apuID, {asynchronous:true, evalScripts:true});
}

function opkv_uusi(selId)
{
	new Ajax.Updater('next_'+selId, '/oppi/tuotetiedot/uusi.php?id='+selId, {asynchronous:true, evalScripts:true});
}

function opkv_tarkista()
{
	var erStr = '';

	var YHTEYSTIEDOT_KOULUN_NIMI = document.getElementById("YHTEYSTIEDOT_KOULUN_NIMI");
	var YHTEYSTIEDOT_YHTEYSHENKILO = document.getElementById("YHTEYSTIEDOT_YHTEYSHENKILO");
	var YHTEYSTIEDOT_LAHIOSOITE = document.getElementById("YHTEYSTIEDOT_LAHIOSOITE");
	var YHTEYSTIEDOT_POSTINUMERO = document.getElementById("YHTEYSTIEDOT_POSTINUMERO");
	var YHTEYSTIEDOT_POSTITOIMIPAIKKA = document.getElementById("YHTEYSTIEDOT_POSTITOIMIPAIKKA");
	var YHTEYSTIEDOT_KOULUN_PUHELIN = document.getElementById("YHTEYSTIEDOT_KOULUN_PUHELIN");
	var YHTEYSTIEDOT_EMAIL = document.getElementById("YHTEYSTIEDOT_EMAIL");


	if(!YHTEYSTIEDOT_KOULUN_NIMI || !YHTEYSTIEDOT_YHTEYSHENKILO || !YHTEYSTIEDOT_LAHIOSOITE || !YHTEYSTIEDOT_POSTINUMERO || !YHTEYSTIEDOT_POSTITOIMIPAIKKA || !YHTEYSTIEDOT_KOULUN_PUHELIN || !YHTEYSTIEDOT_EMAIL) return;

	if(YHTEYSTIEDOT_KOULUN_NIMI.value=='')
	{
		erStr = erStr + 'Koulun nimi puuttuu.' + "\n";
	}
	if(YHTEYSTIEDOT_YHTEYSHENKILO.value=='')
	{
		erStr = erStr + 'Yhteyshenkilö puuttuu.' + "\n";
	}
	if(YHTEYSTIEDOT_LAHIOSOITE.value=='')
	{
		erStr = erStr + 'Lähiosoite puuttuu.' + "\n";
	}
	if(YHTEYSTIEDOT_POSTINUMERO.value=='')
	{
		erStr = erStr + 'Postinumero puuttuu.' + "\n";
	}
	if(YHTEYSTIEDOT_POSTITOIMIPAIKKA.value=='')
	{
		erStr = erStr + 'Postitoimipaikka puuttuu.' + "\n";
	}

	if(YHTEYSTIEDOT_KOULUN_PUHELIN.value=='')
	{
		erStr = erStr + 'Koulun puhelin puuttuu.' + "\n";
	}

	if(YHTEYSTIEDOT_EMAIL.value=='')
	{
		erStr = erStr + 'Koulun email puuttuu.' + "\n";
	}

	if(erStr)
	{
		alert(erStr);
		return false;
	}

	return true;
}

function checkPostinumero(strString)
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;

	if (strString.length != 5) return false;

	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function selectSubArea(area_value)
{
	//alert(area_value);
	var subAreaDiv = document.getElementById(area_value + '_subAreas').innerHTML;
	var subArea = document.getElementById('subArea');
	subArea.innerHTML = subAreaDiv;
}

function focusTo(lahjakorttiID)
{
	for(i=1; i<=4; i++)
	{
		var theImg = document.getElementById('lahjakortti_'+i);
		if(lahjakorttiID == i)
		{
			theImg.setAttribute('class', 'normImg');
		  theImg.setAttribute('className', 'normImg');
		}
		else
		{
			theImg.setAttribute('class', 'blurImg');
		  theImg.setAttribute('className', 'blurImg');
		}
	}
}
