﻿function pokaz(blok,td) {
       document.getElementById(blok).style.visibility="visible";
       document.getElementById(td).style.cursor="pointer";
}

function GO(url){
	document.location.href=url;
}

function Browser() {
  var ua,s,i;
  this.isIE=false; this.isOP=false; this.isNS=false;
  this.version=null;
  ua = navigator.userAgent;
  s="Opera";		if ((i = ua.indexOf(s)) >= 0) {this.isOP = true;this.version=parseFloat(ua.substr(i + s.length));return;}
  s="Netscape6/";	if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;this.version = parseFloat(ua.substr(i + s.length));return;}
  s="Gecko";		if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;this.version = 6.1;return;}
  s="MSIE";			if ((i = ua.indexOf(s))) {this.isIE = true;this.version = parseFloat(ua.substr(i + s.length));return;}
}

function GoOf(i){
    document.location.href="oferta.aspx?id="+String(i);
}

// oferta.js //

var scroll=0;
var scrollValue = 0;
var scrollrodzaj=1;
var o_innerWidth = 0;
var gal=document.getElementById("galeria");
var galc=document.getElementById("galContainer");

function scrolldown(i){
	scroll=1;
	scrollrodzaj=i;	
}
function scrollout(){
	scroll=0;	
}
function startscroll(){
	gal=$("galeria");
	galc=$("galContainer");
	var dcx=window.setInterval("step()",50); 

	if (gal != null) {
	    var imags = gal.select('div');
	    var img;

	    var ll = imags.length;
    	
	    if (ll > 0) img = imags[0];

	    o_innerWidth = (ll * (img.getWidth()+10)) - galc.getWidth();
	}

	scrollValue = 0;
}
function step(){
	if (scroll==1){
	    gal=$("galeria");
	    galc=$("galContainer");
	    	    
	    scrollValue += scrollrodzaj;
	    
	    var imags = gal.select('div');
	    var img;

	    var ll = imags.length;
    	
	    if (ll > 0) img = imags[0];

	    o_innerWidth = (ll * (img.getWidth()+10)) - galc.getWidth();

	    if (scrollValue < 0) scrollValue = 0;
	    
	    if (scrollValue*20 > o_innerWidth) {
	        if (scrollValue*20 > img.getWidth()) {
	            scrollValue = o_innerWidth/20;
	        } else {
	            scrollValue = 0;
	        }
	    }

	    gal.style.marginLeft = -scrollValue*20 + "px"	 
	}
}

function Taba(i,prefix){
	if (!prefix)prefix="";
	var x=document.getElementById(prefix+"tab"+String(i));
	if (x.style.display!="block"){x.style.display="block"} else {x.style.display="none"};
}
function Pokaz(o){
	var x=document.getElementById(o);
	if (x.style.display!="block"){x.style.display="block"} else {x.style.display="none"};
	$(o).scrollTo();
}
function Big(i){
	window.open("virgobig.ashx?"+String(i));

}
function OpenMap(i){
	var de=window.open("mapa.aspx?id="+i,"","width=600,height=400");
}

function ShowPrint(url){
	var w=window.open(url,"","width=800,scrollbars=yes,resizable=yes,menubar=yes ");
}

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('Map');
    hideTab('Form');
}

function showTab($tabId) {
    hideTabs();
    document.getElementById('ctl00_cntMain_div' + $tabId).style.display = "block";
    document.getElementById('ctl00_cntMain_div' + $tabId).attributes["class"] = "selected";
}

function GAL_Decoder(tekst) {

    tekst = tekst.replace("_", " ");
    
    tekst = tekst.gsub("#1#", "ę");
    tekst = tekst.gsub("#2#", "ą");
    tekst = tekst.gsub("#3#", "ó");
    tekst = tekst.gsub("#4#", "ś");
    tekst = tekst.gsub("#5#", "ć");
    tekst = tekst.gsub("#6#", "ź");
    tekst = tekst.gsub("#7#", "ż");
    tekst = tekst.gsub("#8#", "ń");
    tekst = tekst.gsub("#9#", "ł");
    
	tekst = tekst.gsub("#01#", "Ę");
    tekst = tekst.gsub("#02#", "Ą");
    tekst = tekst.gsub("#03#", "Ó");
    tekst = tekst.gsub("#04#", "Ś");
    tekst = tekst.gsub("#05#", "Ć");
    tekst = tekst.gsub("#06#", "Ź");
    tekst = tekst.gsub("#07#", "Ż");
    tekst = tekst.gsub("#08#", "Ń");
    tekst = tekst.gsub("#09#", "Ł");

    return tekst;
}
    
// ================================= Obsługa onEnter dla całego serwisu ========================= //
    
var KeyID = 0;

document.onkeydown = KeyCheck;       

function KeyCheck(e) {
   KeyID = getEventKeyCode(e);
      
   var inpClass = getEventTarget(e).className;
   if (KeyID == 13) {
      switch(inpClass) {
        case "frmPanelLogowanie":
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cntFormularze$LoginForm$frml_btnLogin", "", true, "", "", false, true));
            break;
        case "frmPreLogin":
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cntMainWide$LoginForm$frml_btnLogin", "", true, "", "", false, true));
            break;
        case "frmSzukajWSerwisieSzablon":
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$cntFormularze$lbSzukajWSerwisie_Submit', '', true, '', '', false, true))
            break;
        case "frmSzukajWSerwisieIndex":
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$cntMain$lbSzukajWSerwisie_Submit', '', true, '', '', false, true))
            break;
        case "frmSzukajOfertyPoNr":
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$cntFormularze$lbNrOferty_Submit', '', true, '', '', false, true))
            break;
        default:
              if ($('jsDropDownBox').visible()) {
                CloseEngine();
              } else {
                if ($('wyszukiwarkaAdvPanelBox') != null) {
                    __doPostBack('ctl00$cntKalkulatory$WebWyszukiwarkaAdv$wysz_submit','');
                } else {
                    __doPostBack('ctl00$cntWyszukiwarka$WebWyszukiwarka$wysz_submit','');
                }
              }  
      }
   }
}

// ================================= Obsługa onEnter dla całego serwisu ========================= //

function OpenLink(link){
	var w=window.open(link,"","");
}

function InitHeaderMenuElements() {
    if ($$('.headerMenuInner')[0] != null) {      
        var headerMenuInner_Right = 0;
        var headerMenuInner = null;
        
        var ie_shift_left = 0;
        
        var IE6 = (navigator.appVersion.indexOf("MSIE 6.")==-1) ? false : true;
        var IE7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
        
        if (IE7) {
            ie_shift_left = 331;
        } else if (IE6) {
            ie_shift_left = 318;
        }

        $$('.headerMenuElementDropmenu').each(function(e) {           
            headerMenuInner = $$('.'+e.getAttribute('rel'))[0];
            
            headerMenuInner_Right = headerMenuInner.offsetLeft+headerMenuInner.getWidth()+ie_shift_left;

            e.setStyle({'left':headerMenuInner_Right-e.getWidth()+'px'});
        });
    }
}
function ShowHeaderMenuElementDropmenu(id) {
    HideAllHeaderMenuElementDropmenus(id);
    
    if (($$('.idHeaderMenuElement_'+id)[0] != null)&&($$('.headerMenuElementDropmenu_'+id)[0] != null)) {
        switchClass($$('.idHeaderMenuElement_'+id)[0], 'headerMenuElement_Over','headerMenuElement');

        $$('.headerMenuElementDropmenu_'+id)[0].show();
        $$('.headerMenuElementDropmenu_'+id+' input')[0].focus();
    }
}
function HideHeaderMenuElementDropmenu(id) {
    if ($$('.idHeaderMenuElement_'+id)[0] != null) {
        switchClass($$('.idHeaderMenuElement_'+id)[0], 'headerMenuElement','headerMenuElement_Over');
        
        $$('div[rel=headerMenuElement_Active]').each(function(e) {
            switchClass($(e), 'headerMenuElement_Over','headerMenuElement');
        });

        setTimeout(function() {
            $$('.headerMenuElementDropmenu_'+id)[0].hide();
        }, 200);
    }
}
function HideAllHeaderMenuElementDropmenus(id) {
    $$('.headerMenuElementDropmenu').each(function(e) {
        if (!hasClass(e, 'headerMenuElementDropmenu_'+id)) {
            e.hide();
        }
    });
    
    $$('.headerMenuElement_Over').each(function(e) {
        if (!hasClass(e, 'idHeaderMenuElement_'+id)) {
            switchClass($(e), 'headerMenuElement','headerMenuElement_Over');
        }
    });
    
    $$('div[rel=headerMenuElement_Active]').each(function(e) {
        switchClass($(e), 'headerMenuElement_Over','headerMenuElement');
    });
}

var BanerPopUpID = "";

function PokazPopup() {
    if (readCookie("dvpopup_" + BanerPopUpID) != BanerPopUpID) {
        if ($('dvPopUp').innerHTML != "") {
            $('dvPopUp').setStyle({ 'left': (getViewPortSizeX() - $('dvPopUp').getWidth()) / 2 + 'px' });
            $('dvPopUp').setStyle({ 'top': (getViewPortSizeY() - $('dvPopUp').getHeight()) / 2 + 'px' });
            $('dvPopUp').show();

            createCookie("dvpopup_" + BanerPopUpID, BanerPopUpID, 1);
        }
    }
}

function ZamknijPopup() {
    $('dvPopUp').hide();
}
