function sterge_inregistrare(filename,id,ref){
if (confirm('Sunteti sigur ca vreti sa stergeti aceasta inregistrare?'))
		window.location.href=filename+'?id='+id+'&ref='+ref;
}

function cauta(){
	document.getElementById('formCautare').submit();
}

function caption(key){
var rlang=(lang==1?'ro':'en');
var cap=new Object();

cap.en=new Array('firstname','surname','company','email','subject','comments','code');
cap.ro=new Array('prenume','nume','companie','mail','subiect','comentarii','cod');
cap.fields=new Array('prenume','nume','companie','email','subiect','mesaj','cod');

for (var i=0; i<cap.fields.length; i++){
	if (cap.fields[i]==key) 
						return (eval('cap.'+rlang+'['+i+']'));
	}
}

function checkForm(e){
//id treb sa fie de forma id_field-lungime_camp-pattern-oblig lung/oblig pattern
//id_field treb sa fie numele campului care o sa apara in msj de alert
var username=/([a-zA-Z0-9\-\._])+/
var phone=/([0-9 \.\-])+/
var letters=/^[a-zA-Z ]{1,50}$/;
var tel=/^[0-9\+\-]{6,20}$/;
var digits=/^[0-9 ]+$/;
var email=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9_\.\-]+$/;
var alphanumeric=/^(.)+$/;
var path=/^[a-zA-Z0-9\.:\/]+$/;
var msg='';
var ar=e.elements;

for (i=0; i<ar.length; i++){
	if (ar[i].type!='submit'){
			elem=ar[i].id.split('-');
			//alert(i)
			//treb verificat doar ca lungine
			if (elem[3] == '10' && ar[i].length<=elem[1]) {
						ar[i].style.backgroundColor='#cc0000';
						msg+='Campul '+caption(elem[0])+' este prea scurt! \n';
						}
						else
						ar[i].style.backgroundColor='#FFFFFF';
			//treb verif  pattern ul
			if (elem[3] == '01'){
					if (eval(elem[2]+'.test(\''+ar[i].value+'\')')==false){
							ar[i].style.backgroundColor='#cc0000';
							msg+='Campul '+caption(elem[0])+' este prea scurt sau contine caractere interzise! \n';
						}
						else
						ar[i].style.backgroundColor='#FFFFFF';
			}
			//treb verif lungimea dar si pattern ul
			if (elem[3] == '11'){
					if (eval(elem[2]+'.test(\''+ar[i].value+'\')')==false || ar[i].length<elem[1]){
							ar[i].style.backgroundColor='#cc0000';
							msg+='Campul '+caption(elem[0])+' este prea scurt sau contine caractere interzise! \n';
						}
						else
						ar[i].style.backgroundColor='#FFFFFF';
			}
			//treb verif daca selectul are valoare aleasa
			if (elem[3] == '00' && (ar[i].type=='select-one' || ar[i].type=='select-multiple')) {
					if (ar[i].selectedIndex==0){
							ar[i].style.backgroundColor='#cc0000';
							msg+='Nu ati ales o optiune pentru  '+caption(elem[0])+'\n';
						}
						else
						ar[i].style.backgroundColor='#FFFFFF';
			}
	}
}

if (msg=='') return true;
		else alert(msg);
return false;
}

function enlarge(posPozeArray){
window.open('popup_produs_poza.php?file='+poze[posPozeArray],'enlarged','width=100px,height=100px,top=200px,left:400px,scrollbars=0,toolbars=0');
}

function changePic(posPozeArray){
if (posPozeArray<0) 
			{ alert('Aveti selectata prima poza!'); return false; }
if (posPozeArray>poze.length-1) 
			{ alert('Aveti selectata ultima poza!'); return false; }
curent=posPozeArray;
document.getElementById('poza_produs').src=thumbs[posPozeArray];
document.getElementById('pozaCurenta').innerHTML='Poza '+(curent+1)+' din '+poze.length+'.';
}

function empty_cart(cart_id){
if (confirm('Sunteti sigur ca doriti sa goliti cosul ?')){
	oInput=document.getElementById(cart_id).getElementsByTagName('input')
	for (i=0; i<oInput.length; i++){
			if (oInput[i].type=='text') oInput[i].value=0;
			}
	document.getElementById(cart_id).submit();
	}
}

/*                            CLASA SCROLL                           */
function _scroll(self,idDiv){
		this.self=self;
		this.scrollId=idDiv;
		this.stop=false;
		this.timeOut='';
		this.ammountPx=1; //distance to be scrolled in px
		this.ammounTime=1; //time between refresh in milliseconds
		
		this.goDown=function(){
					if (this.stop==false){
							document.getElementById(this.scrollId).scrollTop+=this.ammountPx;
							this.timeOut=setTimeout(this.self+".goDown()",this.ammounTime);
							}
							else this.clear();
					}
		
		this.goUp=function(){
					if (this.stop==false){
							document.getElementById(this.scrollId).scrollTop-=this.ammountPx;
							this.timeOut=setTimeout(this.self+".goUp()",this.ammounTime);
							}
						else this.clear();
					}
		
		this.autoScroll=function(){
    }
    
		this.clear=function(){
				this.stop=false;
				clearTimeout(this.timeOut);
				}
				
		this.plus=function(){
		document.getElementById(this.scrollId).scrollTop+=40;
		return false;
		}
		
		this.minus=function(){
		document.getElementById(this.scrollId).scrollTop+=-40;
		return false;
		}
}


/*                                         CLASA CEAS                                                */
function _clock(self,id){
			this.self=self;
			this.container=id;
			
			this.refresh = function () {
				 if(this.clockID) {
						clearTimeout(this.clockID);
						this.clockID  = 0;
				 }
				this.tDate = new Date();
				
				document.getElementById(this.container).innerHTML = "" + this.format(this.tDate.getHours()) + ":" + this.format(this.tDate.getMinutes()) + ":" + this.format(this.tDate.getSeconds())+' '+this.zi(this.tDate.getDay())+', '+this.tDate.getDate()+' '+this.luna(this.tDate.getMonth());
				this.clockID = setTimeout(this.self+".refresh()", 1000);
			}
			
			this.format = function (val){
			val="" + val;
			if (val.length==1) return '0'+val; else return val;
			}
			
			this.zi=function (x){
					switch(x){
					case 0: return 'Duminica'; break;
					case 1: return 'Luni'; break;
					case 2: return 'Marti'; break;
					case 3: return 'Miercuri'; break;
					case 4: return 'Joi'; break;
					case 5: return 'Vineri'; break;
					case 6: return 'Sambata'; break;
					}
			}
			
			this.luna=function (x){
					switch(x){
					case 0: return 'Ianuarie'; break;
					case 1: return 'Februarie'; break;
					case 2: return 'Martie'; break;
					case 3: return 'Aprilie'; break;
					case 4: return 'Mai'; break;
					case 5: return 'Iunie'; break;
					case 6: return 'Iulie'; break;
					case 7: return 'August'; break;
					case 8: return 'Septembrie'; break;
					case 9: return 'Octombrie'; break;
					case 10: return 'Noiembrie'; break;
					case 11: return 'Decembrie'; break;
					}
			}
}