

function GBI(obj)
{
  return document.getElementById(obj); 
}

/*
*  funkcie na nastavenie zisteie cookies
*/
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

/** 
 *  Presmeruvava na vybranu sekciu.
 *  Vyuziva sa v hornej navigacii so select boxom.
 */
function changeSection(host) 
{
	box=document.forms["sections_nav"].section;
	destination=host+"/vyhladavanie?keyword="+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}
function changeSection2(host) 
{
	box=document.forms["special_section"].section;
	destination=host+"/"+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}		  
/**
 *  Meni formular medzi instituciou a osobu-pri kto je kto
 */
function changeForm(host)
{
	box=document.forms['ipform'].ftype;
	destination=host+box.options[box.selectedIndex].value;
	if (destination) location.href=destination;
}
/**
 *  Meni adresu pri vybrani sortovanie clankov alebo eventov z nejakej sekcie.
 *  Vyuziva sa koli zmene partnerov na pravo, aby sa zobrazili partnery vybranej sekcie.
 */
function filterButtonChange(host)
{
	box=document.forms['navigation'];		  
	if (box) {
  	asection=box.asection.value;
  	type=box.atype.value;
  	section=box.section.options[box.section.selectedIndex].value;
  	mounth=box.mounth.options[box.mounth.selectedIndex].value;
  	year=box.year.options[box.year.selectedIndex].value;
  	if (section == "") {
  		section="all";
  	}			  
    if (asection == "agenda") {
      destination=host+"/"+asection+"/"+section+"/"+mounth+"/"+year;
    } 
    else {
  	  if (section == "all") {
         destination=host+"/"+"archiv"+"/show/"+type+"/"+section+"/"+mounth+"/"+year 
 			} 
 			else {
          destination=host+"/"+"archiv"+"/show/"+type+"/"+section+"/"+mounth+"/"+year
  		}
  	}
  	if (destination) location.href=destination;
	}
}
/**
 * Prida stranku do oblubenych
 */
function addToFavourites(site,title)
{
if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, site,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( site, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
/*
  NS4=(document.layers) ? 1 : 0;
  IE4=(document.all) ? 1 : 0;
  if (IE4 && !NS4) {	
    window.external.AddFavorite(site,title);
  }
	else {	
    alert('Pre túto službu musíte mať Internet Explorer 5.0 alebo vyšší');
	}
*/
}
		  
function findPosY(obj)
{
  var curtop=0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curtop += obj.offsetTop
      obj=obj.offsetParent;
	 }
	}
	else if (obj.y)
    curtop += obj.y;
	return curtop;
}

function findPosX(obj)
{
  var curleft=0;
  if (obj.offsetParent) {
    while (obj.offsetParent) {
      curleft += obj.offsetLeft
		  obj=obj.offsetParent;
		}
	}
	else if (obj.x)
    curleft += obj.x;
	return curleft;
}
/**
 *  Zobrazuje a skryva element.
 */
function showTable(table, linka) {
  t=document.getElementById(table);
  caption=document.getElementById(table+'_caption');
	link=document.getElementById(linka);
	t.style.left=findPosX(link)+'px' ;
	t.style.top=findPosY(link)+20+'px'; 
	if (t.style.visibility == "visible") {
    t.style.visibility="hidden";
    caption.style.visibility="hidden";
    caption.style.cursor="normal";
	} else {
    t.style.visibility="visible";
    caption.style.visibility="visible";
    caption.style.cursor="move";
	}
}	  
/*
 *  posuvanie tabuliek
 */

var tempY=0;
var tempX=0;
var posY=0;
var posX=0;

var adjuststate=0;
var tempA=0;
var tempB=0;
var tempC=0;
var tempD=0;

var y=0;
var x=0;
var topPos=0;
var leftPos=0;
var offsetPosY=0;
var offsetPosX=0;
var mouseoffset=0;
var mouseoffset2=0;

var curKnownPos=0;
var currentslider=null;


function getMouseXY(e) {		  	
  if(navigator.appName == "Netscape"){
    tempX=e.pageX;
		tempY=e.pageY;
  } else {
    tempX=window.event.clientX+window.document.body.scrollLeft;
		tempY=window.event.clientY+window.document.body.scrollTop;
	}
	if (tempX <= 0) {tempX=0}
  if (tempY <= 0) {tempY=0}
  posX=tempX;
  posY=tempY;
	if (adjuststate == 1) {
    topPos=parseFloat(document.getElementById(currentslider).style.top);
    leftPos=parseFloat(document.getElementById(currentslider).style.left);
		tempB=tempA;
		tempA=posY;
    tempD=tempC;
		tempC=posX;
    mouseoffset=tempB-topPos;
    offsetPosY=posY-mouseoffset;
    mouseoffset2=tempD-leftPos;
    offsetPosX=posX-mouseoffset2;
    y=posY-tempB;
		x=posX-tempD;
		if (y>1) y=1;
		if (y<-1) y=-1;
    document.getElementById(currentslider).style.top=offsetPosY+'px';
    document.getElementById(currentslider).style.left=offsetPosX+'px';
	}
	return true
}
function captureStart(slider, state){
  currentslider=slider;
  adjuststate=state;
  if (adjuststate == 0){
    adjuststate=1;
		tempA=posY;
		tempC=posX;
	} else {
    adjuststate=0;
	}
}

//document.onmousemove=setTimeout("getMouseXY()", 3000);

/*
 *
 *  Zmena velkosti prisma
 *  pouziva sa pri clankoch a roznych detailoch
 *
 */		  
/* aktualny krok pri meneni velkosti */
var actual=1;		  
/* 
 *  pole objektov ktorych velkosti sa menia
 *  0-id objektu
 *  1-zakladna velkost
 *  2-minimalna velkost
 *  3-maximalna velkost
 */
var ch_obj=Array();		  
/**
 * Prida objekt s danymy parametrami k objektom ktorych velkost sa bude menit.
 */
function setRes(id, init, min, max) 
{
	actual=1;
	if (!ch_obj) ch_obj=Array();
	ch_obj[ch_obj.length]=Array(id, init, min, max);
}

/**
 *  Zvecsi alebo zmensi nastavene objekty o danu hodnotu.
 */
function resize(size) 
{
  	actual=actual+size;
	if (!refresh()) actual=actual-size;
	return true;
}
/**
 *  Refreshe na stranke velkosti pouzivanych objektov.
 */
function refresh() 
{
	changed=false; 
	for (i=0; i < ch_obj.length; i++) 
  	{
    	o=document.getElementById(ch_obj[i][0]);
    	init=ch_obj[i][1];
    	min =ch_obj[i][2];
		max =ch_obj[i][3];
		step=ch_obj[i][4];
    	size=init+(actual-1);
		if (size<=max && size>=min) {
		  o.style.fontSize=size+'px';
		  /*
			if (size>140) o.style.lineHeight=1.4;
			else o.style.lineHeight=1.3;
			*/
			changed=true;
		}
	}		  
	return changed;
}
		  
var show=true;

function showWord(pop, anchor) {
  show=true;
  a=document.getElementById(anchor);
  p=document.getElementById(pop);
  p.style.top=findPosY(a)+15+"px";
  p.style.left=findPosX(a)+"px";	  	  
  p.style.visibility="visible";
}
function hideWord(pop) {
  show=false;
  wTimer=window.setTimeout("hm('"+pop+"')",30); 
}		  
function hm(pop) {
  if (!show) {
    p=document.getElementById(pop);
    p.style.visibility="hidden";
	}
}

// rolovanie zoznamu pomocou sipiek 

function scrollForward() {
     
  if(eas_pos < (eas_max-1))
    {       
      var pom = eas_pos - (eas_show-1);
      var past = GBI("bottom" + pom);
      past.style.display='none';
      
      var eas_link_back = GBI("eas_link_back");
      if( (eas_pos+1 - eas_max) == 0 )
      {
        eas_link_back.className = 'unact_prev';
      }
      else
      {
        eas_link_back.className = 'prev';
      }
      
      eas_pos++;
      
      var eas_link_forward = GBI("eas_link_forward");
      if(eas_pos == (eas_max-1)) 
      {      
      eas_link_forward.className = 'unact_next';
      }
      else      
      {
      eas_link_forward.className = 'next';
      }
                  
      var next = GBI("bottom" + eas_pos);
      next.style.display='block';
            
    }  
    else
      {
      var eas_link_forward = GBI("eas_link_forward");
      eas_link_forward.className = 'unact_next';
      } 
           
}


function scrollBack() {
   
  if(eas_pos > (eas_show-1) )
    { 
      
      var pom = eas_pos - (eas_show);      
      var past = GBI("bottom" + pom);
      past.style.display='block';
      
      var next = GBI("bottom" + eas_pos);
      next.style.display='none';
            
      var eas_link_back = GBI("eas_link_back");
      if( (eas_pos - eas_show) == 0 )
      {
        eas_link_back.className = 'unact_prev';
      }
      else
      {
        eas_link_back.className = 'prev';
      }
    
      eas_pos--;
      
      var eas_link_forward = GBI("eas_link_forward");            
      if(eas_pos == (eas_max-1)) 
      {      
      eas_link_forward.className = 'unact_next';
      }
      else
      {
      eas_link_forward.className = 'next';
      }                        
            
    }  
    else
      {
       var eas_link_back = GBI("eas_link_back");
      eas_link_back.className = 'unact_prev';
      } 

}

function eas_init()
{     
  for(i = 0; i < eas_max; i++) {
    eas_block = GBI("bottom"+i);
    if(i < eas_show) {
      eas_block.style.display = 'block';
    }
    else {
     eas_block.style.display = 'none';
    }
  }
      if(eas_max < eas_show)
      {
      var eas_link_forward = GBI("eas_link_forward");
      eas_link_forward.className = 'unact_next';
      } 
}

var agenda_height;
var all_height;
var scroll_konst;
var pom_konst = 22;
var agenda_array = new Array;


function agenda_init(box_height, week_number)
{ 
  agenda_array['top_'+week_number] = 0;
  //alert(agenda_array['top_'+week_number]);
  //alert(week);
  var obj1 = GBI("scroll_week_"+week_number);
  all_height = obj1.offsetHeight;
  
  
  
  var obj2 = GBI("scroll_week_content_"+week_number);
  obj2.style.height = box_height+'px';
  obj2.style.overflow = 'hidden';
  obj2.style.position = 'relative';
  
  var obj3 = GBI("week_"+week_number);
  obj3.style.position = 'absolute';
  
  agenda_top = 0;
  agenda_height = box_height;  
  scroll_konst = 30;
  
  // skryje posuvanie 
  if (all_height < agenda_height) 
  {
    var obj4 = GBI("agenda_prev_"+week_number);
    obj4.style.display = 'none';
    
    var obj5 = GBI("agenda_next_"+week_number);
    obj5.style.display = 'none';    
  }
  
}

function scrollBack_vertical(week_number){
  if(agenda_array['top_'+week_number] <= 0 ) { 
    obj = GBI("agenda_prev_"+week_number);
    obj.className = "agenda_unact_prev";   
  }
  else {  
    agenda_array['top_'+week_number] -= scroll_konst;
    setTop(week_number);
    obj = GBI("agenda_prev_"+week_number);
    obj.className = "agenda_prev";
  }
     
  if(agenda_array['top_'+week_number] < all_height)
  {
    obj = GBI("agenda_next_"+week_number);
    obj.className = "agenda_next";  
  }
}

function scrollForward_vertical(week_number){
  
  
  var pom = parseInt(agenda_array['top_'+week_number]) + parseInt(agenda_height);
  
 // alert(pom);
  //alert( all_height);
  if(parseInt(pom) < all_height)
  {    
    var pom = 0;
    agenda_array['top_'+week_number] += scroll_konst;
    setTop(week_number);
    obj = GBI("agenda_next_"+week_number);
    obj.className = "agenda_next"; 
  } 
  else
  {
    obj = GBI("agenda_next_"+week_number);
    obj.className = "agenda_unact_next";    
  }
  
   if(agenda_array['top_'+week_number] >= 0)
  {        
    obj = GBI("agenda_prev_"+week_number);
    obj.className = "agenda_prev"; 
  }
    
} 

function setTop(week_number)
{
var obj1 = GBI("week_"+week_number);
var pom_top = agenda_array['top_'+week_number];
pom_top = pom_top*(-1)
obj1.style.top = pom_top+"px";
}



function change_article_box(obj)
{
  most_read = GBI("most_read");
  by_editor = GBI("by_editor");
  
  ol_most_read = GBI("ol_most_read");
  ol_by_editor = GBI("ol_by_editor");
  
  object = GBI(obj);

  if(object == most_read)
    { 
      most_read.className = 'sel';
      by_editor.className = '';
      ol_most_read.className = '';
      ol_by_editor.className = 'hdn';      
    }
    else
    { 
      by_editor.className = 'sel';
      most_read.className = '';
      ol_most_read.className = 'hdn';
      ol_by_editor.className = '';      
    }

}

function anchor_eas_light(anchor_eas_i, anchor_eas_limit) {

   for(i = 0; i <= anchor_eas_limit; i++) {
     var anchor_eas = GBI("id_anchor_eas_"+anchor_eas_i+"_"+i);
     anchor_eas.className = 'anchor_other_eas';     
   }
}

function anchor_eas_dark(anchor_eas_i, anchor_eas_limit) {

  for(i = 0; i <= anchor_eas_limit; i++) {
     var anchor_eas = GBI("id_anchor_eas_"+anchor_eas_i+"_"+i);
     anchor_eas.className = '';     
   }
}

function CreateBookmarkLink(url, title) {
/*
title = "EurActiv.sk";
url = "http://www.euractiv.sk";
*/
if (window.sidebar) {
// Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
// IE Favorite
window.external.AddFavorite( url, title);
}
else if(window.opera && window.print) {
// Opera Hotlist
return true; }
}

function check_input(str_default, str_actual, name_id_input) { 
  if(str_actual != '') {
    if(str_default == str_actual) {
      var id_input = GBI(name_id_input); 
    }   
  }
  else {
    var id_input = GBI(name_id_input);
    id_input.value = '';
  }
}

   