function deleteLotImage(fileName, uniqueDivID, sessionID, lid)
{
	//Filename verwijderen uit het hidden field
	document.getElementById('images').value = document.getElementById('images').value.replace(fileName, '');
	//Foto niet meer tonen op de website
	document.getElementById(uniqueDivID).style.display = 'none';
	//Foto's uit het hidden field wegschrijven naar de sql server
	saveNewLotField(sessionID, document.getElementById('images'), lid);
}

function checkLotMaxImages(control)
{
	//Controleer of er al 10 foto's geupload zijn.
	if (document.getElementById('images').value.split('|').length >= 11)
	{
		alert("Maximaal 10 foto's");
		return false;
	}else
	{
		return true;
	}
}

function RDWCall(url)
{
	document.getElementById('upload_target').src=url;
/*
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) 
	{
		alert ("Javascript moet aan staan in uw browser om een auto aan te melden.");
		return;
	} 
	
	xmlHttp.onreadystatechange = ajaxRDWStateChanged;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
*/
}

function ajaxRDWStateChanged()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById('rdw_info').innerHTML = xmlHttp.responseText;
	}
}

function saveNewLotField(sessionID, formItem, lid)
{
	var controlID;
	var controlValue;
	
	if ((formItem.type == 'text') || (formItem.type == 'select-one') || (formItem.type == 'radio') || (formItem.type == 'textarea') || (formItem.type == 'hidden'))
	{
		//Haal de naam en de waarde van het object op.
		controlID = formItem.name;
		controlValue = escape(formItem.value);

		//Als de value 'Other' is moet er een invoerveld getoond worden.
		if (controlValue == 'Other')
		{
			if (document.getElementById(formItem.name + '_other_row')) { 
				document.getElementById(formItem.name + '_other_row').style.display = '';
			}
		}else{
			if (document.getElementById(formItem.name + '_other_row')) { 
				document.getElementById(formItem.name + '_other_row').style.display = 'none';
			}
		}
		
		//Controleer of '_other' voorkomt in de naam van het object, als dit zo is moet de waarde in het hoofdveld in sql geplaatst worden objectnaam - '_other'
		controlID = controlID.replace('_other', '');
	}else if (formItem.type == 'checkbox')
	{
		controlID = formItem.name;
		controlValue = formItem.checked;
		if (controlValue == true) 
		{
			controlValue = '1';
		}
		else
		{
			controlValue = '0';
		}
	}

	if (controlID != '')
	{
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp==null) 
		{
			alert ("Javascript moet aan staan in uw browser om een auto aan te melden.");
			return;
		} 
		var url="/auction/auction/control.asp";
		url = url + "?s=" + sessionID;
		url = url + "&act=lot_save_specs";
		url = url + "&controlID=" + controlID;
		url = url + "&controlValue=" + controlValue;
		url = url + "&lid=" + lid;
		
		xmlHttp.onreadystatechange = ajaxLotSaveSpecsFieldStateChanged;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

function ajaxLotSaveSpecsFieldStateChanged()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText != 'OK')
		{
			alert(xmlHttp.responseText);
			document.location = '/auction/auction/control.asp?act=lot_session_expire';
		}
	}
}

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;
}

