function RedrawTable(table_id) 
{
  $('#'+table_id+' > tbody').each(function(i) 
																  {
																		$(this).mouseover(function ()	{ $(this).addClass('over'); });
																		$(this).mouseout (function ()	{ $(this).removeClass('over'); });
																		$(this).addClass(i%2?'even':'odd');
																	});
}

function RedrawTable_OddEven(table_id) 
{
	$('#'+table_id+' > tbody').each(function(i) 
																  {
																		$(this).addClass(i%2?'even':'odd');
																	});
}

function AddBasket(obj,par_id,max_qty)
{
  $.get("/ajax/add_basket.php",{id:par_id,mode:'add',max:max_qty},function(txt){
	                                $("#basket").load("/ajax/show_basket.php");
																	if (txt >= max_qty)
																	{
																	  $(obj).parents("tr").find("a.plus > img").attr({src:"/imgs/basket+off.jpg"});
																	  $(obj).parents("tr").find("a.plus").attr({href:""});
																	}	
																	else	
																	  $(obj).parents("tr").find("a.plus > img").attr({src:"/imgs/basket+.jpg"});

																	if ( (txt <= 0) || (txt == "") )
																	{
																	  $(obj).parents("tr").find("a.moins > img").attr({src:"/imgs/basket-off.jpg"});
																	  $(obj).parents("tr").find("a.moins").attr({href:""});
																	}	
																	else	
																	  $(obj).parents("tr").find("a.moins > img").attr({src:"/imgs/basket-.jpg"});

																  $(obj).parents("tr").find(".set").html(txt);
																	});
	return false;																
}

function SubBasket(obj,par_id,max_qty)
{
  $.get("/ajax/add_basket.php",{id:par_id,mode:'sub',max:max_qty},function(txt){
	                                $("#basket").load("/ajax/show_basket.php");
																	if (txt >= max_qty)
																	{
																	  $(obj).parents("tr").find("a.plus > img").attr({src:"/imgs/basket+off.jpg"});
																	  $(obj).parents("tr").find("a.plus").attr({href:""});
																	}	
																	else	
																	{
																	  $(obj).parents("tr").find("a.plus > img").attr({src:"/imgs/basket+.jpg"});
																	  $(obj).parents("tr").find("a.moins").attr({href:""});
																	}	

																	if ( (txt <= 0) || (txt == "") )
																	  $(obj).parents("tr").find("a.moins > img").attr({src:"/imgs/basket-off.jpg"});
																	else	
																	  $(obj).parents("tr").find("a.moins > img").attr({src:"/imgs/basket-.jpg"});

																  $(obj).parents("tr").find(".set").html(txt);
																	});
	return false;																
}


Email = function (value) {this.val = value || "";return this;}
Email.prototype = String;
Email.prototype.toString = function() {return this.val;}
Email.prototype.check = function()
{
	var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-_])+\.)+([a-zA-Z0-9]{2,4})$/;
	return filter.test(this.toString());
}

Phone = function (value) {this.val = value || "";this.emptyAllowed = false;return this;}
Phone.prototype = String;
Phone.prototype.toString = function() {return this.val;}
Phone.prototype.checkFix = function()
{
	if (this.emptyAllowed && this.toString() == "") return true;
	var filter1=/^([0-9]{2})[ -\/]?([0-9]{7})$/;	
	var filter2=/^([0-9]{3})[ -\/]?([0-9]{6})$/;	
	return filter1.test(this.toString()) || filter2.test(this.toString());
}

Phone.prototype.checkMobile = function()
{
	if (this.emptyAllowed && this.toString() == "") return true;
	var filter=/^([0-9]{4})[ \/\-]?([0-9]{6})$/;
	return filter.test(this.toString());
}


function CheckField(valid,field,msg,msg_field)
{
	if (valid) 
	{
	  $("#"+field).removeClass('field_error');
	  $("#"+msg_field).hide();
		return true;
	}	
	else
	{
	  $("#"+field).addClass('field_error');
		$("#"+msg_field).text(msg);
	  $("#"+msg_field).show();
		return false;
	}	

}