function popUppi(URL) {
	eval("window.open(URL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=1,height=1,left=0,top=0');");
}
function popUppi2(URL) {
	eval("window.open(URL,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1,height=1,left=0,top=0');");
}
function popUppi3(URL) {
	eval("window.open(URL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=500,left=0,top=0');");
}
function popUp(URL) {	eval("window.open(URL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=180,left=0,top=0');");
}
function tpopUp(URL) {
var wiinle = (screen.width - 704) / 2;
var wiinUp = (screen.height - 549) / 2;
eval("window.open(URL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=704,height=449,left='+wiinle+',top='+wiinUp);");
}
function popUps(URL,width,height) {	eval("window.open(URL,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left=0,top=0');");
}

document.onmousemove = mouseMove;
var mousePos;

function mouseMove(ev){
	ev           = ev || window.event;
	mousePos = mouseCoords(ev);
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function naita_korvi_summat(todo) {
	var aken = document.getElementById('ostukorvi_sisu');
	if(todo=='show') {
		aken.style.left=mousePos.x - 172;
		aken.style.display="";
	} else {
		aken.style.display="none";
	}
}

function change_tab(vali) {
	var menu = document.getElementById('menu_tabel');
	var tabelid = menu.getElementsByTagName('table');
	for (i=0;i<tabelid.length ; i++)
	{
		if(vali==tabelid[i].rows[0].cells[0]) {		
			menu.rows[0].cells[i].className='horiz_punktiir_act';
			tabelid[i].rows[0].cells[0].className='tab_active';
			var text = tabelid[i].rows[0].cells[0].innerHTML.replace(/(<([^>]+)>)/ig,""); 
			tabelid[i].rows[0].cells[0].innerHTML = '<DIV class="pealkiri2">'+text+'</div>';
			var d = document.getElementById('cont_'+text);
			if (d)
				d.style.display='';
			createCookie('activeTab_name', text, 2);
			createCookie('activeTab_ID', i, 2);
		} else {
			menu.rows[0].cells[i].className='horiz_punktiir_nok';
			tabelid[i].rows[0].cells[0].className='tab_nok';
			var text = tabelid[i].rows[0].cells[0].innerHTML.replace(/(<([^>]+)>)/ig,""); 
			tabelid[i].rows[0].cells[0].innerHTML = '<DIV class="pealkiri_nok">'+text+'</div>';
			var text = tabelid[i].rows[0].cells[0].innerHTML.replace(/(<([^>]+)>)/ig,""); 
			var d = document.getElementById('cont_'+text);
			if (d)
				d.style.display='none';
		}
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

$(function(){
	$('.lyteframe').click(function(){
		myLytebox.start($(this).find('a')[0], false, true);
	});
});
