

/* javascript file: flexiweb.js */

/**
*   Bibliotek funkcji JS dla FlexiWeb
*
*/

function init() {
    obj=document.getElementsByTagName('a');
    if(obj) {
        for(i=0;i<obj.length;i++){
            //alert(obj[i].href);
            //obj[i].onfocus = new Function("return false");
            if(obj.addEventListener)
                obj.addEventListener('focus',blur());
            else if(obj.attachEvent)
                obj.attachEvent('onfocus',blur());
            else
                obj.onfocus=blur;
        }
    }
}

function setCookie(name, value, expires, path, domain, secure){
//ustawia cookie
    var d=new Date();
    dat=new Date(d.getTime() + expires*1000);
    var cookieString = name + "=" +escape(value) + 
        ((expires) ? ";expires="+dat : "") +
               ( (path) ? ";path=" + path : "") +
               ( (domain) ? ";domain=" + domain : "") +
               ( (secure) ? ";secure" : "");
        document.cookie = cookieString;
    }

function getCookie(name){
//pobiera cookie
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
    }

function delCookie(name,path,domain) {
//usuwa cookie
       if (getCookie(name)) document.cookie = name + "=" +
      ( (path) ? ";path=" + path : "") +
      ( (domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function create_pass(id_source, id_target) {
// pobiera string z id_source, hashuje z id sesji, zapisuje do id_target
    var hashed_pass = hex_sha1(document.getElementById(id_source).value);
    var sesid       = getCookie('SID');
    document.getElementById(id_target).value = hex_sha1(sesid+hashed_pass);
}

function email_decoding(fun)
/*
* Funkcja wyszukuje na calej stronie zakodowane adresy e-mail w znacznikach <span class="email_conv"></span>
* Nastepnie kazdy zakodowany adres poddaje obrobce funkcja o nazwie zawartej w parametrze fun.
* Funkcja fun musi przyjmowac jako parametr string bedacy zakodowanym adresem e-mail i zwraca string bedacy adresem odkodowanym.
*/
{
    if(fun==undefined)
        fun="toAscii";

    var i,
        span=document.getElementsByTagName('span');

    for(i=0;i<span.length;i++)
        if(span[i].className.match(/(^|\s)email_conv(\s|$)/))
        {
            span[i].innerHTML=eval(fun+"('"+span[i].innerHTML+"');");
				span[i].style.display='inline';
        }
}

function toAscii(code)
/*
* Funkcja zamienia kodowany (funkcja php toPseudoAscii()) e-mail z parametru code na odkodowany w encjach html, a na koncu go zwraca.
*/
{
    decode="";
    for(var j=0;j<code.length;j+=3)
        decode=decode+"&#"+code.substr(j,3)+";";
    return decode;
}

function openPopupWindow(id,w_href,w_width,w_height)
{
    window.open(w_href,'Image_'+id, 'scrollbars=yes,menubar=no,status=no,location=no,top=200,left=200,width='+(w_width+20)+',height='+(w_height+20));
}

show_block = function (block_id) {
    if (obj = document.getElementById(block_id)) {
        obj.style.display= 'block';
    } 
}

show_linear = function (block_id) {
    if (obj = document.getElementById(block_id)) {
        obj.style.display= 'inline';
    }
}

hide_block = function (block_id) {
    if (obj = document.getElementById(block_id)) {
        obj.style.display= 'none';
    }
    
}
function submit_search(id)
{
	if(document.getElementById(id))
    {
        document.getElementById(id).submit();
    }
}

function openPopUp(url,windowName)
{
    window.open(url,windowName,'scrollbars=yes,menubar=no,status=no,location=no,top=50,left=50,width=760,height=500,resizable=no');
}

window.onload = function() {
    email_decoding();
}


/* javascript file: hide_show.js */

var  actTab = 0;
var tabs = {
    version:            '2007.04.27',

    // const
    CONTAINER_ID:       'tabs_container',
    PRFX:               'tab_',
    PRFX_MIN:           'tabmin_',
    START_TAB :         1,
    CNT :               0,

    setup: function(count) {
        tabs.CNT=(count > 0 ? count : 0);
        tabs.set(tabs.START_TAB);
    },

    set: function(tab) {
       if(
            actTab>0        &&
            (tab>0)         && 
            (tab<=tabs.CNT)
            ) {
            tabs.unset(actTab);
        }
        // podmiana styli
        try {
            var obj=document.getElementById(tabs.PRFX + tab);
            var mobj=document.getElementById(tabs.PRFX_MIN + tab);
            if(obj){
                //obj
                mobj.className = "selected";
                obj.style.display = "block";
                actTab = tab;
           }
        }
        catch(e){
            return false;
        }
    },

    unset: function(tab) {
        if(
            (tab>0)         && 
            (tab<=tabs.CNT)
            ){
            // podmiana styli
            try {
                var obj=document.getElementById(tabs.PRFX + tab);
                var mobj=document.getElementById(tabs.PRFX_MIN + tab);
                if(obj){
                    //obj
                    mobj.className = "";
                    obj.style.display="none";
                }
            }
            catch(e){
                return false;
            }
        }
    }
}



/* javascript file: voting.js */

document.getElementsByClassName = function(className, parentElement) {
  if (typeof parentElement == 'string'){
    parentElement = document.getElementById(parentElement);
  } else if (typeof parentElement != 'object' ||
             typeof parentElement.tagName != 'string'){
    parentElement = document.body;
  }
  var children = parentElement.getElementsByTagName('*');
  var re = new RegExp('\\b' + className + '\\b');
  var el, elements = [];
  var i = 0;
  while ( (el = children[i++]) ){
    if ( el.className && re.test(el.className)){
      elements.push(el);
    }
  }
  return elements;
} 

function MRU() {}

MRU.prototype.count = function() {
    check_objs = document.getElementsByClassName('checkbox');    

    count = 0;
    for(i in check_objs) {
        if(check_objs[i].checked) {
            count++;
        }    
    }
    return count;
}


MRU.prototype.check = function() {
    count = this.count();
    vc = document.getElementById('vCount');
    if(vc) {
        vc.innerHTML = count;

        if (count == 12) {
            vc.style.color = '#b29217';
            vc.style.fontWeight = 'bold';
        } else {
            vc.style.color = '#cec5be';
            vc.style.fontWeight = 'normal';
        }
    }
}


MRU.prototype.voteCount = function() {
    count = this.count();
    return count == 12;
}

mru = new MRU();
