function dictionaryObj(desc, en, pl){
	this.desc = new String(desc);
	this.en = new String(en);
	this.pl = new String(pl);
}

function alphObj(bas, letters){
	this.bas = new String(bas);
	this.letters = letters;
}
	
function putWord(dict, key){
	for(i=0; i<dict.length; i++){
		if(dict[i].desc == key){
			switch(readCookie('lang')){
				case 'en' : document.write(dict[i].en); break;
				default : document.write(dict[i].pl);
			}
		}
	}
}

function getWord(dict, key){
	for(ii=0; ii<dict.length; ii++){
		if(dict[ii].desc == key){
			switch(readCookie('lang')){
				case 'en' :  return dict[ii].en;
				default : return dict[ii].pl;
			}
		}
	}
}

function writeCookie(name, value){
	dzis = new Date();
	dzis.setTime(dzis.getTime() + 20*24*60*60*1000);
	s = dzis.toGMTString();
	document.cookie = name + '=' + escape(value) + "; expires=" + s;
}

function readCookie(name){
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (document.cookie.substring(0, name.length) != name)){
		return new String('');
	}
	if (start == -1){
		return new String('');
	}
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

function getVariable(adres, varName){
	var str = new String(adres);
	var pos = str.indexOf('?');
	if(pos > -1){ // sa parametry
		str = str.slice(pos+1)
		pos = str.search(varName + '=');
		if(pos > -1){ // jest szukana zmienna
			str = str.slice(pos + varName.length + 1);
			var amppos = str.indexOf('&');
			if(amppos > -1){ // sa inne parametry
				return str.slice(0,amppos);
			}else{
				return str;
			}
		}
		else{
			return -1;
		}
	}else{
		return -1;
	}
}

function getVar(varName){
	var str = new String(document.location);
	var pos = str.indexOf('?');
	if(pos > -1){ // sa parametry
		str = str.slice(pos+1)
		pos = str.search(varName + '=');
		if(pos > -1){ // jest szukana zmienna
			str = str.slice(pos + varName.length + 1);
			var amppos = str.indexOf('&');
			if(amppos > -1){ // sa inne parametry
				return str.slice(0,amppos);
			}else{
				return str;
			}
		}
		else{
			return ''; //-1
		}
	}else{
		return ''; //-1
	}
}

function remSpaces(word){
	while(word.search(' ') != -1){
    	word = word.replace(' ', '_');
	}
	return word;
}

function putSpaces(word){
	while(word.search('_') != -1){
		word = word.replace('_', ' ');
	}
	return word;
}

alph = new Array();
var cc = 0;
alph[cc++] = new alphObj('', ['%B9']);
alph[cc++] = new alphObj('', ['%A5']);
alph[cc++] = new alphObj('', ['%E6']);
alph[cc++] = new alphObj('', ['%C6']);
alph[cc++] = new alphObj('', ['%EA']);
alph[cc++] = new alphObj('', ['%CA']);
alph[cc++] = new alphObj('', ['%B3']);
alph[cc++] = new alphObj('', ['%A3']);
alph[cc++] = new alphObj('', ['%F1']);
alph[cc++] = new alphObj('', ['%D1']);
alph[cc++] = new alphObj('', ['%F3']);
alph[cc++] = new alphObj('', ['%D3']);
alph[cc++] = new alphObj('', ['%9C']);
alph[cc++] = new alphObj('', ['%8C']);
alph[cc++] = new alphObj('', ['%9F']);
alph[cc++] = new alphObj('', ['%8F']);
alph[cc++] = new alphObj('', ['%BF']);
alph[cc++] = new alphObj('', ['%AF']);
alph[cc++] = new alphObj('@', ['%40']);

nalph = new Array();
cc = 0;
nalph[cc++] = new alphObj('a', ['%B1', '%B9', '']);
nalph[cc++] = new alphObj('A', ['%A1', '%A5', '']);
nalph[cc++] = new alphObj('c', ['%E6', '']);
nalph[cc++] = new alphObj('C', ['%C6', '']);
nalph[cc++] = new alphObj('e', ['%EA', '']);
nalph[cc++] = new alphObj('E', ['%CA', '']);
nalph[cc++] = new alphObj('l', ['%B3', '']);
nalph[cc++] = new alphObj('L', ['%A3', '']);
nalph[cc++] = new alphObj('n', ['%F1', '']);
nalph[cc++] = new alphObj('N', ['%D1', '']);
nalph[cc++] = new alphObj('o', ['%F3', '']);
nalph[cc++] = new alphObj('O', ['%D3', '']);
nalph[cc++] = new alphObj('s', ['%9C', '%B6', '']);
nalph[cc++] = new alphObj('S', ['%A6', '%8C', '']);
nalph[cc++] = new alphObj('z', ['%BC', '%9F', '%BF', '', '']);
nalph[cc++] = new alphObj('Z', ['%AC', '%AF', '%8F', '', '']);
nalph[cc++] = new alphObj('@', ['%40']);

function codin(word){
	for(ai=0; ai<alph.length; ai++){
		for(li=0; li<alph[ai].letters.length; li++){
			lit = alph[ai].letters[li];
			while(word.search(lit) != -1){ word = word.replace(lit, alph[ai].bas);}
		}
	}
	return word;								
}

function nopl(word){
	for(ai=0; ai<nalph.length; ai++){
		for(li=0; li<nalph[ai].letters.length; li++){
			lit = nalph[ai].letters[li];
			while(word.search(lit) != -1){ word = word.replace(lit, nalph[ai].bas);}
		}
	}
	return word;								
}

var address_allston = new String('181 Harvard Ave.<br/>Allston, MA 02134<br/>tel: 617 779 7272<br/>fax: 617 779 7227');
var address_dorchester = new String('827 Dorchester Ave.<br/>Dorchester, MA 02125<br/>tel: 617 288 7777<br/>fax: 617 288 5777');
