function swap_top(title, section, dat, img, url, sectionurl, elm) {
	var preview = document.getElementById('top_article_preview');
	if (!preview) return false;

	var titleElm = preview.getElementsByTagName('h2');
	var sectionElm = preview.getElementsByTagName('p');
	var imgElm = preview.getElementsByTagName('img');

	var items = preview.getElementsByTagName('a');
	for (var i = 0, each = null; null != (each = items[i]); i++) {
		each.href = url;
	}


	if (titleElm) titleElm[0].innerHTML = '<a href="' + url + '">' +title + '</a>';
	if (sectionElm) sectionElm[0].innerHTML = '<a href="' + sectionurl + '">' + section + '</a>' + ' <span> | </span>' + dat;
	if (imgElm) {
		imgElm[0].src = img;
		imgElm[0].alt = title;
	}

	var list = document.getElementById('top_article_list');
	if (!list) return false;
	var items = list.getElementsByTagName('li');
	for (var i = 0, each = null; null != (each = items[i]); i++) {
    var tmplink = items[i].getElementsByTagName('a')[0];
	  if (tmplink==elm) elm.className = 'sel';
	  else  tmplink.className = '';
	  if (0==i) each.className = 'first';
	  else 	each.className = '';
	}

	return true;
}

function swap_top_wanda(title, section, dat, img, url, sectionurl, text, foto, video, period, elm, idArticle) {
	var preview = document.getElementById('img_' + period);
	if (!preview) return false;

	var titleElm = preview.getElementsByTagName('h2');
	var sectionElm = preview.getElementsByTagName('h3');
	//var txtElm = preview.getElementsByTagName('p');
	var imgElm = preview.getElementsByTagName('img');
	var bigImg = document.getElementById('bigimg_' + period);
	var linkDetail = document.getElementById('detail_' + period);
	bigImg.href = url;
	linkDetail.href = url;

	var list = document.getElementById('list_' + period);
	if (!list) return false;
	var items = list.getElementsByTagName('li');
	for (var i = 0, each = null; null != (each = items[i]); i++) {
    var tmplink = each.getElementsByTagName('a')[0];
    tmplink.href = url;
	  if (tmplink==elm) {
      each.className = 'sel';
    } else {
      each.className = '';
    }
	}

	if (titleElm) titleElm[0].innerHTML = '<a title="'+ title +'" href="' + url + '">' + title + '</a>';
	spanfoto = ''; spanvideo = '';
	if (foto!='') spanfoto = '<span class="foto"></span><span class="sep"> </span>';
	if (video!='') spanvideo = '<span class="video"></span><span class="sep"> </span>';
	if (sectionElm) sectionElm[0].innerHTML = spanfoto + spanvideo + '<a href="' + sectionurl + '">' + section + '</a>' + '<span class="sep"> </span>' + dat;
	//if (txtElm) txtElm[0].innerHTML = '<a title="'+ title +'" href="' + url + '">' + text + '</a>';
	if (imgElm[0].src) {
		imgElm[0].src = img;
		imgElm[0].alt = title;
	}

	return true;
}

function swap_top2(title, elm) 
{
	var preview = document.getElementById('top_article_preview2');
	if (!preview) return false;

	var titleElm = preview.getElementsByTagName('div');

	
	var tab1 = '<div class="map"><ul class="cesta">	<li class="sel"><a class="link_cesta" onmouseover="swap_top2('+1+', this);" href="#">Naplánovať cestu</a></li><li><a class="link_mapa" onmouseover="swap_top2('+2+', this);" href="#">Nájsť na mape</a></li></ul>	<form target="_blank" id="map_route" action="http://mapy.atlas.sk/" method = "post">	<fieldset>	<label>Od:</label><input type="text" class="input_text" style="margin-bottom:2px" name="start"/><label>Do:</label><input type="text" class="input_text" name="finish"/>				<input type="hidden" name="whatsearch" value="route"/>		<input type="submit" value="vyhladat" class="input_submit"/></fieldset></form></div>';
	var tab2 = '<div class="map">			<ul class="mapa"> 		<li>			<a class="link_cesta" onmouseover="swap_top2('+1+', this);" href="#">Naplánovať cestu</a></li>			<li  class="sel">		 <a class="link_mapa" onmouseover="swap_top2('+2+', this);" href="#">Nájsť na mape</a></li>		</ul> 		 <form target="_blank" id="map_route" action="http://mapy.atlas.sk/" method = "get">			 <input type="hidden" name="whatdisp" value="search"/>				 		 <fieldset>			   <input style="margin-bottom:2px"  type="text" class="input_text map_box" name="phrase"/>			<strong> <div class="map_box" style="font-size:10px;">Zadajte meno mesta, obce, ulice alebo názov hľadanej firmy.</div> </strong>  <div class="search_submit"><input type="submit" value="vyhladat" class="input_submit"/></div>		 </fieldset> </form>		 </div>';	
	
  titleElm[0].innerHTML = tab1;
	if (title == '1') titleElm[0].innerHTML = tab1;
	if (title == '2') titleElm[0].innerHTML = tab2;

	
	return false;
}

function fbs_click(u) {
  t='';
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&#038;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436')
  ;return false;
}

function newWindow2(url, width, height, windowName) {
	var left = (screen.availWidth / 2) - (width / 2);
	var top = (screen.availHeight / 2) - (height / 2);
	var newWindow;

	if(!windowName) {
		var windowName = 'newWindow' + Math.floor(Math.random() * 100);
	}

	newWindow = window.open( url, windowName, 'top=' + top + 'px,left=' + left + 'px,screenX=' + left + 'px,screenY=' + top + 'px,width=' + width + 'px,height=' + height + 'px,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
  if(!document.all)
		newWindow.focus();
	return false;
}




