function doSearch(){
	// this method is called on submit
		str = document.forms[0].searchstring.value;
		document.forms[0].searchstring.value = "";
		if (str != ""){
			str = (escape(str));
			//document.location.href="/web/viewers/news/search.aspx?searchstring=" + str;
			
			var srch = "http://search.mandieselturbo.com/search?q=" + str + "&site=default_collection&client=benelux&output=xml_no_dtd&proxystylesheet=benelux";
			document.location.href=srch;
			return false;
		}	
		return false;	
}

function doSearchOrSubmitFormular(){
	// this method is called by clicking the searchbutton or the submit button of a formular
	
		str = document.forms[0].searchstring.value;
		
		if (str != ""){
			str = (escape(str));
			//document.location.href="/web/viewers/news/search.aspx?searchstring=" + str;
			var srch = "http://search.mandieselturbo.com/search?q=" + str + "&site=default_collection&client=benelux&output=xml_no_dtd&proxystylesheet=benelux";
			document.location.href=srch;

			return false;			
		}
		return checkObligatoryFormFields();	
		return false;	
}

function doSearchEngines(){
		var str = document.forms[0].txtSearch.value;
				
		if (str == ""){
			return doSearch();
		}
		
		str = document.forms[0].action;
		if (str.indexOf('/web') == -1){
			arr = str.split('viewers');
			document.forms[0].action = arr[0] + "/web/viewers" + arr[1];			
		}
		return true;
}

function doSearchOrSubmitForm(){
	// this method is called by clicking the searchbutton or the submit button of a formular
	
		str = document.forms[0].searchstring.value;
		
		if (str != ""){
			str = (escape(str));
			//document.location.href="/web/viewers/news/search.aspx?searchstring=" + str;
			var srch = "http://search.mandieselturbo.com/search?q=" + str + "&site=default_collection&client=benelux&output=xml_no_dtd&proxystylesheet=benelux";
			document.location.href=srch;
			return false;			
		}
		str = document.forms[0].action;
		if (str.indexOf('/web') == -1){
			arr = str.split('viewers');
			document.forms[0].action = arr[0] + "/web/viewers" + arr[1];			
		}		
}

function doSearchByButton(){
	// this method is called by clicking the searchbutton
		str = document.forms[0].searchstring.value;
		if (str != ""){
			str = (escape(str));
			//document.location.href="/web/viewers/news/search.aspx?searchstring=" + str;			
			var srch = "http://search.mandieselturbo.com/search?q=" + str + "&site=default_collection&client=benelux&output=xml_no_dtd&proxystylesheet=benelux";
			document.location.href=srch;
		}			
}

// This function is special for engines
// Handling search-submit and engines-submit
function submitEngineOrSearch(){
	if (document.forms[0].searchstring.value == ""){
		return true
	}else doSearch();
	
	return false;
}


// This function is special for subscribe
// Handling search-submit and subscribe-submit
function submitSubscribeOrSearch(){
	if (document.forms[0].Email.value == ""){
		return doSearch();
	}else return true;
}

// This function is special for unsubscribe
// Handling search-submit and unsubscribe-submit
function submitUnsubscribeOrSearch(){
	if (document.forms[0].UnsubscribeEmail.value == ""){
		return doSearch();
	}else return true;
}

// This function is special for questionnaire
// Handling search-submit and questionnaire-submit
function submitQuestionnaireOrSearch(){
	if (document.forms[0].TextBox1.value == ""){
		return doSearch();
	}else return true;
}

// This function is special for service searchpage
// Handling search-submit and service search submit
function submitServiceSearchOrSearch(){
	if (document.forms[0].searchstring.value == ""){
		str = document.forms[0].action;
		if (str.indexOf('/web') == -1){
			arr = str.split('/viewers');
			document.forms[0].action = arr[0] + "/web/viewers" + arr[1];			
		}
		return true
	}else doSearch();
	
	return false;
}


function setWindowStatus(){
	window.status="MAN Diesel - Homepage";
	setTimeout('setWindowStatus()', 500);
}

/*
 * Check if textfields in the form marked by "obligatory" are filled.
 */
function checkObligatoryFormFields(){

	if (document.forms[0] != null){	// ist there a form?
		
		var elems = document.forms[0].elements;	// get the formelements
			
		for (i = 0; i < elems.length; i++){	// walk over the elements
			var el = elems[i];
			if (el.name != null){	// is there a name?
				if (el.name.toLowerCase().indexOf("mailform") > -1){	// is the element relevant?
					if (el.name.toLowerCase().indexOf("obligatory") > -1){	// is the element obligatory?
						if (el.value != null && el.value == ""){			// does the element have a value?
							alert("Fill out all obligatory fields please!");
							return false;
						}
					}
				}		
			}
		}	
	}
	return true;
}
//setWindowStatus();

function openPrintWindow(str){
	
	window.open(str,'','width=515; height=630; scrollbars=yes');
}


// added 09.11.2005
/*function rollover() {
	if (!document.getElementById) return
	
	var imgOrSrc;
	var imgPreload = new Array();
	var images = document.getElementsByTagName('img');
	
	for (var i = 0; i < images.length; i++) {
		if (images[i].getAttribute('rsrc')) {
			imgPreload[i] = new Image();
			imgPreload[i].src = images[i].getAttribute('rsrc');
						
			images[i].onmouseout = function() {
				this.setAttribute('src',imgOrSrc)
			}
			
			images[i].onmouseover = function() {
				imgOrSrc = this.getAttribute('src');
				this.setAttribute('src',this.getAttribute('rsrc'))
			}			
		}
	}
}*/

