var newWindow = null;

function BSelect(pSrc, pAr, pDest, idDestSel)
{
 var vyber = pSrc.selectedIndex
 var hodnota = pSrc.options[vyber].value
 var j=0
 pDest.options[j++] = new Option(" — Model — ", "")
 for (var i=0; i<pAr.length; i++) {
  if (parseInt(pAr[i][2])==parseInt(hodnota)) {
   pDest.options[j++] = new Option(pAr[i][1], pAr[i][0]);
   if(idDestSel == pAr[i][0]) pDest.options[j-1].selected = true;
  }
 }
 pDest.options.length = j
}

function setModel()
{
	src = document.getElementById('f_make');
	dest = document.getElementById('f_model');
	BSelect(src, Models, dest, dest.value);
}


function showReserveForm()
{
	Effect.BlindDown('reserve_form');
	Effect.Shrink('reserve_button');
	//document.getElementById('reserve_form').style.display='block';
	//document.getElementById('reserve_button').style.display='none';
}

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	
	leftVal = (screen.width - strWidth ) / 2;
	topVal = (screen.height - strHeight) / 2;	
	
	var tools="";	
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left="+leftVal+",top="+topVal+"";
	if (type == "scroll") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left="+leftVal+",top="+topVal+"";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function hideadvert()
{
	document.getElementById('advert').style.display = 'none';
	document.getElementById('currency-select').style.visibility = 'visible';
}

function showBasicSearch()
{
	document.getElementById('bsearch').style.display = 'block'; 
	document.getElementById('esearch').style.display = 'none' ; 
	Set_Cookie('search', 1, '/');

}

function showExtSearch()
{
	document.getElementById('esearch').style.display = 'block'; 
	document.getElementById('bsearch').style.display = 'none'; 	
	Set_Cookie('search', 2, '/');

}

function Set_Cookie( name, value, path, domain) {
				var today = new Date();
				today.setTime( today.getTime() );
				expires = 1 * 24;
				var expires_date = new Date( today.getTime() + (expires) );							
				document.cookie = name + "=" +escape(value) +					
					( ( path ) ? ";path=" + path : "" ) + 
					( ( domain ) ? ";domain=" + domain : "" ) 
}