

/* 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';
    }
    
}

/* wysyła formularz o podanym id */
function submitForm(id) {
	var form;
	if(form = document.getElementById(id)) {
		form.submit();
	}
}

function changeRadioUrl(radio_id) {
	 if (obj2 = document.getElementById(radio_id)) {
	 		var radios = obj2.getElementsByTagName('input');
 	    for(i = 0; i < radios.length; i++) {          
          if(radios[i].checked) {
        	radioValue = radios[i].value;  
          }
      }
	 	  window.location = radioValue;
	 }
}

function changeUrl(selectId) {
  var selectObj;
  if (selectObj = document.getElementById(selectId)) {
    location.href = selectObj.options[selectObj.selectedIndex].value;
  }
}

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();
}


/* przełączanie wyświetlania elemantu blokowego */
function changeDisplayBlock(id) {
	var block;
	if(block = document.getElementById(id)) {
		if(block.style.display != 'block') {
			block.style.display = 'block';
		} else {
			block.style.display = 'none';
		}
	}
}

/* zastępuje podaną wartość inputa nową wartośćią, jeśli podana jest gwazdka, to zastępuje każdą wartość */
function replaceInputValue(id, valueToReplace, newValue) {
	var input;
	if(input = document.getElementById(id)) {
		if(valueToReplace == '*') {
			input.value = '';
		} else {
			if(input.value == valueToReplace) {
				input.value = newValue;
			}
		}
	}
}


/* 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: search.js */

// Wyszukiwarka, Lukasz Podkalicki dla eol-group.com


var szukacz = {
    // Wyszukiwarka po technologiach
    PREFIX :                        'http://',

    TECHNOLOGY_SEARCH_ID :              'technology_search',
    technology : function() {
        if(obj = document.getElementById(this.TECHNOLOGY_SEARCH_ID)){            
            if((val = obj.options[obj.selectedIndex].value) != 0){
                url = this.PREFIX + document.domain + "/tech/" + val +"/";
                location.href = url;
            }
            else return false;
        }
    },

    BRANDPRODUCTS_SEARCH_ID :           'brandproducts_search',
    brandproducts : function() {
        if(obj = document.getElementById(this.BRANDPRODUCTS_SEARCH_ID)){            
            if((val = obj.options[obj.selectedIndex].value) != 0){
                url = val;
                location.href = url;
            }
            else return false;
        }
    },

    USEPRODUCTS_SEARCH_ID :             'useproducts_search',
    useproducts : function() {
        if(obj = document.getElementById(this.USEPRODUCTS_SEARCH_ID)){            
            if((val = obj.options[obj.selectedIndex].value) != 0){
                url = val;
                location.href = url;
            }
            else return false;
        }
    }
    
} //search

/* javascript file: sideMain2d.js */

var sideMain2d_active = 0;

switch_sideMain2d = function (key) {
    hide_block("sideMainSub_"+sideMain2d_active);
    show_block("sideMainSub_"+key);
    sideMain2d_active = key;
}

init_sideMain2d = function(key){
    sideMain2d_active = key;
}

