function endlargeImage(imagePath, linkPath) {		
	var image = document.getElementById('endlarged');
	var link  = document.getElementById('endlargelink');
	
	image.style.display = 'block';
	link.href = linkPath;
	image.src = imagePath;
}

function selectBoxAddOption(text,value,elementId,selected) {
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = value;
	elOptNew.selected = (selected) ? true : false;  
  var elSel = document.getElementById(elementId);

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }	
}

function showHide(idShow,idHide){
	document.getElementById(idShow).style.display = 'block';
	document.getElementById(idShow).style.visibility = 'visible';
	
	document.getElementById(idHide).style.display = 'none';
	document.getElementById(idHide).style.visibility = 'hidden';
	
}

function show_or_hide(id,style,link){
	if(style == 's'){
		document.getElementById(id).style.display = 'block';
		document.getElementById(id).style.visibility = 'visible';
	}
	if(style == 'h'){
		document.getElementById(id).style.display = 'none';
		document.getElementById(id).style.visibility = 'hidden';
	}
	document.getElementById(id).onclick = function(){ window.location.href=link; }
}

function doIcoSearch(catid,damaged){
	document.getElementById('category').value = catid;
	document.getElementById('damaged').value = damaged;
	/*document.getElementById('catform').submit();*/
	document.forms.catform.submit();
	return true;
}

function change_listmax(link){
	window.location.href = link;
}

function open_url(link){
	window.location.href = link;
	return false;
}

function Set_Cookie( name, value, expires, path, domain, secure ){
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
	
}

function s_set_category(checkBox, fieldid){
	if(checkBox.checked && checkBox.name == 'select_category1'){
		document.getElementById(fieldid).value = checkBox.value;
		document.getElementById('select_category2').checked = false;
		document.getElementById('select_category3').checked = false;
		xajax_setMakes(checkBox.value,'makes');
		xajax_setModels(0,'models');
		xajax_setCarros(checkBox.value,'carrosvorm');
		xajax_getLatestAdded(checkBox.value);
		Set_Cookie( 'c4eCat', checkBox.value, 3, '/prev3/', null, null );
		Set_Cookie( 'c4eCarros', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eFuel', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eColor', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4ePriceStart', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eMake', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eModel', '', 3, '/prev3/', null, null );
	}
	if(checkBox.checked && checkBox.name == 'select_category2'){
		document.getElementById(fieldid).value = checkBox.value;
		document.getElementById('select_category1').checked = false;
		document.getElementById('select_category3').checked = false;
		xajax_setMakes(checkBox.value,'makes');
		xajax_setModels(0,'models');
		xajax_setCarros(checkBox.value,'carrosvorm');
		xajax_getLatestAdded(checkBox.value);
		Set_Cookie( 'c4eCat', checkBox.value, 3, '/prev3/', null, null );
		Set_Cookie( 'c4eCarros', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eFuel', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eColor', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4ePriceStart', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eMake', '', 3, '/prev3/', null, null );
		Set_Cookie( 'c4eModel', '', 3, '/prev3/', null, null );
	}
	if(checkBox.checked==true && checkBox.name == 'select_category3'){
		document.getElementById('damaged').value = checkBox.value;
		Set_Cookie( 'c4eDamaged', checkBox.value, 3, '/', null, null );
		//document.getElementById('select_category1').checked = false;
		//document.getElementById('select_category2').checked = false;
	}
	if(checkBox.checked==false && checkBox.name == 'select_category3'){
		document.getElementById('damaged').value = '';
		Set_Cookie( 'c4eDamaged', '', 3, '/prev3/', null, null );
		//document.getElementById('select_category1').checked = false;
		//document.getElementById('select_category2').checked = false;
	}
}

//document.oncontextmenu = new Function("return false");