function menuselval(id1,id2,id3,id4)
{
	
	document.getElementById(id1).className = "menuleftsel";
	document.getElementById(id2).className = "menubgsel";
	document.getElementById(id3).className = "menurightsel";
	document.getElementById(id4).className = "menusel";
}
function menuunselval(id1,id2,id3,id4)
{
	document.getElementById(id1).className = "menuleftunsel";
	document.getElementById(id2).className = "menubgunsel";
	document.getElementById(id3).className = "menurightunsel";
	document.getElementById(id4).className = "menuunsel";
}




function hide()
{
		setTimeout("$('#suggestions').hide();", 200);
}
//Trim
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
}

//retain search text box values
function showsame(obj,val,show,textval)
{
	if(show==1)
	{
		if(obj.value==textval){
			obj.value=''
			}
	}
	else
	{
		if(obj.value=='')
			obj.value=val
	}
}

function fieldSort(val,cur,per) {
		showPreloader();
	    $("#pageautomoto").load("index.php?f=pagingautoMotoList&curpage="+cur+"&perpage="+per+"&sort="+val+"&rnd="+rnd);
		$("sortvalue").val = val;
		hidePreloader();	
	}
function setPagingControlValues(curpage,perpage,pageurl) {
		//showPreloader();
		
		rnd=Math.random();
		sorting = '';
		var sortVal = document.getElementById('sortvalue').value;
		if (sortVal != '')
		{
			sorting = "&sort="+sortVal;
		}
		if(pageurl!='')
		{
			$.ajax({
				type: "GET",
				url: "index.php?f=pagingautoMotoList",
				data: 	pageurl + 
						"&curpage="+curpage+
						"&perpage="+perpage+
						sorting+
						"&rnd=" + rnd ,
				beforeSend: function(){},		
				success: function(symp){
					$("#pageautomoto").html(symp);
				}
			});
		//$("#pageautomoto").load("index.php?f=pagingautoMotoList"+pageurl+"&curpage="+curpage+"&perpage="+perpage+sorting+"&rnd="+rnd); 
		}
		else
		{
		$.ajax({
				type: "GET",
				url: "index.php?f=pagingautoMotoList",
				data: 	 sorting+ 
						"&curpage="+curpage+
						"&perpage="+perpage+
						"&rnd=" + rnd ,
				beforeSend: function(){},		
				success: function(symp){
					$("#pageautomoto").html(symp);
				}
			});
	//	$("#pageautomoto").load("index.php?f=pagingautoMotoList&curpage="+curpage+"&perpage="+perpage+sorting+"&rnd="+rnd); 
		}
		//hidePreloader();	
	}
function selectModele(marquevalue,modelevalue) {
	$.ajax({
				type: "GET",
				url : "index.php?f=reacher_modele",
				data: 'marque=' +marquevalue+
					  '&modele=' +modelevalue+
					  '&rnd=' + rnd,
				beforeSend: function(){
				},
				success: function(contentRes){
					$("#displayModele").html(contentRes);
					$("#recherModele").focus();
				}
			   });
}
