// JavaScript Document
/* box z ofertami sponsorowanymi POZIOMY */
scrollStep=5;
scrolled=0;
timerLeft="";
timerRight="";
function toLeft(id){
  document.getElementById(id).scrollLeft=0
}
function scrollDivLeft(id){
  scrolled+=1;
  clearTimeout(timerRight) ;
  document.getElementById(id).scrollLeft+=scrollStep;
  timerRight=setTimeout("scrollDivLeft('"+id+"')",20);
  if (scrolled>=32){stopMe();}
}
function scrollDivRight(id){
  scrolled+=1;
  clearTimeout(timerLeft);
  document.getElementById(id).scrollLeft-=scrollStep;
  timerLeft=setTimeout("scrollDivRight('"+id+"')",20);
  if (scrolled>=32){stopMe();}
}
function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}
function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
  scrolled=0;
}
/* box z ofertami sponsorowanymi PIONOWY */
scrollStepPion=5;
scrolledPion=0;
timerTop="";
timerBottom="";
function toTop(id){
  document.getElementById(id).scrollTop=0
}
function scrollDivTop(id){
  scrolledPion+=1;
  clearTimeout(timerBottom) ;
  document.getElementById(id).scrollTop+=scrollStepPion;
  timerBottom=setTimeout("scrollDivTop('"+id+"')",20);
  if (scrolledPion>=21){stopMePion();}
}
function scrollDivBottom(id){
  scrolledPion+=1;
  clearTimeout(timerTop);
  document.getElementById(id).scrollTop-=scrollStepPion;
  timerTop=setTimeout("scrollDivBottom('"+id+"')",20);
  if (scrolledPion>=21){stopMePion();}
}
function toBottom(id){
  document.getElementById(id).scrollTop=document.getElementById(id).scrollWidth
}
function stopMePion(){
  clearTimeout(timerBottom) 
  clearTimeout(timerTop)
  scrolledPion=0;
}
/*funkcje dotyczące kalkulatorów np. zdolnosc kredytowa itd*/
function kalk_zrodlo_dochodu_obsluga(zrodlo_val){
  document.getElementById('kalk_zrodlo_okres').style.display='none';
  document.getElementById('kalk_zrodlo_miesiace').style.display='none';
  switch (parseInt(zrodlo_val)){
    case 1:
    case 2:
    case 6: 
    {
      document.getElementById('kalk_zrodlo_okres_text').innerHTML='Staż u obecnego pracodawcy';
      document.getElementById('kalk_zrodlo_okres').style.display='block';
      if (parseInt(zrodlo_val)==2)
      {
        document.getElementById('kalk_zrodlo_miesiace').style.display='block';
      }
      ;break;
    }
    case 3: 
    {
      document.getElementById('kalk_zrodlo_okres_text').innerHTML='Okres uzyskiwania dochodów z umowy o dzieło';
      document.getElementById('kalk_zrodlo_okres').style.display='block';
      ;break;
    }
    case 4: 
    {
      document.getElementById('kalk_zrodlo_okres_text').innerHTML='Okres uzyskiwania dochodów z umowy zlecenia';
      document.getElementById('kalk_zrodlo_okres').style.display='block';
      ;break;
    }
    case 8: 
    {
      document.getElementById('kalk_zrodlo_okres_text').innerHTML='Okres uzyskiwania dochódów z umowy najmu';
      document.getElementById('kalk_zrodlo_okres').style.display='block';
      ;break;
    }
    case 9: 
    {
      document.getElementById('kalk_zrodlo_okres_text').innerHTML='Okres prowadzenia działalności gospodarczej';
      document.getElementById('kalk_zrodlo_okres').style.display='block';
      ;break;
    }
  }//end of switch
}
function kalk_cel_kredytu_obsluga(zrodlo_val){
  document.getElementById('kalk_cel_kredytu_rynek').style.display='none';
  document.getElementById('kalk_cel_kredytu_przedmiot').style.display='none';
  document.getElementById('kalk_cel_tekst_zmieniany').innerHTML='Przedmiot zakupu';
  switch (parseInt(zrodlo_val)){
    case 1:
    {
      document.getElementById('kalk_cel_kredytu_rynek').style.display='block';
      if(!document.getElementById('f1').rynek_[0].checked)
      {
        document.getElementById('kalk_cel_kredytu_przedmiot').style.display='block';
      }
      
      ;break;
    }
    case 2:
    case 3:
    case 5: 
    {
      document.getElementById('kalk_cel_kredytu_przedmiot').style.display='block';
      document.getElementById('kalk_cel_tekst_zmieniany').innerHTML='Przedmiot zabezpieczenia';
      ;break;
    }
  }//end of switch
}
/*funkcja do polecenia artykułu / forum*/
function polec(lang)
{
	link = "../polec_strone/polec.php?lang_id=" + lang + "&url="+document.location.href;
	window.open(link,"polec","width=350,height=350,scrollbars=1,");
}
function kalk_cel_kredytu_obsluga_rynek(zrodlo_val){
  if (parseInt(zrodlo_val)==1){document.getElementById('kalk_cel_kredytu_przedmiot').style.display='none';}
  else {document.getElementById('kalk_cel_kredytu_przedmiot').style.display='block';}
}
/*obsluga boxu z wyjasnieniem czym jest wskaznik ryzyka - FI*/
function pokaz_info_wskaznik()
//pokazuje informacje dotyczaca wskaznika
{
  if ((document.getElementById('wskaznik_info').style.display=='none')
  ||(document.getElementById('wskaznik_info').style.display=='')){
    
    if (document.getElementById('wskaznik_info').innerHTML==""){  
        var req = mint.Request();
        req.AddParam("p", 1);
        
        req.OnSuccess = function() {
            if (this.responseText!=-1){
              document.getElementById('wskaznik_info').innerHTML=this.responseText;
              document.getElementById('wskaznik_info').style.display='block';
              document.getElementById('wyniki_FI_wskaznik_link_img').src="../_img/_templates/link_ico3.png";
            }
          }
        req.Send("../fundusze_inwestycyjne/wskaznik_ryzyka.php");
    }
    else{
    document.getElementById('wskaznik_info').style.display='block';
    document.getElementById('wyniki_FI_wskaznik_link_img').src="../_img/_templates/link_ico3.png";
    }
  }else{
  document.getElementById('wskaznik_info').style.display='none';
  document.getElementById('wyniki_FI_wskaznik_link_img').src="_img/_templates/link_ico.png";
  }
}
/* obsluga plusikow i minusikow przy wyszukiwaniu kont bankowych - formularzu wyszukiwania*/
function plusminuschange(id,act){   
  var field=document.getElementById(id);           
  var num=parseInt(field.value);
  if (isNaN(num)) {num=0;}
  num=num+act;
  if (num<0){num=0;}
  field.value=num;
}
/*----------WALIDACJE FORMULARZY WYSZUKIWANIA OFERT---------------*/
/* walidacja - konta osobiste*/
function check_form_KO(form_id, naj_bank){
  var strmatch="^[1-9][0-9]*$";
  var strmatch2="^[0-9][0-9]*$";
  if (!document.getElementById(form_id).saldo_.value.match(strmatch)){
    alert("Niepoprawny format średniego salda rachunku");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_o_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_o_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych w oddziale");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_i_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_i_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych internetowych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_t_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_t_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych telefonicznych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_o_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_o_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych w oddziale");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_i_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_i_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych internetowych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_t_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_t_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych telefonicznych");return false;
  }
  if((document.getElementById(form_id).stale_zlecenia_z_.value!=="")&&(!document.getElementById(form_id).stale_zlecenia_z_.value.match(strmatch2))){
  alert("Niepoprawny format ilości stałych zleceń zewnętrznych");return false;
  }
  if((document.getElementById(form_id).stale_zlecenia_w_.value!=="")&&(!document.getElementById(form_id).stale_zlecenia_z_.value.match(strmatch2))){
  alert("Niepoprawny format ilości stałych zleceń wewnętrznych");return false;
  }
  if ((document.getElementById(form_id).liczba_kart_platniczych_.value!=="")&&(!document.getElementById(form_id).liczba_kart_platniczych_.value.match(strmatch2))){
  alert("Niepoprawny format liczby kart płatniczych");return false;
  }
  if((document.getElementById(form_id).ilosc_wyplat_bankomatow_w_.value!=="")&&(!document.getElementById(form_id).ilosc_wyplat_bankomatow_w_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wypłat z bankomatu własnych Banku");return false;
  }
  if((document.getElementById(form_id).ilosc_wyplat_bankomatow_z_.value!=="")&&(!document.getElementById(form_id).ilosc_wyplat_bankomatow_z_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wypłat z bankomatu innych Bankomatów");return false;
  }
 
  if((document.getElementById(form_id).ilosc_wyplat_bankomatow_s_.value!=="")&&(!document.getElementById(form_id).ilosc_wyplat_bankomatow_s_.value.match(strmatch2))
  ){
  alert("Niepoprawny format ilości wypłat z bankomatów za granicą");return false;
  }
  if (naj_bank==1) //czyli z przycisku najlepsza oferta banku
  {
      if (document.getElementById(form_id).bank_naj_.value==0)
    {
      document.getElementById(form_id).bank_naj_.value=1;
    }
    else
    {
      document.getElementById(form_id).bank_naj_.value=0;
    }
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/* walidacja - konta oszczednosciowe*/
function check_form_KOSZ(form_id, naj_bank){
  var strmatch="^[1-9][0-9]*$";
  var strmatch2="^[0-9][0-9]*$";
  if (!document.getElementById(form_id).saldo_.value.match(strmatch)){
    alert("Niepoprawny format średniego salda rachunku");return false;
  }
  if (!document.getElementById(form_id).okres_.value.match(strmatch)){
    alert("Niepoprawny format okresu oszczędzania");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_o_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_o_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych w oddziale");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_i_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_i_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych internetowych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_w_t_.value!=="")&&(!document.getElementById(form_id).ilosc_p_w_t_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji wewnętrznych telefonicznych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_o_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_o_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych w oddziale");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_i_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_i_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych internetowych");return false;
  }
  if((document.getElementById(form_id).ilosc_p_z_t_.value!=="")&&(!document.getElementById(form_id).ilosc_p_z_t_.value.match(strmatch2))){
  alert("Niepoprawny format ilości wykonywanych transakcji zewnętrznych telefonicznych");return false;
  }
  if (naj_bank==1) //czyli z przycisku najlepsza oferta banku
  {
      if (document.getElementById(form_id).bank_naj_.value==0)
    {
      document.getElementById(form_id).bank_naj_.value=1;
    }
    else
    {
      document.getElementById(form_id).bank_naj_.value=0;
    }
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - karty kredytowe*/
function check_form_KK(form_id, naj_bank){ 
  var strmatch="^[1-9][0-9]*$";
  //limit karty
  if (!document.getElementById(form_id).wysokosc_limitu_.value.match(strmatch)){
  alert("Niepoprawny format wysokości limitu karty");return false;
  }
  if (naj_bank==1) //czyli z przycisku najlepsza oferta banku
  {
      if (document.getElementById(form_id).bank_naj_.value==0)
    {
      document.getElementById(form_id).bank_naj_.value=1;
    }
    else
    {
      document.getElementById(form_id).bank_naj_.value=0;
    }
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - lokaty strukturyzowane*/
function check_form_LBS(form_id){
  var strmatch="^[1-9][0-9]*$";
  //wpisanie kwoty lokaty
  if (!document.getElementById(form_id).kwota_.value.match(strmatch)){
    alert("Niepoprawny format wysokości lokaty");return false;
  }
  //waluta
  if (document.getElementById(form_id).waluta_.value==0){//nie wybrano waluty
        alert("Proszę wybrać walutę");return false;
  }
  //okres lokaty
 /* if (document.getElementById(form_id).okres_.value==0){//nie wybrano waluty
        alert("Proszę wybrać okres trwania lokaty");return false;
  }
*/
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - lokaty bankowe*/
function check_form_LB(form_id, naj_bank){
  var strmatch="^[1-9][0-9]*$";
  //wpisanie kwoty lokaty
  if (!document.getElementById(form_id).kwota_.value.match(strmatch)){
    alert("Niepoprawny format wysokości lokaty");return false;
  }
  //wybranie oprocentowanie
 /* if (document.getElementById(form_id).typ_.value==0)//nie wybrano 
  {
    alert("Proszę wybrać rodzaj oprocentowania");
    return false;
  }
  */
  //waluta
  if (document.getElementById(form_id).waluta_.value==0){//nie wybrano waluty
        alert("Proszę wybrać walutę");return false;
  }
  //okres lokaty
  if (document.getElementById(form_id).okres_.value==0){//nie wybrano waluty
        alert("Proszę wybrać okres trwania lokaty");return false;
  }
  if (naj_bank==1) //czyli z przycisku najlepsza oferta banku
  {
      if (document.getElementById(form_id).bank_naj_.value==0)
    {
      document.getElementById(form_id).bank_naj_.value=1;
    }
    else
    {
      document.getElementById(form_id).bank_naj_.value=0;
    }
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}

/*walidacja - otwarty fundusz emerytalny*/
function check_form_OFE(form_id){
  if (document.getElementById(form_id).stopa_zwrotu_.value==0){
    alert("Wybierz stopę zwrotu");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/* walidacja - leasing*/
function check_form_LIS(form_id){
  if (document.getElementById(form_id).przedmiot_.value==0){
    alert("Proszę wybrać przedmiot leasingu");return false;
  }
  if (document.getElementById(form_id).cel_.value==0){
    alert("Proszę wybrać cel leasingu");return false;
  }
  if (document.getElementById(form_id).cena_.value==0){
    alert("Proszę uzupełnić cenę netto przedmiotu leasingu");return false;
  }
  if (document.getElementById(form_id).oplata_.value==0){
    alert("Proszę wybrać opłatę wstępną");return false;
  }
  if (document.getElementById(form_id).okres_.value==0){
    alert("Proszę wybrać okres leasingu");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - fundusze inwestycyjne*/
function check_form_FI(form_id){
  var strmatch="^[1-9][0-9]*$";
  if (document.getElementById(form_id).kwota_.value==""){
    alert("Pole kwota do zainwestowania jest obowiązkowe");return false;
  }
  if (!document.getElementById(form_id).kwota_.value.match(strmatch)){
    alert("Niepoprawny format kwoty do zainwestowania");return false;
  }
  if (document.getElementById(form_id).stopa_zwrotu_.value==0){
    alert("Wybierz stopę zwrotu");return false;
  }
  if ((!document.getElementById(form_id).waluta_PLN_.checked)&&(!document.getElementById(form_id).waluta_EUR_.checked)&&(!document.getElementById(form_id).waluta_USD_.checked)){
    alert("Przynajmniej jedna waluta wyceny musi być zaznaczona");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - kredyt samochodowy*/
function check_form_KS(form_id){
  //wybranie celu kredytu
  if (document.getElementById(form_id).cel_.value==0){//nie wybrano
    alert("Proszę wybrać cel kredytu"); return false;
  }
  var strmatch="^[1-9][0-9]*$";
  //wybranie roku produkcji o ile nie wybrano ze nowy
  if (document.getElementById(form_id).cel_.value==1){
    var d = new Date();
    var curr_year = d.getFullYear();
    document.getElementById(form_id).rok_produkcji_.value=curr_year;
  }
  if ((document.getElementById(form_id).cel_.value!=1)&&(!document.getElementById(form_id).rok_produkcji_.value.match(strmatch)))
  {
    alert("Niepoprawny format roku produkcji");return false;
  }
  //cena samochodu
  if (!document.getElementById(form_id).cena_samochodu_.value.match(strmatch)){
    alert("Niepoprawny format ceny samochodu");return false;
  }
  //wpisanie kwoty kredytu
  if (!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format kwoty kredytu");return false;
  }
  //wybranie waluty 
  if (document.getElementById(form_id).waluta_.value==0){//nie wybrano waluty
        alert("Proszę wybrać walutę");return false;
  }
  //wybranie rodzaju rat
  if (document.getElementById(form_id).raty_.value==0){//nie wybrano raty
        alert("Proszę wybrać rodzaj raty");return false;
  }
  //wpisanie okresu kredytu
    if (!document.getElementById(form_id).okres_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format okresu kredytu");return false;
  }
    //wpisano cos w wartosc rata od
  if ((document.getElementById(form_id).rataod_.value!="")&&(!document.getElementById(form_id).rataod_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej od");return false;
  }
    //wpisano cos w wartosc rata do
  if ((document.getElementById(form_id).ratado_.value!="")&&(!document.getElementById(form_id).ratado_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej do");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*walidacja - kredyt gotowkowy*/
function check_form_KG(form_id){
  var strmatch="^[1-9][0-9]*$";
  //wpisanie kwoty kredytu
  if (!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format kwoty kredytu");return false;
  }
  //wybranie rodzaju rat
  if (document.getElementById(form_id).raty_.value==0){//nie wybrano raty
        alert("Proszę wybrać rodzaj raty");return false;
  }  
  //wybranie waluty 
  if (document.getElementById(form_id).waluta_.value==0){//nie wybrano waluty
        alert("Proszę wybrać walutę");return false;
  }
  //wpisanie okresu kredytowania
    if (!document.getElementById(form_id).okres_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format okresu kredytu");return false;
  }
  //wpisano cos w wartosc rata od
  if ((document.getElementById(form_id).rataod_.value!="")&&(!document.getElementById(form_id).rataod_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej od");return false;
  }
  //wpisano cos w wartosc rata do
  if ((document.getElementById(form_id).ratado_.value!="")&&(!document.getElementById(form_id).ratado_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej do");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*zmiany podczas obslugi formularza KH */
function change_form_KH(form_id){
  nr=document.getElementById(form_id).typ_.value;
  if ((nr==0)||(nr==3))//wybierz.. lub pozyczka
  {
    document.getElementById("rynek_item").style.display="none";
    document.getElementById("przedmiot_item").style.display=""; 
    document.getElementById("przedmiot_text").parentNode.className="form_item_text3"
    document.getElementById("przedmiot_text").innerHTML="przedmiot zabezpieczenia";
    document.getElementById("kkk_item").style.display="none";
    
  }
  else if ((nr==1)||(nr==2))//zakup lub refinansowanie
  {
    if (nr==1){
      document.getElementById("rynek_item").style.display="";
      document.getElementById(form_id).rynek_.value=2;
    }
    else{
      document.getElementById("rynek_item").style.display="none";
      document.getElementById("przedmiot_item").style.display="none";
    }
    document.getElementById("przedmiot_item").style.display="";
    document.getElementById("przedmiot_text").parentNode.className="form_item_text2";
    document.getElementById("przedmiot_text").innerHTML="przedmiot zakupu";
    document.getElementById("kkk_item").style.display="none";
  }
  else if(nr==4){//budowa domu
    document.getElementById("rynek_item").style.display="none";
    document.getElementById("przedmiot_item").style.display="none";
    document.getElementById("przedmiot_text").parentNode.className="form_item_text2";
    document.getElementById("kkk_item").style.display="none";
  }
  else if (nr==5)//konsolidacja
  {
    document.getElementById("rynek_item").style.display="";
    document.getElementById(form_id).rynek_.value=2;
    document.getElementById("przedmiot_item").style.display="";
    document.getElementById("przedmiot_text").parentNode.className="form_item_text2";
    document.getElementById("przedmiot_text").innerHTML="przedmiot zakupu";
    document.getElementById("kkk_item").style.display="";
  }
}
/*walidacja - kredyt hipoteczny */
function check_form_KH(form_id){
//wybranie produktu
  if (document.getElementById(form_id).typ_.value==0)//nie wybrano 
  {
    alert("Proszę wybrać cel kredytu");
    return false;
  }
  //wybranie rynku ewentualnie przedmiotu
  if ((document.getElementById(form_id).typ_.value==1)||(document.getElementById(form_id).typ_.value==2)||(document.getElementById(form_id).typ_.value==5))//wybrano zakup lub refinansowanie lub konsolidacje - widoczny jest rynek
  {
  
      if (document.getElementById(form_id).rynek_.value==0){//nie wybrano rynku
        alert("Proszę wybrać rynek");return false;
      }
      if ((document.getElementById(form_id).rynek_.value!=1)&&(document.getElementById(form_id).przedmiot_.value==0)){//wybrano rynek inny niz pierwotny i nie wybrano przedmiotu
        alert("Proszę wybrać przedmiot zakupu");return false;
      }
      
  }
  else if (document.getElementById(form_id).typ_.value==3)//pozyczka
  {
        if (document.getElementById(form_id).przedmiot_.value==0){//nie wybrano przedmiotu
        alert("Proszę wybrać przedmiot zabezpieczenia");return false;
      }
  } 
  var strmatch="^[1-9][0-9]*$";
  //wpisanie wartosci nieruchomosci
  if (!document.getElementById(form_id).wartosc_.value.match(strmatch)){
    alert("Niepoprawny format wartosci nieruchomosci");return false;
  }
  //wpisanie kwoty kredytu
  if (!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format kwoty kredytu");return false;
  }
  if (document.getElementById(form_id).typ_.value==5){//konsolidacja
    if ((document.getElementById(form_id).kwota_kredytu_.value!="")&&(!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch))){
      alert("Niepoprawny format sumy kredytów konsumpcyjnych");return false;
    }
  }
   //wybranie waluty 
  if (document.getElementById(form_id).waluta_.value==0){//nie wybrano waluty
        alert("Proszę wybrać walutę");return false;
  }
  //wybranie rodzaju rat
  if (document.getElementById(form_id).raty_.value==0){//nie wybrano raty
        alert("Proszę wybrać rodzaj raty");return false;
  }
  //wpisanie okresu kredytu
  if (!document.getElementById(form_id).okres_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format okresu kredytu");return false;
  }
  //wpisanie wieku najstarszego kredytobiorcy
  if (!document.getElementById(form_id).wiek_.value.match(strmatch)){
    alert("Niepoprawny format wieku najstarszego kredytobiorcy");return false;
  }
  //wpisano cos w wartosc rata od
  if ((document.getElementById(form_id).rataod_.value!="")&&(!document.getElementById(form_id).rataod_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej od");return false;
  }
    //wpisano cos w wartosc rata do
  if ((document.getElementById(form_id).ratado_.value!="")&&(!document.getElementById(form_id).ratado_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej do");return false;
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}
/*---KONIEC WALIDACJI FORMUARZY WYSZUKIWANIA ----*/
/*ladowanie boxa pomoc przy wyniku oferty */
function load_doradca_pomoc_box(prefix,id_rodzaj,id_bank,id_oferty){
  var req = mint.Request();
  req.AddParam("action", 1);
  req.AddParam("id", id_rodzaj);
  req.AddParam("id_bank", id_bank);
  req.AddParam("id_oferty", id_oferty);
  req.AddParam("prefix", prefix);
  req.OnSuccess = function() {
    if (this.responseText!=-1){
      response=this.responseText.split("@#@");
      document.getElementById('doradca_pomoc_box_div').innerHTML=response[1];
      if ((response[0]!="") &&(response[0]!=0))
      {
        document.getElementById('pomoc_id_bank').value=response[0];
      }
      else 
      {
        document.getElementById('pomoc_id_bank').value=id_bank;//id banku
      }
      document.getElementById('pomoc_id_podz').value=response[2];//rodzaj podziekowania
      document.getElementById('pomoc_id_oferty').value=id_oferty;//rodzaj oferty
      document.getElementById('pomoc_id_rodzaj').value=id_rodzaj;//rodzaj boxa
      document.getElementById('pomoc_prefix').value=response[4];//prefix produktu
      document.getElementById('doradca_pomoc_reg_tresc').innerHTML=response[3];
      document.getElementById('doradca_pomoc_reg_tresc').style.clear='both';
      document.getElementById('doradca_pomoc_box_div').style.display='block';
    
    }
  }
  req.Send("../_inc/pomoc_doradca_box.php");
}
/*walidacja formualurza pomoc */
function validate_doradca_pomoc_box(f){
  var form=document.getElementById(f);
  var error="";
  var was_error=false;
  var tekst = /^\D*$/;
  var email = /^[^@]+@([a-z0-9\-]+\.)+[a-z]{2,4}$/;
  var	tel_kier=/^0[1-9][0-9]{8}$/; //numer poprzedzony zerem
  var	tel=/^[1-9][0-9]{8}$/;//numer nieporzedzony zerem
  var kwota=/^[1-9][0-9]*$/;//kwota kredytu
  if ((form.imie_.value=="Twoje imię")||(form.imie_.value=="")){
    error+="Uzupełnij swoje imię \n";
    was_error=true;
  }
  else if (!tekst.test(form.imie_.value)){
    error+="Niepoprawny format pola imię \n";
    was_error=true;
  }
  if ((form.nazwisko_.value=="Twoje nazwisko")||(form.nazwisko_.value=="")){
    error+="Uzupełnij swoje nazwisko \n";
    was_error=true;
  }
  else if (!tekst.test(form.nazwisko_.value)){
    error+="Niepoprawny format pola nazwisko \n";
    was_error=true;
  }
  if ((form.telefon_.value=="Twój telefon")||(form.telefon_.value=="")){
    error+="Uzupełnij swój telefon \n";
    was_error=true;
  }
  else if((!tel_kier.test(form.telefon_.value))&&(!tel.test(form.telefon_.value))){
    error+="Niepoprawny format pola telefon \n";
    was_error=true;
  }
  if ((form.email_.value=="Adres e-mail")||(form.email_.value=="")){
    error+="Uzupełnij swój e-mail \n";
    was_error=true;
  }
  else if(!email.test(form.email_.value)){
    error+="Niepoprawny format pola email \n";
    was_error=true;
  }
  if ((form.kwota_.value=="Kwota kredytu")||(form.kwota_.value=="")){
    error+="Uzupełnij kwotę kredytu \n";
    was_error=true;
  }
  else if (!kwota.test(form.kwota_.value)){
    error+="Niepoprawny format pola kwota kredytu \n";
    was_error=true;
  }
  if ((form.miasto_.value=="Twoje miasto")||(form.miasto_.value=="")){
    error+="Uzupełnij swoje miasto \n";
    was_error=true;
  }
  else if (!tekst.test(form.miasto_.value)){
    error+="Niepoprawny format pola miasto \n";
    was_error=true;
  }
  if (form.wojewodztwo_.value==17){
    error+="Wybierz województwo \n";
    was_error=true;
  }
  if (!document.getElementById('akceptacja_dane_').checked){
    error+="Wyrażenie zgody na przetwarzanie danych osobowych jest obowiązkowe  \n";
    was_error=true;
  }
  if (was_error){
    alert(error);
  }
  if (!was_error){//wyslij formularz
    var req = mint.Request();
    req.AddParam("action", 2);
    if (document.getElementById('akceptacja_dane_').checked){ dane=1;} else {dane=0;}
    if (document.getElementById('akceptacja_newsletter_').checked){ news=1;} else {news=0;}
    req.AddParam("akceptacja_dane_", dane);
    req.AddParam("akceptacja_newsletter_", news);
    req.AddParam("imie_", form.imie_.value);
    req.AddParam("imie_", form.imie_.value);
    req.AddParam("nazwisko_", form.nazwisko_.value);      
    req.AddParam("telefon_", form.telefon_.value);
    req.AddParam("email_", form.email_.value);      
    req.AddParam("kwota_", form.kwota_.value);
    req.AddParam("miasto_", form.miasto_.value);
    req.AddParam("wojewodztwo_", form.wojewodztwo_.value);
    req.AddParam("id_bank", form.pomoc_id_bank.value);
    req.AddParam("id_oferty", form.pomoc_id_oferty.value);
    req.AddParam("id_podz", form.pomoc_id_podz.value);
    req.AddParam("id_rodzaj", form.pomoc_id_rodzaj.value);
    req.AddParam("prefix", form.pomoc_prefix.value);
    req.OnSuccess = function() {
        if (this.responseText==-2){
          alert('Formularz został nieprawidłowo wypełniony');
        }
        else if (this.responseText!=-1){
          document.getElementById('doradca_pomoc_box_div').innerHTML=this.responseText;
          document.getElementById('doradca_pomoc_box_div').style.display='block';
        }
        else {
            alert('Wystąpił nieoczekiwany błąd. Prosimy spróbować później');
        }
    }
    req.Send("../_inc/pomoc_doradca_box.php");
  }
  return false;
}
/*uzupelnianie wartosciami domyslnymi*/
function set_doradca_pomoc_inputs(clicked,clicked_text, f1,t1,f2,t2,f3,t3){
/*clicked - klikniete pole (imie lub nazwisko lub telefon lub email)
jesli jest wypelnione domyslnie to jest czyszczone
reszta f1,f2,f3 - inne pola ktore akurat nie sa klikniete
jesli ktore z nich jest puste jest wypelniane wartosciami domyslbnymi t1,t2,t3
zeby uzytkownik wiedzial co tam tzreba wpisac*/
  if (document.getElementById(clicked).value==clicked_text){
    document.getElementById(clicked).value="";
  }
  if (document.getElementById(f1).value==""){
    document.getElementById(f1).value=t1;
  }
  if (document.getElementById(f2).value==""){
    document.getElementById(f2).value=t2;
  }
  if (document.getElementById(f3).value==""){
    document.getElementById(f3).value=t3;
  }
}
function set_doradca_pomoc_inputs_default(id, default_text){
  if (document.getElementById(id).value==""){
    document.getElementById(id).value=default_text;
  }
}
function set_doradca_pomoc_inputs_clear(id, default_text){
  if (document.getElementById(id).value==default_text){
    document.getElementById(id).value="";
  }
}
/*kalklulator pln czy waluta*/
function kursy_srednie(x,kk2,ks2,kk3,ks3,kk4,ks4){
		if(x==2)
		{
			document.getElementById('f1').kurs_kupno.value = kk2;
			document.getElementById('f1').kurs_sprzedaz.value =ks2;
		}	
		else if(x==3)
		{
			document.getElementById('f1').kurs_kupno.value = kk3;
			document.getElementById('f1').kurs_sprzedaz.value = ks3;
		}
		else if(x==4)
		{
			document.getElementById('f1').kurs_kupno.value = kk4;
			document.getElementById('f1').kurs_sprzedaz.value = ks4;
		}
		else
		{
			document.getElementById('f1').kurs_kupno.value = "";
			document.getElementById('f1').kurs_sprzedaz.value = "";
		}

}	
/*---polec znajomemu ---*/
function showNlRegulamin(reg){
  document.getElementById(reg).style.display='block';
  document.getElementById(reg).style.position='absolute';
  document.getElementById(reg).style.top="300px";
  document.getElementById(reg).style.left="350px";
}
/*walidacja formularza w newsletterze - polec znajomemu newsletter*/
function polec_newsletter(){
  if (document.form_polec_newsletter.imie_polecajacy.value==""){
    alert('Proszę uzupełnić imię osoby polecającej');
    return false;
  }
  if (document.form_polec_newsletter.email_polecajacy.value==""){
    alert('Proszę uzupełnić adres email osoby polecającej');
    return false;
  }
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  var address = document.form_polec_newsletter.email_polecajacy.value;
  if(reg.test(address) == false) {
        alert('Niepoprawny format adresu email osoby polecającej');
        return false;
  }
  if (document.form_polec_newsletter.email_znajomy.value==""){
    alert('Proszę uzupełnić adres email znajomego');
    return false;
  }
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  var address = document.form_polec_newsletter.email_znajomy.value;
  if(reg.test(address) == false) {
        alert('Niepoprawny format adresu email znajomego');
        return false;
  }
  if (document.form_polec_newsletter.imie_znajomy.value==""){
    alert('Proszę uzupełnić imię znajomego');
    return false;
  }
    if (document.form_polec_newsletter.otrzymywanie.checked==false){
    alert('Proszę zaznaczyć akceptację regulaminu');
    return false;
  }
  var req = mint.Request();
  req.AddParam("captcha_val", document.form_polec_newsletter.kod.value);
  req.OnSuccess = function() {
    if(this.responseText=="-1"){
      alert('Wpisz poprawny kod.');
      return false;
    }
    else{
      document.form_polec_newsletter.submit();               
    }
  }
  req.Send("../_inc/check_captcha.php");
}
$(document).ready(function(){

  /*
  *
  *  Boxy przewijane - pion, poziom
  *
  */
  var limitd=0; 
  var poziom_Flag=true; 

	
  $(".button_next_horizon").click(function(){ 
       var id_box=$(this).attr("id").substr($(this).attr("class").length+1);
		if(poziom_Flag){
			poziom_Flag=false;
			limitd++; 
			$(".spons_offers_content").append('<div>&nbsp <a href="../kredyty_hipoteczne/">Kliknij</a></div>'); 
			$(".spons_offers_content div:last").addClass('spons_offers_item'); 
			$(".spons_offers_content div.spons_offers_item:last").load("../ajax/box_polecamy_oferty.php?limitd="+limitd+"&side=next&id_box="+id_box); 
    		scrollDivLeft('container'); 
			$("#container").scrollLeft(-1); 
    		setTimeout(function(){
        		$(".spons_offers_content div.spons_offers_item:first").remove(); 
      	  		$("#container").scrollLeft(-1); 
				poziom_Flag=true;
       		}, 1000);
		}
	});
  
	$(".button_prev_horizon").click(function(){
	  var id_box=$(this).attr("id").substr($(this).attr("class").length+1);
		if(poziom_Flag){
			poziom_Flag=false;
	 		limitd--; 
			$(".spons_offers_content").prepend('<div>&nbsp <a href="../kredyty_hipoteczne/">Kliknij</a></div>'); 
			$(".spons_offers_content div:first").addClass('spons_offers_item'); 
			$("#container").scrollLeft(145); 
			$(".spons_offers_content div.spons_offers_item:first").load("../ajax/box_polecamy_oferty.php?limitd="+limitd+"&side=prev&id_box="+id_box); 
    		scrollDivRight('container');
			setTimeout(function(){
		    	$("#container").scrollLeft(-1); 
        		$(".spons_offers_content div.spons_offers_item:last").remove(); 
				poziom_Flag=true;
      		}, 1000);
		}
	});

	var limitd2=0; 
	var pion_Flag=true;
    	
  $(".button_next_vertical").click(function(){ 
  var id_box=$(this).attr("id").substr($(this).attr("class").length+1);
		if(pion_Flag){
			pion_Flag=false;
			limitd2++; 
			$(".spons_offers_pion_content").append('<div>&nbsp <a href="../kredyty_hipoteczne/">Kliknij</a></div>'); 
			$(".spons_offers_pion_content div:last").addClass('spons_offers_pion_item'); 
			$(".spons_offers_pion_content div.spons_offers_pion_item:last").load("../ajax/box_polecamy_oferty.php?limitd="+limitd2+"&side=next&kierunek=pion&id_box="+id_box); 
			$('#container_pion').animate({scrollTop: 108});
    		setTimeout(function(){
        $(".spons_offers_pion_content div.spons_offers_pion_item:first").remove(); 
				$("#container_pion").attr({ scrollTop: 5 });
				pion_Flag=true;
       		}, 1000);
		}
	});
 
	$(".button_prev_vertical_2").click(function(){
	var id_box=$(this).attr("id").substr($(this).attr("class").length+1);	
		if(pion_Flag){
		pion_Flag=false;
	 		limitd2--; 
			$(".spons_offers_pion_content").prepend('<div>&nbsp <a href="../kredyty_hipoteczne/">Kliknij</a></div>');
			$(".spons_offers_pion_content div:first").addClass('spons_offers_pion_item'); 
			$(".spons_offers_pion_content div.spons_offers_pion_item:first").load("../ajax/box_polecamy_oferty.php?limitd="+limitd2+"&side=prev&kierunek=pion&id_box="+id_box); 
    	$("#container_pion").attr({ scrollTop: 108 }, 1000);
			scrollDivBottom('container_pion'); 
			setTimeout(function(){
				$(".spons_offers_pion_content div.spons_offers_pion_item:last").remove(); 
				$("#container_pion").attr({ scrollTop: 3 });
				pion_Flag=true;
      		}, 1000);
		}
	});
	$("#container_pion").attr({ scrollTop: 0 });

});
/* box forum na home obsluga przewijania */
function home_forum_move_list(id_basic,limit_start){
  var req = mint.Request();
  req.AddParam("action", 1);
  req.AddParam("id_basic", id_basic);
  req.AddParam("limit_start", limit_start);

  req.OnSuccess = function() {
    if (this.responseText!=-1){
      response=this.responseText.split("##@@##");
      document.getElementById('box_forum_butt_'+id_basic).innerHTML=response[0];
      document.getElementById('box_forum_content_'+id_basic).innerHTML="<div class='clear'></div>"+response[1];    
    }
  }
  req.Send("../_inc/box_forum_ajax.php");
}
/*newsletter finansowy */
function check_fast_add_nl(id_form){
//funkcja walidujaca poprawnosci wypelnionych pol
  if ((document.getElementById(id_form).imie.value=="")||(document.getElementById(id_form).imie.value=="Twoje imię")){
    alert('Proszę uzupełnić imię');
    return false;
  }
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  var address = document.getElementById(id_form).email.value;
  if(reg.test(address) == false) {
    alert('Niepoprawny format adresu email');
    return false;
  }
  var req = mint.Request();
  req.AddParam("imie", document.getElementById(id_form).imie.value);
  req.AddParam("email", document.getElementById(id_form).email.value);      
  req.OnSuccess = function() {
  var box=document.getElementById("blue_newsletter_box_content");
   box.innerHTML=this.responseText;
  }
  req.Send("../register/short_register.php");
}
function set_reg_box(){
//funkcja wstawia ponownie do boxu tresc
  var content='<span class="blue_18_g">Porady finansowe, zupełnie <span class="underline">bezpłatnie</span> i obiektywnie</span><br>';
  content+='<span class="grey_12_a">Zaprenumeruj newsletter</span>';
  content+='<div class="clear"></div>';
  content+='<form method="get" id="form_short_add_nl">';
  content+='<div class="newsletter_box_field"><input type="text" class="newsletter_input_field" name="imie"  value="Twoje imię" onClick="javascript:if (this.value==\'Twoje imię\'){this.value=\'\';}"></div>'
  content+='<div class="clear"></div>';
  content+='<div class="newsletter_box_field"><input type="text" class="newsletter_input_field" name="email"  value="Wpisz adres e-mail"  onClick="javascript:if (this.value==\'Wpisz adres e-mail\'){this.value=\'\';}"></div>';
  content+='<a href="javascript:check_fast_add_nl(\'form_short_add_nl\');void null;" class="button_zapisz"></a>';
  content+='</form>';   
  var box=document.getElementById("blue_newsletter_box_content");
  box.innerHTML=content;
}

/*obsluga mapy strony */
function show_map(id_p,level,lang,img_plus){
//wyswietla dla strony jej dzieci
  var children=document.getElementById("childof_"+id_p);//divka z dziecmi strony
  if (children!=null) {
    children.style.display='';
    document.getElementById(img_plus).src="../_img/_templates/minus_tree.gif";
    document.getElementById(img_plus).onclick=function(){hide_map(id_p,level,lang,img_plus);};
  }
  else{//nie istnieje trzeba stworzyć
    var curr_div=document.getElementById("pagetree_"+id_p);//divka ktorej dzieci chcemy znaleźć
    curr_div.innerHTML=curr_div.innerHTML+"<div id='childof_"+id_p+"'></div>";
    children=document.getElementById("childof_"+id_p);//divka z dziecmi strony
    children.style.display='none';
    var req = mint.Request();
    req.AddParam("level", level);
    req.AddParam("id", id_p); 
    req.AddParam("lang_id", lang); 
    req.OnSuccess = function() {
      document.getElementById(img_plus).src="../_img/_templates/minus_tree.gif";
      document.getElementById(img_plus).onclick=function(){hide_map(id_p,level,lang,img_plus);};
      children.innerHTML=this.responseText;
      children.style.display='';
   }  
   req.Send("../site_map/get_page_children.php");
  }
}
function hide_map(id_p,level,lang,img_minus){
  var children=document.getElementById("childof_"+id_p);//divka z dziecmi strony
  children.style.display='none';
  document.getElementById(img_minus).src="../_img/_templates/plus_tree.gif";
  document.getElementById(img_minus).onclick=function(){show_map(id_p,level,lang,img_minus);};
}
function przejdz_do(a)
{
	window.open('http://'+a,'window',' left=100, top=100, width=780, height=500, resizable=1, scrollbars=yes, status=yes, toolbar=yes, directories=yes, location=yes');
}
/*rozwijanie i zwijanie tematów w centrum wiedzy*/
$(document).ready(function() { 
	/*przgotoanie do pierwszego wyswietlenia*/
	$('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_linki').css({"display":"none"}); //ukrycie wszystkich zakladek
	var zakladka = $('div.centrum_wiedzy_left .blue_36_g').text();
	if(zakladka == 'Konta')
	{
	   $('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_linki:first').next().next().css({"display":"block"}); //odsloniecie pierwszej zakladki
    $('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_title:first').next().next().find('img:first').attr('src', '../_img/_templates/opcje_off.png'); //znikniecie strzalki rozwijajacej
  }
  else
  {
    $('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_linki:first').css({"display":"block"}); //odsloniecie pierwszej zakladki
    $('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_title img:first').attr('src', '../_img/_templates/opcje_off.png'); //znikniecie strzalki rozwijajacej
  }
  
	$('div#centrum_wiedzy_tematy .centrum_wiedzy_tematy_title').click(function() { //akcja wykonywana przy kliknieciu w przycisk
		/*ustalenie czy zakladka jest rozwinieta czy zwinieta*/
		var szerokosc=$(this).children('img').attr('src');
		if(szerokosc=='../_img/_templates/opcje_off.png')
		{
			$(this).children('img').attr('src', '../_img/_templates/opcje_on.png'); //pokazanie strzalki
			$(this).next('.centrum_wiedzy_tematy_linki').toggle("fast") //szybkie zwiniecie
		}
		else
		{
			$(this).children('img').attr('src', '../_img/_templates/opcje_off.png'); //znikniecie strzalki
			$(this).next('.centrum_wiedzy_tematy_linki').toggle("normal") //normalne zwiniecie
		}
	});
	/*
	 *
	 * Cenntrum Wiedzy - krok po kroku
	 *
	 */
	 
	$("#centrum_informacji_button_1").click(function(){		
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
    $('.step_by_step_content_mask').animate({opacity: 0}, 500, function() { //animowanie znikania obrazu
    		$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){ //zaladowanie nowych danych
			     $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active'); //usuniecie aktywnej zkladki
			     $("#centrum_informacji_button_1").parent().addClass('step_by_step_link_active').removeClass('step_by_step_link'); //ustawienie nowej aktywnej zakladki
			     $('.step_by_step_content_mask').animate({opacity: 1}, 500); //animacja pojawienia sie nowego obrazu
  		  });
      });
	});
	$("#centrum_informacji_button_2").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_2").parent().addClass('step_by_step_link_active').removeClass('step_by_step_link');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
		  });
    });
	});
	$("#centrum_informacji_button_3").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_3").parent().removeClass('step_by_step_link').addClass('step_by_step_link_active');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
			});
		});
	});
	$("#centrum_informacji_button_4").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_4").parent().removeClass('step_by_step_link').addClass('step_by_step_link_active');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
			});
		});
	});
	$("#centrum_informacji_button_5").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_5").parent().removeClass('step_by_step_link').addClass('step_by_step_link_active');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
			});
		});
	});
	$("#centrum_informacji_button_6").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_6").parent().removeClass('step_by_step_link').addClass('step_by_step_link_active');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
		  });
    });
	});
	$("#centrum_informacji_button_7").click(function(){
		var sorter = $(this).text() - 1;
		var zakladka_identyfikator = $(this).parent().parent().children('em').text();
		$('.step_by_step_content_mask').animate({opacity: 0}, 500, function() {
			$(".step_by_step_content_mask").load("../_inc/box_cw_krok_po_kroku_ajax.php?sort=" + sorter + "&zakladka=" + zakladka_identyfikator, function(){
			   $(".step_by_step_link_active").addClass('step_by_step_link').removeClass('step_by_step_link_active');
			   $("#centrum_informacji_button_7").parent().removeClass('step_by_step_link').addClass('step_by_step_link_active');
			   $('.step_by_step_content_mask').animate({opacity: 1}, 500);
			});
		});
	});
});
/*
 *
 * Centrum wiedzy - top 3 kredyty
 *
 */
$(document).ready(function(){
	/*obsluga przycisku 'pokaz kh'*/
	$('a.button_pokaz_kh').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var rodzaj = $('.top_3_form_item_select_1').val();
		rodzaj = parseInt(rodzaj, 10)
		if(!rodzaj)
		{
			$('.top_3_errors').html('Wybierz rodzaj raty');
		}
		var kwota = $('.top_3_form_item_input_1').val();
		kwota = parseInt(kwota, 10)
		if(!kwota)
		{
			$('.top_3_errors').html('Okresl kwote kredytu');
		}
		var okres = $('.top_3_form_item_input_2').val();
		okres = parseInt(okres, 10)
		if(!okres)
		{
			$('.top_3_errors').html('Okresl dlugosc kredytu');
		}
		var waluta = $('.top_3_form_item_select_2').val();
		waluta = parseInt(waluta, 10)
		if(!waluta)
		{
			$('.top_3_errors').html('Okresl walute w jakiej bedziesz bral kredyt');
		}
		if(rodzaj && kwota && okres && waluta)
		{
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_hipoteczny.php?kwota="+kwota+"&rodzaj="+rodzaj+"&okres="+okres+"&waluta="+waluta+"", function(){
			   $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
      
      //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Rata')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Oprocentowanie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }
    }
	});
	/*obsluga przycisku 'pokaz kg'*/
	$('a.button_pokaz_kg').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var rodzaj = $('.top_3_form_item_select_1').val();
		rodzaj = parseInt(rodzaj, 10)
		if(!rodzaj)
		{
			$('.top_3_errors').html('Wybierz rodzaj raty');
		}
		var kwota = $('.top_3_form_item_input_1').val();
		kwota = parseInt(kwota, 10)
		if(!kwota)
		{
			$('.top_3_errors').html('Okresl kwote kredytu');
		}
		var okres = $('.top_3_form_item_input_2').val();
		okres = parseInt(okres, 10)
		if(!okres)
		{
			$('.top_3_errors').html('Okresl dlugosc kredytu');
		}
		var waluta = $('.top_3_form_item_select_2').val();
		waluta = parseInt(waluta, 10)
		if(!waluta)
		{
			$('.top_3_errors').html('Okresl walute w jakiej bedziesz bral kredyt');
		}
		if(rodzaj && kwota && okres && waluta)
		{
		  //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Rata')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Oprocentowanie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }
      
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_gotowkowy.php?kwota="+kwota+"&rodzaj="+rodzaj+"&okres="+okres+"&waluta="+waluta+"", function(){
			   $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});
	
	/*obsluga przycisku 'pokaz ks'*/
	$('a.button_pokaz_ks').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var rodzaj = $('.top_3_form_item_select_1').val();
		rodzaj = parseInt(rodzaj, 10)
		if(!rodzaj)
		{
			$('.top_3_errors').html('Wybierz rodzaj raty');
		}
		var kwota = $('.top_3_form_item_input_1[name=kwota]').val();
		kwota = parseInt(kwota, 10)
		if(!kwota)
		{
			$('.top_3_errors').html('Okresl kwote kredytu');
		}
		var wartosc = $('.top_3_form_item_input_1[name=wartosc]').val();
		wartosc = parseInt(wartosc, 10)
		if(!wartosc)
		{
			$('.top_3_errors').html('Okresl wartość pojazdu');
		}
		var rok_produkcji = $('.top_3_form_item_input_2[name=rok_produkcji]').val();
		rok_produkcji = parseInt(rok_produkcji, 10)
		if(!rok_produkcji)
		{
			$('.top_3_errors').html('Okresl rok produkcji pojazdu');
		}
		var okres = $('.top_3_form_item_input_2[name=okres]').val();
		okres = parseInt(okres, 10)
		if(!okres)
		{
			$('.top_3_errors').html('Okresl dlugosc kredytu');
		}
		var waluta = $('.top_3_form_item_select_2').val();
		waluta = parseInt(waluta, 10)
		if(!waluta)
		{
			$('.top_3_errors').html('Określ walutę w jakiej bedziesz brał kredyt');
		}
		if(rodzaj && kwota && okres && waluta)
		{
		  //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Rata')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Oprocentowanie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }
      
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_samochodowy.php?kwota="+kwota+"&wartosc="+wartosc+"&rok_produkcji="+rok_produkcji+"&rodzaj="+rodzaj+"&okres="+okres+"&waluta="+waluta+"", function(){
          $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});

	/*obsluga przycisku 'pokaz kk'*/
	$('a.button_pokaz_kk').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var typ = $('.top_3_form_item_select_1[name=typ]').val();
		typ = parseInt(typ, 10);
		if(!typ)
		{
			$('.top_3_errors').html('Wybierz typ karty');
		}
		var organizacja = $('.top_3_form_item_select_1[name=organizacja]').val();
		organizacja = parseInt(organizacja, 10);
		if(!organizacja)
		{
			$('.top_3_errors').html('Okresl rok produkcji pojazdu');
		}
		var technologia = $('.top_3_form_item_select_1[name=technologia]').val();
		technologia = parseInt(technologia, 10);
		if(!technologia)
		{
			$('.top_3_errors').html('Wybierz technologię w jakiej jest wykonana karta');
		}
		var wysokosc_limitu = $('.golden_standard_box_content_3 input').val();
		wysokosc_limitu = parseInt(wysokosc_limitu, 10);
		if(!wysokosc_limitu)
		{
			$('.top_3_errors').html('Określ wysokość limity na karcie');
		}
		if(typ && organizacja && technologia && wysokosc_limitu)
		{
		  //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Okres bezodstekowy');
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Oprocentowanie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }

		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_karty_kredytowe.php?typ="+typ+"&organizacja="+organizacja+"&technologia="+technologia+"&wysokosc_limitu="+wysokosc_limitu+"", function(){
          $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});
  	/*obsluga przycisku 'pokaz lb'*/
	$('a.button_pokaz_lb').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var kwota = $('.top_3_form_item_input_1[name=kwota_lokaty]').val();
		kwota = parseInt(kwota, 10);
		if(!kwota)
		{
			$('.top_3_errors').html('Wpisz kwotę jaką chcesz zainwestować');
		}
		var okres = $('.top_3_form_item_select_1[name=okres_lokaty]').val();
		okres = parseInt(okres, 10);
		if(!okres)
		{
			$('.top_3_errors').html('Wybierz jak długo ma trwać lokata');
		}
		var waluta = $('.top_3_form_item_select_2[name=waluta_lokaty]').val();
		waluta = parseInt(waluta, 10);
		if(!waluta)
		{
			$('.top_3_errors').html('Walutę w jakiej będzie założona lokata');
		}
		if(kwota && okres && waluta)
		{
		  //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Okres bezodstekowy');
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Oprocentowanie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }
      
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_lokaty_bankowe.php?kwota="+kwota+"&waluta="+waluta+"&okres="+okres+"", function(){
          $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});
  
  
  	/*obsluga przycisku 'pokaz lp*/
	$('a.button_pokaz_ps').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var kwota = $('.top_3_form_item_input_1[name=kwota_lokaty]').val();
		kwota = parseInt(kwota, 10);
		if(!kwota)
		{
			$('.top_3_errors').html('Wpisz kwotę jaką chcesz zainwestować');
		}
		var okres = $('.top_3_form_item_select_1[name=okres_lokaty]').val();
		okres = parseInt(okres, 10);
		if(!okres)
		{
			$('.top_3_errors').html('Wybierz jak długo ma trwać lokata');
		}
		var waluta = $('.top_3_form_item_select_2[name=waluta_lokaty]').val();
		waluta = parseInt(waluta, 10);
		if(!waluta)
		{
			$('.top_3_errors').html('Walutę w jakiej będzie założona lokata');
		}
		if(kwota && okres && waluta)
		{
		  //zmiana naglowka
      var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
      if(naglowek == 'Poziom ochrony');
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Opłata wstępna'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      }
      
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_strukturyzowane.php?kwota="+kwota+"&waluta="+waluta+"&okres="+okres+"", function(){
          $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});
   // obsluga przycisku pokaz ko - konta osobiste
  $('a.button_pokaz_ko').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var waluta = $('.top_3_form_item_select_2').val();
		waluta = parseInt(waluta, 10)
		if(!waluta)
		{
			$('.top_3_errors').html('Wybierz rodzaj waluty');
		}
		var saldo = $('.top_3_form_item_input_1').val();
		saldo = parseInt(saldo, 10)
		if(!saldo)
		{
			$('.top_3_errors').html('Okresl kwote salda.');
		}
		
	 if(saldo && waluta)
		{  //zmiana naglowka
		  var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
		  if(naglowek == 'Koszty użytkowania')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Opłata za prowadzenie'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      } 
		
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_konta_osobiste.php?saldo="+saldo+"&waluta="+waluta+"", function(){
			   $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});
 // obsluga przycisku pokaz ko - konta oszczednosciowe 
$('a.button_pokaz_kosz').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var waluta = $('.top_3_form_item_select_2').val();
		waluta = parseInt(waluta, 10)
		if(!waluta)
		{
			$('.top_3_errors').html('Wybierz rodzaj waluty');
		}
		var saldo = $('.top_3_form_item_input_1').val();
		saldo = parseInt(saldo, 10)
		if(!saldo)
		{
			$('.top_3_errors').html('Okresl kwote salda.');
		}
		var okres = $('.top_3_form_item_input_2').val();
		okres = parseInt(okres, 10)
		if(!okres)
		{
			$('.top_3_errors').html('Określ okres oszczędzania.');
		}
		
	 if(saldo && waluta && okres)
		{  //zmiana naglowka
		  var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
		  if(naglowek == 'Oprocentowanie')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Odsetki po podatku'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      } 
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_konta_osz.php?saldo="+saldo+"&waluta="+waluta+"&okres="+okres+"", function(){
			   $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});  
  
$('a.button_pokaz_fi').click(function(){
		/* odczytanie wartosci z formularza i sprawdzenie ich poprawnosci */  
		$('.top_3_errors').html('');
		var ryzyko = $('.top_3_form_item_select_3').val();
		
		var stopa = $('.top_3_form_item_select_1').val();
		saldo = parseInt(stopa, 10)
		if(!stopa)
		{
			$('.top_3_errors').html('Okresl stopę zwrotu.');
		}
		var typ = $('.top_3_form_item_select_2').val();
		
		
	 if(ryzyko && typ && stopa)
		{  //zmiana naglowka
		  var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
		  if(naglowek == 'Stopień ryzyka')
      {
        $(".top_3_item_head_val span.grey_12_a").animate({opacity: 0}, 500, function(){
          $(".top_3_item_head_val span.grey_12_a").text('Stopa zwrotu'); 
          $(".top_3_item_head_val span.grey_12_a").animate({opacity: 1}, 500);
        });
      } 
		  //animacja zejscia z ekranu
		  $(".tip_3_items_content").animate({opacity: 0}, 250, function(){
		    //zaladowanie nowych wyników
			  $(".tip_3_items_content").load("../_inc/top3_oferty_kalkulator_fi.php?ryzyko_="+ryzyko+"&stopa_zwrotu_="+stopa+"&typ_="+typ+"", function(){
			   $(".tip_3_items_content").animate({opacity: 1}, 250);//powrót na ekran
        });  
      });
    }
	});   
  
  
  	
	var kalkulator = $('#centrum_wiedzy_top_3 .golden_bg_standard_box_header .grey_dark_18_g').text();
	if(kalkulator == 'Top 3 karty kredytowe')
	{
	  rotate_rata1(); //zamiana oprocentowania na okres bezodset i odwrotnie
  }
  else if(kalkulator == 'Top 3 lokaty bankowe')
  {
    rotate_rata2(); //zamiana oprocentowania na odsetki i odwrotnie
  }
    else if(kalkulator == 'Top 3 konta osobiste')
  {
    rotate_stopa3(); //zamiana oprocentowania na odsetki i odwrotnie
  }
     else if(kalkulator == 'Top 3 konta oszczędnościowe')
  {
    rotate_stopa2(); //zamiana oprocentowania na odsetki i odwrotnie
  }
     else if(kalkulator == 'Top 3 produkty strukturyzowane')
  {
    rotate_rata4(); //zamiana oprocentowania na odsetki i odwrotnie
  }
      else if(kalkulator == 'Top 3 fundusze inwestycyjne')
  {
    rotate_rata5(); //zamiana oprocentowania na odsetki i odwrotnie
  }
  else
  {
    rotate_rata(); //zamiana oprocentowania na ratę i odwrotnie
  }
});

var rotate_stopa_rata = 0;
var rotate_stopa_rata_time = 8;
/* funkcje zamieniajšce ratę na oprocentowanie */
function rotate_stopa()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500, function (){
		$('.top_3_item_head_val span.grey_12_a').text('Rata').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_stopa').hide(500, function(){ //ukrycie oprocentowania
		$('.top_3_rata').css("position", "relative").css("right", "35px").show(500); //pokazywanie raty
	});

	
}
function rotate_rata()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();

	if(naglowek == 'Rata')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function() {
			$('.top_3_item_head_val span.grey_12_a').text('Oprocentowanie').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_rata').hide(500, function() { // ukrycie raty
			$('.top_3_stopa').show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
 }

/* funkcje zamieniajšce oprocentowanie na dni bez splaty (dla kk) */
function rotate_stopa1()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
		$('.top_3_item_head_val span.grey_12_a').text('Okres bezodstekowy').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata1()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_stopa').hide(500, function(){ //ukrycie oprocentowania
		$('.top_3_bezodset').css("position", "relative").css("right", "35px").show(500); //pokazywanie raty
	});
	
}
function rotate_rata1()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
	if(naglowek == 'Okres bezodstekowy')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
			$('.top_3_item_head_val span.grey_12_a').text('Oprocentowanie').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa1()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_bezodset').hide(500, function(){ // ukrycie raty
			$('.top_3_stopa').show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa1()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
}

/* funkcje zamieniajšce oprocentowanie na odsetki (dla lb) */
function rotate_stopa2()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500,function (){
		$('.top_3_item_head_val span.grey_12_a').text('Odsetki po podatku').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata2()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_stopa').hide(500, function(){ //ukrycie oprocentowania
		$('.top_3_bezodset').css("position", "relative").css("right", "35px").show(500); //pokazywanie raty
	});
	
}
function rotate_rata2()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
	if(naglowek == 'Odsetki po podatku')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
			$('.top_3_item_head_val span.grey_12_a').text('Oprocentowanie').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa2()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_bezodset').hide(500, function(){ // ukrycie raty
			$('.top_3_stopa').show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa2()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
}
/* funkcje zamieniajšce oplate na koszt (dla ko) */
function rotate_stopa3()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
		$('.top_3_item_head_val span.grey_12_a').text('Opłata za prowadzenie').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata3()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_koszt').hide(500, function(){ //ukrycie oplaty
		$('.top_3_oplata').css("position", "relative").css("right", "15px").show(500); //pokazywanie raty
	});
}
function rotate_rata3()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
	if(naglowek == 'Opłata za prowadzenie')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
			$('.top_3_item_head_val span.grey_12_a').text('Koszty użytkowania').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa3()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_oplata').hide(500, function(){ // ukrycie kosztow
			$('.top_3_koszt').css("position", "relative").css("right", "15px").show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa3()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
}

/* funkcje zamieniajšce oprocentowanie na odsetki (dla lb) */
function rotate_stopa4()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
		$('.top_3_item_head_val span.grey_12_a').text('Poziom ochrony').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata4()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_stopa').hide(500, function(){ //ukrycie oprocentowania
		$('.top_3_bezodset').css("position", "relative").css("right", "35px").show(500); //pokazywanie raty
	});
}
function rotate_rata4()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
	if(naglowek == 'Poziom ochrony')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
			$('.top_3_item_head_val span.grey_12_a').text('Opłata wstępna').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa4()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_bezodset').hide(500, function(){ // ukrycie oplaty wstepnej
			$('.top_3_stopa').show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa4()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
}

function rotate_stopa5()
{
	clearTimeout(rotate_stopa_rata);
	$('.top_3_item_head_val span.grey_12_a').hide(500,function () {
		$('.top_3_item_head_val span.grey_12_a').text('Stopień ryzyka').show(500);//zmiana naglowka
		rotate_stopa_rata = setTimeout("rotate_rata5()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
	});
	$('.top_3_koszt').hide(500, function(){ //ukrycie oplaty
		$('.top_3_oplata').css("position", "relative").show(500); //pokazywanie raty
	});
}
function rotate_rata5()
{
	clearTimeout(rotate_stopa_rata);
	var naglowek = $(".top_3_item_head_val span.grey_12_a").text();
	if(naglowek == 'Stopień ryzyka')
	{
		$('.top_3_item_head_val span.grey_12_a').hide(500,function (){
			$('.top_3_item_head_val span.grey_12_a').text('Stopa zwrotu').show(500);//zmiana naglowka
			rotate_stopa_rata = setTimeout("rotate_stopa5()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
		});
		$('.top_3_oplata').hide(500, function(){ // ukrycie kosztow
			$('.top_3_koszt').css("position", "relative").show(500); //pokazanie oprocentowania
		});
		return 0;
	}
	rotate_stopa_rata = setTimeout("rotate_stopa5()", rotate_stopa_rata_time * 2000); // odczekanie i wywolanie kolejnej rotacji
}

function validate_stopy_form(f){
var form=document.getElementById(f);
var error="";
var was_error=false;
var rok = /^(19|20)[0-9]{2,2}$/;
var miesiac = /^([1-9]|0[1-9]|[1][0-2])$/;
var dzien = /^([1-9]|0[1-9]|[12][0-9]|3[01])$/;
if (  (!rok.test(form.data_od_rok_.value)) 
|| (!rok.test(form.data_do_rok_.value)) 
|| (!miesiac.test(form.data_od_miesiac_.value)) 
      || (!miesiac.test(form.data_do_miesiac_.value)) 
      || (!dzien.test(form.data_od_dzien_.value)) 
      || (!dzien.test(form.data_do_dzien_.value))
    )
  {
    alert("Niepoprawny format daty");
    return false;
  }
var data_ok=true;
if (
(form.data_od_dzien_.value=="31") && 
		  ((form.data_od_miesiac_.value=="4") || (form.data_od_miesiac_.value=="6") || (form.data_od_miesiac_.value=="9") ||
                  (form.data_od_miesiac_.value=="11") || (form.data_od_miesiac_.value=="04") || (form.data_od_miesiac_.value=="06") ||
                  (form.data_od_miesiac_.value=="09"))) {
			data_ok=false; // only 1,3,5,7,8,10,12 has 31 days
	     } else if ((form.data_od_miesiac_.value=="2") || (form.data_od_miesiac_.value=="02")) {
                  //leap year
		  if (((form.data_od_rok_.value % 4==0)&&(form.data_od_rok_.value % 100 !=0))
      || (form.data_od_rok_.value % 400 ==0 )){
			  if((form.data_od_dzien_.value=="30") || (form.data_od_dzien_.value=="31")){
				  data_ok=false;
			  }else{
				  data_ok=true;
			  }
		  }else{
		         if((form.data_od_dzien_.value=="29")||(form.data_od_dzien_.value=="30")|| (form.data_od_dzien_.value=="31")){
				  data_ok=false;
		         }else{
				  data_ok=true;
			  }
		  }
	      }else{				 
		data_ok=true;				 
	      } 
	if (!data_ok){
	    alert("Niepoprawny format daty");
    return false;
  }
var data_ok=true;
if (
(form.data_do_dzien_.value=="31") && 
		  ((form.data_do_miesiac_.value=="4") || (form.data_do_miesiac_.value=="6") || (form.data_do_miesiac_.value=="9") ||
                  (form.data_do_miesiac_.value=="11") || (form.data_do_miesiac_.value=="04") || (form.data_do_miesiac_.value=="06") ||
                  (form.data_do_miesiac_.value=="09"))) {
			data_ok=false; // only 1,3,5,7,8,10,12 has 31 days
	     } else if ((form.data_do_miesiac_.value=="2") || (form.data_do_miesiac_.value=="02")) {
                  //leap year
		  if (((form.data_do_rok_.value % 4==0)&&(form.data_do_rok_.value % 100 !=0))
      || (form.data_do_rok_.value % 400 ==0 )){
			  if((form.data_do_dzien_.value=="30") || (form.data_do_dzien_.value=="31")){
				  data_ok=false;
			  }else{
				  data_ok=true;
			  }
		  }else{
		         if((form.data_do_dzien_.value=="29")||(form.data_do_dzien_.value=="30")|| (form.data_do_dzien_.value=="31")){
				  data_ok=false;
		         }else{
				  data_ok=true;
			  }
		  }
	      }else{				 
		data_ok=true;				 
	      } 
	if (!data_ok){
	    alert("Niepoprawny format daty");
    return false;
  }
  var data_od =new Date(form.data_od_rok_.value, form.data_od_miesiac_.value, form.data_od_dzien_.value);
  var data_do =new Date(form.data_do_rok_.value, form.data_do_miesiac_.value, form.data_do_dzien_.value);
  if (data_od>data_do){
  alert("Data 'do' musi być późniejsza");
  return false;
  }
  form.submit();
 return true;
}
/* koniec centrum wiedzy */
/*funckja obslugi opinii o kontakcie*/

function wyraz_opinie(id_kontakt, time, opinia)
/*lg - jezyk, limit - ograniczenie ile ma zwrocic wynikow, period - okres 'd'-dzien t-tydzien
bg1-kolor tla,bg2-kolor tla, und-czy pisac podkreslenie oddzielajace*/
{
  document.getElementById('kontakt_opinia_error').style.display='none';
  document.getElementById('kontakt_opinia_error2').style.display='none';
  document.getElementById('kontakt_opinia_nie').style.display='none';
  document.getElementById('kontakt_opinia_tak').style.display='none';
  var req = mint.Request();
  req.AddParam("id_kontakt", id_kontakt);
  req.AddParam("time", time);      
  req.AddParam("opinia", opinia); 
  req.AddParam("action",1); 
  req.OnSuccess = function() {
  var odp=this.responseText;
  //alert(this.responseText);
    var l=document.getElementById("art_naj_list");
    if (odp==-1){
    document.getElementById('kontakt_opinia_error').style.display='block';
    }
    else if (odp==-2){
        //wyswietl odpowiednie okno
        document.getElementById('kontakt_opinia_error2').style.display='block';
   }
    else{
        //wyswietl odpowiednie okno
        document.getElementById('kontakt_opinia_'+opinia).style.display='block';
   }
   
  }
  req.Send("../doradca/wyraz_opinie.php");
}
function drukuj(){
  window.print();
}
/*funkcja zwiazana ze statystykami*/
function wpisz_do_bazy_statystyki(id){
  var req = mint.Request();
  req.AddParam("action", 1);
  req.AddParam("id", id);
  req.AddParam("system", navigator.platform);//system operacyjny
  if (navigator.appName == 'Netscape')
    var language = navigator.language;
  else
    var language = navigator.browserLanguage;
  var code = language.substring(0,2);
  req.AddParam("language", code);//jezyk uzytkownika
  req.AddParam("javascript", 1);//ze ma wlaczony javascript
  req.AddParam("colors",window.screen.colorDepth);//glebia koloru
  req.AddParam("resolution", screen.width+'x'+screen.height);//rozdzielczosc
  req.OnSuccess = function() {
  }
  req.Send("../_inc/statystyki_dla_comperii_javascript.php");
}
/*rodzina na swoim */
function check_form_RNS(form_id){
  //cel kredytu
  if (document.getElementById(form_id).typ_.value==0)//nie wybrano celu kredytu
  {
    alert("Proszę wybrać cel kredytu");
    return false;
  }
  //wybranie  przedmiotu
  if ((document.getElementById(form_id).typ_.value==1))//wybrano zakup 
  {
  
      if (document.getElementById(form_id).przedmiot_.value==0){//nie wybrano przedmiotu
        alert("Proszę wybrać przedmiot zakupu");
        return false;
      }      
  }
  var strmatch="^[1-9][0-9]*$";
  //wpisanie metrazu
  if (document.getElementById(form_id).metraz_.value==""){
    alert("Proszę wpisać metraż");return false;
  }
  //wpisanie metrazu
  if (!document.getElementById(form_id).metraz_.value.match(strmatch)){
    alert("Niepoprawny format metrażu");return false;
  }
  //wojewodztwo
    if (document.getElementById(form_id).wojewodztwo_.value==17){
    alert("Proszę wybrać województwo");return false;
  }
  if (!(document.getElementById(form_id).wojewodztwo_.value>=1 && document.getElementById(form_id).wojewodztwo_.value<=16)){
    alert("Proszę wybrać województwo z dostępnych wartości na liście");return false;
  }
  //miasto
    if (document.getElementById(form_id).miasto_.value==0){
    alert("Proszę wybrać miasto");return false;
  }
  //brak wartosci nieruchomosci
  if (document.getElementById(form_id).wartosc_.value==""){
    alert("Proszę wpisać wartość nieruchomości");
    return false;
  }
  //wpisanie wartosci nieruchomosci
  if (!document.getElementById(form_id).wartosc_.value.match(strmatch)){
    alert("Niepoprawny format wartosci nieruchomosci");
    return false;
  }
  //brak kwoty kredytu
  if (document.getElementById(form_id).kwota_kredytu_.value==""){
    alert("Proszę wpisać kwotę kredytu");
    return false;
  }
  //wpisanie kwoty kredytu
  if (!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format kwoty kredytu");
    return false;
  }
  if (document.getElementById(form_id).kwota_kredytu_.value > document.getElementById(form_id).wartosc_.value){
    alert("Kwota kredytu nie może przekraczać wartości nieruchomości");
    return false;  
  }
  
   //wybranie waluty 
  if (document.getElementById(form_id).waluta_.value==0 && document.getElementById(form_id).waluta_.value!=undefined){//nie wybrano waluty
        alert("Proszę wybrać walutę");
        return false;
  }
  //wybranie waluty 
  if (document.getElementById(form_id).waluta_.value!=1 && document.getElementById(form_id).waluta_.value!=undefined){//wybrano inny niz PLN
        alert("Jedyną dostępna walutą w Rodzinie na swoim jest złoty polski");
        return false;
  }
  //wybranie rodzaju rat
  if (document.getElementById(form_id).raty_.value==0){//nie wybrano raty
        alert("Proszę wybrać rodzaj raty");
        return false;
  }
  //wpisanie okresu kredytu
  if (document.getElementById(form_id).okres_kredytu_.value==""){
    alert("Proszę wpisać okresu kredytu");return false;
  }
  //wpisanie okresu kredytu
  if (!document.getElementById(form_id).okres_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format okresu kredytu");return false;
  }
  //wpisanie wieku najstarszego kredytobiorcy
  if (document.getElementById(form_id).wiek_.value==""){
    alert("Proszę wpisać wieku najstarszego kredytobiorcy");return false;
  }
  //wpisanie wieku najstarszego kredytobiorcy
  if (!document.getElementById(form_id).wiek_.value.match(strmatch)){
    alert("Niepoprawny format wieku najstarszego kredytobiorcy");return false;
  }
  //wpisano cos w wartosc rata od
  if ((document.getElementById(form_id).rataod_.value!="")&&(!document.getElementById(form_id).rataod_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej od");return false;
  }
    //wpisano cos w wartosc rata do
  if ((document.getElementById(form_id).ratado_.value!="")&&(!document.getElementById(form_id).ratado_.value.match(strmatch))){
    alert("Niepoprawny format raty miesięcznej do");return false;
  }
  //teraz czy się inne rzeczy zgadzają
  if ((parseInt(document.getElementById(form_id).okres_kredytu_.value) + parseInt(document.getElementById(form_id).wiek_.value))>75)
  {
      alert("Dla okresu kredytu wynoszącego "+ document.getElementById(form_id).okres_kredytu_.value+" lat wiek najstarszego kredytobiorcy nie może przekraczać "+ (75 - document.getElementById(form_id).okres_kredytu_.value)+ " lat" );
      return false;
  }
  //czy metraze się zgadzają
  //zakup+mieszkanie+>75m
  if (document.getElementById(form_id).typ_.value==1 && document.getElementById(form_id).przedmiot_.value==1 && document.getElementById(form_id).metraz_.value>75)
  {
        alert("Przy zakupie mieszkania maksymalny metraż wynosi 75 metrów");
        return false;
  }   
  //zakup+dom+>140m
  //zakup+mieszkanie+>75m
  if (document.getElementById(form_id).typ_.value==1 && document.getElementById(form_id).przedmiot_.value==2 && document.getElementById(form_id).metraz_.value>140)
  {
        alert("Przy zakupie domu maksymalny metraż wynosi 140 metrów");
        return false;
  }    
 if (document.getElementById(form_id).wartosc_.value/document.getElementById(form_id).metraz_.value > document.getElementById(form_id).max_val_metr_.value)
 {
        //alert("Maksymalna wartość nieruchomości za 1m2 to " + document.getElementById(form_id).max_val_metr_.value+"\nNatomiast dla zadanej wartości i metrażu wynosi "+ (document.getElementById(form_id).wartosc_.value/document.getElementById(form_id).metraz_.value) +" za 1m2");
        
        alert("Wpisana wartość nieruchomości w przeliczeniu na 1m2 przewyższa ustawowy limit. \nLimit dla wybranej lokalizacji wynosi: "+ (document.getElementById(form_id).max_val_metr_.value)+" zł za 1m2.\nProsimy o wpisanie innych danych.");
        return false;
 }
//czy kwota za metr sie zgadza
  document.getElementById(form_id).submit();//walidacja poprawna 
}

/*walidacja kredyty dla firm*/
function check_form_KDF(form_id){

  var strmatch="^[1-9][0-9]*$";

  //brak kwoty kredytu
  if (document.getElementById(form_id).kwota_kredytu_.value==""){
    alert("Proszę wpisać kwotę kredytu");
    return false;
  }
  //wpisanie kwoty kredytu
  if (!document.getElementById(form_id).kwota_kredytu_.value.match(strmatch)){
    alert("Niepoprawny format kwoty kredytu");
    return false;
  }
  //zbyt duza kwota kredytu
  if (parseInt(document.getElementById(form_id).kwota_kredytu_.value) > 999999999){
	    alert("Proszę wpisać mniejszą kwotę kredytu");
	    return false;  
  }
  //zbyt niska kwota kredytu
  if (parseInt(document.getElementById(form_id).kwota_kredytu_.value) < 1000){
	    alert("Minimalna kwota kredytu wynosi 1000 PLN");
	    return false;  
  }
  //brak okresu trwania kredytu
  if (document.getElementById(form_id).okres_.value==""){
    alert("Proszę wpisać okres trwania kredytu");
    return false;
  }
  //wpisanie okresu trwania kredytu
  if (!document.getElementById(form_id).okres_.value.match(strmatch)){
	    alert("Niepoprawny format okresu trwania kredytu");
	    return false;
  }
  if (parseInt(document.getElementById(form_id).okres_.value) > 999){
	    alert("Proszę wpisać krótszy okres trwania kredytu");
	    return false;  
  }
  document.getElementById(form_id).submit();//walidacja poprawna 
}


/*formularze kontaktowe */
 function otworzFormularz(link, szer, wys) {
 if ( szer==null || szer==''){
  szer = 950;
 }
 if (wys==null || wys=='') 
 {
  wys = 700;
 }
 
 form = window.open(link, '', 'width=' + szer + ',height=' + wys + ',status=no,scrollbars=yes');
 form.focus();
 }
 /* druga wersja zliczajaca*/
  function otworzFormularzWithCounter(id_box,id_box_data_config,link,szer) {
 count_click_of_spons(id_box,id_box_data_config, link);
 form = window.open(link, '', 'width='+szer+',height=700,status=no,scrollbars=yes');
 form.focus();
 }
 /*funkcja zliczajaca klikniecia w oferty sponsorowane w boxie ktory ma od 1-4 ofert na cala szerokosc szablonu*/
 function count_click_of_spons(id_box,id_box_data_config, link){
  var req = mint.Request();
  req.AddParam("id_box", id_box);
  req.AddParam("id_box_data_config", id_box_data_config);
  req.AddParam("action", 1);
  req.OnSuccess = function() {
   //window.location.href = link;
  }
  req.Send("../_inc/box_oferty_sponsorowane_ajax.php");
}
// funkcja ktora nie pozwala wybrac obu checkboxow w wyszukiwarce kredytow
function OneCheckBox(box) {
if(box==0)
{
elem = document.getElementById("szuk_oferta_t_prom");
elem.checked=false       }
if(box==1)
{
elem = document.getElementById("szuk_oferta_b_prom");
elem.checked=false       }
}


//***********************LOKALIZATOR BANKOW ***************************/
function bnk_change_bank_region(){
  var req = mint.Request();
  req.AddParam("id_bank", document.getElementById('bank_bnk_').value);
  req.AddParam("id_wojewodztwo", document.getElementById('wojewodztwo_bnk_').value);
  req.AddParam("action", 1);
  req.OnSuccess = function() {
      if (this.responseText!=-1){
        response=this.responseText.split("@#@");
        //zaladowanie wojewodztwa
        document.getElementById('wojewodztwo_bnk_').innerHTML=response[1];
        //jesli zaznaczenie wojewodztwa zostalo zajmij sie miastami
        if (response[0]==1) //zachowano zaznaczenie zrob z miasta select 
        {
            
        }
        else //trzeba zamienic na input i wyczyscic
        {
            $("#div_miasto_select_bnk_").css("display", "none");
            $("#miasto_select_bnk_").attr("disabled", "disabled");
            $("#div_miasto_input_bnk_").css("display", "block");
            $("#miasto_input_bnk_").attr("disabled", "");
            $("#miasto_select_bnk_").value==0;
            $("#miasto_input_bnk_").value=="";
                       
        }
      }     
  }
  req.Send("../_inc/lokalizator_bankow_ajax.php");
}
function bnk_change_region_miasto(){
  var req = mint.Request();
  req.AddParam("id_bank", document.getElementById('bank_bnk_').value);
  req.AddParam("id_wojewodztwo", document.getElementById('wojewodztwo_bnk_').value);
  req.AddParam("id_wojewodztwo", document.getElementById('wojewodztwo_bnk_').value);
  req.AddParam("action", 1);
  req.OnSuccess = function() {
      if (this.responseText!=-1){
        response=this.responseText.split("@#@");
        //zaladowanie wojewodztwa
        document.getElementById('wojewodztwo_bnk_').innerHTML=response[1];
        //jesli zaznaczenie wojewodztwa zostalo zajmij sie miastami
        if (response[0]==1)
        {
            
        }
        else //trzeba zamienic na input i wyczyscic
        {
            $("#div_miasto_select_bnk_").css("display", "none");
            $("#miasto_select_bnk_").attr("disabled", "disabled");
            $("#div_miasto_input_bnk_").css("display", "block");
            $("#miasto_input_bnk_").attr("disabled", "");
            $("#miasto_select_bnk_").value==0;
            $("#miasto_input_bnk_").value=="";                  
        }
      }     
  }
  req.Send("../_inc/lokalizator_bankow_ajax.php");
}
$(function(){
    $(document).oneTime("5s", function() {
        $("#fb_likebutton").html('<iframe src="http://www.facebook.com/plugins/like.php?app_id=275297852497542&href=http%3A%2F%2Fwww.facebook.com/Comperia&send=false&layout=button_count&width=110&show_faces=false&action=like&colorscheme=light&font=lucida+grande&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:21px;" allowTransparency="true"></iframe>');
        $("#gp_likebutton").html('<g:plusone size="small"></g:plusone><script type="text/javascript" src="/_js/plusone.js"></script>');
    });
})
function otworz_link(id_link)
{
  if(id_link == 1)
  {
    window.open("http://www.banki.pl/?utm_source=Comperia&utm_medium=graphical&utm_content=sekcja_Uwaga_&utm_campaign=Autopromo");
  }
  else if(id_link == 2)
  {
    window.open("http://www.comperia.pl/optymalne-oszczedzanie-z-bgzoptima.html");
  }
}
/* box najczesciej wybierane */
$(function(){
	if ($("#nw").length > 0){

    change.init();
    
    $("#nw .links a").click(function(){
        var nr = $(this).attr("href");
        nr = nr.substring(1);
        change.pokaz(nr);
        $("#nw .links a").removeClass("active");
        $(this).addClass("active");
        change.stopInterval();
        return false;
    });
	}
});

	var change = {
			intervalId : null,
			init : function() {
        		var self = this;
        		this.intervalId = setInterval(function(){
        			var active = $("#nw .links .active");
        			var next = active.next("a");
            
        			active.removeClass("active");
        			if(next.length < 1) {
        				next = $("#nw .links a:first");
        			}
        			next.addClass("active");
        			var number = next.attr("href");
        			number = number.substring(1);
            
        			self.pokaz(number);
            
        		}, 5000);
    	},
    	pokaz : function(nr) {
    		if($("#nw .content.box" + nr).length > 0) {
    			$("#nw .content").removeClass("visible");
    			$("#nw .content.box" + nr).addClass("visible");
        	} 
    	},
    	stopInterval : function() {
    		clearInterval(this.intervalId);
    	}
	}

/* KDF */
$(function(){
    // ziwjanie i rozwijanie opcji po lewej
    $("#l_param_fin .rollToggle").click(function(){
        
        if($("#l_param_fin .content.rolling").is(":visible")) {
            $("#l_param_fin .rollToggle").text("rozwiń");
            $("#l_param_fin .rollToggle").removeClass("down");
        } else {
            $("#l_param_fin .rollToggle").text("zwiń");
            $("#l_param_fin .rollToggle").addClass("down");
        }
        $("#l_param_fin .content.rolling").slideToggle("normal");
    });
    
    // reset forma
    $(".resetForm").click(function(){
        //$("input[type=reset]").click();
        $("typ_kredyt_na_dzialanosc_").selectedIndex = -1;
        $("bank_").selectedIndex = -1;
        $("input[name=zabezpieczenie_kredyt_]").attr('checked', false);
        $("input[name=podstawa_przyznania_]").attr('checked', false);
        $("input[name=okres_dzialalnosci_firmy_min_]").attr('checked', false);
        $("input[name=prowizja_przygotowawcza_]").attr('checked', false);
        $("input[name=dodatkowy_par_wyszukiwania_]").attr('checked', false);
        $("input[name=odnawialnosc_]").attr('checked', false);
        $("input[name=dodatkowy_par_wyszukiwania_2_]").attr('checked', false);
        $("input[name=dodatkowy_par_wyszukiwania_]").attr('checked', false);
        return false;
    });
      
    if($(".wyniki .topText").length > 0) {
        var txt = $(".wyniki .topText").html();
        var pos = txt.indexOf("&nbsp;");
        var first = txt.substr(0, pos);
        var second = txt.substr(pos + 6);
        
        $(".wyniki .topText").html(first + "... ");
    }
    
    var zwinKlik = false;
    $(".text_top_rolling").click(function() {
        if(zwinKlik == true) return false; // jezeli animacja trwa to nie reaguje na klik
        
        zwinKlik = true;
        if($(".wyniki .topText").height() == 62) { // rozwijamy
            $(".wyniki .topText").html(first + " " + second);
            $(".wyniki .topText").css("height", "auto");
            h = $(".wyniki .topText").height();
            $(".wyniki .topText").css("height", 62);
            $(".text_top_rolling").addClass("down");
            $(".text_top_rolling").text("zwiń");
        } else { // zwijamy
            h = 62;
            $(".text_top_rolling").removeClass("down");
            $(".text_top_rolling").text("rozwiń");
        }
        
        $(".wyniki .topText").animate({
            height: h
        }, 1000, function(){
            if(h == 62)
                $(".wyniki .topText").html(first + "... ");
            zwinKlik = false;
        });
        return false;
    });
    
    var donotcheck = false;
    $(".checkbox_box input").mouseover(function(){
        donotcheck = true;
    });
    $(".checkbox_box input").mouseout(function(){
        donotcheck = false;
    });
    
    var timeout;
    
    $(".checkbox_box").click(function(){
        var chb = $(this).children("input");
        $("#checkbox_tooltip_diff").hide();
        if(!donotcheck) chb.attr('checked', !chb.attr("checked"));
        
        var checked = 0;
        
        if(chb.attr("checked")) {
            var pokazTT = true;
            var pokazTTD = false;
            var compare = false;
            var creditTypes = Array;
            $(".wyniki input[type=checkbox]").each(function(){
                if($(this).attr('checked')) {
                	var ids=$(this).val().split("_");
                	creditTypes[checked] = (ids[1]);
                	checked++;
                	if (checked == 1){
                		$('#id_oferty_1_').val(ids[0]);
                		$('#typ_kredyt_na_dzialanosc_1_').val(ids[1]);
                		$('#bank_1_').val(ids[2]);
                	} else if (checked == 2) {
                		$('#id_oferty_2_').val(ids[0]);
                    	$('#typ_kredyt_na_dzialanosc_2_').val(ids[1]);
                    	$('#bank_2_').val(ids[2]);
                	}
                }
                if (checked == 2){
                	if (creditTypes[0] == creditTypes[1]){
                		compare=true; //$('#form_wyniki').submit();
                	} else {
                		pokazTTD = true;
                	}
                	
                }
                if (checked>2){
                	compare = false;
                }
                if(checked > 1) {
                    pokazTT = false;
                    $("#checkbox_tooltip").hide();
                    if(typeof timeout == "number")
                    clearTimeout(timeout);
                    //return false;
                } else if (checked < 2) {
                	$("#checkbox_tooltip_diff").hide();
                }
            });
            
            if(pokazTT == true) {
                var o = chb.offset();
                
                $("#checkbox_tooltip").css("left", o.left + 5);
                $("#checkbox_tooltip").css("top", o.top - $("#checkbox_tooltip").height() - 30);
                $("#checkbox_tooltip").show();
                
                timeout = setTimeout(function(){
                    $("#checkbox_tooltip").hide();
                }, 5000);
            }
            if (pokazTTD == true&&checked==2){
            	var o = chb.offset();
                
                $("#checkbox_tooltip_diff").css("left", o.left + 5);
                $("#checkbox_tooltip_diff").css("top", o.top - $("#checkbox_tooltip_diff").height() - 30);
                $("#checkbox_tooltip_diff").show();
            } else {
            	$("#checkbox_tooltip_diff").hide();
            }
        }
        
        if(checked == 0) {
            $("#checkbox_tooltip").hide();
            if(typeof timeout == "number")
                clearTimeout(timeout);
        }
        if (compare){
        	$('#form_wyniki').submit();
        }
        if (checked>2){
        	alert('Można zaznaczyć tylko 2 oferty!');
        	$(".wyniki input[type=checkbox]").each(function(){
        		$(this).attr("checked",false);
        	});
        }
    });
    $(".options").mouseover(function(){
    	if(!($(this).hasClass('active'))){
    		$(this).css("background-color","#fff");
    	}
    });
    $(".options").mouseout(function(){
    	if(!($(this).hasClass('active'))){
    		$(this).css("background-color","transparent");
    	}
    });
    $(".options").click(function(){
        var klasy = new Array( 'marza', 'prowizja', 'okres', 'waluta', 'oceny' );
        var wszystkieZakladki = false;
        
        var kliknietyElem = $(this);
        var kliknietyClas = null;
        
        for(i in klasy) {
            if(kliknietyElem.hasClass(klasy[i])) {
                kliknietyClas = klasy[i];
                break;
            }
        }
        
        if(wszystkieZakladki == false) {
            kliknietyElem.parents(".first").children(".header_line").children(".options").removeClass("active");
            $(".wyniki .options").css("background-color","transparent");
            $("div.active").css("background-color","#fff");
            kliknietyElem.addClass("active");
            kliknietyElem.css("background-color","#fff");
            
            kliknietyElem.parents(".first").next(".second").children("td").children(".opis").addClass("hidden");
            kliknietyElem.parents(".first").next(".second").children("td").children("." + kliknietyClas).removeClass("hidden");
        } else {
            $(".wyniki .options").removeClass("active");
            $(".wyniki .options").css("background-color","transparent");
            $(".wyniki .options." + kliknietyClas).css("background-color","#fff");
            $(".wyniki .options." + kliknietyClas).addClass("active");
            $(".wyniki .opis").addClass("hidden");
            $(".wyniki .opis." + kliknietyClas).removeClass("hidden");
        }
    });
    
    var all = document.getElementsByTagName("*");
    for(i in all) {
        if(hasClass(all[i], "options") || hasClass(all[i], "field")) {
			//Lukasz Kraszynski - wylaczenie wywolania funkcji - psula inputy, nie dalo sie zaznaczac tekstu
            //disableSelection(all[i]);
        }
    }
    
    var check = true;
    $("#brak_wynikow .field input[type=checkbox]").mouseover(function(){
        check = false;
    });
    $("#brak_wynikow .field input[type=checkbox]").mouseout(function(){
        check = true;
    });
    $("#brak_wynikow .field").click(function(){
        var chb = $(this).children("input[type=checkbox]");
        if(check) {
            chb.attr("checked", !chb.attr("checked"));
            chb.change();
        } 
            
        if(chb.attr("checked")) $(this).addClass("checked");
        else $(this).removeClass("checked");
        
    });
    
    $("#brak_wynikow .field input[type=checkbox]").change(function(){
        var line = $(this).parents(".line");
        var chb = $(this);
        
        $("#brak_wynikow .col_l .line").each(function(i){
            var t_name = $(this).children(".field").children("input[type=checkbox]").attr("name");
            if(t_name == chb.attr("name")) {
                
                $("#brak_wynikow .col_r .line").each(function(n){
                    if(n == i) {
                        
                        if(chb.attr("checked")) {
                            $(this).children("input").val(chb.val());
                            $(this).children(".label").addClass("bold");
                            $(this).children(".label").text(chb.prev("p").text());
                        } else {
                            $(this).children(".label").removeClass("bold");
                            $(this).children("input").val($(this).children(".hidden").attr("title"));
                            $(this).children(".label").text($(this).children(".hidden").text());
                        }
                        
                        return false;
                    }
                });
                return false;
            }
        });
        $.ajax({
            type: "POST",
            url: "/kredyty_dla_firm/KDF_ajax_brak_wynikow.php",
            data: $("#brak_wynikow_form").serialize(),
            success: function(data) {
                if(data != null && data != '') {
                    $("#komunikat_brak_wynikow").html("<span class=\"bold font18\">Udało się!</span><br/><a href=\"javascript:KDFShow()\">Zobacz wyniki</a>");
                } else {
                	$("#komunikat_brak_wynikow").html("<span class=\"bold\">Niestety, brak wyników, spróbuj jeszcze raz.</span>");
                }
            }
        });
    });
})
function KDFShow() {
	$('#brak_wynikow_form').submit();
}
function KDFCompareDiff() {
	$('#form_wyniki').submit();
}
	
//wylaczanie zaznaczenia na liscie wynikow KDF
function KDFClearSelection() {
		$(".wyniki input[type=checkbox]").each(function(){
			$(this).attr('checked', false);
			$("#checkbox_tooltip_diff").hide();
		});
}
//porownanie kredytow roznego typu
function KDFCompareDiff() {
	$('#form_wyniki').submit();
}
//link wypelnij formularz w komentarzu produktu KDF
$(function(){
	$(".wyp_form").mouseover(function(){
		$(this).children('img').attr('src', '../images/wyp_form_u.png');
	});
	$(".wyp_form").mouseout(function(){
		$(this).children('img').attr('src', '../images/wyp_form.png');
	});
});
//link szczegoly kdf
$(function(){
	$(".blue_10_a_kdf").mouseover(function(){
		$(this).children('img').attr('src', '../images/details_u_50x15.png');
	});
	$(".blue_10_a_kdf").mouseout(function(){
		$(this).children('img').attr('src', '../images/details_50x15.png');
	});
});


function disableSelection(target){
/*
    if (typeof target.onselectstart!="undefined") //IE route
        target.onselectstart=function(){return false;}
    else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
        target.style.MozUserSelect="none";
    else //All other route (ie: Opera)
        target.onmousedown=function(){return false;}
		*/
}

function hasClass(ele,cls) {
    if(ele != undefined && ele.className != undefined && ele.className.indexOf(cls) != -1 ) return true;
    return false;
}

$(function(){
    
    $(".szczegoly .tab").click(function(){
        var show = $(this).attr("href");
        show = show.substr(1);
        
        $(".szczegoly .tab").removeClass("active");
        $(this).addClass("active");
        $(".szczegoly .top_box").hide();
        $(".szczegoly ." + show).show();
        
        return false;
    });
    
})

/*top 3 KDF*/
$(function(){
    
    changeData.startInterval();
    
    $("#top3 select").change(function(){
        // zmieniamy zawartosc calej tabelki
        changeData.setKategoria( $(this).val() );
    });
    
})

var changeData = {
    kategoria : 1,
    intervalId : null,
    
    startInterval : function() {
        var self = this;
        this.intervalId = setInterval(function(){
            self.toggleColumn();
        }, 5000);
    },
    stopInterval: function() {
        clearInterval(this.intervalId);
    },
    setKategoria : function(kat) {
        this.stopInterval();
        this.kategoria = kat;
        this.getData();
        this.startInterval();
    },
    toggleRodzaj : function() {
        if(this.rodzaj == "o") this.rodzaj = "r";
        else this.rodzaj = "o";
    },
    getData: function() {
        var self = this;
        if(this.kategoria == 1)
        {
          $("#top3 .bottom_btn").attr("href", '/finansowanie_dzialanosci_biezacej/');
        }
        else if(this.kategoria == 2)
        {
          $("#top3 .bottom_btn").attr("href", '/kredyty_hipoteczne_dla_firm/');
        }
        else if(this.kategoria == 3)
        {
          $("#top3 .bottom_btn").attr("href", '/kredyty_samochodowe_dla_firm/');
        }
        else
        {
          $("#top3 .bottom_btn").attr("href", '/kredyty-inwestycyjne-dla-firm/');
        }
        $.ajax({
            type: "GET",
            url: "_inc/top3_oferty_kalkulator_kdf.php",
            data: {
                'typ': this.kategoria
            },
            dataType: "json",
            success: function(data) {
                if(data != null) {
                    if($("#top3 .brak_wynikow").is(":visible")) {
                        $("#top3 .brak_wynikow").fadeOut("200", function(){
                            $("#top3 .rata").addClass("hidden").removeAttr("style");
                            $("#top3 .okres_prowadzenia").addClass("hidden").removeAttr("style");
                            $("#top3 .oprocentowanie").removeAttr("style");
                            $("#top3 .results_data").fadeIn("200");
                        });
                    }
                    $("#top3 .bank").each(function(i){
                        $(this).text(data[0][i]);
                    });
                    
                    $("#top3 .oprocentowanie").each(function(j){
                        $(this).text(data[1][j]);
                    });
                    
                    $("#top3 .rata").each(function(n){
                        $(this).text(data[2][n]);
                    });
                    
                    $("#top3 .okres_prowadzenia").each(function(n){
                        $(this).text(data[3][n]);
                    });
                    
                    $("#top3 .line").each(function(m){
                        $(this).children("a").each(function(l){
                            console.log($(this));
                            $(this).attr("href", data[4][m]);
                        });
                    });
                } else {
                    if($("#top3 .brak_wynikow").length < 1) 
                        $("#top3 .results").prepend("<div class='brak_wynikow hidden'><p class='text'>Nie ma ofert w tej kategorii<br/><a href='#'>Sprawdź inne oferty</a></p></div>")
                    
                    $("#top3 .results_data").fadeOut("200", function(){
                        $("#top3 .brak_wynikow").fadeIn("200");
                        self.stopInterval;
                    });
                }
            }
        });
    },
    toggleColumn : function() {
        if($("#top3 .oprocentowanie").is(":visible")) {
            $("#top3 .oprocentowanie").fadeOut("200", function(){
                $("#top3 .rata").fadeIn("200");
            });
        } else if ($("#top3 .rata").is(":visible")) {
            $("#top3 .rata").fadeOut("200", function(){
                $("#top3 .okres_prowadzenia").fadeIn("200");
            });
        } else {
            $("#top3 .okres_prowadzenia").fadeOut("200", function(){
                $("#top3 .oprocentowanie").fadeIn("200");
            });
        }
    }
}
/*ostatnio porownywane*/
$(function(){

    // pierwszy argumnt to czas w ms
    // drugi to kierunek "f" > do przodu (forward)  "b" > do tyłu (backward)
    changeBoxostatnio_porownywane.init(1000, "f");
    
    $("#ostatnio_porownywane .prev").click(function(){
        changeBoxostatnio_porownywane.click_prev();
        return false;
    });
    
    $("#ostatnio_porownywane .next").click(function(){
        changeBoxostatnio_porownywane.click_next();
        return false;
    });

})

var changeBoxostatnio_porownywane = {
    intervalId : null,
    curentBox : null,
    onlyOne   : false,
    init    : function(time, direction) {
        if($("#ostatnio_porownywane .content .boxes").length < 2) {
            this.onlyOne = true;
            return false;
        }
        
        this.curentBox = $("#ostatnio_porownywane .content .boxes:first");
        var self = this;
        this.intervalId = setInterval(function(){
            self.stop();
            /*if(direction == "f") self.next();
            else if(direction == "b") self.prev();*/
        }, time);
    },
    prev    : function() {
        var prev = this.curentBox.prev();
        var self = this;
        if(prev.length < 1) 
            prev = $("#ostatnio_porownywane .content .boxes:last");
            
        this.curentBox.fadeOut("fast", function(){
            prev.fadeIn("fast", function(){
                self.curentBox = prev;
            });
        });
    },
    next    : function() {
        var next = this.curentBox.next();
        var self = this;
        if(next.length < 1)
            next = $("#ostatnio_porownywane .content .boxes:first");
            
        this.curentBox.fadeOut("fast", function(){
            next.fadeIn("fast", function(){
                self.curentBox = next;
            });
        });
    },
    stop    : function() {
        clearInterval(this.intervalId);
    },
    click_next : function() {
        if(this.onlyOne) return false;
        this.next();
        this.stop();
    },
    click_prev : function() {
        if(this.onlyOne) return false;
        this.prev();
        this.stop();
    }
}

/*ostatnio przeglądane*/
$(function(){

    // pierwszy argumnt to czas w ms
    // drugi to kierunek "f" > do przodu (forward)  "b" > do tyłu (backward)
    changeBox.init(1000, "f");
    
    $("#ostatnio_przegladane .prev").click(function(){
        changeBox.click_prev();
        return false;
    });
    
    $("#ostatnio_przegladane .next").click(function(){
        changeBox.click_next();
        return false;
    });

})

var changeBox = {
    intervalId : null,
    curentBox : null,
    init    : function(time, direction) {
        this.curentBox = $("#ostatnio_przegladane .content .boxes:first");
        var self = this;
        this.intervalId = setInterval(function(){
            self.stop();
            /*if(direction == "f") self.next();
            else if(direction == "b") self.prev();*/
        }, time);
    },
    prev    : function() {
        var prev = this.curentBox.prev();
        var self = this;
        if(prev.length < 1) 
            prev = $("#ostatnio_przegladane .content .boxes:last");
            
        this.curentBox.fadeOut("fast", function(){
            prev.fadeIn("fast", function(){
                self.curentBox = prev;
            });
        });
    },
    next    : function() {
        var next = this.curentBox.next();
        var self = this;
        if(next.length < 1)
            next = $("#ostatnio_przegladane .content .boxes:first");
            
        this.curentBox.fadeOut("fast", function(){
            next.fadeIn("fast", function(){
                self.curentBox = next;
            });
        });
    },
    stop    : function() {
        clearInterval(this.intervalId);
    },
    click_next : function() {
        this.next();
        this.stop();
    },
    click_prev : function() {
        this.prev();
        this.stop();
    }
}

