function esteIE()
	{
		var browser = navigator.appName;

		if(browser == "Microsoft Internet Explorer") 
			return true;
			
		return false;		
	}
function MakeObject() {
	var xmlhttp=false; 
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); 
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); 
        }
		return xmlhttp;
	}
	
	

function sterge(id)
{
	var request=MakeObject();
	
	


	total=1*$("#total_tot").html()-1*$("#pret_total_"+id).html();

var newtotal = new Number(total);
total = newtotal.toFixed(2);

	$("#total_tot").html(total);
$("#tr_"+id).remove();
	
			request.open('get', 'returnant.php?tip=stergecos&id=' + id);
		/*	request.onreadystatechange = function () {
				
						if(request.readyState == 4)
					{ 
						
						var raspuns = request.responseText;	
						alert(raspuns);
						/*
						var c = document.getElementById('select_localitati');
						if(esteIE() || (navigator.appName.indexOf("Opera") + 1))
						{
							c.outerHTML = '<select name="select_localitati">'+raspuns+'</select>';
						}
						else {
							c.innerHTML = raspuns;
						}
						
					} 
			}*/
			request.send(false);
						
		
}

function update_bucati(key,nr_bucati)
{
	var request=MakeObject();


   $("#pret_total_"+key).html(nr_bucati*$("#pret_unitar_"+key).html()); 
		total=0.0;
			$("[id^=pret_total_]").each(function(){
				total +=parseInt(this.innerHTML*100)/100;
			})
		$("#total_tot").html(total);
	
			request.open('get', 'returnant.php?tip=updatecos&key='+key+'&buc='+nr_bucati);
			request.send(false);
						
		
}



$(document).ready(function(){
	 $(".carteopt").mouseover (function() {
		 $(this).addClass("hovered");
	 });
	 $(".carteopt").mouseout (function() {
		 $(this).removeClass("hovered");
	 });
	 $("li:last-child").addClass("borderless");
	 $("li:last-child a").addClass("borderless");
	 $("#bestseller1 li:last-child").removeClass("borderless");
	 $("#bestseller2 li:last-child").removeClass("borderless");
});

function rasfoieste(id) {
	var ok=false,j;
	if (document.getElementById("rasfoieste_"+id).style.display=='block') {ok=true;}
		else {clearTimeout(masa);}
		$("#rasfoieste_"+id).slideToggle();
		if (id==1) j=5;
		else j=id-1; 
		if (ok) {sch(j);$("#arasf"+id).html('rasfoieste cartea');}
		else {$("#arasf"+id).html('inchide cartea');}
	}	

$(function(){
	$('#pozecarte a').lightBox();
});

function arata(id) {
		$("#rasfoieste_1, #rasfoieste_2, #rasfoieste_3, #rasfoieste_4, #rasfoieste_5").hide();
		$("#promo .sevede").fadeOut("fast", function() {
			$("#promo .sevede").removeClass("sevede");
			$("#promo .visible").removeClass("visible");
				$("#carte"+id).fadeIn("fast", function () {
					$("#carte"+id).addClass("sevede");
					$("#arata"+id).addClass("visible");
			});
		});
		
		$("#arasf1").html('rasfoieste cartea');
		$("#arasf2").html('rasfoieste cartea');
		$("#arasf3").html('rasfoieste cartea');
		$("#arasf4").html('rasfoieste cartea');
		$("#arasf5").html('rasfoieste cartea');
		
}

function termeni(id) {
		$("#termen"+id).slideToggle("fast");
	}




function sch(id)
{
	if (id==5) id=1;else id++;
	arata(id);
	try
	{
	clearTimeout(masa);
	}
	catch(e)
	{
		
	}
	masa=setTimeout("sch('"+id+"')",15000); 
}	



