function time_to_date(time) {
	time_array=new Array;
	time_array['zile']=Math.floor(time/(3600*24));
	time_array['ore']=Math.floor((time%(3600*24))/3600);
	time_array['minute']=Math.floor(((time%(3600*24))%3600)/60);
	time_array['secunde']=((time%(3600*24))%3600)%60;
	return time_array;
}
function print_time(time) {
	var time_array=time_to_date(time);
	var string="";
	if(time_array['ore']<10) time_array['ore']='0'+time_array['ore'];
	if(time_array['minute']<10) time_array['minute']='0'+time_array['minute'];
	if(time_array['secunde']<10) time_array['secunde']='0'+time_array['secunde'];
	if (time_array['zile']>0) string+=time_array['zile']+" Gün ";
	string+=time_array['ore']+":";
	string+=time_array['minute']+":"+time_array['secunde'];
	return string;
}
function put_text(id,text) {
	if (document.getElementById(id)) {
		document.getElementById(id).innerHTML=text;
	}
}
function prd(x) {
	put_text('clock',x.time);
	for (k=0; k<=x.l.length; k++) {
		if (x.l[k]) {
			xlk=x.l[k];
			$('#product_'+xlk.i+' button').removeClass('myoffer');
			if (xlk.u=='' && xlk.u!='') $('#product_'+xlk.i+' button').addClass('myoffer');
			put_text('cumparator_'+xlk.i,xlk.u);
			put_text('price_add_'+xlk.i,xlk.a);
			var $element=document.getElementById('pret_'+xlk.i);
			if ($element) {
				var $moneda=document.getElementById('moneda_'+xlk.i).innerHTML;
				if (document.getElementById('pret_'+xlk.i).innerHTML!=xlk.p+' '+$moneda) {
					//alert(BASEHREF);
					put_text('pret_'+xlk.i,xlk.p+' '+$moneda);
					next_time(xlk.i,xlk.p);
					$('#pret_'+xlk.i).effect("highlight", {color:'#ff0000'},900);
					if($('#bids_'+xlk.i).size()>0) $('#bids_'+xlk.i).load(BASEHREF+'content/ajax/last_bids.php?lid='+xlk.i);
				}
			} else {
				next_time(xlk.i,xlk.p);
				if($('#bids_'+xlk.i).size()>0) $('#bids_'+xlk.i).load(BASEHREF+'content/ajax/last_bids.php?lid='+xlk.i);
			}
			if (document.getElementById('lastSold_'+xlk.i)!=null) {
				$('#lastSold_'+xlk.i).load(BASEHREF+'content/ajax/last_sold.php?ida='+xlk.i);
			}
			temp_int=parseInt(xlk.r);
			temp_obj=document.getElementById('timp_'+xlk.i);
			//alerta($sound_on_off);
			//			if (temp_int<6  && temp_int>=0 && $sound_on_off=='on') {
			//				if($('#bg_sound_'+xlk.i).size()>0) $('#bg_sound_'+xlk.i).html(' ');
			//			}
			/*			if (temp_int<10 && temp_obj.className=='time') temp_obj.className='time ending';
			if (temp_int>10 && temp_obj.className=='time ending') temp_obj.className='time';
			*/
			$('#timp_'+xlk.i).removeClass('ending');
			if (temp_int<11) $('#timp_'+xlk.i).addClass('ending');
			if (temp_obj) {
				if (temp_int>=0) temp_obj.innerHTML=print_time(temp_int);
				else {
					if(xlk.u!='') {
						temp_obj.innerHTML='Satılmış';
						//					var d=new Date();
						//					if (d.getMonth()<10) var month='0'+d.getMonth();
						//					if (d.getDate()<10) var date='0'+d.getDate();
						//					temp_obj.innerHTML='Sona erdi:
';
						//					+date+'.'+month+'.'+d.getYear()+' '+d.getHours()+':'+d.getMinutes();
						//					$('#timp_'+xlk.i).addClass('sold');
					} else {
						temp_obj.innerHTML='Kazanılmamış';
					}
				}
			}
		}
		//		alert($.datepicker.formatDate('d-m-y',d));
	}
	if (x.e==1) alerta ('Kayıt olmalısınız');
	if (x.e==2) alerta ('Açık artırma başlamamıştır');
	if (x.e==3) alerta ('Ürün satıldı');
	if (x.e==41) alerta ('Düşük bir teklif girdiniz! Minimum teklif:'+xlk.w);
	if (x.e==111) alerta ('Ai introdus o oferta mult prea mare!');
	if (x.e==43) alerta ('Ai introdus care nu este multiplu de '+xlk.z);
	if (x.e==42) alerta ('Geçerli fiyattan daha düşük bir teklif girdiniz!');
	if (x.e==5) alerta ('Açık artırma şu anda aktif değil');
	if (x.e==6) alerta ('Zaten geçen ay 10 ihale kazandınız. Bu vuruş olamaz!');
	if (x.e==7) alerta ('Zaten son teklif sahibisiniz');
	if (x.e==8) alerta ('Bu ihaleyi sadece yeni başlayanlar kullanıcıların kullanılabilir!');
}
var valid=true;
var ids='';
var nr_script=0;
//
//function refresh_script(lid,autobid) {
//	temp_str='';
//
//	if (autobid!=null) {
//		temp_str+='&autobid='+document.getElementById(autobid).value;
//		if(document.getElementById('autobid_max_containter').style.display=='none') {
//			document.getElementById('autobid_max_containter').style.display='block';
//		}
//		document.getElementById('autobid_max').innerHTML=document.getElementById(autobid).value;
//	}
//
//	if (lid!=null) {
//		temp_str+='&lid='+lid+'&price_add='+$('#price_add_'+lid).val();
//	}
//
//	last_script=document.getElementById('refresh_'+nr_script);
//
//	if (last_script) {
//		document.getElementsByTagName('head')[0].removeChild(last_script);
//	}
//
//	nr_script++;
//
//	var script = document.createElement('script');
//	script.type = 'text/javascript';
//	script.src = BASEHREF+'script.php?nocache='+(new Date()).getTime()+'&ids='+ids+temp_str;
//	script.id =  'refresh_'+nr_script;
//
//	document.getElementsByTagName('head')[0].appendChild(script);
//
//	if (lid==null) {
//		t=setTimeout(function () { refresh_script(); },3000);
//	}
//}
function refresh_script(lid,autobid) {
	temp_str='';
	if (autobid!=null) {
		temp_str+='&autobid='+document.getElementById(autobid).value;
		if(document.getElementById('autobid_max_containter').style.display=='none') {
			document.getElementById('autobid_max_containter').style.display='block';
		}
		document.getElementById('autobid_max').innerHTML=document.getElementById(autobid).value;
	}
	if (lid!=null) {
		temp_str+='&lid='+lid+'&price_add='+$('#price_add_'+lid).val();
	}
	last_script=document.getElementById('refresh_');
	if (last_script) {
		document.getElementsByTagName('head')[0].removeChild(last_script);
	}
	nr_script++;
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = BASEHREF+'script.php?nocache='+(new Date()).getTime()+'&ids='+ids+temp_str;
	script.id =  'refresh_';
	document.getElementsByTagName('head')[0].appendChild(script);
	if (lid==null) {
		t=setTimeout(function () { refresh_script(); },2000);
	}
}
function AjaxW(parametrii,fisier,id_f,titlu_f,latime_f,inaltime_f,min_b,max_b,close_b) {
	//	NSS_win(id_f,,'',,true);
	options={
		'modal' :true,
		'width' :latime_f+20,
		'height' :inaltime_f,
		'title' : titlu_f
	};
	do_win("