// make&&model selector
var xmlHttp
function showResult(searchURL,displayDiv)
{
	document.getElementById(displayDiv).style.display = "block";
	xmlHttp=GetXmlHttpObject()
	var url= searchURL ;
	if(displayDiv=='makeDiv') 
	{
		xmlHttp.onreadystatechange = makeloadSearch
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)		
	}
	if(displayDiv=='modelDiv') 
	{
		make = document.getElementById('makeselect').value;
		document.getElementById('bikeMake').value = make ;
		url = url+'?bikeMake='+make;
		xmlHttp.onreadystatechange = modelloadSearch
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
} 

function makeloadSearch()
{ 
	if (xmlHttp.readyState==4|| xmlHttp.readyState=="complete")
	{ 
		document.getElementById("makeDiv").innerHTML=xmlHttp.responseText;
		document.getElementById("makeDiv").style.border="0px solid #A5ACB2";
	} 
}
function modelloadSearch()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("modelDiv").innerHTML=xmlHttp.responseText;
		document.getElementById("modelDiv").style.border="0px solid #A5ACB2";
	} 
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function saveModel(model)
{
	document.getElementById('bikeModel').value = model ;
}

// end:make&&model selector

function displayTyre(id)
{
	for(i=1;i<3; i++)
	{
		document.getElementById('tyre'+i).style.display = 'none';
	}
	document.getElementById('tyre'+id).style.display = 'block';
}

function scrollDivLoad(divID, limit)
{
	// get target position
	target = document.getElementById(divID).scrollTop + limit ;
	
	if(limit<0)	scrollDivUpAction(divID, target);
	else scrollDivDownAction(divID, target);
}
function scrollDivUpAction(divID, target)
{
	curPos = document.getElementById(divID).scrollTop; 
	if((curPos>document.getElementById(divID).scrollHeight) && (curPos>target))
	{
		document.getElementById(divID).scrollTop -= 10 ;
		setTimeout("scrollDivUpAction('"+divID+"', '"+target+"')", 10);
	}
}

function scrollDivDownAction(divID, target)
{
	curPos = document.getElementById(divID).scrollTop; 
	if((curPos<=document.getElementById(divID).scrollHeight) && (curPos<=target))
	{
		document.getElementById(divID).scrollTop += 10 ;
		setTimeout("scrollDivDownAction('"+divID+"', '"+target+"')", 10);
	}
}

// calendar popup
function SM_js_calpopup(location, selDay,selMonth,selYear, randID)
{
	if(document.getElementById('calpopupdiv'+randID).style.display=='block') 
	{
		document.getElementById('calpopupdiv'+randID).style.display = 'none';
	}
	else 
	{
		document.getElementById('calpopupdiv'+randID).style.display = 'block';
		document.getElementById('calpopupframe'+randID).src = location +'?randID='+randID+'&cur_calDay='+document.getElementById(selDay).selectedIndex+'&cur_calMonth='+document.getElementById(selMonth).selectedIndex+'&selDay='+selDay+'&selMonth='+selMonth+'&selYear='+selYear;
	}
}	
function SM_js_selectDate(day,month,year, selDayID, selMonthID, selYearID,randID)
{
	document.getElementById(selDayID+''+day).selected = true ;
	document.getElementById(selMonthID+''+month).selected = true ;
	document.getElementById(selYearID+''+year).selected = true ;
	document.getElementById('calpopupdiv'+randID).style.display = 'none';
}

// HTML Controllers
function setImage(target,value)
{
	document.getElementById(target).src = value ;
}
