	
	function checkAll(e, id){
		if($(e).attr('checked')){
			var c = true;
		}
		else{
			var c = false;
		}
		$('#' + id + ' input[type=checkbox]').each(function(){
			$(this).attr({'checked' : c})
		});
	}
	
	function simpleElement(parent, tag, param){
		var elem 	= document.createElement(tag);
		if(param){
			$.each(param, function(key, value){
				if(key == 'txt')	$(elem).html(html_entity_decode(value));
				else 				$(elem).attr(key, value);
			});
		}			
		return parent.appendChild(elem);
	}				
	function editDomain(param){
		this.active = new Array();
		this.param 	= param;
		this.check 	= function(e){
			$('.checkdom > input[type=checkbox]', $(e).parent().parent()).attr({'checked' : true});
			$(e).css({background : '#fff url(v3/libs/img/puce_edit.gif) no-repeat top left'});
			$('#v3_field_action').css({background : '#F0CFCF', border : '1px solid #ff0000'});
		}
		this.edit 	= function(e, name){
			var n 	= this.param[name];
			if(n){
				if(!this.active[$('input', $(e).parent()).attr('name')]){
					this.active[$('input', $(e).parent()).attr('name')] = true;
					switch(n.type){
						case 'select':
							$(e).hide();
							var _select = simpleElement($(e).parent().get(0), 'select', {
								'name' 		: $('input', $(e).parent()).attr('name'),
								'style' 	: $('input', $(e).parent()).attr('style'),
								'class' 	: $('input', $(e).parent()).attr('class')
							});
							if(n.data){
								$.each(n.data, function(value, txt){
									if(value == $('input', $(e).parent()).val()){
										var selected = true;
									}
									else{
										var selected = false;
									}
									simpleElement(_select, 'option', {
										'value' 	: value,
										'txt' 		: txt,
										'selected' 	: selected
									});
								});
							}
							_select.focus();
							this.check(e);
							$(_select).blur(function(){
								$(e).show();
								$(e).html($(this).val());
								$('input', $(e).parent()).val($(this).val());
								$(this).remove();
							});
						break;
					}
					this.active[$('input', $(e).parent()).attr('name')] = false;
				}
			}
		}
	}



			$(function(){
				$('.rounded').each(function(){
					$(this).corner('sc:' + $(this).attr('lang'));
				});
				$('#field_offer').focus();
				setInterval(function(){
					new decompte();
				}, 1000);
			});
			
			function v3_minOffer(){			
				var field_offer = $('#field_offer').val();
				var min_offer 	= $('#min_offer').val();
				field_offer 	= field_offer.replace(new RegExp(',', 'gi'), '.');
				field_offer 	= Number(field_offer.replace(new RegExp('[^0-9\\.]*', 'gi'), ''));
				min_offer 		= min_offer.replace(new RegExp(',', 'gi'), '.');
				min_offer 		= Number(min_offer.replace(new RegExp('[^0-9\\.]*', 'gi'), ''));				
				if(field_offer <= min_offer){
					alert('Veuillez saissir une offre supérieure à ' + min_offer + ' €');
					$('#field_offer').select();
					$('#field_offer').focus();
					return false;
				}else return true;
			}
			
			function s(n){
				if(n > 1) 	return 's';
				else 		return '';
			}
			
			var json_time_i;
			var json_time_cache;
			function decompte(){
				var _this = this;
				this.json = function(){
					$.getJSON('v3/time.php', function(data){
						json_time_cache = data.time;
						json_time_i 	= 0;
						_this.process(data.time);
					});				
				}
				this.process = function(t){
					var dt 		= $('#v3_sincetime').attr('lang');
					var tps 	= parseInt(dt) - (parseInt(t));
					var _day 	= Math.floor(tps/(3600*24));
					tps			-= _day*(3600*24);
					var _hour 	= Math.floor(tps/(3600));
					tps			-= _hour*(3600);
					var _min 	= Math.floor(tps/(60));
					tps			-= _min*(60);
					var _sec 	= tps;
					$('#v3_sincetime').html(
						_day 	+ ' <span>jour' 	+ s(_day) + '</span> ' +
						_hour 	+ ' <span>h' 		+ '</span> ' +
						_min 	+ ' <span>min' 		+ '</span> ' +
						_sec 	+ ' <span>sec' 		+ '</span> '
					);	
					json_time_i++;			
				}
				if(!json_time_cache || json_time_i >= 60)	this.json();
				else 										this.process((Number(json_time_cache) + Number(json_time_i)));
			}
			
		
		function confirmMsg(msg, url){
			if(confirm(msg)){
				window.location.href = url;
				return true;			
			}else return false;
		}
			