var ml_Picker_SearchString = 'Search on:';
var ml_Picker_Title = 'Picker';
var ml_Picker_SearchButton = 'Search';

function simplePickerFind(view, fieldName, modelProperty, context, width, height)
{ 
	var newHTML = new String();
	
	
	newHTML += '<table>';
	newHTML += '	<tr>';
	newHTML += '		<td style="width: 80px" >' + ml_Picker_SearchString + '</td>';
	// HAKH VPA-4138 29-11-2011 : textbox moest even breedt zijn als de textbox organisatie op de gebruiker admin pagina (300px)
	newHTML += '		<td style="width: 310px" ><input type="text" id="' + view + 'PickerSearch" style="width:300px;" onkeyup="JavaScript:simplePickerSearchRequest(document.getElementById(\'' + view + 'PickerSearch\').value, \'' + view + '\', \'' + fieldName + '\')"></input></td>';
	newHTML += '		<td style="TEXT-ALIGN: center"><INPUT id="btnSearch" type="button" value="' + ml_Picker_SearchButton + '" runat="server" size="30" ';
	newHTML += ' onclick="JavaScript:simplePickerSearchRequest(document.getElementById(\'' + view + 'PickerSearch\').value, \'' + view + '\', \'' + fieldName + '\')"></td>';
	newHTML += '	</tr>';
	newHTML += '</table>';
	newHTML += '<table>';
	newHTML += '	<tr>';
	newHTML += '		<td colspan="3">';
	newHTML += '			<br><table class="grid_table"><tr><td>';
	newHTML += '			<div class="pickerTableContainer" style="OVERFLOW: none; LEFT: 20px; WIDTH: ' + width.toString  + 'px; HEIGHT: ' + height.toString + 'px;"';
	newHTML += '				runat="server" id="' + view + fieldName + 'PickerDiv"></div></td></tr></table>';
	newHTML += '		</td>';
	newHTML += '	</tr>';
	newHTML += '</table>';
	
	var xmlDOMText = new String();
	
	xmlDOMText += '<Dialog DialogText="a" View="[VIEW]" Title="[TITLE]" Width="[WIDTH]" Height="[HEIGHT]" />';
	xmlDOMText = xmlDOMText.replace(/\[VIEW\]/g, view);
	xmlDOMText = xmlDOMText.replace(/\[TITLE\]/g, ml_Picker_Title);
	xmlDOMText = xmlDOMText.replace(/\[WIDTH\]/g, width);
	xmlDOMText = xmlDOMText.replace(/\[HEIGHT\]/g, height);
	
	eval( view + 'Controls.' + fieldName + 'PickerDiv = "' + view + fieldName + 'PickerDiv";');
		
	var dialogXML = xmlDOM(xmlDOMText);
	dialogXML.getElementsByTagName('Dialog')[0].setAttribute('DialogText',newHTML);
	//dialogXML.getAttribute('DialogText') = encode(newHTML);
	
	showDialog(dialogXML.getElementsByTagName('Dialog')[0]);
	
	var inputBox = document.getElementById(view + 'PickerSearch');
	pickerButton = document.getElementById('btnSearch');
	try { inputBox.focus(); inputBox.focus();} catch(e) {}	
}
	
function simplePickerPost(view, fieldName, modelProperty, context)
{
	var commandString = new String();
	var controllerId = null;
	eval('controllerId = ' + view + 'ControllerId;');
	
	commandString = controllerURL + '?_method=PickerReturned&_sender=[PICKER]&_modelProperty=[MODELPROPERTY]&_controller_id=[CONTROLLERID]';
	commandString = commandString.replace(/\[PICKER\]/g,fieldName);
	commandString = commandString.replace(/\[CONTROLLERID\]/g,controllerId);	
	commandString = commandString.replace(/\[MODELPROPERTY\]/g,modelProperty);	
	
	ajax_request(commandString,'',null, context);				
}

function simplePickerSearchRequest(searchString, view, fieldName)
{	
	var commandString = new String();
	var controllerId = null;
	eval('controllerId = ' + view + 'ControllerId;');
	
	commandString = controllerURL + '?_method=PickerSearchRequest&_sender=[PICKER]&_search_string=[SEARCHSTRING]&_controller_id=[CONTROLLERID]';
	commandString = commandString.replace(/\[PICKER\]/g, fieldName);
	commandString = commandString.replace(/\[CONTROLLERID\]/g,controllerId);	
	// VWC-3050 - BISA - 23-01-2008 - Search string BASE64 encoden zodat eventuele vreemde characters (& teken bijv.) wel meegenomen worden.
	commandString = commandString.replace(/\[SEARCHSTRING\]/g,encode(searchString));		
	
	ajax_request(commandString,'',null, null);	
	
}

function simplePickerSelectRequest(view, fieldName, searchString) //(searchString, view, fieldName)
{
	var commandString = new String();
	var controllerId = null;
	eval('controllerId = ' + view + 'ControllerId;');
	
	commandString = controllerURL + '?_method=PickerSelectRequest&_sender=[PICKER]&_search_string=[SEARCHSTRING]&_controller_id=[CONTROLLERID]';
	commandString = commandString.replace(/\[PICKER\]/g, fieldName);
	commandString = commandString.replace(/\[CONTROLLERID\]/g,controllerId);	
	// VWC-3050 - BISA - 23-01-2008 - Search string BASE64 encoden zodat eventuele vreemde characters (& teken bijv.) wel meegenomen worden.
	commandString = commandString.replace(/\[SEARCHSTRING\]/g,encode(searchString));		
	
	ajax_request(commandString,'',null, null);	
}

function simplePickerClearRequest(view, fieldName, modelPropName)
{	
	var commandString = new String();
	var controllerId = null;
	eval('controllerId = ' + view + 'ControllerId;');
	
	commandString = controllerURL + '?_method=PickerClearRequest&_sender=[PICKER]&_model_prop_name=[MODELPROPNAME]&_controller_id=[CONTROLLERID]';
	commandString = commandString.replace(/\[PICKER\]/g, fieldName);
	commandString = commandString.replace(/\[CONTROLLERID\]/g,controllerId);		
	commandString = commandString.replace(/\[MODELPROPNAME\]/g,modelPropName);
	ajax_request(commandString,'',null, null);				
}


function returnFromPicker(view, ForField, datakey)
{
	pickerButton = null;
	
	var controllerId = null;
	eval('controllerId = ' + view + 'ControllerId;');
	
	var modelProperty;
	eval( 'modelProperty = ' + view + 'ValueStore.' + ForField + '.modelProperty;');
	
	created_buffered_update(view, ForField, modelProperty, encode(datakey), controllerId)
	
	simplePickerPost(view, ForField, modelProperty, null);
	hidePopWin(false, view);
	
}


