﻿

<!--

<!--
var debug;
var imgTemp,imgTemp2,click_count = 0,no_tmp = 0;
var tmpAns = "";
function zamknijKreator(){
tb_remove();
  getConf();
  
}
$(function(){
/* 
$.ajax({
  type: "GET",
  url: "/tematyczne/hifi/simpleconfigurator/",
  dataType: "html",
  success: function(msg){
   //alert( "Data Saved: " + msg );
   $("#konfBody").html(msg);
   $("#konfBody #dalej img").click(pyt1);
  },
  error: function(obj, msg){
   //alert("error "+msg);
  }
 });
*/
getConf()
});
var v1, v2, v3, v4, v5, v6 = '';
var enableConditions = !false;
var ile_pytan = 4;
var dlugosc = 427;
var krok = dlugosc/ile_pytan;
var aktualne_pytanie = 0;
function getConf(){
 $.ajax({
  type: "GET",
  url: "/tematyczne/hifi/simpleconfigurator/",
  dataType: "html",
  success: function(msg){
   //alert( "Data Saved: " + msg );
   $("#TB_window").attr("style","margin-left: -263px; width: 526px; margin-top: -164px; display: block;");
   $("#konfBody").attr("style","");
   $("#konfBottom").attr("style","");
   $("#konfBody").html(msg);
    aktualne_pytanie = 0;
   $("#konfBody #dalej img").click(pyt1);
   $("#konfBody #wstecz img").hide();
  },
  error: function(obj, msg){
   //alert("error "+msg);
   $("#konfBody").html("Konfigurator chwilowo niedostępny");
  }
 });
}
function showErr(){
  //alert("show");
 
 $("#konfErr").show();
 $("#konfBody #dalej img").show();
 $("#konfBody #wstecz img").show();
 $("#konfBody #wstecz img").hide();
 //$("#konfSet").hide();
}
function hideErr(){
  //alert("hide");
 $("#konfErr").hide();
 //$("#konfSet").hide();
}


function pierwsze(){
var nr_P = 1;
$("#p"+(nr_P+1)).hide();
$("#p"+(nr_P)).show();
$("#konfBody #dalej img").unbind();
  $("#konfBody #dalej img").click(pyt1_2);
  $("#konfBody #wstecz img").show();
  $("#konfBody #wstecz img").unbind();
  $("#konfBody #wstecz img").hide();

}

function pyt1(){
 //alert("pyt1");
 hideErr();
 var nr_P = 1;
 $("#bar").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers1]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers1]:checked").val();
  $("#p"+nr_P).hide();
  $("#p"+(nr_P+2)).hide();
  $("#p"+(nr_P+1)).show();
  v1 = v;
  $("#konfBody #dalej img").unbind();
  $("#konfBody #dalej img").click(pyt2);
  $("#konfBody #wstecz img").show();
  $("#konfBody #wstecz img").unbind();
  $("#konfBody #wstecz img").click(pierwsze);
 } else {
  showErr();
 }
}
function pyt2(){
 //alert("pyt2");
 hideErr();
 var nr_P = 2;
 $("#bar").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers2]:checked").size();
 if( s == 1 ){
    var v = $(".odpowiedzi input[name=answers2]:checked").val();
    $("#p"+nr_P).hide();
   $("#p"+(nr_P+2)).hide();
   $("#p"+(nr_P+1)).show();
    v2 = v;
    if( enableConditions && ( v2=='A' ) ){
      $("#3_3").hide();
      $("#3_4").hide();
    }
    $("#konfBody #dalej img").unbind();
    $("#konfBody #dalej img").click(pyt3);
    $("#konfBody #wstecz img").show();
    
    $("#konfBody #wstecz img").unbind();
    $("#konfBody #wstecz img").click(pyt1);
 } else {
  showErr();
 }
}
function pyt3(){
 //alert("pyt3");
 hideErr();
 var nr_P = 3;
 $("#bar").css("width",nr_P*krok);
 var s = $(".odpowiedzi input[name=answers3]:checked").size();
 if( s == 1 ){
  var v = $(".odpowiedzi input[name=answers3]:checked").val();
  v3 = v;
  $("#p"+nr_P).hide();  
  $("#p"+(nr_P+2)).hide();
  $("#p"+(nr_P+1)).show();
  $("#konfBody #dalej img").unbind();
  $("#konfBody #dalej img").click(pyt4);
  $("#konfBody #wstecz img").hide();
  $("#konfBody #wstecz img").show();
  $("#konfBody #wstecz img").unbind();
  $("#konfBody #wstecz img").click(pyt2);  
 } else {
  showErr();
 }
}
function pyt4(){
 hideErr();
 var s = $(".odpowiedzi input[name=answers4]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers4]:checked").val();
  v4 = v;
  showQuizResult();
  //$("#p4").hide();
  //$("#p5").show();
  //$("#konfBody .dalej span").click(pyt5);
  //$("#konfBody .submit").show();
  //nextStep();
 } else {
  showErr();
 }
}
function pyt5(){
 hideErr();
 var s = $(".odpowiedzi input[name=answers5]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers5]:checked").val();
  v5= v;
  $("#p5").hide();
  $("#p6").show();
  $("#konfBody .dalej span").click(pyt6);
 } else {
  showErr();
 }
}
function pyt6(){
 hideErr();
 var s = $(".odpowiedzi input[name=answers6]:checked").size();
 if(s==1){
  var v = $(".odpowiedzi input[name=answers6]:checked").val();
  v6= v;
  showQuizResult();
  //getSet();
 } else {
  showErr();
 }
}
function showQuizResult(){
 aktualne_pytanie =5;
 $("#konfBody .pytanie").hide();
 $("#konfBody .loader").show();
 getSet();
}
function getSet(){
 var answers = "";
 for( var i=1; i<=ile_pytan; i++ ){
  answers += $(".odpowiedzi input[name=answers"+i+"]:checked").val();
  //answers += "A"; // tutaj ma byc wlasciwa wartosc wybranej opcji!! AAABA
 }
 //alert(answers); return;
 //answers = "AAAB";
 tmpAns = answers;
 advAJAX.get({
  url: "/tematyczne/hifi/simpleconfigurator/getset?_answers=" + answers,
  onSuccess : function( obj ) { showSet( obj.responseText ); }
 });
}
function showSet( responseText ){
 var mySet;
 $("#konfSetWrap").show();
 if( !responseText ){
  return;
 }
 eval( "mySet = " + responseText );
 
 debug2 = mySet;
 $("#konfBody .loader").hide();
 $("#TB_window").css("height","auto").css("width",700).css("margin-left",-300).css("margin-top",-500);
 $("#konfBody").css("height","auto").css("width",700).css("background","url(/tematyczne/kino_domowe/_img/layout/konfigurator_width_bg.gif) repeat-y");
 $("#konfBottom").css("width",700).css("background-image","url(/tematyczne/kino_domowe/_img/layout/konfigurator_width_bottom.gif)");
 $("#konfSet").show();
 $("#confPrint").attr("href","/tematyczne/hifi/wydruk.html?a="+tmpAns);
  
 if( mySet.ERR ){
  $("#konfBody").html(msg);
  $("#konfSet").html( 'BLAD: ' + mySet.ERR );
  //alert( 'BLAD: ' + mySet.ERR );
  return;
 }
 if( mySet.set == 'NotMatched' ){
  $("#konfSet").html( 'Nie pasuje mi zaden zestaw' );
  //alert( 'Nie pasuje mi zaden zestaw' );
  return;
 }
 
 var set = mySet.set;
 var prodUrl = '/tematyczne/hifi/catalog/product/';
 
 var setCount = 0;
 for(i in set.sapseparated) {
  setCount++;
  $("#s"+setCount).append('<br /><b class="zestaw_click">Zestaw '+setCount+':</b><br /><br />');
  $("#s"+setCount).append('<div class="setTop"><img class="zestaw_click" /><br /><br /></div>');
  $("#s"+setCount).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;
 }
 }
 
 var arr = set.sapsharedfull;
 var ind = 0;
 var dir = set.cpdir;
 for(i in arr) {
  ind++;
  for(j=0;j<setCount;j++) {
 var tmpImg = "'"+arr[i].cp_icon+"'";
 var tmp2Img = "'"+prodUrl+arr[i].cp_id+"'";
   var app = '<a class="link_konf" target="_blank" href="'+prodUrl+arr[i].cp_id+'">'+arr[i].cp_name+'</a>';
   var app2 = '<div class="wrap_icon_small"><a onMouseOver="onImg('+tmpImg+','+tmp2Img+',this)" onmouseout="outImg()" target="_blank" href="'+prodUrl+arr[i].cp_id+'"><img class="photo_dol" src="/_uploaded/productsimages/'+arr[i].cp_icon_small+'"/></a></div>'; // ---- ------
   var app3 = arr[i].cp_price; // ---- ------
   
if(app3 == 0 || app3 == null){
     app3 = "na telefon";
    }
   
   $("#s"+(j+1)).append('<span class="icon_small">'+app2+'</span>');
   $("#s"+(j+1)).append('- <span>'+app+'</span><br />');
   
   
   if(app3 == "na telefon"){
     $("#s"+(j+1)).append('<span class="odstep_cena">- Cena: '+app3+'</span><br/><br/>');
   }
   else{
  $("#s"+(j+1)).append('<span class="odstep_cena">- Cena: '+app3+' zł</span><br/><br/>');
  }   
   //         ------------------             DODANE 06.09.2008         ----------------------------------
   
  
   
   
   spanLength[j] += 1;
   flashVars[j][ind] = "";
   imgCount[j] += 1;
   if(arr[i].cp_icon_small.length > 0) {
    flashVars[j][ind] = arr[i].cp_icon_small;
   }
 }
 
//---------------------------
 
 
 }
 
 //for(j=0;j<setCount;j++) {  
 // $("#s"+(j+1)+"_2").append('- '+set.sapshared.replace( /;/g, '<br>- ' )+'<br />');
 //}
 arr = set.sapseparatedfull;
 for(j=0;j<setCount;j++) {
  var setArr = arr[j+1];
  var ind2 = ind;
  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";
   }
  
   //    ------------   DODANE 06.09.2008  --------------------------
   $("#s"+(j+1)).append('<span class="icon_small">'+app2+'</span>');
   $("#s"+(j+1)).append('- <span>'+app+'</span><br />');
   
   if(app3 == "na telefon"){
     $("#s"+(j+1)).append('<span class="odstep_cena">- Cena: '+app3+'</span><br/><br/>');
   }
   else{
  $("#s"+(j+1)).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)).append('- '+set.sapseparated[j+1].replace( /;/g, '<br>- ' )+'<br />');
 }
 
 if(initPic.length > 0) {
  imgTemp = $("#picture img").attr("src");
  $("#picture").append('<img src="" />');
  //$("#picture_2").append('<img src="'+set.scdir+initPic+'" />');
  imgTemp2 = set.scdir+initPic;
  $("#picture_temp").append('<a target="_blank" href=""></a>');
  $("#picture").append('<br/><br/><b class="zestaw_click"></b><br/>');
  $("#picture_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)+" .setTop img").attr("src",set.scdir+"min_"+flashVars[j][0]);
  }
 if(imgCount[j] > 1) {
  avail[j] = true;
  if(!click[j]) {
    $("#s"+(j+1)+" .setTop img").attr("src",set.cpdir+flashVars[j][1]);
    curr[j] = 1;
   }
 }
 if(click[j]) {
  $("#s"+(j+1)+" .setTop").css("cursor","pointer");
  
  doClick(set.scdir+flashVars[j][0],j+1);
 }
 
 if(click[j]) {
  $("#s"+(j+1)+" .zestaw_click").css("cursor","pointer");
  doClick2(set.scdir+flashVars[j][0],j+1);
 }
 
 if(!avail[j]) {
  $("#s"+(j+1)+" .setTop").remove();
 } else {
 
 }
 
 if(!oneMore[j]) {
  $($("#s"+(j+1)+" 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)+" .setTop img").attr("src",dir+src);
   $("#s"+(j+1)+" span.current").removeClass("current");
   if((spanSelect[j] == 0) && oneMore[j]) {
   } else if(oneMore[j]) {
    $($("#s"+(j+1)+" span")[spanSelect[j]-1]).addClass("current");
   } else {
    $($("#s"+(j+1)+" 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;
    }
      $("#desc .zestaw").css("margin-left","30px")
     $("#konfSetWrap_2").css("padding-left","0")
     $(".TB_overlayBG").css("height",wys+"px");
     //$("#konfBody_2").css("height","1600px;");
}
 
  $("#desc").after("<div class='cl'></div>");
 
  doAbsolute();
  return;
} //koniec f. showSet2
//  --------------------------------------------------  
 function doClick(src,no) {
  $("#s"+(no)+" .setTop").click(function() {
  $("#picture img").attr("src",src);
 });
 };
 
function doClick2(src,no) {
  $("#s"+(no)+" .zestaw_click").click(function() {
  
  click_count = click_count+1;
  $("#picture img").attr("src",src);
  $("#picture img").hide();
  
  if(click_count == 1){
  no_tmp = no;
 $("#picture").slideDown(1500);
 $("#picture 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;
    }
    else{
    wys = wys + 400;
    }
      $(".TB_overlayBG").css("height",wys+"px");
     //$("#konfBody_2").css("height","1600px;");
}
 
 $("#picture img").fadeIn(2000);
 
 $("#picture_temp").css("background-color","transparent");
 $("#picture_temp").hide();
 }
 if(click_count == 2){
  if(no_tmp == no){ 
  $("#picture b.zestaw_click").html("");
   $("#picture img").fadeOut(2000);
   $("#picture").slideUp(1500);
   click_count = 0;
   no_tmp = 0;
      $("#picture_temp").css("background-color","transparent");
 $("#picture_temp").hide();
  }
  else{
  $("#picture img").fadeIn(1000);
  $("#picture b.zestaw_click").html("Zestaw "+no);
  no_tmp = no;
  click_count = 1;
  }
 }
  
  imgTemp2 = src;
 });
  
  
 /*
  $("#s"+(no)+"_2 .zestaw_click").hover(
  function(){
    $("#picture_2 img").attr("src",src);
    $("#picture_2").show();
// tutaj był komentarz
  $("#picture_2_temp").show();
     $("#picture_2_temp").css("background-color","transparent");
     $("#picture_2_temp").css("border","none");
   $("#picture_2_temp").css("position","absolute");
   $("#picture_2_temp").css("width","600px");
   $("#picture_2_temp").css("height","260px");
    $("#picture_2_temp").css("top",100);
    $("#picture_2_temp").css("left",41);
     // do tego miesjca
  }
 
 ,
  function(){
   $("#picture_2").hide();
   $("#picture_2 img").attr("src",imgTemp2);
    $("#picture_2").show();
  }
 
 
 );
 
 */
 };
 
function onImg(zrodlo,zrodlo2,kto) {
 //alert("Hello World !!!!");   
 //imgTemp = $("#picture_2 img").attr("src");
 $("#picture_temp a").attr("href",zrodlo2);
 $("#picture_temp a img").attr("src","/tematyczne/kino_domowe/_img/content/blank.gif");
 putImg(kto);
 //console.log(kto);
 //console.log($(kto));
 //$("#picture_2 img").attr("src","/_uploaded/productsimages/"+zrodlo);
 $("#picture_temp a img").attr("src","/_uploaded/productsimages/"+zrodlo);
 $("#picture_temp").slideDown(300);
 }
 
 
 function outImg() {
 $("#picture_temp").hover(function(){
 $("#picture_temp").slideDown(300); 
},
 function(){
 $("#picture_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;
   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").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;
   
   //alert(' h2: ' + h2 + '; h: ' + h + ' pageY: ' + pageY);
   
   $("#picture_temp").css("background-color","#ffffff");
   $("#picture_temp").css("border","none");
  $("#picture_temp").css("position","absolute");
  $("#picture_temp").css("z-index","4");
   $("#picture_temp").css("width","216px");
   //$("#picture_2_temp").css("margin-left",w+"px");
   //$("#picture_2_temp").css("top",h+"px");
  
   //console.log(top);
   
   if ($.browser.msie) {
      $("#picture_temp").css("height","108px");
      $("#picture_temp").css("padding-top","0px");
     $("#picture_temp").css("top",top-114);
     $("#picture_temp").css("left",left);
  }
  else {
   $("#picture_temp").css("height","108px");
     $("#picture_temp").css("top",top-144);
     $("#picture_temp").css("left",left);
  }
  
  
   
} 
//-->
//-->

