function setOptions(dest,val,defaultSelect)
{
	dest.length = 0;
	dest.options[0] = new Option(defaultSelect,''); 
	index = 1;

	
	for(i=0;i<ModelsArray.length;i++)
		if(ModelsArray[i][0].toLowerCase() == val.toLowerCase())
		{
			dest.options[index] = new Option(ModelsArray[i][1],ModelsArray[i][1]); 
			index++;

		}
}

function setCars(dest,model,type,price)
{
	eval("arrayDest = "+dest.name)
	dest.length = 0;
	index = 0;
	
	for(i=0;i<arrayDest.length;i++)
	{

		if(
		   (arrayDest[i][1] == model || model=="") && 
		   (arrayDest[i][2] == type || type=="") && 
		   (arrayDest[i][3] >= price || price=="-1") && 
		   (arrayDest[i][3] <= +price+4999 || price=="-1")
		  )
		{
			dest.options[index] = new Option(arrayDest[i][0],arrayDest[i][0]); 
			index++;
		}
	}
	
	document.getElementById("current_options").innerHTML=dest.options.length; 

}



function setIndex(dest,index)
{
	selectedIndex = 0;
	for(i=0;i<dest.options.length;i++)
		if(dest.options[i].value == index)
			selectedIndex = i;
	dest.selectedIndex = selectedIndex;
}


function in_array(needle, haystack) {

    for (var i = 0; i < haystack.length; i++) 
        if (haystack[i]+'' == needle+'')
			return true;

    return false;
	
}	
