$(document).ready(function(){
$("#information").bind("mouseenter",function() {
$("#information p").show("");
});
$("#information").bind("mouseleave",function() {
$("#information p").hide("");
});
//$("#cautare").insertAfter("#flags");
/*$("#schimba1").click(function(event){
event.preventDefault();
$("#promo2, #promo3, #promo4").slideUp("slow", function() {
$("#promo1").slideDown("slow");
$("#schimba4, #schimba3, #schimba2").removeClass("activ");
$("#schimba1").addClass("activ");
$("#stirea").slideUp("slow");
$("#imaginile").slideDown("slow");
$("#sidebarchestie2").slideUp("slow");
$("#sidebarchestie3").slideUp("slow");
$("#sidebarchestie4").slideUp("slow");
$("#sidebarchestie1").slideDown("slow");
});
});
$("#schimba2").click(function(event){
event.preventDefault();
$("#promo1, #promo3, #promo4").slideUp("slow", function() {
$("#promo2").slideDown("slow");
$("#schimba1, #schimba3, #schimba4").removeClass("activ");
$("#schimba2").addClass("activ");
$("#stirea").slideUp("slow");
$("#imaginile").slideDown("slow");
$("#sidebarchestie1").slideUp("slow");
$("#sidebarchestie3").slideUp("slow");
$("#sidebarchestie4").slideUp("slow");
$("#sidebarchestie2").slideDown("slow");
});
});
$("#schimba3").click(function(event){
event.preventDefault();
$("#promo1, #promo2, #promo4").slideUp("slow", function() {
$("#promo3").slideDown("slow");
$("#schimba1, #schimba4, #schimba2").removeClass("activ");
$("#schimba3").addClass("activ");
$("#stirea").slideUp("slow");
$("#imaginile").slideDown("slow");
$("#sidebarchestie1").slideUp("slow");
$("#sidebarchestie2").slideUp("slow");
$("#sidebarchestie4").slideUp("slow");
$("#sidebarchestie3").slideDown("slow");
});
});
$("#schimba4").click(function(event){
event.preventDefault();
$("#promo1, #promo3, #promo2").slideUp("slow", function() {
$("#promo4").slideDown("slow");
$("#schimba1, #schimba3, #schimba2").removeClass("activ");
$("#schimba4").addClass("activ");
$("#stirea").slideUp("slow");
$("#imaginile").slideDown("slow");
$("#sidebarchestie1").slideUp("slow");
$("#sidebarchestie3").slideUp("slow");
$("#sidebarchestie2").slideUp("slow");
$("#sidebarchestie4").slideDown("slow");
});
});*/
$("#close-overlay a").click(function(event){
event.preventDefault();
$("#modalwindow").fadeOut();
$("#background-overlay").fadeOut();
$("#close-overlay").fadeOut();
});
$(".produs").mouseover(function(event){
event.preventDefault();
// $(".produs.activ").removeClass("activ");
$(this).addClass("activ");
});
$(".produs").mouseout(function(event){
event.preventDefault();
$(this).removeClass("activ");
});
$("#content #produselist li").mouseover(function(event){
event.preventDefault();
$(this).addClass("activat");
});
$("#content #produselist li").mouseout(function(event){
event.preventDefault();
$(this).removeClass("activat");
});
blink();
$(function() {
$('#pozathumb').lightBox();
$('#les_poze a').lightBox();
});
});
function blink(){
if($("#blink_proaspat").css("visibility")=='visible') $("#blink_proaspat").css("visibility","hidden");
else $("#blink_proaspat").css("visibility","visible");
setTimeout("blink();",500);
}
function adauga(id,nume,buc,pret)
{
if($("#h2cos").css("display")=='none') $("#h2cos").fadeIn('fast');
$("#divgol").fadeOut('fast');
$("#divc").fadeIn('fast');
$("#acomanda").fadeIn('fast');
$("#atentie").fadeIn('fast');
$("#text_comanda_nelogat").fadeIn('fast'); $("#divcos").fadeIn('fast');
if ( $("#tr_"+id).length > 0 ) //tr exista updatam nr-ul
{
var cant=$("#buc_"+id).val();
$("#bucati_"+id).val(cant-(-$("#bucati_"+id).val()));
$("#pret_"+id).val(pret*$("#bucati_"+id).val());
}
else //creeam tr
{
var cant=$("#buc_"+id).val();
//alert('buc'+buc);alert('pret'+pret);
$("#cosu").html($("#cosu").html()+'
| '+nume+' | '+buc+' | |  |
');
// document.write('');
}
$.post("ajax_cos.php",{todo:"adauga", id: id, cant: cant},function(data){
if(data.x==1) $("#nota_importanta").fadeIn();
if(data.x==0) $("#nota_importanta").fadeOut();
},"json");
}
function func(id,pret)
{
var nr_bucati=$("#bucati_"+id).val();
var key=id;
update_bucati(key,nr_bucati,pret);
}
function sterge(id)
{
$("#tr_"+id).remove();
$.post("ajax_cos.php",{todo:"sterge", id: id},function(data){
if (data.gol=='gol')
{
$("#divc").fadeOut('fast');
$("#divcos").fadeOut('fast');
$("#acomanda").fadeOut('fast');
$("#atentie").fadeOut('fast');
$("#divgol").fadeIn('fast');
}
if(data.x==1) $("#nota_importanta").fadeIn();
if(data.x==0) $("#nota_importanta").fadeOut();
},"json")
}
function update_bucati(key,nr_bucati,pret)
{
$.post("ajax_cos.php",{todo:"bucati", id: key, bucati: nr_bucati, pret: pret})
$("#pret_"+key).val(pret*nr_bucati);
// alert($("#pret_"+key).val())
}
function verifica_client()
{
var emailPattern= /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
err='';
var fizic=true;
if (document.getElementById('fizic').style.display=='none') {fizic=false;} //pers juridica
if (!emailPattern.test($('#email').val())) err+="Introduceti email-ul\n";
if (!$('#pass').val()) err+="Introduceti parola\n";
if (fizic)
{
if (!$('#firma').val()) err+="Introduceti numele \n";
if (!$('#prenume').val()) err+="Introduceti prenumele \n";
}
else
{
if (!$('#firma').val()) err+="Introduceti numele firmei\n";
if (!$('#codfiscal').val()) err+="Introduceti codul fiscal\n";
if (!$('#j').val()) err+="Introduceti numarul de inreg la reg comertului\n";
if (!$('#cont').val()) err+="Introduceti contul\n";
if (!$('#banca').val()) err+="Introduceti banca\n";
if (!$('#adresasediu').val()) err+="Introduceti adresa sediului\n";
}
//if (!$('#adresalivrare').val()) err+="Introduceti adresa livrare\n";
//if (!$('#zilivrare').val()) err+="Introduceti ziua de livrare\n";
//if (!$('#telefon').val()) err+="Introduceti telefonul\n";
//if (!$('#perscontact').val()) err+="Introduceti persoana de contact\n";
//if (!$('#telperscontact').val()) err+="Introduceti telefonul persoanei de contact\n";
//if (!$('#oraslivrare').val()) err+="Introduceti orasul de livrare\n";
//if (!$('#stradalivrare').val()) err+="Introduceti strada de livrare\n";
//if (!$('#nrstradaliv').val()) err+="Introduceti numarul strazii de livrare\n";
if (!$("#termeni_si_conditii").attr("checked")) err+="Trebuie sa fiti de acord cu termenii si conditiile\n";
if (err) {alert(err);return false;}
return true;
}
function verifica_clientul()
{
err='';
var fizic=false; if (fizic)
{
if (!$('#firma').val()) err+="Introduceti numele \n";
if (!$('#prenume').val()) err+="Introduceti prenumele \n";
}
else
{
if (!$('#firma').val()) err+="Introduceti numele firmei\n";
if (!$('#codfiscal').val()) err+="Introduceti codul fiscal\n";
if (!$('#j').val()) err+="Introduceti numarul de inreg la reg comertului\n";
if (!$('#cont').val()) err+="Introduceti contul\n";
if (!$('#banca').val()) err+="Introduceti banca\n";
if (!$('#adresasediu').val()) err+="Introduceti adresa sediului\n";
if (!$('#perscontact').val()) err+="Introduceti persoana de contact\n";
//if (!$('#telperscontact').val()) err+="Introduceti telefonul persoanei de contact\n";
}
//if (!$('#adresalivrare').val()) err+="Introduceti adresa livrare\n";
if (!$('#datalivrare').val()) err+="Introduceti ziua de livrare\n";
if (!$('#telefon').val()) err+="Introduceti telefonul\n";
if (!$('#orasrestrict').val()) err+="Introduceti orasul de livrare\n";
if (!$('#stradalivrare').val()) err+="Introduceti strada de livrare\n";
if (!$('#nrstradaliv').val()) err+="Introduceti numarul strazii de livrare\n";
//if (!$("#termeni_si_conditii").attr("checked")) err+="Trebuie sa fiti de acord cu termenii si conditiile\n";
if (err) {alert(err);return false;}
return true;
}
function recuperare_pass(){
var email = $("#email_recover").val();
$.post("ajax_cos.php",{todo:"recover_pass", email: email},function(data){
if(data.eroare==1){
$("#raspuns_recover").html(data.eroare_email);
}
if(data.eroare==0){
$("#raspuns_recover").html(data.raspuns);
$("#email_recover").val("");
setTimeout("$('#raspuns_recover').html('')",10000);
}
},"json")
}
function ImageBlender(container, imgs, d){
this.imgs = imgs;
this.container = container;
this.index = 0;
this.duration = d;
this.cache = [];
this.isCached = false;
this.startBlending = function(){
if(this.index == this.imgs.length){
this.index = 0;
this.isCached = true;
}
var src = this.imgs[this.index++];
this.changePhoto(src);
var that = this;
window.setTimeout(function(){
that.startBlending();
}, this.duration);
}
this.changePhoto = function(src){
var oldImg = this.container.getElementsByTagName('img')[0];
if(this.isCached == true) {
var newImg = this.cache[this.index];
if (newImg != undefined) {
newImg.style.display = 'none';
this.container.appendChild(newImg);
$(newImg).fadeIn("slow", function(){$(oldImg).remove();});
}
}else {
var newImg = document.createElement('img');
this.cache.push(newImg);
newImg.className = oldImg.className;
newImg.style.display = 'none';
this.container.appendChild(newImg);
newImg.src = src;
if (newImg.complete) {
$(newImg).fadeIn("slow", function(){$(oldImg).remove();});
}
else {
newImg.onload = function(){
$(newImg).fadeIn("slow", function(){$(oldImg).remove();});
}
}
}
}
this.startBlending();
};
function gonext() {
var visibleSlot = parseFloat(jQuery('#visibleSlot').html());
var newSlot = visibleSlot-(-1);
if (newSlot == '5')
{
gofirst();
} else {
jQuery('#show-slide-'+visibleSlot).removeClass('active');
jQuery('#show-slide-'+newSlot).addClass('active');
var newMargin = -1*478*visibleSlot+'px';
jQuery('#home-carousel-container').animate({ marginLeft: newMargin }, 350);
jQuery('#visibleSlot').html(newSlot);
}
}
function changeSlide(id) {
var newSlot = id;
var visibleSlot = newSlot-1;
if (newSlot == '0')
{
gofirst();
} else {
jQuery('#home-carousel-buttons .active').removeClass('active');
jQuery('#show-slide-'+newSlot).addClass('active');
var newMargin = -1*478*visibleSlot+'px';
jQuery('#home-carousel-container').animate({ marginLeft: newMargin }, 350);
jQuery('#visibleSlot').html(newSlot);
}
}
function gofirst() {
jQuery('#home-carousel-container').animate({ marginLeft: 0 }, 350);
jQuery('#home-carousel-buttons .active').removeClass('active');
jQuery('#show-slide-1').addClass('active');
jQuery('#visibleSlot').html('1');
}
function schPause() {
clearTimeout(masa);
};