// combined.js

<!-- // hide scripts for JavaScript disabled browsers

//autojump functions
var downStrokeField;


function enableAutoJump(theForm) {
	for(veldIndex=0; veldIndex < theForm.length; veldIndex++) {
		field = theForm.elements[veldIndex];
		if ((field.type == "text" || field.type == "password") && field.jump) {
			if (field.maxLength > 0 && field.maxLength < 255) { 
				field.onkeydown = autojump_keyDown;
				field.onkeyup = autojump_keyUp;
			}
		}
	}
}

function autojump_keyDown() {
	this.beforeLength = this.value.length;
	downStrokeField = this;
}

function autojump_keyUp() {
	if ((this == downStrokeField) && 
	   	(this.value.length >= this.beforeLength) && 
	   	(this.value.length >= this.maxLength)) {
	   	// slice belet dat er meer dan maxlength aantal karakters kunnen ingegeven worden
			this.value = this.value.slice(0, this.maxLength);
	   	// enkel hier gaan we het volgende veld ophalen
	   	nextField = this.form.elements[(getIndex(this)+1) % this.form.length];
	   	// We springen naar het volgende veld als dat geen button, submit of reset knop is
	   	if (!(nextField.type == "button" || nextField.type == "submit" ||	nextField.type == "reset")) {
				nextField.focus();
				if (nextField.type == "text" || nextField.type == "password") {
					nextField.select();
				}
			}
	}
	downStrokeField = null;
}

function getIndex(input) {
	var index = -1, i = 0;
	while (i < input.form.length && index == -1) {
		if (input.form.elements[i] == input) {
			index = i;
		} else {
			i++;
		}
	}
	return index;
}

//checkboxSelection functions
function checkboxSelection(formName, checkbox, groupname) {

 if(groupname) {
  for (var i = 0; i < formName.elements.length; i++) {    
    if (formName.elements[i].type == "checkbox" 
    	  && formName.elements[i].name == groupname) {
    		formName.elements[i].checked = checkbox.checked;
   }
  }	
 } else {
  for (var i = 0; i < formName.elements.length; i++) {    
    if (formName.elements[i].type == "checkbox") {
    		formName.elements[i].checked = checkbox.checked;
   }
  }	
 }
}

//checkFormChanged functions
function checkFormChanged(theForm) {
	changedForm = false;
	veldIndex=0;
	
	while((!changedForm) && (veldIndex < theForm.length)){
		field = theForm.elements[veldIndex];
		//if (field.type != "button") {
		if( field.type == "checkbox" || 
			field.type == "radio" || 
			field.type == "select-one" || 
			field.type == "select-multiple" || 
			field.type == "text" || 
			field.type == "textarea"){
			if (field.type == "radio" || field.type == "checkbox") {
				if(field.initValue != field.checked){
					changedForm = true;
				}	
			}else{
				if(field.initValue != field.value){
					changedForm = true;
				}
			}
		}
		veldIndex++;
	}
	if(changedForm){
		theForm._formChanged.value = "Y";
	}
	else{
		theForm._formChanged.value = "N";
	}
}




//fillDestinationAndSubmit functions
function fillDestinationAndSubmit(formName,destination)
{
      formName._dest.value = destination;
      formName.submit();	
}

//fillMAndSubmit functions
function fillMAndSubmit(formName,mValue)
{
      formName.m.value = mValue;
      formName.submit();	
}

//openHelp functions
function openHelp(url)
{
	var win = window.open(url, 'help', 'dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	return false;
}

//saveFormValues functions
function saveFormValues(theForm) {
	veldIndex=0;
	while(veldIndex < theForm.length){
		field = theForm.elements[veldIndex];
		//if (field.type != "button") {
		if( field.type == "checkbox" || 
			field.type == "radio" || 
			field.type == "select-one" || 
			field.type == "select-multiple" || 
			field.type == "text" || 
			field.type == "textarea"){
			if (field.type == "radio" || field.type == "checkbox") {
				field.initValue = field.checked;
			}else{
				field.initValue = field.value;
			}
		}
		veldIndex++;
	}
}

//setFocus functions
function setFocus(field) {
  if (field) {
    if (field[0] && (field[0].type == "radio" || 
        field[0].type == "checkbox")) {
         field[0].focus();
    } else if(field.type == "text") {
       field.focus();
       field.select();
    } else {
       field.focus();
    }
  }
}

//setFocusAndSelect
function setFocusAndSelect(formField)
{
    	formField.select();
	formField.focus();	
}

//showContent functions
function showContent() {
	document.getElementById('waitMessage').style.display = 'none';
	document.getElementById('content').style.display = 'block';
}

//showWaitMessage functions
function showWaitMessage() {
	document.getElementById('content').style.display = 'none';
	document.getElementById('waitMessage').style.display = 'block';
}

//showWaitSearch functions
function showWaitSearch() {
	document.getElementById('screenButtons').style.display = 'none';
	if (document.getElementById('screenInfo')) {
		document.getElementById('screenInfo').style.display = 'none';
	}
	if (document.getElementById('screenError')) {
		document.getElementById('screenError').style.display = 'none';
	}
	document.getElementById('searchWaitInfo').style.display = 'block';
}

//For displaying the stop button, when stopM is filled by the user.
function showStopButton(){

	document.getElementById('searchStopButton').style.display = 'block';
	document.searchStopForm.stopButton.focus();

}

//fillBehavior functions
function fillBehavior(formName,behaviorValue)
{
      formName.behavior.value = behaviorValue;
}

//fillMConfirmAndSubmit functions
function fillMConfirmAndSubmit(formName, mValue, message){
    confirmed = confirm(message);
    
    if (confirmed) {
      formName.m.value = mValue;
      formName.submit();
    }
}

//fillDestinationConfirmAndSubmit functions
function fillDestinationConfirmAndSubmit(formName, destination, message){
    confirmed = confirm(message);    
    if (confirmed) {
      formName._dest.value = destination;
      formName.submit();	
    }
}

//fillParam functions
function fillParam(param,paramValue)
{
      param.value = paramValue;
}

//setErrorLayout functions
function setErrorLayout(field) {
	
	if ( field && field.type && 
			(field.type == "text" || 
			 field.type == "password" ||
			 field.type == "textarea" ||
			 field.type == "file" ||
			 field.type == "select-multiple" ||
			 field.type == "select-one") ) {
		if (field.className) {
			field.className += ' errorBackground';
		} else {	
			field.className = 'errorBackground';
		}
	}
}

function fillListMetadata(formName, mValue, listId, list, index) {

	formName.f_t_scrollPixels.value = document.getElementById(listId).scrollTop;
	formName._list.value = list;
	if(index) {
		formName._index.value = index;
	}
	formName.m.value = mValue;
}

function fillMOnEnter(form, param, e) {

  var code = e.keyCode;           //IE
  if (!code) code = e.charCode;   //FireFox

  if (code == 13) {
    form.m.value = param;          
  }
}
 
function selectRadio(field, e) {

  var code = e.keyCode;           //IE
  if (!code) code = e.charCode;   //FireFox

	if ((32<=code) && (code<=126)) {
    field.checked = true;
  }
        
}

//textarea max length functions
function checkLength(field,maximum,id){

	if(field.value.length>maximum){
		document.getElementById(id).style.display='block';
		field.className='errorBackground';
	}else{
		document.getElementById(id).style.display='none';
	    field.className='';
	}
}


//for sorting columns in a list
function fillListMetadataHeader(formName, destValue, sort, order, listId) {
	formName.t_sort.value = sort;
	formName.t_order.value = order;		
	formName.t_listId.value = listId;
	formName._from_list_sort.value = 'true';
	formName.m.value = '';
	formName._dest.value = destValue;	
	formName.target = '_self';	
	formName.submit();
}

// To prevent the form getting submitted twice
function canConfirmAndSubmit(message){

	confirmed = confirm(message);
    
    if (!confirmed) {
    	return false;
    }
    return true;
}

//For Header checkbox selection
function headerCheckboxSelection(formName, groupname, headerName) {
  var status = 'true';
    
  for (var i = 0; i < formName.elements.length; i++) { 
    if (formName.elements[i].type == "checkbox" && formName.elements[i].checked == false
    	&& formName.elements[i].name == groupname) {
    	status = 'false';
    	break;   	   
	}
 } 
 
 for (var i = 0; i < formName.elements.length; i++) {
	if (formName.elements[i].type == "checkbox" && formName.elements[i].name == headerName) {
		if(status == 'true'){
	  		formName.elements[i].checked = true;
		} else { 
		 	formName.elements[i].checked = false;
		} 	
	  	return;
	}
  }   
}

function storeLocationInShop() {
	var params = window.location.search;
	if(params && params.indexOf("f_locationInShop") != -1) {
		params = params.substring(1,params.length);
		var name = "f_locationInShop";
		var locationInShop = params.substring(17, params.length);
		document.cookie = name + "=" + locationInShop + "; path=/";		
	}
}







function activateFunction(activate) {
			var sellerTD = document.getElementById('sellerTD');
			var butcherTD = document.getElementById('butcherTD');
			
			document.getElementById('f_function').value = activate;
			
			if(activate == 'V') {
				sellerTD.className = 'active';
				butcherTD.className = 'inactive';
			} else {
				sellerTD.className = 'inactive';
				butcherTD.className = 'active';
			}
		}
		
		var visibleLogon = "operatoridTr";
		var hiddenLogon = "useridTr";
		var visibleLegend = "Fill in your Operator id and optionally a Password";
		var hiddenLegend = "Please enter User Id and Password";
		
		function switchLogon(focusField) {
			document.getElementById(visibleLogon).style.display = "none";
			/*display = "" will let all kind of browsers fall back to théir default,
			for example in IE it is "block", but in FF it is "table-row" for a tr.*/
			document.getElementById(hiddenLogon).style.display = "";
			
			var tmp = visibleLogon;
			visibleLogon = hiddenLogon;
			hiddenLogon = tmp;
			tmp = visibleLegend;
			visibleLegend = hiddenLegend;
			hiddenLegend = tmp;

			setFocus(focusField);
			document.getElementById("theLegend").innerHTML = visibleLegend;
		}


//Dynamic submit button for xlist-T429
function fillListMetadataOnEnter(e, listId) {

	var code = e.keyCode;           //IE
	if (!code) code = e.charCode;   //FireFox
	
	 if (code == 13) {
	  	if(document.getElementById(listId) != null){
	  		document.getElementById(listId).click();
	  		return false;
		}		
	}else{
			return true;
	}
}


// end hiding of JavaScript code -->
