function insert_sort(obj)
{
document.getElementById('srt').value=obj.value;
document.getElementById('search_form_new').submit();
}
function setupRemoveDefault() {
    var els = document.getElementsByTagName("input");

    for(var i=0,j=els.length; i<j; i++) {
     els[i].onclick = function () {removeDefault(this);}
    }    
 }
function removeDefault(el) {
  if(el.name == 'model')
  {
	if((!el.rel || el.value == el.rel) && (el.type == "text" || el.type == "")) {     el.rel = el.value;
	   
		 el.value = '';
	
		 var elName = el.id;
	
		 el.onblur = function () { if(!el.value) {addDefault(elName);}}
	
		 return true;
	
		}
   }
   
 }

function addDefault(elName) {

		var el = document.getElementById(elName);
        
		var searched_model = document.getElementById('searched_model').value;

		if(searched_model == '')

		{

		el.value = el.rel;

		}

		else

		{
		
		el.value = 'Model';

		}

 }
function submit_form()
 {
  $('#compare').submit();
 }
 function save(list_id,list_location)
 {
 var site_path = $('#site_path').val(); 
 $.post(site_path+"/modules/module-get-ajax.php",{action:'list',list_id:list_id,location:list_location}, function(response){
       if(response)
	   {
		$('#div_saved_cart').html(response);
	   }
 });
}
function img_delete(id,list_id)
{
var site_path = $('#site_path').val();	
$.post(site_path+"/modules/module-get-ajax.php",{action:'delete_record',list_id:list_id}, function(response){
   if(response)
   {
	 $('#car_'+id).remove();
   }
   });
}
//////To get finance Rate////////////////////
function finance_calc()
{	
	var cal_price = 0;
	var finance_rate = $("#finance_rate").val();
	var finance_month = $("#finance_period").val();
	var price = $("#price").val();
	var sale_price = $("#sale").val();
	cal_price = (price == '')?cal_price = sale_price:cal_price = price;
	if((finance_rate != '') && (finance_rate > 0))
	{
	  var monthly_price = (cal_price*((finance_rate/100)/12))/(1-Math.pow((1+(finance_rate/100)/12),-finance_month));
	  var weekly_payment = (monthly_price*12)/52;
	  var price_final = parseFloat(weekly_payment).toFixed(2);
	  var price_array = price_final.split('.');
	  $("#doller_price").html('$'+price_array[0]);
	  $("#cent_price").html('.'+price_array[1]);
	}
	
}
