// Part of Adeptus Knowledge Place. Copyright Adeptus Partners 2006-function submitenter(myfield,e) {var keycode;if (window.event) keycode = window.event.keyCode;else if (e) keycode = e.which;else return true;if (keycode == 13) {   encode();   return false;}else   return true;}function encode() {  try {   var sq = document.getElementById('D_SimpleQuery').value;   } catch ( e ) {}   if ( eval ('sq') =='') {      alert('The search entry is empty. Enter one or more keywords.');     document.getElementById('D_SimpleQuery').focus();     return false;   } else {     var query = encodeURI( sq );     document.forms[0].SimpleQuery.value = query;     return openSearchForm ( query );   } }function getQuery( query, field ) {	return 'FIELD%20'+field+'%20CONTAINS%20%22*'+query+'*%22';}function openSearchForm ( query ) {   var doc=this.document;   var newUrl= '';   var langValue = getCookie( 'AKPLang' );	if ( langValue=="" ) {	    langValue = 'en';	}   sep = '%20OR%20';   var myQuery = query;   query = 		getQuery( langValue, 'UsedLanguages' ) + '%20AND%20(' + 		getQuery( query, 'Company' ) + sep + 		getQuery( query, 'Keyword_1_'+langValue ) +sep +		getQuery( query, 'Keyword_2_'+langValue ) +sep +		getQuery( query, 'ProName_'+langValue ) +sep +		getQuery( query, 'Body_'+langValue )+ ')' +		'&SearchOrder=1&start=1&count=10';	newUrl= '/inet/sks/tuote.nsf/Search?SearchView' + '&Query=' + query+"&MyQuery="+myQuery;	var target = parent.frames['content'];	if ( target == null ) {	  parent.parent.location =		'/inet/sks/'+langValue+'/akp.nsf/frameset/Frameset?OpenDocument&content='+newUrl+'&top=/inet/sks/'+langValue+		'/akp.nsf/Top?ReadForm&showheadertop=0';	} else {		target.location = newUrl;	}	return false;}function expandCollapseSingleCat( docNumber ) {	docNumber = docNumber.substring( docNumber.indexOf( "." )+1 );	expandCollapse( docNumber );}// Category text works as linkfunction expandCollapse( docNumber ) {	var url = (window.location.href).toLowerCase();	var expandB = url.indexOf( "expand=" ) != -1;	var expandViewB = url.indexOf( "expandview" ) != -1;	var collapseB = url.indexOf( "collapse=" ) != -1;	var collapseViewB = url.indexOf( "collapseview" ) != -1;	// alert( url +" docNum: "+docNumber+" expands:" + expandB+expandViewB+collapseB+collapseViewB );	var newUrl = "";	if ( expandB ) {		newUrl = getUrl( url, "expand", docNumber );	} else if ( expandViewB ) {		var index = url.indexOf( "expandview" );		var start = url.substring( 0, index );		newUrl = start+"collapse="+docNumber+"#"+docNumber;	} else if ( collapseB ) {		newUrl= getUrl( url, "collapse", docNumber );			} else if ( collapseViewB ) {		var index = url.indexOf( "collapseview" );		var start = url.substring( 0, index );		newUrl = start+"expand="+docNumber+"#"+docNumber;		} else {		newUrl = url+"&expand="+docNumber+"#"+docNumber;		}	window.location.href = newUrl;}// Subfunction of expandCollapse. Returns url with right parsed expand or collapse query.function getUrl( url, action, docNumber ) {	var index = url.indexOf( action+"=" );	var start = url.substring( 0, index );	var end = url.substring( index );	var endIndex = end.indexOf( "." );	var endIndex2 = end.indexOf( "#" );	var num = end.substring( action.length+1, endIndex );	var num2 = end.substring( action.length+1, endIndex2 );	if ( action == "expand" ) {		if ( num == docNumber || num2 == docNumber ) {			action = "collapse";		}	} else {		action = "expand";	}	return start+action+"="+docNumber+"#"+docNumber;}// Prevents alt -text from twistie images (expand.gif and collapse.gif) to be shown. function catLinks()	{	var docUrl = document.location.href.toLowerCase();	var expandIndex = docUrl.indexOf( '&expand' );	var docNum = -1;	if ( expandIndex > -1 ) {		var end = docUrl.substring( expandIndex );		docNum = end.substring( end.indexOf( '=' )+1, end.indexOf( '=' )+2 );	}	var links = document.links;	var link;	for (i=0;i<links.length;i++)	{		id = links[i].id;		if ((id.indexOf('catLink')>-1) | (id.indexOf('catLink')>-1)) {			var linkHref = links[i].href.toLowerCase();			var index = linkHref.indexOf('&expand');			var num = 1;			var expand='';			if ( index > -1 ) {				var start = linkHref.substring( 0, index );				var end = linkHref.substring( index );				num = end.substring( end.indexOf( '.' )+1 );				if ( num == docNum ) {					expand = '&collapse='+num;				} else {					expand = '&expand='+num;				}			}			var newLink = start + '&restricttocategory='+escape(document.getElementById('Category').value) + expand;			// alert( newLink );			links[i].href = newLink;		}	}}// Used in brochures view to form link codefunction writeLink( readField, db, targetField ) {	var value = writeField ( readField );	document.getElementById( targetField ).value = '<a target="_blank" href="/'+db+'/DocsPlWeb/'+value+'/$file/'+value+'">';}// Used in product document and brochures view to get language versions automaticallyfunction writeField ( field ) {	alert( field );	lang = document.getElementById( 'AKPLang' ).value;	valueField =document.getElementById( field+"_"+lang );	if ( valueField == null || valueField.value=="" ) {		valueField = document.getElementById( field+"_EN" );	}	if ( valueField == null || valueField.value==""  ) {		value = "Error. Could not find field "+field;	} else {		value = valueField.value;	}	return value;}function writeField ( field, optionalField ) {	lang = document.getElementById( 'AKPLang' ).value;	valueField =document.getElementById( field+"_"+lang );	if ( valueField == null || valueField.value==""  ) {		valueField = document.getElementById( field+"_EN" );	}	if ( valueField == null || valueField.value=="" ) {		valueField =document.getElementById( optionalField+"_"+lang );		if ( valueField == null || valueField.value==""  ) {			valueField = document.getElementById( optionalField+"_EN" );		}	}	if ( valueField == null || valueField.value==""  ) {		value = "Lorem ipsum dolor sit amet, concestetaur adipiscing etli, Cras laoreet. Fuscte iaculis, dolor et elementum";	} else {		value = valueField.value;	}	return value;}function changeLanguage( lang ) {		setCookie("AKPLang", lang, 1, "/");		window.location = document.getElementById( 'Path_Info_Decoded' ).value;}
