
//<script>


if(typeof(onwa)=='undefined'){onwa=Array();}


ns4 = (document.layers) ? true : false;


//alert(open_in_new_win_img_widthplusf);

//if (open_in_new_win_img_heightplus == "undefined")
	//open_in_new_win_img_heightplus = 40;
	open_in_new_win_img_heightplus = 0;
	

	
//if (open_in_new_win_img_widthplusf == "undefined")	
	//open_in_new_win_img_widthplus = 40;
	open_in_new_win_img_widthplus = 0;
	
//alert(open_in_new_win_img_widthplus);		
	
/*
function open_in_new_win_img_a_click(obj) {
	
	ns4 = (document.layers) ? true : false;
	

	//alert(obj.className);
	
	if (!ns4 && obj.getAttribute)
	{
		width = obj.getAttribute("_width", 2);
		height = obj.getAttribute("_height", 2);

		_id = obj.getAttribute("_id", 2);
		_sid = obj.getAttribute("_sid", 2);
		
		target = obj.getAttribute("_target", 2);
		border = obj.getAttribute("_border", 2);
		
		
		
		if ((_id != null) && (_id != ""))
			idpart = "id=" + _id;
		else
			idpart = "sid=" + _sid;		
	}
	else if (ns4)
	{
		width = nn_open_in_new_win_img_a[obj]["_width"];
		height = nn_open_in_new_win_img_a[obj]["_height"];
		
		if (nn_open_in_new_win_img_a[obj]["_id"])
		{
			_id = nn_open_in_new_win_img_a[obj]["_id"];
			idpart = "id=" + _id;
		}
		else
		{
			_sid = nn_open_in_new_win_img_a[obj]["_sid"];
			idpart = "sid=" + _sid;		
		}

		target = nn_open_in_new_win_img_a[obj]["_target"];
		border = nn_open_in_new_win_img_a[obj]["_border"];
		
	}
	else
		return false;

	
	
	//if (!obj._target || !target || (target == ""))
	//	target = "_blank";
		
	//alert(target);
	
	
	
	
	width = (1 * width + open_in_new_win_img_widthplus);
	height = (1 * height + open_in_new_win_img_heightplus);
	
	//alert(width + "_" + height + "_" + idpart);

	//var mywin = window.open("?a=show_img_in_new_win&" + idpart + "", target, "width=" + width + ", height=" + height + ", menubar=no, toolbar=no, status=no, resizable=yes, scrollbars=yes, location=no, copyhistory=yes", false);

	//avaakennoscroll("?a=show_img_in_new_win&" + idpart + "", width, height);
	var mywin = window.open("?a=show_img_in_new_win&" + idpart + "", target,'width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=yes,copyhistory=0');


	if (!ns4)	//netscape manages by himself :)
	{
	
		var isIE=document.all?1:0;
		var isOp=window.opera?1:0;	
		var MS = isIE&&!isOp;
		db = "body";
	
		winW = MS ? mywin.document[db].clientWidth : mywin.innerWidth;
		winH = MS ? mywin.document[db].clientHeight : mywin.innerHeight
	
		//alert(width + "_" + height + "_" + winW + "_" + winH);

		if ((winW != width) || (winH != height))
			mywin.resizeBy(width - winW, height - winH);
			
		//mywin.resizeTo(width, height);
		
		//mywin._oldwidth = width;
		//mywin._oldheight = height;
	}
	
	mywin.focus();
	
	return false;
}

*/

//###################################################################################
//
//###################################################################################

function onwa_c(obj_id, obj) {


//Array('$nn_idpart_k', '$nn_idpart_v', '$border', '".slashtext($target)."', '".slashtext($width)."', '".slashtext($height)."', '$borderwidth', '$borderheight'

	//ns4 = (document.layers) ? true : false;
	

	width = onwa[obj_id][2];
	height = onwa[obj_id][3];
	/*
	if (onwa[obj][0] == "id")
	{
		_id = onwa[obj][1];
		idpart = "id=" + _id;
	}
	else
	{
		_sid = onwa[obj][1];
		idpart = "sid=" + _sid;		
	}
	*/
	target = onwa[obj_id][1];
	if (target == "")
		target = "_blank";
	
	border = onwa[obj_id][0];
	/*
	custom_data = onwa[obj][8];
	if (custom_data != "")
		custom_data = "&custom_data=" + escape(custom_data);
	*/
	
	open_in_new_win_img_widthplus_1 = onwa[obj_id][4];
	open_in_new_win_img_heightplus_1 = onwa[obj_id][5];
	
	allowscroll = onwa[obj_id][6];
	
	if (open_in_new_win_img_widthplus_1 == '')
		open_in_new_win_img_widthplus2 = open_in_new_win_img_widthplus;
	else
		open_in_new_win_img_widthplus2 = open_in_new_win_img_widthplus_1;
	
	if (open_in_new_win_img_heightplus_1 == '')
		open_in_new_win_img_heightplus2 = open_in_new_win_img_heightplus;
	else
		open_in_new_win_img_heightplus2 = open_in_new_win_img_heightplus_1;
	
	
	width = (parseInt(width) + parseInt(open_in_new_win_img_widthplus2));
	height = (parseInt(height) + parseInt(open_in_new_win_img_heightplus2));
	
	//alert(width + "_" + height);
	
	/*
	if (ns4)
	{
		if (open_in_new_win_img_widthplus2 != 0)
			hpad = "&hpad=" + open_in_new_win_img_widthplus2 / 2;
		else
			hpad = "";
			
		if (open_in_new_win_img_heightplus2 != 0)
			vpad = "&vpad=" + open_in_new_win_img_heightplus2 / 2;
		else
			vpad = "";
	}
	else
	{
		hpad = "";
		vpad = "";
	}
	*/
	//alert(width + "_" + height + "_" + idpart);

	//var mywin = window.open("?a=show_img_in_new_win&" + idpart + "", target, "width=" + width + ", height=" + height + ", menubar=no, toolbar=no, status=no, resizable=yes, scrollbars=yes, location=no, copyhistory=yes", false);

	//avaakennoscroll("?a=show_img_in_new_win&" + idpart + "", width, height);
	//var mywin = window.open("?a=show_img_in_new_win&" + idpart + vpad + hpad + custom_data, target,'width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=yes,copyhistory=0');

	var isIE=document.all?1:0;
	var isOp=window.opera?1:0;	
	var isDOM=document.getElementById?1:0;
	var isMoz = isDOM && !isIE;

	
	if ((typeof(maxsize_h_for_show_img_in_new_win) == "undefined") || (maxsize_h_for_show_img_in_new_win == ""))
	{
		if (!isOp)
			maxsize_h_for_show_img_in_new_win = screen.height - 70;
		else
			maxsize_h_for_show_img_in_new_win = screen.height - 370;
	}
	else
		maxsize_h_for_show_img_in_new_win = Math.min(parseInt(maxsize_h_for_show_img_in_new_win), screen.height - 70);

	if ((typeof(maxsize_w_for_show_img_in_new_win) == "undefined") || (maxsize_w_for_show_img_in_new_win == ""))
		maxsize_w_for_show_img_in_new_win = screen.width - 40;
	else
		maxsize_w_for_show_img_in_new_win = Math.min(parseInt(maxsize_w_for_show_img_in_new_win), screen.width - 40);

		
	width_real = width;
	height_real = height;
	
	//alert ("_" + document.body.scrollWidth + "_" + document.body.offsetWidth + "_" + document.body.clientwidth + "_");
	
	
	if (isOp)
		scrollbar_w = 24;
	else if (isIE)
		scrollbar_w = document.body.offsetWidth - document.body.scrollWidth - 2;
	else if (/*isDOM*/isMoz)
		scrollbar_w = 18;
	else
		scrollbar_w = 18;
		
	if (!allowscroll)
		showscrollbars = "no";
	else
		showscrollbars = "yes";
		
	if (!allowscroll)
	{
		w_exceeded = false;
		h_exceeded = false;
		if (height_real > maxsize_h_for_show_img_in_new_win)
		{
			height_real = maxsize_h_for_show_img_in_new_win;
			h_exceeded = true;
			width_real = width_real + scrollbar_w;
			showscrollbars = "yes";
		}
		if (width_real > maxsize_w_for_show_img_in_new_win)
		{
			width_real = maxsize_w_for_show_img_in_new_win;
			w_exceeded = true;
			
			if (showscrollbars == "no")
			{
				height_real = height_real + scrollbar_w;
				//h_exceeded = true;
				
				if (height_real > maxsize_h_for_show_img_in_new_win)
				{
					height_real = maxsize_h_for_show_img_in_new_win;
					h_exceeded = true;
				}
				
				showscrollbars = "yes";
			}
		}
	}
	

	if (showscrollbars == "no")
	{
		hasscroll = 0;
		
		//if (isOp)
		//	width -= 8;
	}
	else
		hasscroll = 1;
	
	
	href2 = "width=" + width + "&height=" + height + "&bwidth=" + open_in_new_win_img_widthplus2 + "&bheight=" + open_in_new_win_img_heightplus2 + "&hasscroll=" + hasscroll;

	if (obj.href.indexOf("?") != -1)
		href = obj.href + "&" + href2;
	else
		href = obj.href + "?" + href2;
	
	
	open_window(href, target, width, height, showscrollbars);
	
	return false;
}

//###################################################################################
//
//###################################################################################

function open_window(href_in, target_in, width_real, height_real, showscrollbars) {

	var command = "var mywin = wi" + "nd" + "ow" + "." + "op" + "en" + "(href_in,target_in,'";
	
	if (width_real && (width_real != -1))
		command = command + "width='+width_real+',";
	if (height_real && (height_real != -1))
		command = command + "height='+height_real+',";

	if (typeof(showscrollbars) == "undefined")
		showscrollbars = 1;
		
	command = command + "toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars='+showscrollbars+',copyhistory=0');";
		
	eval(command);
	

	//mywin = new Object();

	if ((typeof(mywin) == "undefined") || (mywin == null) || (typeof(mywin.opener) == "undefined") || (mywin.opener == null))
	{
		alert("Sul on tõenäoliselt mõni pop-up blocker tarkvara aktiivne.\nPalun lülita see välja või seadista leebemaks, et koduleht tohiks Sinu kliki peale uut akent avada!");
		return false;
	}
	
	mywin.focus();
	
	return false;

}

//###################################################################################
//
//###################################################################################

function img_win_opened_callback(mywin, width, height, hasscroll) {


	var isIE=document.all?1:0;
	var isOp=window.opera?1:0;	
	var isDOM=document.getElementById?1:0;
	var isMoz = isDOM && !isIE;
	var MS = (isIE && !isOp || /*isDOM*/isMoz);

	//alert(mywin.document.body.scroll);
	
	if (!ns4 && (!((/*isDOM*/isMoz || MS) && (!hasscroll))) || isOp || isIE)	//netscape does not give innerWidth props correctly
	{
	
		//if (showscrollbars == "no")
		//{
			db = "body";
		
			winW = MS ? mywin.document.body.clientWidth : mywin.innerWidth;
			winH = MS ? mywin.document.body.clientHeight : mywin.innerHeight;
		
			//alert(mywin.document.body.clientWidth + "_" + mywin.innerWidth + "_" + mywin.document.width + "_" + mywin.width);
	
			if ((winW != width) || (winH != height))
			{
				if (w_exceeded == false)
					width_diff = width - winW;
				else
					width_diff = 0;
					
				if (h_exceeded == false)
					height_diff = height - winH;
				else
					height_diff = 0;	
					
				if (hasscroll && isOp)
				{
					width_diff += 0; //23;
					height_diff += 0;// 23;
				}
				else if (isOp)
				{
					width_diff += 13;
					height_diff += 13;
				}
				
				//alert(width + "_" + height + "_" + winW + "_" + winH + "_" + width_diff + "_" + height_diff + "_"  + open_in_new_win_img_heightplus2);
				
				
				if ((width_diff != 0) || (height_diff != 0))
				{
					try {
						mywin.resizeBy(width_diff, height_diff);
					}catch(e){}
				}
			}
				
			//mywin.resizeTo(width, height);
			
			//mywin._oldwidth = width;
			//mywin._oldheight = height;
		//}
	}
	else if (/*isDOM*/isMoz)
	{
		try {
			mywin.resizeBy(0, 1);
		}catch(e){}
		
		try {
			mywin.resizeBy(0, -1);
		}catch(e){}
	}


}

//###################################################################################
//
//###################################################################################

/*
if (typeof(slideshow_trans_timers) == "undefined")
	slideshow_trans_timers = Array();
if (typeof(slideshow_activepos) == "undefined")
	slideshow_activepos = Array();

function init_slideshow(slideshow_index, slideshow_interval, slideshow_transitiontime) {

	slideshow_trans_timers[slideshow_index] = slideshow_transitiontime;
	slideshow_activepos[slideshow_index] = 0;
	
	setInterval("slideshow_swapimage(" + slideshow_index + ", 0);", slideshow_interval);

}
*/

ie4 = (document.all) ? true : false;
MSIE55p = 0;
if (ie4)
{
	var browser = navigator.userAgent;
	
	pos = browser.indexOf("MSIE");
	if (pos != -1)
	{
		ver = browser.substr(pos + 4);
		
		//ver = trim(ver);
		pos_end = ver.indexOf(";");
		if (pos_end == -1)
			pos_end = ver.indexOf(")");
		ver = ver.substr(0, pos_end);
		
		//ver = "5.5";
		
		if (ver.valueOf() >= 5.5)
		{
			MSIE55p = 1;
			//alert("MSIE55p");
		}
	}
}

//###################################################################################
//
//###################################################################################

function select_random_img(slideshow_index) {


	var activepos_next;
	var maxlen;
	
	
	eval("maxlen = sls_a_" + slideshow_index + ".length;");
	
	//return;
	//alert(maxlen);
	
	if (maxlen == 0)
		return;
	
	do
	{
		activepos_next = Math.random() * maxlen;		//number generated is between 0 and 1 inclusive
		activepos_next = Math.floor(activepos_next);
	} 
	while (activepos_next == maxlen);

	
	//alert(activepos_next);
	
	
	eval("img = document.slideshow_img_" + slideshow_index + "");
	setTimeout("img.src = sls_a_" + slideshow_index + "['" + activepos_next + "'].src;", 1);
	
	//alert(img);
	//alert(activepos_next);
	//alert(img.src);
	
}

//###################################################################################
//
//###################################################################################

//oldimg = null;
oldimg_a = Array();

function get_slideshow_nextimg(slideshow_index, notrans, return_only_url) {


	var activepos = slideshow_activepos[slideshow_index];

	if (typeof(slideshow_autoresume) != "undefined")
		curr_slideshow_autoresume = slideshow_autoresume[slideshow_index];
	else
		curr_slideshow_autoresume = 0;


	
	if (activepos == -1) 
	{
		if (curr_slideshow_autoresume && (typeof(getCookieF) != "undefined"))
		{
			var activepos1 = getCookieF("slsp_" + slideshow_index);
			
			if (activepos1 == "")
				activepos = 0;
			else
				activepos = activepos1;
		}
		else
		{
			activepos = 0;
		}
	}
	
	
	var activepos_next;
	
	if (!notrans)
		activepos_next = activepos * 1 + 1;
	else
		activepos_next = activepos;
		
	//if (activepos == -1)
	//	activepos = 0;
		
	var maxlen;
	eval("maxlen = sls_a_" + slideshow_index + ".length;");
	
	
	//alert(activepos_next);
	
	if (activepos_next >= maxlen)
	{
		//alert(maxlen + "_" + activepos_next);
		activepos_next = 0;
	}
	
	
	var nextimg;
	eval("nextimg = sls_a_" + slideshow_index + "[" + activepos_next + "].src;");
	
	
	//alert(slideshow_index + "_" + activepos_next + "_" + nextimg);		
	
	
	if (!return_only_url)
		return Array(activepos, activepos_next, nextimg);
	else
		return nextimg;

}

//###################################################################################
//
//###################################################################################

function slideshow_swapimage(slideshow_index, elapsed_trans_time, notrans) {

	//alert("!");
	
	var trans_time = slideshow_trans_timers[slideshow_index];
	var curr_slideshow_autoresume;
	
		
	
	var ns4 = (document.layers) ? true : false;
	var isIE=document.all?1:0;
	var isOp=window.opera?1:0;	
	var isDOM=document.getElementById?1:0;
	var isMoz = isDOM && !isIE;
	
	


	var res = get_slideshow_nextimg(slideshow_index, notrans, false);
	var activepos = res[0];
	var activepos_next = res[1];
	var nextimg = res[2];

	
	if (activepos_next == activepos)			//there is only one image, nothing to swap!
		return;	
	
	
	
	//alert(trans_time);
	
	
	var activepos_for_cookie;
	
	if (0 || ns4 || isOp || (trans_time == 0) || (!(isIE || /*isDOM*/isMoz)) || notrans/* || (isIE && (!MSIE55p))*/)
	{
		//alert("?");
	
		//alert(slideshow_index + "_" + activepos_next);
		
		//var nextimg;
		//eval("nextimg = sls_a_" + slideshow_index + "[" + activepos_next + "].src;");
		
		
		var oldimg;
		
		if (typeof(oldimg_a[slideshow_index]) != "undefined")
			oldimg = oldimg_a[slideshow_index];
		else
			oldimg = null;
		
		
		var oldimg_prev = oldimg;
		
		//alert(activepos_next + "_" + slideshow_index + "_" + nextimg);
		
		//var oldimg;
		var img;
		if (oldimg_prev == null)
		{
			//do nothing, simply store the information about oldimg
		} 
		else if (!/*isDOM*/isMoz)
		{			
			eval("img = document.slideshow_img_" + slideshow_index + "");

			oldimg = img.src;
			
			img.src = nextimg;
		}
		else
		{
			img = document.getElementById("slideshow_img_" + slideshow_index + "");
			
			oldimg = img.src;
			
			img.src = nextimg;
			/*
			div = document.getElementById("slideshow_div_" + slideshow_index + "");
			
			div.style.backgroundRepeat = "no-repeat";
			div.style.backgroundImage = 'url(' + nextimg + ')';	
			div.style.width = div.width;
			div.style.height = div.height;*/
		}
			
		//if (oldimg == null)
		//	oldimg = nextimg;
		
		
		oldimg_a[slideshow_index] = oldimg;
		
		slideshow_activepos[slideshow_index] = activepos_next;
		activepos_for_cookie = activepos_next;
	}
	else	//if (0 || ns4 || isOp || (trans_time == 0) || (!(isIE || /*isDOM*/isMoz)) || notrans/* || (isIE && (!MSIE55p))*/)
	{
		var img;
		var div;
	
		if (isIE)
		{
			img = document.all["slideshow_img_" + slideshow_index + ""];
			div = document.all["slideshow_div_" + slideshow_index + ""];
		}
		else if (/*isDOM*/isMoz)
		{
			//alert("!");
		
			img = document.getElementById("slideshow_img_" + slideshow_index + "");
			div = document.getElementById("slideshow_div_" + slideshow_index + "");
		}
			
		//if (elapsed_trans_time == 0)  
		//{			  
		
			var oldimg;
		
			if (typeof(oldimg_a[slideshow_index]) != "undefined")
				oldimg = oldimg_a[slideshow_index];
			else
				oldimg = null;
				
				
		
			var oldimg_prev = oldimg;
		
		
			eval("oldimg = sls_a_" + slideshow_index + "[" + activepos + "].src;");
			//eval("nextimg = sls_a_" + slideshow_index + "[" + activepos_next + "].src;");
						
			//alert(oldimg + "_" + nextimg);
						
			//var trans_time = slideshow_trans_timers[slideshow_index]; 
			
			/*if (0 && (oldimg_prev == null) || (oldimg.search("picture") == -1) || (nextimg.search("picture") == -1))
			{
				//some crap... do nothing
			}*/
			//else 
			{
				//img.left = 1;
				if (isIE)
				{
					img.style.filter = "blendTrans(duration=" + trans_time + ");";
					img.filters.blendTrans.apply();
					img.src = oldimg;
					img.filters.blendTrans.play();
					
					//if (MSIE55p
					//img.filters.Play();		
					
					
					div.style.backgroundRepeat = "no-repeat";
					div.style.width = div.width;
					div.style.height = div.height;
					div.style.backgroundImage = 'url(' + nextimg + ')';
					
					
					activepos_for_cookie = activepos;
				}
				else	
				{				
					
					
					img.style.MozOpacity = 0.99;
					img.src = oldimg;
					setTimeout("moz_trans(" + slideshow_index + ");", 1);		
					
					
					div.style.backgroundRepeat = "no-repeat";
					div.style.width = div.width;
					div.style.height = div.height;
					
					if (div.style.backgroundImage == "")
						div.style.MozOpacity = 0.3;
						
					div.style.backgroundImage = 'url(' + nextimg + ')';	
					
					img.style.MozOpacity = 0.98;
					img.src = oldimg;
					setTimeout("moz_trans(" + slideshow_index + ");", 1);		
					
					div.style.MozOpacity = 1;			
					
					
					activepos_for_cookie = activepos_next;	
				}
			}
			
		//}
		
		
		oldimg_a[slideshow_index] = oldimg;
		
		slideshow_activepos[slideshow_index] = activepos_next;
		
		
	}	//if (0 || ns4 || isOp || (trans_time == 0) || (!(isIE || /*isDOM*/isMoz)) || notrans/* || (isIE && (!MSIE55p))*/)
	
	
	if (typeof(setCookieF) != "undefined")
	{
		//var cookies = slideshow_activepos[slideshow_index].toString();
		var cookies = activepos_for_cookie.toString();
		
		
		//alert(cookies);
		setCookieF("slsp_" + slideshow_index, cookies);
	}
	
}
	
//###################################################################################
//
//###################################################################################
	
function moz_trans(slideshow_index) {

	var img = document.getElementById("slideshow_img_" + slideshow_index + "");
	
	var opac = img.style.MozOpacity;
	opac -= 0.1;
	img.style.MozOpacity = opac;
	
	if (opac > 0)
	{
		var  trans_time = slideshow_trans_timers[slideshow_index];
		setTimeout("moz_trans(" + slideshow_index + ");", 100 * trans_time);
	}
}	
	
//###################################################################################
//
//###################################################################################
	
if (typeof(preload_imgs_a) == "undefined")	
	preload_imgs_a = Array();	
	
function preload(img_url) {

	
	var pos = preload_imgs_a.length;
	preload_imgs_a[pos]=new Image();
	setTimeout('preload_imgs_a['+pos+'].src = "' + img_url + '";', 1 + pos);

}	

//###################################################################################
//
//###################################################################################

function unborder_flash() {

	var theObjects = document.getElementsByTagName("object"); 
	
	for (var i = 0; i < theObjects.length; i++) 
	{ 
		theObjects[i].outerHTML = theObjects[i].outerHTML; 
	}
}
	
//###################################################################################
//
//###################################################################################
	
	

