function start() {
}

var scroll=0;
var scrollValue = 0;
var scrollrodzaj=1;
var gal=document.getElementById("galeria");

function scrolldown(i){
	scroll=1;
	scrollrodzaj=i;	
}
function scrollout(){
	scroll=0;	
}
function startscroll(){
	gal=document.getElementById("galeria");
	var dcx=window.setInterval("step()",50); 
	
	scrollValue = 0;
}
function step(){
	if (scroll==1){
	    gal=document.getElementById("galeria");
	    
	    scrollValue += scrollrodzaj;
	    
	    if (scrollValue < 0) scrollValue = 0;
	    gal.style.marginLeft = -scrollValue*20 + "px"	 
	}
}

function OpenMap(i){
	var de=window.open("mapa.aspx?id="+i,"","width=600,height=400")
}

function ShowPrint(i){
	var w=window.open("wydruk.aspx?id="+i,"","width=700,scrollbars=yes,resizable=yes,menubar=yes ");
}

function ChangeZak(id) {
    var zidx = 5;
    
    $('zak'+id).style.zIndex = zidx;
    swapClasses($('zak'+id), 'zak','zak_active');
    $('pan'+id).show();
    
    for (var i=1; i<=3; i++) {
        if ('zak'+id != 'zak'+i) {
            zidx -= 1;
            $('zak'+i).style.zIndex = zidx;
            switchClass($('zak'+i), 'zak','zak_active');
            $('pan'+i).hide();
        }
    }               
}

function DodajDoNotatnika(Id, msg) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(","+Id+",") == -1) c += Id+",";
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);
    
    if (msg != "") alert(msg);
}

function UsunZNotatnika(Id, msg, reload) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(","+Id+",") > -1) c = c.replace(Id+",", "");
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);
    
    if (msg != "") alert(msg);
    
    if (reload) {
        document.location.reload(false);
    }
}

function hideTab($tabId) {
    document.getElementById('ctl00_cntMain_div' + $tabId).style.display = "none";
    document.getElementById('ctl00_cntMain_div' + $tabId).className = "";
}
function hideTabs() {
    hideTab('Brief');
    hideTab('Main');
    hideTab('Form');
}
function showTab($tabId) {
    hideTabs();
    document.getElementById('ctl00_cntMain_div' + $tabId).style.display = "block";
    document.getElementById('ctl00_cntMain_div' + $tabId).attributes["class"] = "selected";
}

// ================================= Obsługa onEnter dla całego serwisu ========================= //

var KeyID = 0;

document.onkeydown = KeyCheck;       

function KeyCheck(e) {
   KeyID = getEventKeyCode(e);

   if (KeyID == 13) {
        if ($('WyszukiwarkaMini_Inner') != null) {
           __doPostBack('ctl00$cntWyszukiwarkaMini$wysz_submit','');
        } else if ($('wyszukiwarkaPanel') != null) {
            __doPostBack('ctl00$cntWyszukiwarka$WebWyszukiwarka$wysz_submit','');
        }
   }
}

// ================================= Obsługa onEnter dla całego serwisu ========================= //

function initHints() {
    $$('.qShowHint').each(function(e){
        inp = new Element('input');
        $(e.getAttribute('rel')).insert(inp);
        inp.setAttribute('rel',e.getAttribute('rel'));
        
        $(e.getAttribute('rel')).hide();
        
        $(e.getAttribute('rel')).setStyle({'width': 'auto'});
        $(e.getAttribute('rel')).setStyle({'height': 'auto'});
        
        RegisterEvent(e, 'mouseover', showHint);
    });
}

function showHint(e) {
    var x = MouseX(e);
    var y = MouseY(e);
    
    var a = getEventTarget(e);

    $(a.getAttribute('rel')).show();

    $(a.getAttribute('rel')).setStyle({'left': x-30+'px'});
    $(a.getAttribute('rel')).setStyle({'top': y-$(a.getAttribute('rel')).offsetHeight-20+'px'});
    
    $$('#'+a.getAttribute('rel')+' input')[0].focus();
    
    RegisterEvent($$('#'+a.getAttribute('rel')+' input')[0], 'blur', hintBlur);
}

function hintBlur(e) {
    var inp = getEventTarget(e);
    
    $(inp.getAttribute('rel')).hide();
}

initHints();
