
//FB
    $(function(){

    $("#wysuwane").css("left","-210px");

$("#wysuwane").hover(
  function () {
    $("#wysuwane").animate({left: "0px"}, 1000 );
        $(this).addClass("zamknij");
  },
  function () {
    $("#wysuwane").animate({left: "-210px"}, 1000 );
        $(this).removeClass("zamknij");
  }
);
});





function PreLoadZ()
{
picAA1= new Image(); picAA1.src="http://www.musicimport.pl/gfx/tabs/AA1.gif";
picAA2= new Image(); picAA2.src="http://www.musicimport.pl/gfx/tabs/AA2.gif";
picAA3= new Image(); picAA3.src="http://www.musicimport.pl/gfx/tabs/AA3.gif";

}
























//dodaj komentarz
function addComment(id_foto)
{
$('#SaveProcess').show();

$.post("inc/ajax_komentarz.php", { id_foto: id_foto, komentarz: $('#komentarz').val(), action: 'add' },
    function(data)
    {
     if(data.status==99)
     {
     $('#komentarz').val('');
     $('#SaveProcess').html(data.info);
     window.location.reload();
     }else{
          $('#SaveProcess').html(data.info);
          }
    },
    "json"
  );
}








//wyslij kontakt
function SendKontakt()
{


if($('#emailK').val()!='' && $('#imieK').val()!='' && $('#trescK').val()!='')
{
$('#PopUpLoader').show();

$.post("inc/ajax_wyslij_kontakt.php", { email:$('#emailK').val(), imie:$('#imieK').val(), tresc:$('#trescK').val(), action: 'kontakt' },
    function(data)
    {
    $('#kontaktBox').text(data);
    }
  );
}else{
     alert('proszę wypełnić formularz');
     }


}
//---------------------













//baner top layer-----------
function close_baner()
{
var theobj= eval ('document.getElementById("Reklama")');
theobj.innerHTML='';
theobj.style.display='none';
}

//close po x sec.
function CloseAfter(sec)
{
 var tgx=setTimeout("close_baner()",sec*1000);
}
//----------------------






function ChClass(divid,newclass)
{
 theobj= eval ('document.getElementById("'+divid+'")');
 theobj.className= newclass;
}














//dodaj do porownania
function addToCompare(id_towar,id_struktura_www)
{
if(id_towar>0)
{
$('#Compare'+id_towar).text('proszę czekać...');

$.post("inc/ajax_compare.php", { id_towar:id_towar, id_struktura_www:id_struktura_www, action: 'add' },
    function(data)
    {
    $('#Compare'+id_towar).html(data);
    }
  );
}

}




//usun z porownania
function delFromCompare(id_towar,id_struktura_www)
{
if(id_towar>0)
{
$('#Compare'+id_towar).text('proszę czekać...');

$.post("inc/ajax_compare.php", { id_towar:id_towar, id_struktura_www:id_struktura_www, action: 'del' },
    function(data)
    {
    $('#Compare'+id_towar).html(data);
    }
  );
}

}












//zapytaj
function SendPytanie(id_towar,rodzaj)
{

if($('#emailZ').val()!='' && $('#imieZ').val()!='' && $('#trescZ').val()!='')
{

 if($('#ok:checked').val()==1)
 {
  $('#PopUpLoader').show();
  $.post("inc/ajax_zapytaj.php", { id_towar: id_towar, email:$('#emailZ').val(), imie:$('#imieZ').val(), tresc:$('#trescZ').val(), action: rodzaj },
    function(data)
    {
    $('#zapytanieBox').text(data);
    }
  );
 }else{
      alert('Prosimy o wyrażenie zgody na przetwarzanie danych')
      }

}else{
     alert('proszę wypełnić formularz');
     }

}

































function sprintf()
{
   if (!arguments || arguments.length < 1 || !RegExp)
   {
      return;
   }
   var str = arguments[0];
   var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
   var a = b = [], numSubstitutions = 0, numMatches = 0;
   while (a = re.exec(str))
   {
      var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
      var pPrecision = a[5], pType = a[6], rightPart = a[7];

      numMatches++;
      if (pType == '%')
      {
         subst = '%';
      }
      else
      {
         numSubstitutions++;
         if (numSubstitutions >= arguments.length)
         {
            alert('Error! Not enough function arguments (' + (arguments.length - 1)
               + ', excluding the string)\n'
               + 'for the number of substitution parameters in string ('
               + numSubstitutions + ' so far).');
         }
         var param = arguments[numSubstitutions];
         var pad = '';
                if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
           else if (pPad) pad = pPad;
         var justifyRight = true;
                if (pJustify && pJustify === "-") justifyRight = false;
         var minLength = -1;
                if (pMinLength) minLength = parseInt(pMinLength);
         var precision = -1;
                if (pPrecision && pType == 'f')
                   precision = parseInt(pPrecision.substring(1));
         var subst = param;
         switch (pType)
         {

         case 'b':
            subst = parseInt(param).toString(2);
            break;
         case 'c':
            subst = String.fromCharCode(parseInt(param));
            break;
         case 'd':
            subst = parseInt(param) ? parseInt(param) : 0;
            break;
         case 'u':
            subst = Math.abs(param);
            break;
         case 'f':
            subst = (precision > -1)
             ? Math.round(parseFloat(param) * Math.pow(10, precision))
              / Math.pow(10, precision)
             : parseFloat(param);
            break;
         case 'o':
            subst = parseInt(param).toString(8);
            break;
         case 's':
            subst = param;
            break;
         case 'x':
            subst = ('' + parseInt(param).toString(16)).toLowerCase();
            break;
         case 'X':
            subst = ('' + parseInt(param).toString(16)).toUpperCase();
            break;
         }
         var padLeft = minLength - subst.toString().length;
         if (padLeft > 0)
         {
            var arrTmp = new Array(padLeft+1);
            var padding = arrTmp.join(pad?pad:" ");
         }
         else
         {
            var padding = "";
         }
      }
      str = leftpart + padding + subst + rightPart;
   }
   return str;
}

//---------------------------------------------































//----sortowanie
function SetSort(typ)
{
$.post("inc/ajax_sort.php", { typ:typ, action: 'sesort' },
    function(data)
    {
     window.location.reload();
    }
  );


}












//kontakt
function SendEmailKontakt() {

$('#KomunikatKontakt').text('proszę czekać...').fadeIn(400);

if($('#k_email').val()!='' && $('#k_temat').val()!='' && $('#k_pytanie').val()!='')
{
$.post("inc/ajax_email_kontakt.php", { firma:$('#k_firma').val(), imie:$('#k_imie').val(), telefon:$('#k_telefon').val(), email:$('#k_email').val(), miasto:$('#k_miasto').val(), temat:$('#k_temat').val(), priorytet:$('#k_priorytet').val(), pytanie:$('#k_pytanie').val(), action: 'kontakt' },
    function(data)
    {
    $('#KomunikatKontakt').text(data);
    }
  );
}else{
      $('#KomunikatKontakt').text('proszę wypełnić formularz');
      $('#KomunikatKontakt').fadeOut(3000);
     }

}








//--------------------------------------------------------
var nr_tmp=0;
var t;
var stop=0;
var IdDivG=0;
var ColorOn='#ff0000';
var ColorOff='#A8A8A8';
var ClassOn='On';
var ClassOff='Off';

//typ A B C
//zakladki-------
function GetZ(elem,nr,typ,max,url)
{
 //gasimy wszystkie
 for(i=1;i<=max;i++) { theobj= $("#"+elem+i);  theobj.hide(); }

 //odpla tylko kliknieta
 theobjActive= $("#"+elem+nr);  theobjActive.fadeIn(800);
 //theobjActive= $("#"+elem+nr);  theobjActive.show();


 //tlo zakladek
 $("#dzial_"+elem).css({'background' : '#ffffff url(/gfx/tabs/'+typ+nr+'.gif) no-repeat'});


 if(nr==1) { $('#see_more').html('<a href="aktualnosci,0,1.html">zobacz wszystkie</a>'); }
 if(nr==2) { $('#see_more').html('<a href="artykuly,0,1.html">zobacz wszystkie</a>'); }
 if(nr==3) { $('#see_more').html('<a href="testy,0,1.html">zobacz wszystkie</a>'); }


 //wylacz napisy OFF ustaw odpowiednie
 for(i=1;i<=max;i++)
 {
 //$("#img_"+elem+i).attr('src','gfx/tabs/btn'+i+typ+tlo[i]+'.gif');
 }


 //aktuwny napis
 //$("#img_"+elem+nr).attr('src','gfx/tabs/btn'+nr+typ+'on.gif');



 if(nr_tmp==nr && typ_tmp==typ) //adres kategorii
 {
 var urlgo='';
 if(url!='') {  top.location.href = url; }
 if(nr==1 && elem=='zak') { urlgo='#';}
 if(nr==2 && elem=='zak') { urlgo='#';}
 if(nr==3 && elem=='zak') { urlgo='#';}
 //if(urlgo!='') { top.location.href = urlgo; }
 }
 nr_tmp=nr; typ_tmp=typ; t=0;
}

//-------------------








//zakladki-------
function Zakladki6000(elem,nr,tlo,typ,max,url)
{
 //gasimy wszystkie
 for(i=1;i<=max;i++) { theobj= $("#"+elem+i);  theobj.hide(); }

 //odpla tylko kliknieta
 theobjActive= $("#"+elem+nr);  theobjActive.fadeIn(800);
 //theobjActive= $("#"+elem+nr);  theobjActive.show();


 //tlo zakladek
 //$("#dzial_"+elem).css({'background' : '#ffffff url(/gfx/tabs/'+typ+nr+'.gif) no-repeat'});



 //wylacz napisy OFF ustaw odpowiednie
 for(i=1;i<=max;i++)
 {
 statusBtn=parseInt(i-1);
 //if(i==1){alert(statusBtn+' '+tlo.indexOf(statusBtn))}
 $("#img_"+typ+i).attr('src','gfx/tabs/btn'+i+typ+tlo.charAt(statusBtn)+'.gif');
 }

 nr_tmp=nr; typ_tmp=typ; t=0;
}

//-------------------












//--zakladki home - ruch-------------------------------------------
var tab_next=0;
var MaxTab=3;
var ActiveMove=1;

function MoveTab()
{
 if(ActiveMove==1) { tab_next=tab_next+1; }
 var t=setTimeout("MoveTab()",CzasTab);
 if(ActiveMove==1) { GetZ('zakA',tab_next,'AA',3,'#'); }
 if(tab_next>=MaxTab) { tab_next=0; }
}

//---------------------------------------------








function NewsletterGo()
{
 if($('#ok:checked').val()==1)
 {
 $('#formularzn').submit();
 }else{
      alert('Prosimy o wyrażenie zgody na przetwarzanie danych')
      }
}















//--wiadomosc ------------------------------
function setProducent(URLparam, URLkat, URLproducent) {

if($('#IDproducent').val()>=0)
{
var url=URLparam+',0,'+URLkat+','+$('#IDproducent').val()+',0,P,produkty.html';
$('#FormProducent').text('Proszę czekać...');
top.location.href = url;
}

}
//-----------------------------------------------
































//wyslij znajomemu
function SendZnajomy()
{

if($('#emailnWZ').val()!='' && $('#emailoWZ').val()!='' && $('#trescWZ').val()!='')
{
$('#PopUpLoader').show();

$.post("inc/ajax_wyslij_znajomemu.php", { emailn:$('#emailnWZ').val(), emailo:$('#emailoWZ').val(), tresc:$('#trescWZ').val(), action: 'znajomy' },
    function(data)
    {
    $('#znajomyBox').text(data);
    }
  );
}else{
     alert('proszę wypełnić formularz');
     }

}

















//dodaj skllep
function AddSklep()
{
var err='';

if($('#nipS').val()=='') {err='NIP';}
if($('#emailS').val()=='') {err='email';}
if($('#sklepS').val()=='') {err='nazwa';}
if($('#adresS').val()=='') {err='ulica';}
if($('#kod_pocztowyS').val()=='') {err='kod pocztowy';}
if($('#id_wojewodztwoS').val()=='') {err='wojewodztwo';}
if($('#telefonS').val()=='') {err='telefon';}
if($('#wwwS').val()=='') {err='www';}
if($('#hasloS').val()=='') {err='hasło';}


if($('#nipS').val()!='' && $('#emailS').val()!='' && $('#sklepS').val()!='' && $('#adresS').val()!='' && $('#kod_pocztowyS').val()!='' && $('#miastoS').val()!='' && $('#id_wojewodztwoS').val()!='' && $('#telefonS').val()!=''  && $('#wwwS').val()!='' && $('#hasloS').val()!='' )
{
$('#PopUpLoader').show();

$.post("inc/ajax_dodaj_sklep.php", { nip:$('#nipS').val(), haslo:$('#hasloS').val(), email:$('#emailS').val(), adres_przedrostek:$('#adres0').val(),  sklep:$('#sklepS').val(), adres:$('#adresS').val(), kod_pocztowy:$('#kod_pocztowyS').val(), miasto:$('#miastoS').val(), id_wojewodztwo:$('#id_wojewodztwoS').val(), telefon:$('#telefonS').val(), www:$('#wwwS').val(), action: 'sklep' },
    function(data)
    {
    $('#znajomyBox').html(data);
    }
  );
}else{
     alert('proszę wypełnić formularz ['+err+']');
     }

}





//aktualizuj nip -haslo
function CheckPass(passok, typ)
{


if(typ=='aktualizuj_dane')
{
 if(passok==$('#hasloS').val())
 {
 $('#Flog').hide(); $('#Fnext').fadeIn(700);
 }else{
      $('#Komunikat').html('Proszę wpisać prawidłowy login i hasło').fadeIn(500).delay(1000).fadeOut(500);
      }
}


if(typ=='login') { Login('login'); /*$('#Fnext').fadeIn(700);*/ }


if(typ=='login_admin') { Login('login_admin');  }

}






//aktualizju nip
function AktualizujNip(ids)
{

if(ids>0 && $('#nipS').val()!='')
{
$('#PopUpLoader').show();

$.post("inc/ajax_sklep.php", { ids:ids, nip:$('#nipS').val(), action: 'updatenip' },
    function(data)
    {
    $('#PopUpLoader').hide();
    $('#Fnext').text(data);
    }
  );
}else{
     alert('proszę wypełnić formularz');
     }

}






/*
//zaloguj do cennikow
function Login(act)
{
if($('#nipS').val()!='')
{
$('#PopUpLoader').show();

$.post("inc/ajax_sklep.php", { haslo: $('#hasloS').val(), nip:$('#nipS').val(), action: act },
    function(data)
    {
     if(parseInt(data)==99)
     {
     //$('#form_log').submit();
     window.location.reload();
     }else{
          $('#PopUpLoader').hide();
          $('#Komunikat').html(data).show();
          }
    //$('#PopUpLoader').hide();
    //$('#Fnext').text(data);
    }
  );
}else{
     alert('proszę wypełnić formularz');
     }

}

*/






//login do cennikow
function LoginForm()
{
displayUrl('modalDialog_contentDiv_foto', 'popup.php?d=Sklepy/Login,download_cennik', 430, 250);
return false;
}






//zapisz dane sklwpu
function AktualizujDane()
{
 if($('#sklepS').val()!='')
 {
 $('#form_ak').submit();
 }else{
       alert('proszę wypełnić nazwę firmy');
      }
}














//zmien logo na activ
function FireLogo(IdImg,SrcImg)
{

 $("#"+IdImg).attr('src','gfx/'+SrcImg);
 //$("#"+IdImg).animate({ opacity: 0.5 }, 1000);

}
//---------------











//*********mediabank******************
function showBigFile(id)
{
$('#BigFile'+id).html('<div style="width:300px; height:300px; background:#ebebeb; border:solid 1px Arial"><img style="border:solid 1px #ebebeb; width:300px;" alt="" src="http://datafile.pl/download/ico/big_'+id+'.jpg"/></div>').fadeIn(500);

$('#BigFile'+id).mouseout(function() {
  hideBigFile(id);
});

}

function hideBigFile(id)
{
$('#BigFile'+id).fadeOut(200);
}
//*********end mediabank******************









//********Rap zmina cen******************
function ZmianCenUsun(iddel)
{

$('#BtnUsun').html('proszę czekać...');

$.post("inc/ajax_zmiana_cen.php", { iddel:iddel, action: 'usun' },
    function(data)
    {
    window.location.reload();
    }
  );

}


//usun caly typ cen
function ZmianCenUsunTyp(tydzien, rok, typ)
{
$('#BtnUsun').html('proszę czekać...');

$.post("inc/ajax_zmiana_cen.php", { tydzien:tydzien, rok:rok, typ:typ, action: 'usuntyp' },
    function(data)
    {
    window.location.reload();
    }
  );

}

//usun dla firmy
function ZmianCenUsunFirma(tydzien, rok, idf)
{
$('#BtnUsun').html('proszę czekać...');

$.post("inc/ajax_zmiana_cen.php", { tydzien:tydzien, rok:rok, idf:idf, action: 'usunfirma' },
    function(data)
    {
    window.location.reload();
    }
  );

}

//*********end Rap zmina cen*****************














//ustaw focus
function setFocusInput(InputId)
{

 if(InputId!='')
 {
  $('#'+InputId).focus();
  $('#'+InputId).delay(500).focus();
 }
}




//akcja w czasie piania po inpucie
function InputKeyUp(thiss, submitaction)
{
jQuery(thiss).keypress(function(e) {
  code = e.keyCode ? e.keyCode : e.which;
  if(code.toString() == 27) {
      hs.close();
  }

  if(code.toString() == 13) {
     $('#formularzpopup').submit();
  }

});

}






function clickUrl(e, id_statystyka_typ, id_obiekt, status)
{

 $.post("inc/ajax_statystyka.php", { id_statystyka_typ: id_statystyka_typ, id_obiekt:id_obiekt, status: status, action: 'statystyka' },
    function(data)
    {
//if(id_statystyka_typ==8) {alert(data)}
    window.location.href = $(e).attr("href");
    }
  );

//window.location.href = $(e).attr("href");
//alert($('#Href1').attr("href"))
//alert($(e).attr("href"))
//$('#Test').html('a');

}


//z onclick gorywy url
function clickUrl2(url, id_statystyka_typ, id_obiekt, status)
{
 $.post("inc/ajax_statystyka.php", { id_statystyka_typ: id_statystyka_typ, id_obiekt:id_obiekt, status: status, action: 'statystyka' },
    function(data)
    {
     if(url!='')
     {
     window.location.href = url;
     }
    }
  );
}


