﻿

<!--

<!--
var debug2;
var inter;
var flaga =0;
var imgTemp,imgTemp2,click_count = 0,no_tmp = 0;
var h,h2,w,w2,bug = 0;
var tmpAns = "";
function zamknijKreator2(){
 tb_remove();
 getConf2();
}
$(function(){
 getConf2()
});
var v1_2, v2_2, v3_2, v4_2, v5_2, v6_2 = '';
var ile_pytan_2 = 5;
var dlugosc = 427;
var krok = dlugosc/ile_pytan_2;
var aktualne_pytanie_2 = 0;
function getConf2(){
 $.ajax({
  type: "GET",
  url: "/tematyczne/car_audio/simpleconfigurator/",
  dataType: "html",
  success: function(msg){
   $("#TB_window").attr("style","margin-left: -263px; width: 526px; margin-top: -164px; display: block;");
   $("#konfBody_2").attr("style","");
   $("#konfBottom_2").attr("style","");
   $("#konfBody_2").html(msg);
   aktualne_pytanie_2 = 0;
   $("#konfBody_2 #dalej_2 img").click(pyt1_2);
   $("#konfBody_2 #wstecz_2 img").hide();
  },
  error: function(obj, msg){
   $("#konfBody_2").html("Konfigurator chwilowo niedostępny");
  }
 });
}
function showErr2(){
 
 $("#konfErr_2").show();
 $("#konfBody_2 #dalej_2 img").show();
 $("#konfBody_2 #wstecz_2 img").show();
 $("#konfBody_2 #wstecz_2 img").hide();
}
function hideErr2(){
 $("#konfErr_2").hide();
}
function pierwsze(){
var nr_P = 1;
$("#p"+(nr_P+1)+"_2").hide();
$("#p"+(nr_P+2)+"_2").hide();
  $("#p"+(nr_P+3)+"_2").hide();
  $("#p"+(nr_P+4)+"_2").hide();
$("#p"+(nr_P)+"_2").show();
$("#konfBody_2 #dalej_2 img").unbind();
  $("#konfBody_2 #dalej_2 img").click(pyt1_2);
  $("#konfBody_2 #wstecz_2 img").show();
  $("#konfBody_2 #wstecz_2 img").unbind();
  $("#konfBody_2 #wstecz_2 img").hide();
}
function pyt1_2(){
 hideErr2();
 
 var nr_P = 1;
 $("#bar_2").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").val();
  $("#p"+nr_P+"_2").hide();
  $("#p"+(nr_P+2)+"_2").hide();
  $("#p"+(nr_P+3)+"_2").hide();
  $("#p"+(nr_P+4)+"_2").hide();
  
  $("#p"+(nr_P+1)+"_2").show();
  v1_2 = v;
  
  
  $("#konfBody_2 #dalej_2 img").unbind();
  $("#konfBody_2 #dalej_2 img").click(pyt2_2);
  $("#konfBody_2 #wstecz_2 img").show();
  $("#konfBody_2 #wstecz_2 img").unbind();
  $("#konfBody_2 #wstecz_2 img").click(pierwsze);
    } else {
  showErr2();
  $("#konfBody_2 #wstecz_2 img").hide();
 }
}
function pyt2_2(){
 hideErr2();
 var nr_P = 2;
 $("#bar_2").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").val();
  $("#p"+nr_P+"_2").hide();
  $("#p"+(nr_P+2)+"_2").hide();
  
    v2_2 = v;
    
   if( v1_2 == 'N' &&  v2_2 == 'N') {
        v3_2 = 'A';
     $($(".odpowiedzi input[name=answers3_2]")[0]).click();
     v4_2 = 'A';
     $($(".odpowiedzi input[name=answers4_2]")[0]).click();
     nr_P += 2;
      $("#konfBody_2 #dalej_2 img").click(pyt5_2);
      flaga++;
   }
   else{
  
  $("#konfBody_2 #dalej_2 img").unbind();
    $("#konfBody_2 #dalej_2 img").click(pyt3_2);
    
    
    $("#konfBody_2 #wstecz_2 img").unbind();
    $("#konfBody_2 #wstecz_2 img").click(pyt1_2);
    $("#konfBody_2 #wstecz_2 img").show();
    $("#3_3_2").show();
    if( (v1_2 == 'T' || v1_2 == 'N') &&  v2_2 == 'N') {
        $("#3_3_2").hide();
   } 
  
  
  }
    $("#p"+(nr_P+1)+"_2").show();
    
    
    
    } else {
  showErr2();
  $("#konfBody_2 #wstecz_2 img").show();
 }
}
function pyt3_2(){
 hideErr2();
 var nr_P = 3;
 $("#bar_2").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").val();
  
  $("#p"+nr_P+"_2").hide();  
  $("#p"+(nr_P+2)+"_2").hide();
  v3_2 = v;
  
  
  
  if(v1_2 == 'T' && v2_2 == 'B' && v3_2 == 'A') {
     v4_2 = 'B';
     $($(".odpowiedzi input[name=answers4_2]")[1]).click();
     nr_P += 1;
      $("#konfBody_2 #dalej_2 img").click(pyt5_2);
      $("#5_3_2").hide();
      flaga++;
  }
  else{
   if(v1_2 == 'T' && v2_2 == 'N' && v3_2 == 'B') {
      v4_2 = 'A';
      $($(".odpowiedzi input[name=answers4_2]")[0]).click();
      nr_P += 1;
       $("#konfBody_2 #dalej_2 img").click(pyt5_2);
       $("#5_3_2").hide();
       flaga++;
       
   }
   else{
  
    $("#konfBody_2 #dalej_2 img").unbind();
     $("#konfBody_2 #dalej_2 img").click(pyt4_2);
     $("#konfBody_2 #wstecz_2 img").show();
     $("#konfBody_2 #wstecz_2 img").unbind();
     $("#konfBody_2 #wstecz_2 img").click(pyt2_2);
     $("#4_1_2").show();
     $("#4_3_2").show();
     
    if(v1_2 == 'T' && v2_2 == 'T' && v3_2 == 'A') {
           $("#4_1_2").hide();
     }
     if(v1_2 == 'T' && v2_2 == 'N' && v3_2 == 'A') {
           $("#4_3_2").hide();
     }
     
     if( (v1_2 == 'T' || v1_2 == 'N') && (v2_2 == 'T' || v2_2 == 'B') && v3_2 == 'C') {
           $("#4_1_2").hide();
     }
  
  
   } 
 
 }
  $("#p"+(nr_P+1)+"_2").show();
  
 } else {
  
  showErr2();
  $("#konfBody_2 #wstecz_2 img").show();
 }
}
function pyt4_2(){
 hideErr2();
 var nr_P = 4;
 $("#bar_2").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").val();
  
  $("#p"+nr_P+"_2").hide();  
  $("#p"+(nr_P+2)+"_2").hide();
  
  v4_2 = v; 
      $("#5_3_2").show();
     $("#5_1_2").show();
 
 
 if(v1_2 == 'N' && (v2_2 == 'T' || v2_2 == 'B') && v3_2 == 'A' && v4_2 == 'C') {
      v5_2 = 'B';
      $($(".odpowiedzi input[name=answers5_2]")[1]).click();
      nr_P += 1;
       showQuizResult2();
   }
   else{
  
  
  if(v1_2 == 'T' && v2_2 == 'B' && v3_2 == 'C' && v4_2 == 'C') {
      v5_2 = 'A';
      $($(".odpowiedzi input[name=answers5_2]")[0]).click();
      nr_P += 1;
       showQuizResult2();
       
   }
   else{
   
  
    if( v1_2 == 'T' && v2_2 == 'T' &&  (v3_2 == 'B' || v3_2 == 'C') && v4_2 == 'A') {
           $("#5_3_2").hide();
     }
     
     if( v1_2 == 'N' && v2_2 == 'B' &&  v3_2 == 'A' && (v4_2 == 'A' || v4_2 == 'B' || v4_2 == 'C')) {
           $("#5_3_2").hide();
     }
     
     if( v1_2 == 'N' &&  (v2_2 == 'T' || v2_2 == 'B') &&  v3_2 == 'A' && v4_2 == 'A') {
           $("#5_3_2").hide();
     }
     
     if( v1_2 == 'N' &&  (v2_2 == 'T' || v2_2 == 'B') &&  v3_2 == 'B' && v4_2 == 'C') {
           $("#5_1_2").hide();
     }
     
     if( v3_2 == 'A' && v4_2 == 'B') {
           $("#5_3_2").hide();
     }
     
     if( v3_2 == 'B' && v4_2 == 'A') {
           $("#5_3_2").hide();
     }
     
     $("#konfBody_2 #dalej_2 img").unbind();
     $("#konfBody_2 #dalej_2 img").click(pyt5_2);
     $("#konfBody_2 #wstecz_2 img").show();
     $("#konfBody_2 #wstecz_2 img").unbind();
     $("#konfBody_2 #wstecz_2 img").click(pyt3_2);
  
  }
  }
  
  $("#p"+(nr_P+1)+"_2").show();
 } else {
  showErr2();
  
  $("#konfBody_2 #wstecz_2 img").show();
 }
}
function pyt5_2(){
  hideErr2();
 var nr_P = 5;
 $("#bar_2").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").size();
 
 if(s==1){
  var v = $(".odpowiedzi input[name=answers"+nr_P+"_2]:checked").val();
  v5_2= v;
  showQuizResult2();
 } else {
   if (flaga == 1){
    flaga++;
   
   }
   else{showErr2(); $("#konfBody_2 #wstecz_2 img").show();}
 }
 
 
}
function showQuizResult2(){
 aktualne_pytanie_2 = 6;
 window.location='#top';
 $("#konfBody_2 .pytanie").hide();
 $("#konfBody_2 .loader").show();
 getSet2();
}
function getSet2(){
 var answers = "";
 for( var i=1; i<=ile_pytan_2; i++ ){
  answers += $(".odpowiedzi input[name=answers"+i+"_2]:checked").val();
  //answers += "A"; // tutaj ma byc wlasciwa wartosc wybranej opcji!! AAABA
 }
 //alert(answers); return;
 //answers = "AAAB";
 tmpAns = answers;
 advAJAX.get({
  url: "/tematyczne/car_audio/simpleconfigurator/getset?_answers=" + answers,
  onSuccess : function( obj ) { showSet2( obj.responseText ); }
 });
}
// ------------------------------------   
// ------------------------------------
function showSet2( responseText ){
 var mySet;
 $("#konfSetWrap_2").show();
 if( !responseText ){
  return;
 }
 eval( "mySet = " + responseText );
 
 debug2 = mySet;
 $("#konfBody_2 .loader").hide();
 $("#TB_window").css("height","auto").css("width",700).css("margin-left",-300).css("margin-top",-500);
 $("#konfBody_2").css("height","auto").css("width",700).css("background","url(/tematyczne/kino_domowe/_img/layout/konfigurator_width_bg.gif) repeat-y");
 $("#konfBottom_2").css("width",700).css("background-image","url(/tematyczne/kino_domowe/_img/layout/konfigurator_width_bottom.gif)");
 $("#konfSet_2").show();
 $("#confPrint").attr("href","/tematyczne/car_audio/wydruk.html?a="+tmpAns);
  
 if( mySet.ERR ){
  $("#konfBody_2").html(msg);
  $("#konfSet_2").html( 'BLAD: ' + mySet.ERR );
  //alert( 'BLAD: ' + mySet.ERR );
  return;
 }
 if( mySet.set == 'NotMatched' ){
  $("#konfSet_2").html( 'Nie pasuje mi zaden zestaw' );
  //alert( 'Nie pasuje mi zaden zestaw' );
  return;
 }
 
 var set = mySet.set;
 var prodUrl = '/tematyczne/car_audio/catalog/product/';
 
 var setCount = 0;
 for(i in set.sapseparated) {
  setCount++;
  $("#s"+setCount+"_2").append('<br /><b class="zestaw_click">Zestaw '+setCount+':</b><br /><br />');
  $("#s"+setCount+"_2").append('<div class="setTop"><img class="zestaw_click" /><br /><br /></div>');
  $("#s"+setCount+"_2").append('<div class="elementy">Elementy zestawu:</div><br /><br />');
  
 }
 
 var flashVars = {};
 var imgCount = {};
 var spanSelect = {};
 var spanLength = {};
 var oneMore = {};
 
 var initPic = "";
 for(j=0;j<setCount;j++) {
  flashVars[j] = {};
  imgCount[j] = 1;
  spanSelect[j] = 0;
  spanLength[j] = 0;
  flashVars[j][0] = "";
  oneMore[j] = false;
  if(set.pictures[j+1].length > 0) {
   if(initPic.length < 1) initPic = set.pictures[j+1];
   flashVars[j][0] = set.pictures[j+1];
   oneMore[j] = true;
   spanLength[j] = 1;
 }
 }
 
 
 arr = set.sapseparatedfull;
 for(j=0;j<setCount;j++) {
  var setArr = arr[j+1];
  var ind2 = 0;
  for(i in setArr) {
   ind2++;
   var tmpImg = "'"+setArr[i].cp_icon+"'";
   var tmp2Img = "'"+prodUrl+setArr[i].cp_id+"'";
   var app = '<a target="_blank"  href="'+prodUrl+setArr[i].cp_id+'">'+setArr[i].cp_name+'</a>';
   var app2 = '<div class="wrap_icon_small"><a onMouseOver="onImg('+tmpImg+','+tmp2Img+',this)" onmouseout="outImg()" target="_blank" href="'+prodUrl+setArr[i].cp_id+'"><img class="photo_dol" src="/_uploaded/productsimages/'+setArr[i].cp_icon_small+'"/></a></div>'; // ---- ------
   var app3 = setArr[i].cp_price; // ---- ------
    //         ------------------             DODANE 06.09.2008         ----------------------------------
   
    if(app3 == 0 || app3 == null){
     app3 = "na telefon";
    }
   
   $("#s"+(j+1)+"_2").append('<span class="icon_small">'+app2+'</span>');
   $("#s"+(j+1)+"_2").append('- <span>'+app+'</span><br />');
   
   
   if(app3 == "na telefon"){
     $("#s"+(j+1)+"_2").append('<span class="odstep_cena">- Cena: '+app3+'</span><br/><br/>');
   }
   else{
  $("#s"+(j+1)+"_2").append('<span class="odstep_cena">- Cena: '+app3+' zł</span><br/><br/>');
  }
   
   //------------       DODANE 06.09.2008         ------------
   
   spanLength[j] += 1;
   flashVars[j][ind2] = "";
   imgCount[j] += 1;
   if(setArr[i].cp_icon_small.length > 0)
    flashVars[j][ind2] = setArr[i].cp_icon_small;
 }
 }
 
 
 for(j=0;j<setCount;j++) {
  if(set.sapseparated[j+1].length > 0)
   $("#s"+(j+1)+"_2").append('- '+set.sapseparated[j+1].replace( /;/g, '<br>- ' )+'<br />');
 }
 
 if(initPic.length > 0) {
  imgTemp = $("#picture_2 img").attr("src");
  $("#picture_2").append('<img src="" />');
  imgTemp2 = set.scdir+initPic;
  $("#picture_2_temp").append('<a target="_blank" href=""></a>');
  $("#picture_2").append('<br/><br/><b class="zestaw_click"></b><br/>');
  $("#picture_2_temp a").append('<img src="/tematyczne/kino_domowe/_img/content/blank.gif" />');
 }
 
 var avail = {};
 var click = {};
 var curr = {};
 
 for(j=0;j<setCount;j++) {
 
  avail[j] = false;
  click[j] = false;
  curr[j] = 0;
  if(flashVars[j][0].length > 0) {
   click[j] = true;
  $("#s"+(j+1)+"_2 .setTop img").attr("src",set.scdir+"min_"+flashVars[j][0]);
  }
 if(imgCount[j] > 1) {
  avail[j] = true;
  if(!click[j]) {
    $("#s"+(j+1)+"_2 .setTop img").attr("src",set.cpdir+flashVars[j][1]);
    curr[j] = 1;
   }
 }
 if(click[j]) {
  $("#s"+(j+1)+"_2 .setTop").css("cursor","pointer");
  
  doClick(set.scdir+flashVars[j][0],j+1);
 }
 
 if(click[j]) {
  $("#s"+(j+1)+"_2 .zestaw_click").css("cursor","pointer");
  doClick2(set.scdir+flashVars[j][0],j+1);
 }
 
 if(!avail[j]) {
  $("#s"+(j+1)+"_2 .setTop").remove();
 } else {
 
 }
 
 if(!oneMore[j]) {
  $($("#s"+(j+1)+"_2 span")[0]).addClass("current");
 } 
 }
 // ---------------- usunięcie interwału 
 inter = function() {
 
  for(j=0;j<setCount;j++) {
  if(avail[j]) {
   var src = "";
   var dir = set.cpdir;
   while(src.length == 0) {
    curr[j] += 1;
    if(curr[j] == imgCount[j]) curr[j] = 0;
    src = flashVars[j][curr[j]];
   }
   spanSelect[j] += 1;
   if(spanSelect[j] == spanLength[j]) spanSelect[j] = 0;
   if(curr[j] == 0) {
    dir = set.scdir + "min_";
   }
   $("#s"+(j+1)+"_2 .setTop img").attr("src",dir+src);
   $("#s"+(j+1)+"_2 span.current").removeClass("current");
   if((spanSelect[j] == 0) && oneMore[j]) {
   } else if(oneMore[j]) {
    $($("#s"+(j+1)+"_2 span")[spanSelect[j]-1]).addClass("current");
   } else {
    $($("#s"+(j+1)+"_2 span")[spanSelect[j]]).addClass("current");
   }
  }
 }
 
 }
 
 if (($.browser.msie) && ($.browser.version < 7)) {
      $("html").css("overflow","scroll");
      var wys = $('#TB_window').height();
      var bod = $('body').height();
      if(bod > wys){
      wys = bod;
    }
   else{
     wys = wys + 200;
     }
      
     $("#konfSetWrap_2").css("padding-left","0") 
     $(".TB_overlayBG").css("height",wys+"px");
     //$("#konfBody_2").css("height","1600px;");
}
$("#desc_2").after("<div class='cl'></div>");
 
  doAbsolute();
  return;
} //koniec f. showSet2
//  --------------------------------------------------  
 function doClick(src,no) {
  $("#s"+(no)+"_2 .setTop").click(function() {
  $("#picture_2 img").attr("src",src);
 });
 };
 
function doClick2(src,no) {
  $("#s"+(no)+"_2 .zestaw_click").click(function() {
  
  click_count = click_count+1;
  $("#picture_2 img").attr("src",src);
  $("#picture_2 img").hide();
  
  if(click_count == 1){
  no_tmp = no;
 $("#picture_2").slideDown(1500);
 $("#picture_2 b.zestaw_click").html("Zestaw "+no);
 
 if (($.browser.msie) && ($.browser.version < 7)) {
      var wys = $('#TB_window').height();
    var bod = $('body').height();
      if(bod > wys){
    wys = bod + 300;
    }
    else{
    wys = wys + 400;
    }
      $(".TB_overlayBG").css("height",wys+"px");
     //$("#konfBody_2").css("height","1600px;");
}
 
 $("#picture_2 img").fadeIn(2000);
 
 $("#picture_2_temp").css("background-color","transparent");
 $("#picture_2_temp").hide();
 }
 if(click_count == 2){
  if(no_tmp == no){ 
   $("#picture_2 b.zestaw_click").html("");
   $("#picture_2 img").fadeOut(2000);
   $("#picture_2").slideUp(1500);
   click_count = 0;
   no_tmp = 0;
   $("#picture_2_temp").css("background-color","transparent");
 $("#picture_2_temp").hide();
  }
  else{
  $("#picture_2 img").fadeIn(1000);
  $("#picture_2 b.zestaw_click").html("Zestaw "+no);
  no_tmp = no;
  click_count = 1;
  }
 }
  
  imgTemp2 = src;
 });
  
 };
 
function onImg(zrodlo,zrodlo2,kto) {
 $("#picture_2_temp").hide();
 $("#picture_2_temp a").attr("href",zrodlo2);
 $("#picture_2_temp a img").attr("src","/tematyczne/kino_domowe/_img/content/blank.gif");
 putImg(kto);
 $("#picture_2_temp a img").attr("src","/_uploaded/productsimages/"+zrodlo);
 $("#picture_2_temp").slideDown(300);
 }
 
 
 function outImg() {
 $("#picture_2_temp").hover(function(){
 $("#picture_2_temp").slideDown(300);
 },
 function(){
 $("#picture_2_temp").hide();
 }
 );
 
}
 
function onImg2(src,no) {
  $("#s"+(no)+"_2 .setTop").click(function() {
  $("#picture_2 img").attr("src",src);
 });
 
 
 }
 
 function doAbsolute() {
   var tb = $("#TB_window").get(0);
  var top = tb.offsetTop + $(document).scrollTop();
   var left = tb.offsetLeft;
   left = left - 42;
   if(top < 20) top = 20;
   $("#TB_window").css("top",100+"px");
   $("#TB_window").css("left",left+"px");
   $("#TB_window").css("position","absolute");
   $("#TB_window").css("margin","0");
 }
 
function putImg(kto){
  $("#temp").show();
  
   var w1 = $("#temp").outerWidth();
   var h1 = $("#temp").outerHeight();
   $("#temp").hide();
     
  w2 = $(document).width();
   h2 = $(document).height();
   w = parseInt(w2/2);
   h = parseInt(h2/2-130);
   
   
   var off2 = $("#konfSetWrap_2").offset( );
   var top2 = off2.top;
   var left2 = off2.left;
   
   var off = $(kto).offset( );
   var top = off.top;
   var left = off.left;
   
   left = left - left2 - 60;
   
   $("#picture_2_temp").css("background-color","#ffffff");
   $("#picture_2_temp").css("border","none");
  $("#picture_2_temp").css("position","absolute");
  $("#picture_2_temp").css("z-index","4");
   $("#picture_2_temp").css("width","216px");
   
   if ($.browser.msie) {
      $("#picture_2_temp").css("height","108px");
      $("#picture_2_temp").css("padding-top","0px");
     $("#picture_2_temp").css("top",top-124);
     $("#picture_2_temp").css("left",left);
     $("")
  }
  else {
   $("#picture_2_temp").css("height","108px");
     $("#picture_2_temp").css("top",top-150);
     $("#picture_2_temp").css("left",left);
  }
  
  
} 
var tab = Array();
i = 0;
j = 0;
var zmienna = 0;
$(".icon_small").each(function(){
zmienna = $(this).height();
tab[i] = zmienna;
if(tab[i]>tab[j])
    j=i;
i++;
});
$(".icon_small").css("min-height", tab[j]+"px");
$(function(){
wyrownaj();
});
//-->
//-->

