
/**
 * domyslne wartosci
 */
var polecaneAutoSliderPlay = 1;
var polecaneAutoSliderPause = 0;

var topProduktyAutoSliderPlay = 1;
var topProduktyAutoSliderPause = 0;

function show_popup(url) {
	var width = 520;
	var height = 680;
	var left = (screen.width - width)/2;
	var top = 8;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', toolbar=no';
	params += ', menubar=no';
	params += ', location=no';
	params += ', personalbar=no';
	params += ', scrollbars=yes';
	params += ', directories=no';
	params += ', status=no';
	params += ', resizable=no';

	window.open(url,'popup', params);
	return true;
} // function

/* scoring begin -mg */

	function scoringInit() {
		if ( document.getElementById("frmtk:porowanieIndywidualne:1")!=null) {  
			if ( document.getElementById("frmtk:porowanieIndywidualne:1").checked == true) {
				showScoring();
			} else {
				hideScoring();
			}
			
			pytanie9click();
	
			document.getElementById("frmtk:porowanieIndywidualne:0").onclick = hideScoring;
			document.getElementById("frmtk:porowanieIndywidualne:1").onclick = showScoring;
//			document.getElementById("porownanieIndywidualne:close").onclick = hideScoring;
			if(document.getElementById("frmtk:kredytKiedykolwiek")) {
                            document.getElementById("frmtk:kredytKiedykolwiek").onclick = pytanie9click;
                            document.getElementById("frmtk:kredytKiedykolwiek").onchange = pytanie9click;
                        }                         
		}		
                
                $('#quickSearchLink').hide();
//                $('#scoring').hide();                
	}
					
	
	function showScoring() {
		hElem(['compareButton1']);
		sElem(['scoring']);
                hElem(['quickSearchButton']);
                sElem(['quickSearchLink']);
		document.getElementById("frmtk:porowanieIndywidualne:0").checked = false;
		document.getElementById("frmtk:porowanieIndywidualne:1").checked = true;                 
	}
	
	function hideScoring() {
		sElem(['compareButton1']);
		hElem(['scoring']);
                sElem(['quickSearchButton']);
                hElem(['quickSearchLink']);
		document.getElementById("frmtk:porowanieIndywidualne:0").checked = true;
		document.getElementById("frmtk:porowanieIndywidualne:1").checked = false;
	}

	function pytanie9click() {				
		if ( document.getElementById("frmtk:kredytKiedykolwiek").selectedIndex == 1) {
			pytanie9tak();
		} else if ( document.getElementById("frmtk:kredytKiedykolwiek").selectedIndex == 2) {
			pytanie9nie();
		} else {
			hElem(['pytanie10WyborTak','pytanie11WyborTak','pytanie12WyborTak','pytanie13WyborTak','pytanie14WyborTak','pytanie15WyborTak','pytanie16WyborTak','pytanie17WyborTak','pytanie18WyborTak']);
			hElem(['pytanie19WyborNie','pytanie20WyborNie','pytanie21WyborNie','pytanie22WyborNie',]);
		}		
	}
						
	function pytanie9tak(){
		sElem(['pytanie10WyborTak','pytanie11WyborTak','pytanie12WyborTak','pytanie13WyborTak','pytanie14WyborTak','pytanie15WyborTak','pytanie16WyborTak','pytanie17WyborTak','pytanie18WyborTak']);
		hElem(['pytanie19WyborNie','pytanie20WyborNie','pytanie21WyborNie','pytanie22WyborNie',]);
	}
	
	function pytanie9nie(){
		hElem(['pytanie10WyborTak','pytanie11WyborTak','pytanie12WyborTak','pytanie13WyborTak','pytanie14WyborTak','pytanie15WyborTak','pytanie16WyborTak','pytanie17WyborTak','pytanie18WyborTak']);
		sElem(['pytanie19WyborNie','pytanie20WyborNie','pytanie21WyborNie','pytanie22WyborNie',]);
	}




/* scoring end -mg */ 





function hElem(options){
  $.each(options,function(i,e){
  $('#'+e).hide();
  });
  hideTooltip();
    return false;
}

function sElem(options) {
  $.each(options,function(i,e){
  $('#'+e).show();
  });
    return false;
}

function closeHelp(){
    $('#help-box').fadeOut(300);
    $('#shimm').fadeOut(300);
    return false;
}

function toggleTooltip(e){

  var p_t = $(this).offset().top - 4;// -$('#help-box'). ;
  var p_l = $(this).offset().left - $('#help-box').width() - 13;
  var left = false;
if($('#col-left').offset().left > p_l)
  {
    p_l = p_l + $('#help-box').width() + 26;
    $('#help-box').addClass('lft');
    left = true;
  } else {
    $('#help-box').removeClass('lft');
   left = false;
    }
  var vhtml = $(this).children().filter('dfn').html();
  var vi = $('#help-box').is(':visible');
  if (vi) {
    $('#help-box').fadeOut(300, function(){
      $('#hb-content').html(vhtml);
      $('#help-box').css('top',( p_t ) );
      $('#help-box').css('left',( p_l ) );
      $('#help-box').fadeIn(300);
      $('#shimm').css('top',p_t);
      if(left == true) {p_l += 13;}
      $('#shimm').css('left',p_l);
      $('#shimm').css('height',$("#help-box").height());
      $('#shimm').fadeIn(300);
  });
  } else {
    $('#hb-content').html( vhtml);
    $('#help-box').css('top',( p_t ) );
      $('#help-box').css('left',( p_l ) );
    $('#help-box').fadeIn(300);
      $('#shimm').css('top',p_t);
      if(left == true) {p_l += 13;}
      $('#shimm').css('left',p_l);
      $('#shimm').css('height',$("#help-box").height());
      $('#shimm').fadeIn(300);
  }
  return false;
}

function hideTooltip(){

  var vi = $('#help-box').is(':visible');
  if (vi) {
    $('#help-box').fadeOut(300);
      $('#shimm').fadeOut(300);
    }
    return false;
}

function initTooltips(){
  $('.info').each(function(index,item){
      $(item).removeClass('info');
      $(item).addClass('jsinfo');
      $(item).removeAttr('href');
      $(item).click(toggleTooltip);
   //   $(item).children().filter('dfn').end().append('<a class="close-tooltip">zamknij</a>');
    });
      if($.browser.msie && $.browser.version == '6.0' && !$("#shimm").is("iframe"))
      {
      $("#help-box").after('<iframe id="shimm" ></iframe>');
      }
  $('#help-close').click(closeHelp);
}

function dictWord(){
  //if(typeof(ld) === 'undefined') ld = false;
  //if(!ld) window.location.reload();
  var tab_pos = "ABCDEFGHIJKLMNOPRSTUWZ";
  l = tab_pos.indexOf(location.href[location.href.indexOf('#')+1].toUpperCase());
  $('#dictionary-list').tabs('select',l);
  //$('#dictionary-list li a').;
  //$('#voc_listing').tabs('select',1);
//alert(location.href.substring(location.href.indexOf('#')+1, location.href.length));
 // $(...).scrollTo($(location.href.substring(location.href.indexOf('#')+1, location.href.length)),0);
  return false;
}

function loadjavascript() {
  $('input[type=text]').each(function(index,item){
    $(item).addClass('input-text');
  });
  $('input[type=radio]').each(function(index,item){
    $(item).addClass('input-radio');
  });
    // inicjalizacja podpowiedzi
  initTooltips();  
  $('.tabs').tabs();

  $('#short-news').show();
  $('ul#news-go').newsticker();

  if(location.href.indexOf('slownik') > -1 ){
    $('#dictionary-list').tabs();
    if(location.href.indexOf('#') > -1){
      dictWord();
    }
  }
  
  //inicjalizacja formatki scoringu -mg
  scoringInit();
}

// kalk scoring indywidualny
$('#porownanieIndywidualneSwitcher').click( function() {
    showScoring();
    return false;
});


/* BEGIN: Tooltips by Bilbo. */
function BTHHideHelpBox(anEvent) {
	var myHB = $("#bth-hb");
	if (myHB != null) {
		if (myHB.is(":visible")) {
			myHB.fadeOut(300);
		} // eof if()
	} // eof if()
	
	return false;
} // eof BTHHideHelpBox()

function BTHSetupHelpBoxForElement_(anElement) {
	var myHB = $("#bth-hb");
	
	if ((myHB != null) && (anElement != null)) {
		var myTop = $(anElement).offset().top;
		var myLeft = $(anElement).offset().left;
		var myHeight = 0;
		var myHtml = $(anElement).children().filter("dfn").html();
		var myHelper = $("#bth-hb-helper");
		
		$("#bth-hb div.content").html(myHtml);
		myHelper.html(myHtml);
		myHeight = parseInt(myHelper.height()) + 59;
		myHB.css("left", myLeft + 16 + 8);
//                myHB.css("left", (myLeft + 16 + 8) - 163); // modified by lw@gre.pl @ 2009.11.19
		myHB.css("top", myTop - myHeight + 8);
	} // eof if()
} // eog BTHSetupHelpBoxForElement_()

function BTHShowHelpBox(anEvent) {
	var myHB = $("#bth-hb");
	
	if (myHB != null) {
		if (myHB.is(":visible")) {
			var myElement = this;
			myHB.fadeOut(300, function() {
				BTHSetupHelpBoxForElement_(myElement);
				myHB.fadeIn(300);
			});
			return false;
		} // eof if()
		
		BTHSetupHelpBoxForElement_(this);
		myHB.fadeIn(300);
		return false;
	} // eof if()
} // eof BTHShowHelpBoxForElement_()

function BTHInitToolTips() {
	$('.info').each(function(index,item){
		$(item).removeClass("info");
		$(item).addClass("jsinfo");
		$(item).removeAttr("href");
		$(item).click(BTHShowHelpBox);
	});
	$("#bth-hb-close-button").click(BTHHideHelpBox);
	// if($.browser.msie && $.browser.version == '6.0' && !$("#shimm").is("iframe")) {
	// 	$("#bth-hb").after('<iframe id="shimm" ></iframe>');
	// } // eof if()
} // eof BTHInitToolTips()

function BTHInitAjaxToolTips() {
	$('#bth-sprawdz-szanse div.form-container a.info').each(function(index,item){
		$(item).removeClass("info");
		$(item).addClass("jsinfo");
		$(item).removeAttr("href");
		$(item).click(BTHShowHelpBox);
	});                 
} // eof BTHInitAjaxToolTips()
/* END: Tooltips by Bilbo. */

/* BEGIN: Functions by Bilbo. */
function BTHCalcShowNextStep() {
	var myBox = $("#scoring");
	
	if (myBox.is(":visible") == false) {
		myBox.css("display", "block");
	} // eof if()
} // eof BTHCalcShowNextStep()
/* END: Functions by Bilbo. */

// (+) added by lw@gre.pl @ 2009.10.23 | powered by Bilbo
function ScoringInitAjaxToolTips() {
    $('#scoring a.info').each(function(index,item){
        $(item).removeClass("info");
        $(item).addClass("jsinfo");
        $(item).removeAttr("href");
        $(item).click(BTHShowHelpBox);
    });                 
} // eof ScoringInitAjaxToolTips()
// (+)

/*
 * ************************************
 * Kod obslugujacy zakladki w Slowniku
 */

function dictionaryTabs() {
    // jesli wybrano strone "slownik"
    if(location.href.indexOf('slownik') > -1 ) {
        // akcja domyslna po zaladowaniu strony
        $('#voc_items div').hide(); // ukryj wszystkie zakladki
        $('#A').show(); // pokaz pierwsza zakladke
        $('#A div').show(); // pokaz takze separatory w zakladce

        // jesli w adresie URL znajduje sie kotwica (znak #)
        if(location.href.indexOf('#') > -1) {
            var tab_pos = "ABCDEFGHIJKLMNOPRSTUWZ"; // spis wszystkich zakladek
            // pobierz "id" zakladki URL
            if($.browser.msie && parseInt(jQuery.browser.version) <= 7){                
                l = window.location.href.toString().charAt(window.location.href.toString().indexOf('#')+1);
            } else {
                l = location.href[location.href.indexOf('#')+1].toUpperCase();
            } // eof if()

            // usun podswietlenie wczesniej zaznaczonej zakladki
//            $('#dictionary-list li a').removeAttr('id');
            $('#dictionary-list li a').removeClass('selected');

            // znajdz i dodaj podswietlenie nowo wybranej zakladki
//            $('#dictionary-list li a').find('span:contains('+l+')').parent().attr('id', 'current');
            $('#dictionary-list li a').find('span:contains('+l+')').parent().addClass('selected');

            $('#voc_items div').hide(); // ukryj wszystkie zakladki
            $('#'+l).show(); // pokaz wybrana zakladke
            $('#'+l+' div').show(); // pokaz takze separatory w zakladce
        } // eof if()
    } // eof if()
} // eof function()

/*
 * koniec kodu do obslugi zakladek w Slowniku
 * ******************************************
 */

/*
 * Kod obslugujacy boksy
 */

function boxesManagement() {

    /**
    * Boks - Sprawdz swoja szanse na kredyt
     */
    // przy pierwszym przeladowaniu serwisu ukryj lewy i prawy koniec progressBaru
    $('#bar_tip_left').hide();
    $('#bar_tip_right').hide();
    // pokaz oba konce progressBaru dla kolejnego kroku w boksie
    $('#szansa_data input:image').click(function() {
        $('#bar_tip_left').show();
        $('#bar_tip_right').show();
    });

    /* ************************
     * Boks - waluty i depozyty
     */

    // ukrywanie zakladki z depozytami
    $('#depozyty').hide();

    // obsluga przycisku z depozytami
    $('#depozytySwitch').click( function() {
        // usuniecie podswietlenia ze wszystkich elementow 'li'
        $(this).parent().parent().children().removeAttr('id');
        // dodanie podswietlenia do przycisku wybranej zakladki
        $(this).parent().attr('id', 'current');
        // ukrycie zakladki z walutami
        $('#waluty').hide();
        // wyswietlenie zakladki z depozytami
        $('#depozyty').show();
//        $('#depozyty').fadeIn();

        return false;
    }); // eof click()

    // obsluga przycisku z walutami
    $('#walutySwitch').click( function() {
        // usuniecie podswietlenia ze wszystkich elementow 'li'
        $(this).parent().parent().children().removeAttr('id');
        // dodanie podswietlenia do przycisku wybranej zakladki
        $(this).parent().attr('id', 'current');
        // ukrycie zakladki z depozytami
        $('#depozyty').hide();
        // wyswietlenie zakladki z walutami
        $('#waluty').show();
//        $('#waluty').fadeIn();

        return false;
    }); // eof click()

    /* *******************
     * Boks - top produkty
     */

     // ukrycie wszystkich zakladek
    $('#top_produkty_wrapper .top_pr_holder').removeClass('hide_it');
    $('#top_produkty_wrapper .top_pr_holder').not('#topGotowka').hide();

    // obsluga linkow do zakladek w boksie "Top produkty"
    $('#top_pr_menu li a').click( function(event, triggered) {
        
        if(!triggered) {
            topProduktyAutoSliderPlay = 0;
        } // eof ()
        
        // usuniecie podswietlenia ze wszystkich zaznaczonych linkow
        $(this).parent().parent().children().filter('.selected').removeAttr('class');
        // dodanie podswietlenia do linku wybranej zakladki
        $(this).parent().attr('class', 'selected');

        // pobranie "id" zakladki poprzez usuniecie ciagu "Switch" z konca "id" linku
        var tabId = $(this).attr('id').substr(0, $(this).attr('id').length-("Switch".length));
        // usuniecie klasy sluzacej do ukrywania zakladki bez obslugi JS
//        $('#'+tabId).removeClass('hide_it');

        $('#top_produkty_wrapper .top_pr_holder').hide();
        // wyswietlenie wybranej zakladki
        $('#'+tabId).show();
//        $('#'+tabId).fadeIn('slow');

        return false;
    }); // eof click()

     /***********************************************
     * Boks - polecane przez analityków finansowych
     */
    // usuniecie z kazdego klipu klasy "hide_it"
    $('#reco_wrapper .reco_container').removeClass('hide_it');
    // ukrycie klipow poza pierwszym klipem
    $('#reco_wrapper .reco_container').not(':first').hide();
    // ukrycie guzika do przewijania klipow w lewo
//    $('#reco_wrapper .reco_container .reco_category_wrapper .polecane_button_prev img').hide();

    // nazwy atrybutow "id"
    var polecaneSwitcherCurrentId = 'polecane_switcherCurrent';
    var polecaneClipCurrentId = 'polecaneCurrent';           

    $('#polecane_switcher li a').click( function(event, triggered) {
        
        if(!triggered) {
            polecaneAutoSliderPlay = 0;
        } // eof ()

        if(! $(this).is('#'+polecaneSwitcherCurrentId)) {
            $(this).parent().parent().find('li a').removeAttr('id');
            $(this).attr('id', polecaneSwitcherCurrentId);

            var index = $('#polecane_switcher li a').index(this);

            $('#reco_wrapper .reco_container').hide().removeAttr('id');
            $('#reco_wrapper .reco_container').eq(index).attr('id', polecaneClipCurrentId).show();
        } // eof if()
        return false
    });        

    $('#reco_wrapper .reco_container .reco_category_wrapper .polecane_button_prev').click( function(event, triggered) {
//        var currentClip = $(this).parent().parent().children('.reco_container');
        var currentClip = $('#'+polecaneClipCurrentId);
        
        if(!triggered) {
            polecaneAutoSliderPlay = 0;
        } // eof ()

        if(currentClip.prevAll().filter('.reco_container').length > 0) {
            // wyswietlenie guzika dzialajacego w przeciwnym kierunku
//            $(this).parent().prev.children('.polecane_button_next').children('img').show();

            currentClip.parent().children('.reco_container').hide().removeAttr('id');
            currentClip.prev().removeClass('hide_it').attr('id', polecaneClipCurrentId).show();

            var currentSwitcher = $('#'+polecaneSwitcherCurrentId);
            currentSwitcher.removeAttr('id');
            currentSwitcher.parent().prev().children('a').attr('id', polecaneSwitcherCurrentId);
        } else {
            $(this).children('img').hide();
        } // eof if()

        return false;
    });

    $('#reco_wrapper .reco_container .reco_category_wrapper .polecane_button_next').click( function(event, triggered) {
//        var currentClip = $(this).parent().parent().children('.reco_container');
        var currentClip = $('#'+polecaneClipCurrentId);
        
        if(!triggered) {
            polecaneAutoSliderPlay = 0;
        } // eof ()

        if(currentClip.nextAll().filter('.reco_container').length > 0) {
            // wyswietlenie guzika dzialajacego w przeciwnym kierunku
//            $(this).parent().children().filter('.polecane_button_prev').children('img').show();

            currentClip.parent().children('.reco_container').hide().removeAttr('id');
            currentClip.next().removeClass('hide_it').attr('id', polecaneClipCurrentId).show();

            var currentSwitcher = $('#'+polecaneSwitcherCurrentId);
            currentSwitcher.removeAttr('id');
            currentSwitcher.parent().next().children('a').attr('id', polecaneSwitcherCurrentId);
        } else {
            $(this).children('img').hide();
        } // eof if()

        return false;
    }); 
    
    // obsluga boksu "Newsletter"
    $('.news_email').focus(function(event) {
        event.stopPropagation();
        if( $(this).attr('value') == 'Twój adres e-mail' ) {
            $(this).attr('value', '');
        } // eof if()
    });
    
    $('.news_email').blur(function(event) {
        event.stopPropagation();
        if( $(this).attr('value') == '' ) {
            $(this).attr('value', 'Twój adres e-mail');
        } // eof if()
    });

} // eof boxesManagement
/*
 * koniec kodu obslugujacego boksy na stronie glownej
 */

/**
 * Funkcja do obslugi automatycznego przewijania boksu 'Polecane przez analitykow'
 */

function polecaneAutoSlider() {

	return false;
        setTimeout(polecaneAutoSlider, 5000);
        
        if( (polecaneAutoSliderPlay == 0) || (polecaneAutoSliderPause == 1) ) {
            return;
        } // eof if()
    
        var switchers = $('#polecane_switcher li a');
        var nextSwitcher = 0;                             
        var currentSwitcher = $('#polecane_switcherCurrent');
        
        currentSwitcher.removeAttr('id');
        
        if($(switchers).index(currentSwitcher) < switchers.size()-1) {
            nextSwitcher = $(switchers).index(currentSwitcher)+1;
        } // eof if()

        if(nextSwitcher > 0) {            
            currentSwitcher.parent().next().children('a').trigger('click', true);
        } else {
            $('#polecane_switcher li a:first').trigger('click', true);
        } // eof if()                

//        setTimeout(polecaneAutoSlider, 5000);
    };

/**
 * Zarzadzanie zdarzeniami dla aktualnej zakladki boksu "Polecane przez analitykow"
 */
function polecaneAutoSliderEvents() {
    
    /**
     * zatrzymanie przewijania boksu "Polecane przez analitykow"
     * po najechaniu kursora myszki z pola aktualnej zakladki
     */
    $('#polecaneCurrent').mouseover(function(event) {
        event.stopPropagation();
        polecaneAutoSliderPause = 1;
    });

    /**
     * wznowienie przewijania boksu "Polecane przez analitykow"
     * po zjechaniu kursora myszki z pola aktualnej zakladki
     */
    $('#polecaneCurrent').mouseout(function(event) {
        event.stopPropagation();
        polecaneAutoSliderPause = 0;
    });
//    
    setTimeout(polecaneAutoSliderEvents, 5001);

}; // eof polecaneAutoSliderEvents()
    
/**
 * Funkcja do obslugi automatycznego przewijania boksu 'Top produkty'
 */
function topProduktyAutoSlider() {
    
        setTimeout(topProduktyAutoSlider, 5000);
        
        if( (topProduktyAutoSliderPlay == 0) || (topProduktyAutoSliderPause == 1) ) {
            return;
        } // eof if()
        
        var switchers = $('#top_pr_menu li').not('.blnk');
        var nextSwitcher = 0;                             
        var currentSwitcher = $('#top_pr_menu .selected');

        currentSwitcher.removeAttr('class');
        
        if($(switchers).index(currentSwitcher) < switchers.size()-1) {
            nextSwitcher = $(switchers).index(currentSwitcher)+1;
        } // eof if()

        if(nextSwitcher > 0) {            
            currentSwitcher.next().next().attr('class', 'selected');
            currentSwitcher.next().next().children('a').trigger('click', true);
        } else {
            $('#top_pr_menu li a:first').trigger('click', true);
        } // eof if()        

//        setTimeout(topProduktyAutoSlider, 5000);
    };
    
/**
 * Zarzadzanie zdarzeniami dla aktualnej zakladki boksu "Top produkty"
 */
function topProduktyAutoSliderEvents() {
    
    /**
     * zatrzymanie przewijania boksu "Top produkty"
     * po najechaniu kursora myszki z pola aktualnej zakladki
     */
    $('#top_produkty_wrapper .top_pr_holder:visible').mouseover(function(event) {
        event.stopPropagation();
        topProduktyAutoSliderPause = 1;
    });

    /**
     * wznowienie przewijania boksu "Top produkty"
     * po zjechaniu kursora myszki z pola aktualnej zakladki
     */
    $('#top_produkty_wrapper .top_pr_holder:visible').mouseout(function(event) {
        event.stopPropagation();
        topProduktyAutoSliderPause = 0;
    });
    
    setTimeout(topProduktyAutoSliderEvents, 5001);

}; // eof topProduktyAutoSliderEvents()

/**
 * Funkcja do obslugi boksow z przesuwanymi klipami
 * @param currentId Nazwa identyfikatora pierwszego klipu
 */
jQuery.fn.switchBox = function(currentId) {
    // usuniecie klasy "hide_it" ze wszystkich klipow w boksie
    $(this).children('.switch_viewport').children().filter('.switcher_entry').removeClass('hide_it');
    // ukrywanie wszystkich klipow w boxie
    $(this).children('.switch_viewport').children().filter('.switcher_entry').hide();
	//dodanie tymczasowej klasy dla pierwszego elementu
    $(this).children('.switch_viewport').children().filter('.switcher_entry:first').addClass('tmp');
	//pokazywanie drugiego elementu
    $(this).children('.switch_viewport').children().not('.tmp').filter('.switcher_entry:first').show();
		// ukrywanie guzika do przewijania klipow w lewo
		//$(this).children('.switcher_left').children('img').hide();
    //usuniecie tymczasowej klasy tmp
    $(this).children('.switch_viewport').children().filter('.switcher_entry.tmp').removeClass('tmp');

    // obsluga lewego guzika sluzacego do przewijania klipow
    $(this).children().filter('.switcher_left').click( function() {
        // jesli guzik jest niewidoczny wyjdz z funkcji
        if($(this).children('img').is(':hidden')) {
            return false;
        } // eof if()

        // wyswietlenie guzika dzialajacego w przeciwnym kierunku
        $(this).parent().children('.switcher_right').children('img').fadeIn('slow');

        // pobranie aktualnego klipu w boksie po identyfikatorze "currentId"
        var currentClip = $('.switch_viewport .switcher_entry[id="'+currentId+'"]');

        // jesli pozostaly jeszcze klipy do przesuniecia w danym kierunku
        if(currentClip.prevAll().filter('.switcher_entry').length > 0) {
            // usun z aktualnego klipu atrybut "id"
            currentClip.removeAttr('id');
            // dodaj do kolejnego klipu atrybut "id"
            currentClip.prev().attr('id', currentId);
            // ustaw kolejny klip jako klip biezacy
            currentClip = currentClip.prev();
        } // eof if()

        // jesli po zmianie klipu nie pozostalo
        // juz wiecej klipow do przesuniecia w danym kierunku
        if(currentClip.prevAll().filter('.switcher_entry').length == 0) {
            // ukryj guzik do przesuwania klipow w tym kierunku
            $(this).children('img').fadeOut();
        } // eof if()

        // ukryj wszystkie klipy
//        $('.switch_viewport .switcher_entry').hide();
        $(this).parent().children('.switch_viewport').children('.switcher_entry').hide();
        // wyswietl tylko biezacy klip
        currentClip.fadeIn();
        return false;
    });

    // obsluga prawego guzika sluzacego do przewijania klipow
    $(this).children().filter('.switcher_right').click( function() {
        // jesli guzik jest niewidoczny wyjdz z funkcji
        if($(this).children('img').is(':hidden')) {
            return false;
        } // eof if()

        // wyswietlenie guzika dzialajacego w przeciwnym kierunku
        $(this).parent().children('.switcher_left').children('img').fadeIn('slow');

        // pobranie aktualnego klipu w boksie po identyfikatorze "currentId"
        var currentClip = $('.switch_viewport .switcher_entry[id="'+currentId+'"]');

        // jesli pozostaly jeszcze klipy do przesuniecia w danym kierunku
        if(currentClip.nextAll().filter('.switcher_entry').length > 0) {
            // usun z aktualnego klipu atrybut "id"
            currentClip.removeAttr('id');
            // dodaj do kolejnego klipu atrybut "id"
            currentClip.next().attr('id', currentId);
            // ustaw kolejny klip jako klip biezacy
            currentClip = currentClip.next();
        } // eof if()

        // jesli po zmianie klipu nie pozostalo
        // juz wiecej klipow do przesuniecia w danym kierunku
        if(currentClip.nextAll().filter('.switcher_entry').length == 0) {
            // ukryj guzik do przesuwania klipow w tym kierunku
            $(this).children('img').fadeOut();
        } // eof if()

        // ukryj wszystkie klipy
//        alert($(this).parent().children('.switch_viewport').html());
        $(this).parent().children('.switch_viewport').children('.switcher_entry').hide();
        // wyswietl tylko biezacy klip
        currentClip.fadeIn();
        return false;
    });

};


// Main function for JS
function mainJSFunction() {
	// Tracking Code - zachowywanie + przykazywanie do Multileada
	//  - utm_campaign
	//  - utm_source
	//  - utm_medium
	//  - utm_version
	//
	var _utm = { utm_content : "", utm_source : "", utm_medium : "", utm_version : "" }
	
	_utm.utm_source = $.cookie("utm_source");
	_utm.utm_medium =  $.cookie("utm_medium");
	_utm.utm_content = $.cookie("utm_content");
	
	if (getURLParam("utm_source").length > 2) {
	$.cookie("utm_source", getURLParam("utm_source"),  { expires: 7 });
	_utm.utm_source = getURLParam("utm_source");
	}
	if (getURLParam("utm_medium").length > 2) {
	$.cookie("utm_medium", getURLParam("utm_medium"),  { expires: 7 });
	_utm.utm_medium = getURLParam("utm_medium");
	}
	if (getURLParam("utm_content").length > 2) {
	$.cookie("utm_content", getURLParam("utm_content"),  { expires: 7 });
	_utm.utm_content = getURLParam("utm_content");
	}
	//if (console) { console.log("S:"+_utm.utm_source); console.log("M:"+_utm.utm_medium); console.log("C:"+_utm.utm_content); console.log("V:"+_utm.utm_version); } // console.log
	var utm_str = "";
	utm_str += (_utm.utm_source != null ? "utm_source="+_utm.utm_source+"&" : "");
	utm_str += (_utm.utm_medium != null ? "utm_medium="+_utm.utm_medium+"&" : "");
	utm_str += (_utm.utm_content != null ? "utm_content="+_utm.utm_content+"&" : "");

		$("a.popup2").each(function() {
	$(this).attr('href',$(this).attr('href')+utm_str);
	});
		
		$('#nad_czym_wrapper').switchBox('currentObecniePracujemy');
		$('#newsy_f_wrapper').switchBox('currentNews');
		dictionaryTabs();
		BTHInitToolTips()
		
		$("a.popup2").click(function() {
			show_popup($(this).attr('href'));
			return false;
		});
		
		$("a.iframe").not("a.popup2").fancybox({
			'showCloseButton':  true,
			'frameWidth':   696,
			'frameHeight':   600,
			'centerOnScroll': true,
			'padding':  0,
			'overlayColor': '#000',
			'overlayOpacity':   0.4,
			'callbackOnStart': fancyCallbackOnStart,
			'callbackOnClose': fancyCallbackOnClose
		});
	
		$("a.iframe.porownanie").not("a.popup2").fancybox({
			'showCloseButton':  true,
			'frameWidth':   547,
			'frameHeight':   363,
			'centerOnScroll': true,
			'padding':  0,
			'overlayColor': '#000',
			'overlayOpacity':   0.4,
			'callbackOnStart': fancyCallbackOnStart,
			'callbackOnClose': fancyCallbackOnClose
		});
	


		


	// hidden elements
	$('.drop_down_menu').each( function() {
	$(this).hide();
	});
	$('#infoZakladka2').hide();
	$('#infoZakladka3').hide();
	$('#infoZakladka4').hide();

	/*******************************************************************************
	* Nasza opinia
	******************************************************************************/
	$('.kg_our_feedback').hide();
	//$('#opinie_all_show input[type=checkbox]').removeAttr('checked');
	$('#opinie_all_show input#no_wez_poka[type=checkbox]').removeAttr('checked');
	$('#opinie_all_show input#no_wez_poka_promocje[type=checkbox]').removeAttr('checked');

	$('.single_detale_wrap .our_fb_title_container, .single_detale_wrap .our_fb_title_container_long').click( function() {
	var switcher = $(this).find('.our_fb_title ul li a');
	var opinions = $(this).parent().nextAll().filter('.kg_our_feedback');

	BTHHideHelpBox();
	
	if(opinions.is(':hidden')) {
		//switcher.text('ukryj opinie');
		switcher.removeClass('expand');
		switcher.addClass('contract');

		opinions.each( function() {
			$(this).slideDown();
		});           
	} else {
		//switcher.text('nasze opinie');
		switcher.removeClass('contract');
		switcher.addClass('expand');

		opinions.each( function() {
			$(this).slideUp();
		});
	}

	return false;
	});

	// IE 6/7/8 hack for checkbox events
	if ($.browser.msie) {
	$('input:checkbox').click(function () {
		this.blur();
		this.focus();
	});
	} // eof if()
	// eof IE 6/7/8 hack for checkbox events


	//$('#opinie_all_show input[type=checkbox]').change( function() {
	$('#opinie_all_show input#no_wez_poka[type=checkbox]').change( function() {
	var switcher = $('.single_detale_wrap .our_fb_title ul li a');

	BTHHideHelpBox();
	
	if($(this).attr('checked') == true) {
		$('.single_detale_wrap .kg_our_feedback').show();
		//switcher.text('ukryj opinie');
		switcher.removeClass('expand');
		switcher.addClass('contract');
	} else {
		$('.single_detale_wrap .kg_our_feedback').hide();
		//switcher.text('nasze opinie');
		switcher.removeClass('contract');
		switcher.addClass('expand');
	}
	});

	$('#opinie_all_show input#no_wez_poka_promocje[type=checkbox]').change( function() {
		if($(this).attr('checked') == true) {
				$("div.single_detale_wrap").hide();
				$("div.single_detale_wrap:has(p.centered_promotion), div.sponsorowane").show();

				$("div.kk_single_box_wrapper").hide();
				$("div.kk_single_box_wrapper:has(p.centered_promotion), div.sponsorowane").show();
		} else {
				$("div.single_detale_wrap").show();
				$("div.kk_single_box_wrapper").show();
		}
	});


	/*******************************************************************************
	* Nasza opinia - wersja dla kart kredytowych
	******************************************************************************/
	$('.kk_no_wrp').hide();
	$('#kfc_container #opinie_all_show input#no_wez_poka[type=checkbox]').removeAttr('checked');
	$('#kfc_container #opinie_all_show input#no_wez_poka_promocje[type=checkbox]').removeAttr('checked');

	$('.kk_single_box_wrapper .kk_bexp_handler').click( function() {

	var switcher = $(this).find('ul li a');
	var opinions = $(this).parent().nextAll().filter('.kk_no_wrp');

	BTHHideHelpBox();

	if(opinions.is(':hidden')) {
		//switcher.text('ukryj opinie');
		switcher.removeClass('exp');
		switcher.addClass('coll');

		opinions.each( function() {
			$(this).slideDown();
		});
	} else {
		//switcher.text('nasze opinie');
		switcher.removeClass('coll');
		switcher.addClass('exp');

		opinions.each( function() {
			$(this).slideUp();
		});
	}

	return false;
	});

	$('#kfc_container #opinie_all_show input#no_wez_poka[type=checkbox]').change( function() {
	var switcher = $('.kk_single_box_wrapper .kk_bexp_handler ul li a');

	BTHHideHelpBox();

	if($(this).attr('checked') == true) {
		$('.kk_single_box_wrapper .kk_no_wrp').show();
		//switcher.text('ukryj opinie');
		switcher.removeClass('exp');
		switcher.addClass('coll');
	} else {
		$('.kk_single_box_wrapper .kk_no_wrp').hide();
		//switcher.text('nasze opinie');
		switcher.removeClass('coll');
		switcher.addClass('exp');
	}
	});
	// *****************************************************************************


	$('#dictionary-list li a').click( function() {
	document.location.href = $(this).attr('href'); // przepisz "id" zakladki do URL
	// jesli w adresie URL znajduje sie kotwica (znak #)
		if(document.location.href.indexOf('#') > -1) {
		//    if($(this).attr('href').indexOf('#') > -1) {
		//        location.href = $(this).attr('href');
			dictionaryTabs();
			return false; // nie przeladowywuj strony
		} // eof if()
		return true;
		} // eof function()
	);




	/************************************************************************
	************************ Boks - nasze porady ***************************
	***********************************************************************/

	// nazwy parametrow "id"
	var naszePoradyCurrentTitleId = 'naszePorady_currentTitle';
	var naszePoradyCurrentContentId = 'naszePorady_currentContent';

	// ukrywanie wszystkich porad poza pierwsza
	$('#porada_container .porada_title_scroll h3').removeClass('hide_it').not(':first').hide();
	$('#switcher_entry #porada_holder_scroll div').removeClass('hide_it').not(':first').hide();
	// ukrywanie przycisku do przewijania porad w lewo
	$('#porada_prev img').hide();

	// obsluga przycisku do przewijania porad w prawo
	$('#porada_next').click( function() {
	// pobranie aktualnej porady (tytul i zawartosc)
	var currentTitle = $('#'+naszePoradyCurrentTitleId);
	var currentContent = $('#'+naszePoradyCurrentContentId);

	// jesli pozostaly jeszcze jakies porady do wyswietlenia
	if(currentTitle.nextAll().filter('.porada_title').length > 0) {

		// ukrycie przycisku do przewijania porad w przeciwna strone
		$('#porada_prev').children('img').show();

		// operacje usuwania atrybutu "id" z aktualnego tytulu (z ukryciem go)
		// i przypisania go do nastepnego tytulu (z wyswietleniem go)
		currentTitle.removeAttr('id');
		currentTitle.next().attr('id', naszePoradyCurrentTitleId);
		currentTitle.parent().children().hide();
		currentTitle.next().show();

		// operacje usuwania atrybutu "id" z aktualnej porady (z ukryciem jej)
		// i przypisania go do nastepnej porady (z wyswietleniem jej)
		currentContent.removeAttr('id');
		currentContent.next().attr('id', naszePoradyCurrentContentId);
		currentContent.parent().children().hide();
		currentContent.next().show();

		// jesli nastepna porada jest ostatnia - ukrywanie przycisku
		if(currentTitle.next().nextAll().filter('.porada_title').length == 0) {
		$(this).children('img').hide();
		} // eof if()
	} else {

		// gdy nie ma juz zadnych porad do przewijania - ukrywanie przycisku
		$(this).children('img').hide();
	} // eof if() 

	return false;
	});

	// obsluga przycisku do przewijania porad w lewo
	$('#porada_prev').click( function() {
	// pobranie aktualnej porady (tytul i zawartosc)
	var currentTitle = $('#'+naszePoradyCurrentTitleId);
	var currentContent = $('#'+naszePoradyCurrentContentId);

	// jesli pozostaly jeszcze jakies porady do wyswietlenia
	if(currentTitle.prevAll().filter('.porada_title').length > 0) {

		// ukrycie przycisku do przewijania porad w przeciwna strone
		$('#porada_next').children('img').show();

		// operacje usuwania atrybutu "id" z aktualnego tytulu (z ukryciem go)
		// i przypisania go do poprzedniego tytulu (z wyswietleniem go)
		currentTitle.removeAttr('id');
		currentTitle.prev().attr('id', naszePoradyCurrentTitleId);
		currentTitle.parent().children().hide();
		currentTitle.prev().show();

		// operacje usuwania atrybutu "id" z aktualnej porady (z ukryciem jej)
		// i przypisania go do poprzedniej porady (z wyswietleniem jej)
		currentContent.removeAttr('id');
		currentContent.prev().attr('id', naszePoradyCurrentContentId);
		currentContent.parent().children().hide();
		currentContent.prev().show();

		// jesli poprzednia porada jest ostatnia - ukrywanie przycisku
		if(currentTitle.prev().prevAll().filter('.porada_title').length == 0) {
		$(this).children('img').hide();
		} // eof if()
	} else {

		// gdy nie ma juz zadnych porad do przewijania - ukrywanie przycisku
		$(this).children('img').hide();
	} // eof if()

	return false;
	});


	//$('#popupCloser').click( function() {
	////    alert('OK Closer');
	////    $.fn.fancybox.close();
	////    parent.top.$('#fancy_close').trigger('click');
	//
	////$("#popupCloser").bind("click", $.fn.fancybox.close);
	////$('.popupCloser').live('click', $.fn.fancybox.close);
	//
	////   parent.tb_remove();
	////   parent.location.reload(1);
	//   return false;
	//});


	/**
	* crumbpath
	*/
	/*
	$('#breadcrumb li a').mouseover( function() {
		
	var drop_menu = $(this).parent().children('.drop_down_menu');
	
	if(drop_menu.length > 0) { // .length - h4ck4jQuery
	
		var pos = $(this).offset();

		drop_menu.css('margin-left', pos.left-300+'px');
		drop_menu.css('margin-top', pos.top-185+'px');

	//    drop_menu.css('padding-top', 8+'px');
	//    drop_menu.css('margin-left', $(this).offset().left-20+'px');
	//    drop_menu.css('margin-top', $(this).offset().top+'px');

		drop_menu.show();
	} // eof if()
	});
	$('#big_bad_wolf').mouseout( function() {
	$(this).find('#breadcrumb .drop_down_menu').hide();
	});

	$('.drop_down_menu').mouseover( function() {
	$(this).show();
	});
	$('.drop_down_menu').mouseout( function() {
	$(this).hide();
	});
	*/

	$('#breadcrumb li').hover(
		function() { $('.drop_down_menu', this).css('display', 'block'); },
		function() { $('.drop_down_menu', this).css('display', 'none'); }
	);

	/*******************************************************************************
	****************** Boks - informacje szczegółowe *******************************
	*******************************************************************************/
	$('.kh_frame_normal').hide();
	$('#kh_details_bottom').hide();
	$('.show_all').hide();

	// odnośnik górny
	$('#coll_exp li a').click(function() {    
	// inicjacja tool-tipow
		BTHHideHelpBox();
	
		if($('.kh_frame_normal').is(':hidden')) {        

			$(this).text('poka\u017c wszystkie szczegóły');
			$('.kh_frame_expanded').hide();
			$('#kh_expanded_bottom').hide();
			$('.kh_frame_normal').show();
			$('#kh_details_bottom').show();
			$('.show_all').show();

			$(this).parent().removeClass('collapse');
			$(this).parent().addClass('expand');
		} else {

			$(this).text('ukryj szczegó\u0142y');
			$('.kh_frame_normal').hide();
			$('#kh_details_bottom').hide();
			$('.kh_frame_expanded').show();
			$('#kh_expanded_bottom').show();
			$('.show_all').hide();

			$(this).parent().removeClass('expand');
			$(this).parent().addClass('collapse');
		} // eof if()

		return false;
	});
	/*
	$('#coll_exp li a').toggle(function(){
	// inicjacja tool-tipow
	BTHHideHelpBox();
	
	$(this).text('ukryj szczegó\u0142y');
	$('.kh_frame_normal').hide();
	$('#kh_details_bottom').hide();
	$('.kh_frame_expanded').show();
	$('#kh_expanded_bottom').show();

	$(this).parent().removeClass('expand');
	$(this).parent().addClass('collapse');

	return false;
	}, function(){
	// inicjacja tool-tipow
	BTHHideHelpBox();

	$(this).text('poka\u017c wszystkie szczegóły');
	$('.kh_frame_expanded').hide();
	$('#kh_expanded_bottom').hide();
	$('.kh_frame_normal').show();
	$('#kh_details_bottom').show();

	$(this).parent().removeClass('collapse');
	$(this).parent().addClass('expand');

	return false;
	});
	*/

	// odnośnik dolny
	$('.show_all .txt_link a').click(function() {
		// inicjacja tool-tipow
		BTHHideHelpBox();

		//    $(this).text('ukryj szczegó\u0142y');
		$('.show_all').hide();
		$('.kh_frame_normal').hide();
		$('#kh_details_bottom').hide();
		$('.kh_frame_expanded').show();
		$('#kh_expanded_bottom').show();
		$('#coll_exp li a').text('ukryj szczegó\u0142y');
		
		//    $(this).parent().removeClass('expand');
		//    $(this).parent().addClass('collapse');

		return false;
	});

	// link - ukryj wszystkie szczegoly
	$('.hide_all .txt_link a').click(function() {
		// inicjacja tool-tipow
		BTHHideHelpBox();

		//    $(this).text('ukryj szczegó\u0142y');
		$('.show_all').show();
		$('.kh_frame_normal').show();
		$('#kh_details_bottom').show();
		$('.kh_frame_expanded').hide();
		$('#kh_expanded_bottom').hide();
		$('#coll_exp li a').text('pokaż wszystkie szczegó\u0142y');

		return false;
	});

	$('.show_all .txt_link li a').toggle(function(){
	// inicjacja tool-tipow
		BTHHideHelpBox();

		$(this).text('ukryj szczegó\u0142y');
		$('.kh_frame_normal').hide();
		$('#kh_details_bottom').hide();
		$('.kh_frame_expanded').show();
		$('#kh_expanded_bottom').show();

		$(this).parent().removeClass('expand');
		$(this).parent().addClass('collapse');

		return false;
		}, function(){
		// inicjacja tool-tipow
		BTHHideHelpBox();

		$(this).text('poka\u017c wszystkie szczegóły');
		$('.kh_frame_expanded').hide();
		$('#kh_expanded_bottom').hide();
		$('.kh_frame_normal').show();
		$('#kh_details_bottom').show();
		$('.show_all').show();

		$(this).parent().removeClass('collapse');
		$(this).parent().addClass('expand');

		return false;
	});

	/*
	$('#kh_details_box_switcher .element_switch').click( function() {
	// inicjacja tool-tipow
	BTHHideHelpBox();
	
	// pobranie aktualnego indeksu zakladki
	var index = $('#kh_details_box_switcher .element_switch').index(this);

	// ustawianie domyslnego stylu dla wszystkich zakladek
	var tabs = $('#kh_details_box_switcher .element_switch div');    
	tabs.removeClass('switch_on');
	tabs.addClass('switch_off');
	tabs.children('a').removeClass('current');

	// ustawianie styli dla wybranej zakladki
	var children = $(this).children('div');
	children.removeClass('switch_off');
	children.addClass('switch_on');
	children.children('a').addClass('current');

	// wyswietlanie/chowanie zawartosci zakladek
	$('#kh_details_box_wrapper').children('.kh_details_box_container').hide();
	$('#infoZakladka'+(index+1)).show();

	return false;
	});
	*/

	$('#kh_details_box_switcher li').click( function() {
	// inicjacja tool-tipow
		BTHHideHelpBox();
		
		// pobranie aktualnego indeksu zakladki
		var index = $('#kh_details_box_switcher li').index(this);

		// ustawianie domyslnego stylu dla wszystkich zakladek
		$('#kh_details_box_switcher li a').removeClass('switch_on');
		
		$(this).children('a').addClass('switch_on');    

		// wyswietlanie/chowanie zawartosci zakladek
		$('#kh_details_box_wrapper').children('.kh_details_box_container').hide();
		$('#infoZakladka'+(index+1)).show();

		return false;
	});

	/*******************************************************************************
	****************** Profile kredytowe - szczegolowy *****************************
	*******************************************************************************/
	function switchProfilContent( profilName ) {
		$('#profilContents').children().hide();
		switch( profilName ) {
			case 'bdob' : { var divId = '#bdobryContent'; break; }
			case 'dobr' : { var divId = '#dobryContent'; break; }
			case 'pods' : { var divId = '#podstawowyContent'; break; }
			case 'slab' : { var divId = '#slabyContent'; break; }
			default : { var divId = '#podstawowyContent'; }
		} // eof switch()
		$(divId).show();
		$(divId).removeAttr('class');
		$('#cool_profile_selector li a').removeAttr('id');
		$('#cool_profile_selector li .'+profilName).attr('id', 'tab_sel');
	} // eof function()

	$('#cool_profile_selector li').click(function() {
		switchProfilContent( $(this).children('a').attr('class') );
		return false;
	});

	$('#wielka_zla_lista_brrrrr .righty').click(function() {
		if($('#tab_sel').parent().nextAll().length > 0) {
			switchProfilContent( $('#tab_sel').parent().next().children('a').attr('class') );
		} // eof if()    
	});

	$('#wielka_zla_lista_brrrrr .lefty').click(function() {
		if($('#tab_sel').parent().prevAll().length > 0) {
			switchProfilContent( $('#tab_sel').parent().prev().children('a').attr('class') );
		} // eof if()
	});

	// header - selects
	$('#big_bo_backgr').click(function() {

	//    $('#selectProductKalk').trigger('click');
	//    $('#selectProductKalk').size = $('#selectProductKalk').length;
	//    $('#selectProductKalk option').each(function(index, item) {
	//        
	//    });
	//    var select = $(this).find('select');
	//    select.trigger('change');
	//    alert($(this).find('select').html());
	});

	$('.kalkulator_porownanie_right form select').change(function() {$('.kalkulator_porownanie_right form fieldset a').click()});

	if (document.getElementById("select#form1:quickSearch")) document.getElementById("select#form1:quickSearch").onchange = (function() {$('#form1:przelicz_ponownie').click(); alert('test');});
	
	//   (+) mr@gre.pl
	$("#daneOsoboweUl li").each(function(){
		if($(this).find('span').text() != ''){
			if($(this).is(".bg-left")){
				/*alert("test");*/
				$(this).css("background-position", "0px -37px");
			}else{
				$(this).css("background-position", "0px -37px");
			}
			/*$(this).parent().parent().parent().css("background-position", "0px -37px")*/
		}
	});
	
	if(!$("#daneOsoboweCheck1").find("input").attr('checked')) {
		$("#daneOsoboweCheck1").css("background-position", "0px -31px");
	}
	if(!$("#daneOsoboweCheck2").find("input").attr('checked')) {
		$("#daneOsoboweCheck2").css("background-position", "0px -31px");
	}
	
	$("#daneOsoboweKodPocztowy .col2 input, div.select-container.bth-fleft.postKey div input").keyup(function (){
		if($(this).val().length == 2){
			$(this).val($(this).val()+"-");
		}
	});
	
	$("#daneOsoboweTelefon .col2 input, div.phone div input").keyup(function (){
		if($(this).val().length == 3){
			$(this).val($(this).val()+"-");
		}
		if($(this).val().length == 7){
			$(this).val($(this).val()+"-");
		}
	});
	
	//$("#tab1 a, #tab2 a, #tab3 a, #tab4 a").click(function () {
		//alert("tada");
		//setTimeout(format_000_maksKredyt, 5000);
		//setTimeout(format_000_maksRata, 5000);
	//});
	
	/*END*/
	
	
	return true;
	//daneOsoboweSet();
} // eof mainFunction()

// popups - select's hacks for IE6
function fancyCallbackOnStart() {
	if($.browser.msie && parseInt(jQuery.browser.version) < 7){
		$("select[id='frmtk:dokumentyZrodloDochodu']").hide();
		$("select[id='frmtk:dokumentyCelKredytowania']").hide();
		$("select[id='frmtk:okresKredytowania']").hide();
		$("select[id='frmtk:currencyId']").hide();
		$("select[id='frmtk:sort_it_by']").hide();
		$('#scoring select').each(function(index, item) { $(item).hide(); });
	} // eof if
} // eof if

function fancyCallbackOnClose() {
	if($.browser.msie && parseInt(jQuery.browser.version) < 7){
		$("select[id='frmtk:dokumentyZrodloDochodu']").show();
		$("select[id='frmtk:dokumentyCelKredytowania']").show();
		$("select[id='frmtk:okresKredytowania']").show();
		$("select[id='frmtk:currencyId']").show();
		$("select[id='frmtk:sort_it_by']").show();
		$('#scoring select').each(function(index, item) { $(item).show(); });
	} // eof if
} // eof if


// (m) pz@gre.pl
function getURLParam(strParamName, strHref){
	var strReturn = "";
	if (strHref == null) strHref = window.location.href;
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
			if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

// (+) pz@gre.pl
function readGoogleKeyword() {
	var ref = document.referrer;
	//var ref = "http://google.com?q=tani+kredyt+mieszkaniowy+z+niską+ratą";
	if (ref.indexOf("google") < 1) {
		var kw = $.cookie("kw_word");		
		var kw_cid = $.cookie("kw_cid");
		// sprawdzamy czy keyword nalezy do tej kategorii
		//if ($("#doradca-fs .dfs-keyword").attr('id') == kw_cid) 
		return kw;
		return false;
	}
	var kw = getURLParam('q', ref).replace(/\+/gi,' ');
	//var kw_cid = "cid11";
	$.cookie("kw_word", kw,  { expires: 3 });
	//$.cookie("kw_cid", kw_cid,  { expires: 3 });
	return kw;
}
function setDoradcaFSKeyword(title) {
	if (title == null) title = readGoogleKeyword();
	if (title == false) return false;
	$("#doradca-fs .dfs_center").text(title);
	return true;
}

function setDoradcaFSPosition() {
	var pl = $("#center_container:first").offset().left - 159;
	if (pl < -15) {
		$("#doradca-fs").css("display", "none");
	} else {
		$("#doradca-fs").css("display", "block");
		$("#doradca-fs").css("left", pl);
	} //if
	if (pl < -70) {
		$("#wyslij-porownanie").css("right", "-105px");
	} else {
		$("#wyslij-porownanie").css("right", "0px");
	}
}


// DOM Ready = start JS
$(document).ready( function() {    
	
	
	
	mainJSFunction();
	
	scoringInit();
	boxesManagement();
	
	
	$(".calc div.next-step-wrapper a.pager1").click();
	$("#cool_profile_selector a#tab_sel").parent().click();
    
	readGoogleKeyword();
	// (+) pz@gre.pl
	// ustawiamy #doradca-fs 
	if ($("#doradca-fs").length > 0) {
		$("#doradca-fs").css("top", $("h2:first").next().offset().top-22);
		$("#wyslij-porownanie").css("top", $("#doradca-fs:first").offset().top+22+102);
		$("#doradca-fs").hover(function() { $(this).addClass('hover');}, function() { $(this).removeClass('hover');});

// 		$("#doradca-fs").css("top", $(".kg_wyniki:first").offset().top-22);
//		$("#doradca-fs").css("top", $("#doradca-fs:first").offset().top-22);
		$("#doradca-fs").css("cursor", "pointer");
		$("#wyslij-porownanie").hover(function() { $(this).css("right","0px");}, function() { setDoradcaFSPosition(); }  );
		$("#doradca-fs").click(function() { 
			// obliczamy aktualna pozycje boksu
			var dfs_top = $(this).find(".dfs-photo").offset().top;
			var ind = 0;
			//console.log("dfs_top: " + dfs_top);
			$("#big_box_opinie .single_detale_wrap").each( function(i, el) {
				if (dfs_top > $(this).offset().top && dfs_top < $(this).offset().top + $(this).height() ) {
					ind = i;
				}
			}); //each
			// console.log('klikamy na #'+ind+" = "+$("#big_box_opinie .single_detale_wrap:eq("+ind+")").find("a.ekspert").attr('href'));
			var str_url = $("#big_box_opinie .single_detale_wrap:eq("+ind+"), .kk_single_box_wrapper:eq("+ind+"), .single_detale_wrap:eq("+ind+")").find("a.ekspert").attr('href');
			var str_url = str_url.replace(/formularz\.finans/i, "doradca.finans");
			show_popup(str_url);
		});
		$(".sprawdz_profil_ponownie").click(function (){
			var dfs_top = $("html").find(".dfs-photo").offset().top;
			var ind = 0;
			//console.log("dfs_top: " + dfs_top);
			$("#big_box_opinie .single_detale_wrap").each( function(i, el) {
				if (dfs_top > $(this).offset().top && dfs_top < $(this).offset().top + $(this).height() ) {
					ind = i;
				}
			}); //each
			// console.log('klikamy na #'+ind+" = "+$("#big_box_opinie .single_detale_wrap:eq("+ind+")").find("a.ekspert").attr('href'));
			var str_url = $("#big_box_opinie .single_detale_wrap:eq("+ind+"), .kk_single_box_wrapper:eq("+ind+"), .single_detale_wrap:eq("+ind+")").find("a.ekspert").attr('href');
			var str_url = str_url.replace(/formularz\.finans/i, "doradca.finans");
			show_popup(str_url);
		});
		$(window).resize(function() { setDoradcaFSPosition() });
		setDoradcaFSPosition();
		setDoradcaFSKeyword();
	} // if()

	

	setTimeout(polecaneAutoSlider, 2000);
	setTimeout(polecaneAutoSliderEvents, 2001);
	setTimeout(topProduktyAutoSlider, 4000);
	setTimeout(topProduktyAutoSliderEvents, 4001);
	
	
	
});

