var x,y,z;
function showmeniu(nr)
{
	if(nr==1){
		clearTimeout(x);
		x=setTimeout("hover(1)",300);
	}
	if(nr==3){
		clearTimeout(y);
		y=setTimeout("hover(3)",300);
	}
	if(nr==5){
		clearTimeout(z);
		z=setTimeout("hover(5)",300);
	}	
}

function hidemeniu(nr)
{
	clearTimeout(x);
	clearTimeout(y);
	clearTimeout(z);
	if(nr==1){
		$('meniu_zbor').style.display='none';
		x=setTimeout("unhover(1)",1);
	}	
	if(nr==3){
		$('meniu_zbor1').style.display='none';
		y=setTimeout("unhover(3)",1);
	}
	if(nr==5){
		$('meniu_zbor2').style.display='none';
		z=setTimeout("unhover(5)",1);
	}	
}

function hover(nr){
	$("img" + nr).src="/scripts/image.php?hover=hover&text_id=" + nr;
	$("img" + nr + "1").src="/images/menu_star_select.jpg";
	if ((nr!=1)&&(nr!=3)&&(nr!=5)){
		x=setTimeout("unhover(1)",1);
		y=setTimeout("unhover(3)",1);
		z=setTimeout("unhover(5)",1);
	}
	if (nr==1){
		hidemeniu(3);
		hidemeniu(5);
		$('meniu_zbor').style.display='block';
		
	}
	if (nr==3){
		hidemeniu(1);
		hidemeniu(5);
		$('meniu_zbor1').style.display='block';
	}
	if (nr==5){
		hidemeniu(1);
		hidemeniu(3);
		$('meniu_zbor2').style.display='block';
	}	
}

function unhover(nr){
	$("img" + nr).src="/scripts/image.php?hover=none&text_id=" + nr;
	$("img" + nr + "1").src="/images/menu_star.jpg"
	if (nr==1){
		$('meniu_zbor').style.display='none';
	}
	if (nr==3){
		$('meniu_zbor1').style.display='none';
	}
	if (nr==5){
		$('meniu_zbor2').style.display='none';
	}	
}

function hov(nr,id){
	if(nr==1)
		$("subitem1" + id).style.background = '#e7d7c0';
	if(nr==3)
		$("subitem3" + id).style.background = '#e7d7c0';
	if(nr==5)
		$("subitem5" + id).style.background = '#e7d7c0';		
}

function unhov(nr,id){
	if(nr==1)
		$("subitem1" + id).style.background = 'none';
	if(nr==3)
		$("subitem3" + id).style.background = 'none';
	if(nr==5)
		$("subitem5" + id).style.background = 'none';		
}

var sto;
function scroll_pics(a,no)
{
	div_pics = $('scroll_box_'+no);
	if(a==0) return;
	else if(a<0)
	{
		if(div_pics.scrollLeft<=0) return;
	}
	else if(a>0)
	{
		if(div_pics.scrollLeft>=div_pics.scrollWidth) return;
	}
	div_pics.scrollLeft = div_pics.scrollLeft+a;
	sto=setTimeout('scroll_pics('+a+','+no+')',30);
}
function stop_scroll_pics()
{
	clearTimeout(sto);
}

function reseteaza_cos(){
	var a,b,i,j;
	new Ajax.Request('/scripts/cos.php',
	{
		method:'get',
		parameters: {reset_cos: 'true'},
		onSuccess: function(transport)
		{
			var response = transport.responseText || "no response text";
			//alert("Success! \n\n" + response);
			if (response == 1)
			{
				$('total1').innerHTML="0";
				$('total2').innerHTML="0";
				a = document.getElementsByClassName('inp left');
				b = document.getElementsByClassName('inp_text left');
				if(a.length>0){ 
				 	for (i=0;i<=a.length;i++){
						//alert(a[i].id);
				 	 	$(a[i].getAttribute("id")).checked = false;
				 	}
				}
				if(b.length>0){
				 	for (j=0;j<=b.length;j++){
						$(b[j].id).value = '';
				 	}
				}
				alert('Cosul de produse si servicii a fost golit!');
			}
		}
	});	
}

function IsNumeric(inputVal) {
     if (isNaN(parseFloat(inputVal))) {
           return false;
     }
     return true
}

function asculta(evt)
{
	if(evt.keyCode==8) alert(1);
}

function alow_calc(id){
	if((IsNumeric($F(id)) && $F(id)>'' && $F(id)>=0)/* || asculta(evt)*/) return true;
	return false;
}

