<!-- hide script from old browsers
// ##########
//
// akil_javascripts.js  v0.1 1999/01/11
//
// Part of the Grey Interactive Project, ( AKIL )
// Javascript funcitons used in in AKIL
// We try to keep this crap to a minimum !!
//
// Oh yeah and this thing seems to be going okay !!! :)
// Copyright 1999,  Fredrick E. Mbuya, ProVisual Oy, planetgrey.org.
//
// Revision History.
//
// ##########

_HEADERFONT = '<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color=white><b>';
// _HEADERTABLEDEF = '<table width="720" border="0" cellspacing="0" cellpadding="0">';
_HEADERTABLEDEF = '<table width="598" border="0" cellspacing="0" cellpadding="0" align="center">';
_HEADERORIENTATION = 'H';

_AKILMENU = '<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFF00">';
_AKILMENU = _AKILMENU + '<tr> <td> <h3 align="center">'
_AKILMENU = _AKILMENU +'<a href = "../../cgi-bin/akil/akil_maintain.pl?function=displayClients" target = "mainFrame">Display Clients</a><br><br>';
_AKILMENU = _AKILMENU +'<a href = "../../cgi-bin/akil/akil_maintain.pl?function=displayMembers" target = "mainFrame">Display Members</a><br><br>';
_AKILMENU = _AKILMENU +'<a href = "../../cgi-bin/akil/akil_maintain.pl?function=displayMailinglistClients" target = "mainFrame">Display Mailinglist</a><br><br>';
_AKILMENU = _AKILMENU +'<a href = "../../cgi-bin/akil/akil_maintain.pl?function=displayAddEcardToDatabseForm" target = "mainFrame">Add Ecard</a><br><br>';
_AKILMENU = _AKILMENU +'<a href = "../../cgi-bin/akil/akil_maintain.pl?function=displayUsers" target = "mainFrame">Display Users</a>';
_AKILMENU = _AKILMENU +'</h3></td></tr></table>';



function makePopupWindow(theURL,winName,features, orgName,x ,y) { //v2.0
var screenHeight = screen.height;
var screenWidth = screen.width;
var xPos = (screenWidth - x) / 2;
var yPos = (screenHeight -y) / 2;

        popupWindowHandle=window.open(theURL,winName,features);

        if (popupWindowHandle.opener == null)
        popupWindowHandle.opener = window;
        popupWindowHandle.opener.name = orgName;
     //   popupWindowHandle.moveTo(xPos,yPos);
        return popupWindowHandle;
}
function makeGuestbookPopup(clientId) {
var newUrl = "http://www.eastpop.com/cgi-bin/akil/akil_guestbook.pl?function=displayEastpopGuestbook&clientId="+clientId;
        makePopupWindow(newUrl,"eastpopGuestbook","width=540,height=500,scrollbars=yes", "opener",  540, 500);
}

function makeSelectEcardImagePopup(ecardCategory,clientId) {
var newUrl = "http://www.eastpop.com/cgi-bin/akil/akil.pl?function=selectEcardImagePopup&ecardCategory="+ecardCategory+"&clientId="+clientId;
        makePopupWindow(newUrl,"selectEcardCategoryWindow","width=540,height=500,scrollbars=yes", "opener",  540, 500);
}

function makeEcardImagePopup(ecardFile, ecardName) {
var newUrl = "akil.pl?function=ecardImagePopup&ecardFile="+ecardFile+"&ecardName="+ecardName;
        makePopupWindow(newUrl,"popWindow","width=520,height=450", "opener",  520, 450);
}

function makeEcardPreviewPopup(ecardId, sendersName, ecardMessageFile, clientId) {
var newUrl = "akil_ecard.pl?function=ecardPreviewPopupHtml&ecardId="+ecardId+"&sendersName="+sendersName+"&ecardMessageFile="+ecardMessageFile+"&clientId="+clientId;
        makePopupWindow(newUrl,"popWindow","width=540,height=600", "opener",  540, 600);
}

function makeEcardPopup(ecardPassword) {
var newUrl = "akil_ecard_pickup.pl?function=displayEcardPopup&ecardPassword="+ecardPassword;
        makePopupWindow(newUrl,"popWindow","width=540,height=700", "opener",  540, 700);
}

function submitEcard() {
	var test = 'hello';
	var test2 = document.sendEcard.sendersName.value;
	if (document.sendEcard.sendersName.value) {
		if (document.sendEcard.sendersEmail.value) {
			if (document.sendEcard.receiversName.value) {
				if (document.sendEcard.recieversEmail.value) {
					if (document.sendEcard.ecardMessage.value) {
						document.sendEcard.button.value = "submit";
						document.sendEcard.submit();
					} else {
						alert('You must enter a message');
					}
				} else {
					alert('You must enter the recievers email address');
				}
			} else {
				alert('You must enter the recievers name');
			}
		} else {
			alert('You must enter your email address');
		}

	} else {
		alert('You must enter your name');
	}
}


function setCookie (name, value, expires) {
	if (!expires) expires = new Date();
	document.cookie = name + "=" + escape (value) +
	"; expires=" + expires.toGMTString() +  "; path=/";
}


function getCookie (name) {
    var dcookie = document.cookie;
    var cname = name + "=";
    var clen = dcookie.length;
    var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
            if (dcookie.substring(cbegin, vbegin) == cname) {
            var vend = dcookie.indexOf (";", vbegin);
                if (vend == -1) vend = clen;
            return unescape(dcookie.substring(vbegin, vend));
            }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
            if (cbegin == 0) break;
        }
    return null;
}

function displayAkilMenu() {
	document.write(_AKILMENU);
}

function displayAkilClientMenu() {
	alert();
	document.write('ksfhsdfh');
	var temp = getCookie("newsPage");
	var clientId = getCookie("clientId");
	if (getCookie("newsPage") == 'Y') {
		var newsPageUrl = getCookie("newsPageUrl");
		_NEWSMENU = '<table width="200" border="0" cellspacing="0" cellpadding="0">';
		_NEWSMENU = _NEWSMENU + '<tr>';
		_NEWSMENU = _NEWSMENU + '<td colspan="2">';
      		_NEWSMENU = _NEWSMENU + '<p>Newspage</p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
  		_NEWSMENU = _NEWSMENU + '</tr>';
  		_NEWSMENU = _NEWSMENU + '<tr>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p>&nbsp;</p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p><a href ="' + newsPageUrl + '" target = "mainFrame">View</a></p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
  		_NEWSMENU = _NEWSMENU + '</tr>';
  		_NEWSMENU = _NEWSMENU + '<tr>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p>&nbsp;</p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p><a href = "../cgi-bin/akil/akil_maintain.pl?function=addToNewsPage&clientId=';
      		_NEWSMENU = _NEWSMENU + clientId + '" target = "mainFrame"> Add</a></p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
  		_NEWSMENU = _NEWSMENU + '</tr>';
  		_NEWSMENU = _NEWSMENU + '<tr>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p>&nbsp;</p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
    		_NEWSMENU = _NEWSMENU + '<td>';
      		_NEWSMENU = _NEWSMENU + '<p><a href = "../cgi-bin/akil/akil_maintain.pl?function=removeFromNewsPage&clientId=';
      		_NEWSMENU = _NEWSMENU + clientId + '" target = "mainFrame">Remove</a></p>';
    		_NEWSMENU = _NEWSMENU + '</td>';
  		_NEWSMENU = _NEWSMENU + '</tr>';
		_NEWSMENU = _NEWSMENU + '</table><br><br>';

		document.write(_NEWSMENU);
	}

	if (getCookie("guestbook") == 'Y') {
		var guestbookUrl = getCookie("guestbookUrl");
		_GUESTBOOKMENU = '<table width="200" border="0" cellspacing="0" cellpadding="0">';
		_GUESTBOOKMENU = _GUESTBOOKMENU + '<tr>';
		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td colspan="2">';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p>Guestbook</p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '</tr>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '<tr>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p>&nbsp;</p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p><a href ="' + guestbookUrl + '" target = "mainFrame">View</a></p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '</tr>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '<tr>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p>&nbsp;</p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p><a href = "../cgi-bin/akil/akil_maintain.pl?function=addToGuestbook&clientId=';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + clientId + '" target = "mainFrame"> Add</a></p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '</tr>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '<tr>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p>&nbsp;</p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '<td>';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + '<p><a href = "../cgi-bin/akil/akil_maintain.pl?function=removeFromGuestbook&clientId=';
      		_GUESTBOOKMENU = _GUESTBOOKMENU + clientId + '" target = "mainFrame">Remove</a></p>';
    		_GUESTBOOKMENU = _GUESTBOOKMENU + '</td>';
  		_GUESTBOOKMENU = _GUESTBOOKMENU + '</tr>';
		_GUESTBOOKMENU = _GUESTBOOKMENU + '</table>';

		document.write(_GUESTBOOKMENU);
	}
}


function displayName() {
	document.write(getCookie("fname"));
	document.write(" ");
	document.write(getCookie("sname"));
	document.write(", (");
	document.write(getCookie("username"));
	document.write(")");
}

function displayAkilUserInfo() {
	document.write("<p>");
	document.write("Username<br>");
	document.write("<b>",getCookie("userUsername"),"</b>");
	document.write("<br>");
	document.write("Access level<br>");
	document.write("<b>",getCookie("userAccessLevel"),"</b>");
	document.write("</p>");
}

function displayLocalDate() {
	document.write(getCookie("localDate"));
}

function displayAmountMessages() {
	var myTemp = getCookie("amountMessages");
	if (myTemp == null) {
		document.write('0');
	} else {
		document.write(myTemp);
	}
}

function displayEcardInfo() {
	document.sendEcard.ecardId.value = getCookie("ecardId");
	document.sendEcard.clientId.value = getCookie("clientId");
	//document.write(getCookie("ecardId"));
}

function displayHeader() {
// Function to display the header at the top of each page.
// Uses the cookies which were sent during login
	var myUserLoggedIn = getCookie("loggedInAsMember");
	if (myUserLoggedIn == "TRUE") {
		if (_HEADERORIENTATION == "H") {
			document.write(_HEADERTABLEDEF);
			document.write('<tr>');
			document.write('<td width="100">');
			document.write(_HEADERFONT);
			document.write('&nbsp;');
			document.write('</font></b>');
			document.write('</td>');

			document.write('<td width="220">');
			document.write(_HEADERFONT);
			document.write('<script>displayName();</script>');
			document.write('</font></b>');
			document.write('</td>');

			document.write('<td width="200">');
			document.write(_HEADERFONT);
			document.write('<script>displayLocalDate();</script></td>');
			document.write('</font></b>');
			document.write('</td>');

			document.write('<td width="200">');
			document.write(_HEADERFONT);
			document.write('<script>displayAmountMessages();</script> viestit');
			document.write('</font></b>');
			document.write('</td>');
			document.write('</tr>');

			document.write('</table>');
		}

		if (_HEADERORIENTATION == "V") {
			document.write(_HEADERTABLEDEF);
			document.write('<tr>');
			document.write('<td align = "right">');
			document.write(_HEADERFONT);
			document.write('<script>displayLocalDate();</script>');
			document.write('<BR><BR>');
			document.write('</font></b>');
			document.write('</td>');
			document.write('</tr>');
			document.write('<tr>');
			document.write('<td align = "right">');
			document.write(_HEADERFONT);
			document.write('<script>displayName();</script>');
			document.write('<BR><BR>');
			document.write('</font></b>');
			document.write('</td>');
			document.write('</tr>');
			document.write('<tr>');
			document.write('<td align = "right">');
			document.write(_HEADERFONT);
			document.write('<script>displayAmountMessages();</script> viestit');
			document.write('</font></b>');
			document.write('</td>');
			document.write('</tr>');
			document.write('<tr>');
			document.write('<td align = "right">');
			document.write(_HEADERFONT);
			document.write('&nbsp;');
			document.write('</td>');
			document.write('  </tr>');
			document.write('</table>');
		}
	} else {
		displayAkilMemberLoginForm();
	}


}


function displayMessageBoardMenu() {
	var menuType = getCookie("menuType");
	var myUsername = getCookie("username");
	var myThreadId = getCookie("threadId");
	var myMessageId = getCookie("messageId");
	if (menuType == "displayingThread") {
		document.write('<p>');
		document.write('<a href = \"akil_respond_to_thread.pl?username=',myUsername,'&threadId=',myThreadId,'">');
		document.write('<img src="forumimg/reply.gif" width="60" height="60" border = 0></a>');
		document.write('<a href = \"akil_display_threads.pl?function=displayAllThreads\">');
		document.write('<img src="forumimg/subjects.gif" width="59" height="60" border = 0></a>');
		document.write('</p>');
	}
	if (menuType == "displayingAllThreads") {
		document.write('<p>');
		document.write('<a href = \"akil_create_thread.pl?function=createThread&clientId=9\">');
		document.write('</a>');
		document.write('</p>');
	}
	if (menuType == "displayingMessage") {
		document.write('<p>');
		document.write('<a href = \"akil_respond_to_message.pl?username=',myUsername,'&threadId=',myThreadId,'&messageId=',myMessageId,'">');
		document.write('<img src="forumimg/reply.gif" width="60" height="60" border = 0></a>');
		document.write('<a href = \"akil_display_threads.pl?function=displayAllThreads\">');
		document.write('<img src="forumimg/subjects.gif" width="59" height="60" border = 0></a>');
		document.write('</p>');
	}

	if (menuType == "answeringMessage") {
		document.write('<p>');
		document.write('<a href = \"akil_display_threads.pl?function=displayAllThreads\">');
		document.write('<img src="forumimg/subjects.gif" width="59" height="60" border = 0></a>');
		document.write('</p>');
	}

	if (menuType == "displayingResponse") {
		document.write('<p>');
		document.write('<a href = \"akil_display_threads.pl?function=displayAllThreads\">');
		document.write('<img src="forumimg/subjects.gif" width="59" height="60" border = 0></a>');
		document.write('</p>');
	}


}

function displayAkilMemberLoginForm() {
	document.write('<style type="text/css">');
	document.write('<!--');
	document.write('a {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-decoration: none}');
	document.write('-->');
	document.write('</style>');





	document.write(_HEADERTABLEDEF);
	document.write(_HEADERFONT);
	document.write('<tr><td width="50%" align="left">');
	document.write('<a href = "http://www.eastpop.com/cgi-bin/akil/akil.pl?function=displayMemberLogin">Kirjaudu sisään</font></a></td>');
	document.write('<td width="50%" align="right">');
	document.write('<a href = "http://www.eastpop.com/cgi-bin/akil/akil_register.pl?function=displayRegistrationForm">Rekisteröidy käyttäjäksi.</font></a></td></tr></table>');
}


// end hiding script from old browsers -->
