function km_onload() {
	if (hasFs)
		km_checkFrameset();
	km_popForms();
	km_showPossibleFormResult();
	if (window.menuOnLoad)
		menuOnLoad(pg,pr,lg);
	if (window.km_extendedOnload)
		km_extendedOnload();
	if (scrHere != '')
		doScroll(scrHere);
	if (window.igl_id)
		km_igl('init');
	if (window.ppi)
		km_openPobPopup();
	if (window.km_shopOnload)
		km_shopOnload();
	if (window.km_prod)
		km_prod.init();
}

// G E N E R A L
function get_object(o) {
	if (document.getElementById && document.getElementById(o) != null)
		return document.getElementById(o);
	else if (document.layers && document.layers[object] != null)
		return document.layers[o];
	else if (document.all)
		return document.all[o];
}
function doScroll() {
	var destinationLink;
	if (doScroll.arguments[0])
		destinationLink=get_object(doScroll.arguments[0]);
	else
		destinationLink=get_object('scrollHere');
	var desty=destinationLink.offsetTop;
	var thisNode=destinationLink;
	while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) {
		thisNode=thisNode.offsetParent;
		desty+=thisNode.offsetTop;
	}
	window.scrollTo(0,desty-20);
}
function km_openSearchResult(pagId,pobId) {
	window.location.href='index.'+ssc+'?pg='+pagId+'&scrHere=pob_'+pobId;
}
function km_openShopSearchResult(itmId) {
	window.location.href='index.'+ssc+'?x=cShopPub.viewItm&ID='+itmId+'&pg='+pg+'&pr='+pr+'&bi=shop';
}
function km_doSearch() {
	var searchForm=document.km_form_search;
	if (trim(searchForm.searchPhrase.value).length != 0)
	{
		if (get_object('searchForm.pg'))
		searchForm.pg.value=pg;
		searchForm.submit();
	}
}
function km_submitSearchFormOnEnter(event) {
	if (km_getKeyCode(event) == 13)
		km_doSearch();
}
function km_openKaxig() {
	window.open('http://www.kaxig.com');
}
function km_openPobPopup() {
	if (ppAlways) {
		km_popAjax_ppi('false');
	} else {
		var url='km/system/ajax/chkPpi.php?ppi='+ppi;
		km_loadAjax('ppi',url,'text');
	}
}
function km_popAjax_ppi(response) {
	var theResponse=trim(response);
	//fix srf dev edition
	theResponse=(theResponse.split('>')[1])?theResponse.split('>')[1]:theResponse;
	if (theResponse == 'false') {
		km_createDimmer();
		var popupSource=get_object('pob_'+ppi);
		//get width
		var width=(parseInt(popupSource.style.width).length != 0)?parseInt(popupSource.style.width):parseInt(popupSource.parentNode.parentNode.style.width);//column width
		//get height
		var bottomDiv=get_object('popupBottom_'+ppi);
		popupSource.style.display='block';
		var height=getPixelsFromTop(bottomDiv)-getPixelsFromTop(popupSource);
		popupSource.style.display='none';
		var content='<div class="'+popupSource.className+'">'+popupSource.innerHTML+'</div>';
		km_createModalPopup(width,height,content,[],!ppClose);
	}
}
function km_openPageFlip(pflId) {
	pageFlipInIframe=false;
	if (!pageFlipInIframe) {
		//safari does not allow window.open in a function called by another function, so we open here, and not in ajax response
		var screen_array=getScreenSize();
		pageFlip_window=window.open('','PageFlip','width='+screen_array[0]+',height='+screen_array[1]+',left=0,top=0,screenX=0,screenY=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
	}
	var url='km/system/ajax/getPfl.'+ssc+'?wp='+wp+'&pflId='+pflId;
	km_loadAjax('pfl',url);
}
function km_popAjax_pfl(responseXML) {
	var pfl=responseXML.getElementsByTagName('pfl')[0];
	var hits=parseInt(pfl.attributes[0].nodeValue);
	if (hits == 1) {
		var pflId=responseXML.getElementsByTagName('id')[0].firstChild.data;
		var width=responseXML.getElementsByTagName('width')[0].firstChild.data;
		var height=responseXML.getElementsByTagName('height')[0].firstChild.data;
		var url=wpg_url+'/km/file/pageflip/index.cfm?pflId='+pflId+'&width='+width+'&height='+height;
		if (pageFlipInIframe) {
			var content='<iframe src="'+url+'" width="'+width+'" height="'+height+'" frameborder="0" scrolling="no" />';
			km_createModalPopup(width,height,content);
		} else {
			pageFlip_window.location.href=url;
		}
	} else {
		alert("Missing file");
	}
}
function km_popAjax_pflContent(response) {
	var content=trim(response);
	var re_width=/pageWidth=(\d)*/;
	var width_find=re_width.exec(content);
	var width=width_find[0].replace(/\D/g,'');
	var re_height=/pageHeight=(\d)*/;
	var height_find=re_height.exec(content);
	var height=height_find[0].replace(/\D/g,'');
	km_createModalPopup(width,height,content);
}
function km_createModalPopup(width,height,content,style_array,noCloseLink) {
	km_createDimmer();
	var popup=document.createElement('div');
	popup.setAttribute('id','km_modalPopup');
	document.body.appendChild(popup);
	var windowSize=getWindowSize();
	var closeLinkHeight=18;
	popup.style.width=width+'px';
	var popupOuterHeight=height+closeLinkHeight;
	popup.style.height=popupOuterHeight+'px';
	var position_array=km_getCenterPositionForPopup(width,popupOuterHeight);
	popup.style.left=position_array[0]+'px';
	popup.style.top=position_array[1]+'px';
	if (!noCloseLink) {
		switch (lg) {
			case 1:
				txt_close='St&auml;ng';
			break;
			default:
				txt_close='Close';
		}
		var closeLink=document.createElement('div');
		closeLink.setAttribute('id','km_closeModalPopup');
		closeLink.onclick=function() {
			km_closeModalPopup();
		}
		popup.appendChild(closeLink);
		closeLink.style.height=closeLinkHeight+'px';
		closeLink.innerHTML=txt_close;
	}
	var contentHolder=document.createElement('div');
	popup.appendChild(contentHolder);
	contentHolder.innerHTML=content;
	contentHolder.style.width=width+'px';
	if (height != 0)
		contentHolder.style.height=height+'px';
	if (style_array) {
		for (var i=0;i<style_array.length;i++) {
			eval("contentHolder.style."+style_array[i][0]+"="+style_array[i][1]+";");
		}
	}
	popup.style.visibility='visible';
}
function km_closeModalPopup() {
	km_removeDimmer();
	document.body.removeChild(get_object('km_modalPopup'));
}
function km_createDimmer(debug) {
	if (!get_object('km_dimmer')) {
		var dimmer=document.createElement('div');
		dimmer.setAttribute('id','km_dimmer');
		km_initialBodyOverflow=document.body.style.overflow;
		var browser_array=km_getBrowserSimple();
		//on safari pc, it can't restore body overflow if we do this
		if (browser_array[0] != 'Safari' || browser_array[1] != 'pc')
			document.body.style.overflow='hidden';
		document.body.appendChild(dimmer);
		if (browser_array[0] == 'Internet Explorer') {
			//Internet Explorer messes up fixed objects 
			switch (wp) {
				case 214://srf
					if (get_object('header'))
						get_object('header').style.position='fixed';
				break;
			}
		}
		var offset_array=km_getScrollXY();
		dimmer.style.left=offset_array[0]+'px';
		dimmer.style.top=offset_array[1]+'px';
	}
}
function km_removeDimmer() {
	document.body.removeChild(get_object('km_dimmer'));
	var browser_array=km_getBrowserSimple();
	if ((browser_array[0] != 'Safari' || browser_array[1] != 'pc'))
		document.body.style.overflow=(km_initialBodyOverflow.length == 0)?'auto':km_initialBodyOverflow;
}
function km_getBrowser() {
	//finds only IE at the moment
	var browser='undefined';
	var version='undefined';
	var ua=window.navigator.userAgent
	var msie=ua.indexOf('MSIE ');
	if (msie > 0) {
		browser='IE';
		version=parseInt(ua.substring(msie+5,ua.indexOf('.',msie)));
	}
	return [browser,version];
}
function km_getBrowserSimple() {
	if (navigator.appName.toLowerCase() == 'opera') return 'Opera';
	var agt=navigator.userAgent.toLowerCase();
	var browser='';
	var platform=(agt.indexOf('windows') != -1)?'pc':'mac';
	if (agt.indexOf("opera") != -1) browser='Opera';
	else if (agt.indexOf("staroffice") != -1) browser='Star Office';
	else if (agt.indexOf("webtv") != -1) browser='WebTV';
	else if (agt.indexOf("beonex") != -1) browser='Beonex';
	else if (agt.indexOf("chimera") != -1) browser='Chimera';
	else if (agt.indexOf("netpositive") != -1) browser='NetPositive';
	else if (agt.indexOf("phoenix") != -1) browser='Phoenix';
	else if (agt.indexOf("firefox") != -1) browser='Firefox';
	else if (agt.indexOf("safari") != -1) browser='Safari';
	else if (agt.indexOf("skipstone") != -1) browser='SkipStone';
	else if (agt.indexOf("msie") != -1) browser='Internet Explorer';
	else if (agt.indexOf("netscape") != -1) browser='Netscape';
	else if (agt.indexOf("mozilla/5.0") != -1) browser='Mozilla';
	else browser=navigator.userAgent;
	return [browser,platform];
}
function km_getCenterPositionForPopup(width,height) {
	var offset_array=km_getScrollXY();
	var windowSize_array=getWindowSize();
	var left=parseInt(offset_array[0]+(windowSize_array[0]-width)/2);
	var top=parseInt(offset_array[1]+(windowSize_array[1]-height)/2);
	if (left < 0)
		left=0;
	if (top < 0)
		top=0;
	return [left,top];
}
function km_getScrollXY() {
	var scrOfX=0, scrOfY=0;
	if (typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		scrOfY=window.pageYOffset;
		scrOfX=window.pageXOffset;
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		//DOM compliant
		scrOfY=document.body.scrollTop;
		scrOfX=document.body.scrollLeft;
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		//IE6 standards compliant mode
		scrOfY=document.documentElement.scrollTop;
		scrOfX=document.documentElement.scrollLeft;
	}
	return [scrOfX,scrOfY];
}
function getWindowSize() {
	var myWidth=0, myHeight=0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth=window.innerWidth;
		myHeight=window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth=document.documentElement.clientWidth;
		myHeight=document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth=document.body.clientWidth;
		myHeight=document.body.clientHeight;
	}
	return [myWidth,myHeight];
}
function getScreenSize() {
	var myWidth=0, myHeight=0;
	myWidth=screen.availWidth;
	myHeight=screen.availHeight;
	return [myWidth,myHeight];
}
function km_getUrlVarArray(urlString) {
	if (urlString.substr(0,1) == '?')
		urlString=urlString.substr(1,urlString.length-1);
	var temp_array=urlString.split('&');
	var urlVar_array=new Array();
	var part_array;
	for (var i=0;i<temp_array.length;i++) {
		part_array=temp_array[i].split('=');
		urlVar_array[i]=new Array();
		urlVar_array[i]['variable']=part_array[0];
		urlVar_array[i]['value']=part_array[1];
	}
	return urlVar_array;
}
// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function getBrowser() {
	if (navigator.appName.toLowerCase() == 'opera') return 'Opera';
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	if (agt.indexOf('\/') != -1) {
	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
	return navigator.userAgent.substr(0,agt.indexOf(' '));
	else return navigator.userAgent;
}
//col functions
function setDivColHeights() {
	var highestColHeight=0;
	var currentHeight;
	var colCount=0;
	var i;
	for (i=1;i<=4;i++) {
		if (get_object('bodycol_'+i)) {
			colCount=i;
			currentHeight=getTDHeight(i);
			if (currentHeight > highestColHeight)
				highestColHeight=currentHeight;
		}
	}
	var browser_array=km_getBrowser();
	switch (browser_array[0]) {
		case 'IE':
			highestColHeight-=14;
		break;
	}
	for (i=1;i<=colCount;i++) {
		get_object('bodycol_'+i).style.height=highestColHeight+'px';
	}
//		alert(highestColHeight);
}
function getTDHeight(col){
	var contentTopDiv=get_object('bodycol_'+col);
	var contentBotDiv=get_object('bodycolBottom_'+col);
	var contentTop=getPixelsFromTop(contentTopDiv);
	var contentBottom=getPixelsFromTop(contentBotDiv);
	var contentHeight=contentBottom-contentTop;
//		alert("The cell height is " + contentHeight);
	return contentHeight;
}
function km_removeColBottoms() {
	for (i=1;i<=4;i++) {
		if (get_object('tdcol_'+i))
			get_object('tdcol_'+i).removeChild(get_object('bodycolBottom_'+i));
	}
}
function getPixelsFromTop(obj){
	var objFromTop=obj.offsetTop;
	var objParent;
	while(obj.offsetParent!=null) {
		objParent=obj.offsetParent;
		objFromTop+=objParent.offsetTop;
		obj=objParent;
	}
	return objFromTop;
}


// U S E R   M A N A G E M E N T
function km_login(theForm) {
	if (km_getEmptyFieldCount(theForm) == 0)
		theForm.submit();
}
function km_loginOnEnter(event,theForm) {
	if (km_getKeyCode(event) == 13) {
		var emptyFieldCount=km_getEmptyFieldCount(theForm);
		if (emptyFieldCount == 0)
			theForm.submit();
	}
}
function km_logout() {
	var i=Math.floor(Math.random()*100);
	window.location.href='km/system/giveAccess.'+ssc+'?logout=true&foo='+i;
}
function km_appendUniqueUrl(url) {
	var dummyUrl="dummy=" + new Date().getTime();
	return (url.indexOf("?") != -1)?url+"&"+dummyUrl:url+"?"+dummyUrl;
}
function km_showArticleCommentForm(pobId)
{
	if (get_object('articleCommentForm_'+pobId).style.display=='none')
		get_object('articleCommentForm_'+pobId).style.display='';
	else
		get_object('articleCommentForm_'+pobId).style.display='none';
}
function km_getArticleCommentCount(pobId) {
	
	if (!window.km_getArticleBusy)
		km_getArticleBusy=false;
		
	var url='km/system/ajax/getArticleCommentCount.'+ssc+'?wp='+wp+'&pobId='+pobId+'&lg='+lg;
	var type='xml';
	if (get_object('commentArticeCount_'+pobId))
	{
		if (!km_getArticleBusy)
		{
			km_articleCommentIdInProgress=pobId;
			km_loadAjax('getArticleCommentCount',url,type);
			km_getArticleBusy=true;
		}
		else
		{
			setTimeout('km_getArticleCommentCount('+pobId+')',100);
		}
	}
	
}
function km_popAjax_getArticleCommentCount(myXML) {
	var pobId=myXML.getElementsByTagName('pobId');
	var count=myXML.getElementsByTagName('count');
	pobId=pobId[0].firstChild.data;
	count=count[0].firstChild.data;
	get_object('commentArticeCount_'+pobId).innerHTML='( '+count+' )';
	km_getArticleBusy=false;
}
function km_putArticleComment(pobId,ACM_str_Name,ACM_str_Email,ACM_str_Text,captcha_check,ACM_str_Captcha) {
	km_articleCommentIdInProgress=pobId;
	var url='km/system/ajax/createComment.'+ssc+'?wp='+wp+'&pobId='+pobId+'&lg='+lg;
	url=url+'&ACM_str_Name='+ACM_str_Name;
	url=url+'&ACM_str_Email='+ACM_str_Email;
	url=url+'&ACM_str_Text='+ACM_str_Text;
	url=url+'&captcha_check='+captcha_check;
	url=url+'&ACM_str_Captcha='+ACM_str_Captcha;
	url=km_appendUniqueUrl(url);
	var type='text';
	var err='';
	if (trim(ACM_str_Name).length == 0)
	err+='\n* Namn: Måste fyllas i';
	if (trim(ACM_str_Email).length == 0)
	err+='\n* Epost: Måste fyllas i';
	if (trim(ACM_str_Text).length == 0)
	err+='\n* Text: Måste fyllas i';

	if (err.length == 0)
		km_loadAjax('putArticleComment',url,type);
	else
		alert('Felmeddelande'+err);
	
	
}
function km_popAjax_putArticleComment(response) {
	var response=trim(response);
	if (String(response).substring(0,5)=='Error')
		alert(response);
	else
		km_getArticleComment(km_articleCommentIdInProgress,1);
}

function km_getArticleComment2(pobId,status) {
	km_getArticleComment(pobId,status);
}
function km_getArticleComment(pobId,status) {
	
	if (!window.km_getArticleBusy)
		km_getArticleBusy=false;
		
	checkLen=trim(get_object('commentArticle_'+pobId).innerHTML).length;

	if (checkLen == 0 || checkLen == 110 || status == 1)
	{
		get_object('commentArticle_'+pobId).innerHTML='<img src="http://cms.webomaten.se/graphic/loader/indicator_blue_large.gif" border="0" style="padding:100px">';
		var url='km/system/ajax/getArticleComment.'+ssc+'?wp='+wp+'&pobId='+pobId+'&lg='+lg+'&status='+status;
		url=km_appendUniqueUrl(url);
		var type='text';
		
		
		if (!km_getArticleBusy)
		{
			km_articleCommentIdInProgress=pobId;
			km_loadAjax('articleComment',url,type);
			km_getArticleBusy=true;
		}
		else
		{
			setTimeout('km_getArticleComment('+pobId+','+status+')',100);
		}
	}
	else
	{
		get_object('commentArticle_'+pobId).innerHTML='';
	}
}
function km_popAjax_articleComment(response) {
	var response=trim(response);
	get_object('commentArticle_'+km_articleCommentIdInProgress).innerHTML=response;
	km_getArticleBusy=false;
	km_getArticleCommentCount(km_articleCommentIdInProgress);
}
var km_week={
	show: function(wsoId,yearWeek) {
		get_object('wek_'+wsoId+'_'+eval('km_activeWeek_'+wsoId)).style.display='none';
		get_object('wek_'+wsoId+'_'+yearWeek).style.display='block';
		eval('km_activeWeek_'+wsoId+'=yearWeek;');
	}
}
function km_getUserData(formId,ugrIdList) {
	km_userFormIdInProgress=formId;
	var url='km/system/ajax/getUsr.'+ssc+'?wp='+wp+'&ug='+ugrIdList+'&lg='+lg;
	url=km_appendUniqueUrl(url);
	var type='xml';
	km_loadAjax('userData',url,type);
}
function km_popAjax_userData(myXML) {
	var myXmlFriendly=myXML;
	if (km_HttpRequestInProcess_type == 'text') {
		myXmlFriendly=myXmlFriendly.replace(/>/g,'&gt;');
		myXmlFriendly=myXmlFriendly.replace(/</g,'&lt;');
		get_object('debugger').innerHTML=myXmlFriendly;
	}
	var fieldTag=myXML.getElementsByTagName('fl');
	var inputTag=myXML.getElementsByTagName('inp');
	var idTag=myXML.getElementsByTagName('id');
	var formatTag=myXML.getElementsByTagName('fr');
	var optionSelectionTag;
	var fieldId;
	var theInput;
	var j;
	var k;
	var currentField;
	var fieldFormat;
	var theForm=eval('document.km_userform_'+km_userFormIdInProgress);
	for (var i=0;i<fieldTag.length;i++) {
		fieldId=idTag[i].firstChild.data;
		fieldFormat=formatTag[i].firstChild.data;
		if (eval('theForm.field_'+fieldId)) {
			var currentField=eval('theForm.field_'+fieldId);
			optionSelectionTag=fieldTag[i].getElementsByTagName('os');
			switch (parseInt(fieldFormat)) {
				case 2://date
				break;
				case 6:
					for (j=0;j<optionSelectionTag.length;j++) {
						k=getFieldIndexForValue(currentField,optionSelectionTag[j].attributes[0].nodeValue);
						if (k != -1) {
							if (currentField.options)
								currentField.options[k].selected=true;
							else
								currentField[k].checked=true;
						}
					}
				break;
				case 7://yes/no checkbox
					if (inputTag[i].firstChild)
						currentField.checked=(parseInt(inputTag[i].firstChild.data) == 1);
				break;
				case 9://file
					if (inputTag[i].firstChild && get_object('usrImg_'+fieldId) && isValid('webImage',unescape(inputTag[i].firstChild.data)))
						get_object('usrImg_'+fieldId).src+='/'+unescape(inputTag[i].firstChild.data);
						get_object('usrImg_'+fieldId).style.display='block';
				break;
				default:
					if (inputTag[i].firstChild)
						currentField.value=unescape(inputTag[i].firstChild.data);//to get to work in IE6, the input is sent from core urlencoded, wherefore we unescape here!
			}
		}
	}
	if (window.userData_onLoad)
		userData_onLoad();
}

// L A N G U A G E
function km_switchLanguage() {
	var lg_new=(lg == lg_array[0])?lg_array[1]:lg_array[0];
	km_changeLanguage(lg_new);
}
function km_changeLanguage(lg_new) {
	if (hasFs) {
		top.window.location.href='index.htm?lg='+lg_new;
	} else {
		//script that change to sent in lanugage and keeps the same location
		var urlVarsToRemove;
		var newUrlVars='?lg='+lg_new;
		if (km_changeLanguage.arguments[1]) {
			newUrlVars+='&pg='+km_changeLanguage.arguments[1]+'&pr=0';
			urlVarsToRemove=['pg','lg','pr'];
		} else {
			urlVarsToRemove=['lg'];
		}
		presetUrlVars=km_removeFromLocationSearch(urlVarsToRemove,true);
		if (presetUrlVars != '')
			newUrlVars+='&'+presetUrlVars;
		window.location.href=window.location.href.split('?')[0]+newUrlVars;
	}
}

// S T R I N G S
function LTrim(value) {
	var re=/\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
function RTrim(value) {
	var re=/((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
function trim(value) {
	return LTrim(RTrim(value));
}

// F O R M S
function setSelect(theSelect,theValue) {
	var j;
	if (setSelect.arguments[2])
		theAction=setSelect.arguments[2];
	else
		theAction='select';
	for (var i=0;i<theSelect.length;i++) {
		if (theSelect.options[i].value == theValue)
			j=i;
	}
	switch (theAction) {
		case 'select':
			theSelect.selectedIndex=j;
		break;
		case 'disable':
			theSelect.options[j].disabled=true;
		break;
		case 'enable':
			theSelect.options[j].disabled=false;
		break;
	}
}
function getCheckedRadioValue(theRadio) {
	var considerDisabled=(getCheckedRadioValue.arguments[1]);
	if (theRadio[1]) {
		for (i=0;i<theRadio.length;i++) {
			if (theRadio[i].checked && (!considerDisabled || (considerDisabled && !theRadio[i].disabled)))
				return theRadio[i].value;
		}
	} else {
		if (theRadio.checked && (!considerDisabled || (considerDisabled && !theRadio.disabled)))
			return theRadio.value;
	}
	return '';
}
function km_doTextareaMax(textarea,maxValue) {
	if (textarea.value.length > maxValue)
		textarea.value=textarea.value.substr(0,maxValue);
}
function km_getEmptyFieldCount(theForm) {
	var count=0;
	for (var i=0;i<theForm.elements.length;i++) {
		if (trim(theForm.elements[i].value).length == 0 && theForm.elements[i].type != 'hidden')
			count++;
	}
	return count;
}
function km_popForms() {
	var theForm;
	for (var i=0;i<document.forms.length;i++) {
		theForm=document.forms[i];
		if (theForm.pg && trim(theForm.pg.value).length == 0)
			theForm.pg.value=pg;
		if (theForm.pr && trim(theForm.pr.value).length == 0)
			theForm.pr.value=pr;
		if (theForm.lg && trim(theForm.lg.value).length == 0)
			theForm.lg.value=lg;
		if (theForm.wp && trim(theForm.wp.value).length == 0)
			theForm.wp.value=wp;
		if (theForm.bi && trim(theForm.bi.value).length == 0)
			theForm.bi.value=bi;
		if (theForm.queryString)
			theForm.queryString.value=km_removeFromLocationSearch(['pg','lg','pr','wp','bi'],true);
		if (theForm.name.substr(0,10) == 'loginForm_') {
			if (theForm.login_user && trim(theForm.login_user.value).length == 0)
				theForm.login_user.focus();
			else
				theForm.login_password.focus();
		}
	}
}
function km_showPossibleFormResult() {
	if (location.search.indexOf('shwFrmRes') != -1) {
		urlVar_array=km_getUrlVarArray(location.search);
		var id=urlVar_array[urlVar_array.length-1]['value'];
		km_getFormResult(id);
	}
}
function km_getKeyCode(event) {
	return event.keyCode?event.keyCode:event.which?event.which:event.charCode;
}
function km_getFormResult(id) {
	km_activeResultFormId=id;
	if (ssc == 'cfm') {
		var url='km/system/ajax/getFormResult.'+ssc+'?wp='+wp+'&id='+id+'&lg='+lg;
		km_loadAjax('formResult',url,'text');
	} else {//due to all php not have curl
		km_setFormResultDisplay(id,true);
	}
}
function km_popAjax_formResult(response) {
	var response=trim(response);
	var o=get_object('km_formResult_'+km_activeResultFormId);
	o.innerHTML=response;
	km_setFormResultDisplay(km_activeResultFormId,true);
}
function km_setFormResultDisplay(id,show) {
	get_object('km_formResult_'+id).style.display=(show)?'block':'none';
	get_object('km_buttonShowResult_'+id).style.display=(show)?'none':'block';
	get_object('km_buttonHideResult_'+id).style.display=(show)?'block':'none';
}
function km_fieldDefaultValue(theField,action) {
	var field_array=theField.name.split('_');
	var field_no=field_array[1];
	var form_name_array=theField.form.name.split('_');
	var form_id=form_name_array[2];
	theField.value=trim(theField.value);
	if (field_array.length == 3) {
		switch(field_array[2]) {
			case 'y':
				field_default_value=(lg == 1)?'ÅÅÅÅ':'YYYY';
			break;
			case 'm':
				field_default_value='MM';
			break;
			case 'd':
				field_default_value='DD';
			break;
		}
	} else {
		field_default_value=eval('fieldDefaultValue_'+form_id+'_'+field_no)
	}
	switch(action) {
		case 'fill':
			if (theField.value.length == 0)
				theField.value=field_default_value;
		break;
		case 'clear':
			if (theField.value == field_default_value)
				theField.value='';
		break;
	}
}
function isValid(type,value) {
	switch (type) {
		case 'email':
			var lCaseValue=value.toLowerCase();
			return lCaseValue.match(/^[\_]*([a-z0-9]+(\.|\_*|\-*)?)+@([a-z0-9\-\.]+(\.|\-*\.))+[a-z]{2,6}$/);
		break;
		case 'date':
			return value.match(/^([1-9]|0[1-9]|[12][0-9]|3[01])\D([1-9]|0[1-9]|1[012])\D(19[0-9][0-9]|20[0-9][0-9])$/);
		break;
		case 'jpg':
			var lCaseValue=value.toLowerCase();
			return lCaseValue.match(/.\jpg$/);
		break;
		case 'webImage':
			var lCaseValue=value.toLowerCase();
			var re=/.jpg$/i;
			if (re.test(lCaseValue))
				return true;
			var re=/.jpeg$/i;
			if (re.test(lCaseValue))
				return true;
			var re=/.gif$/i;
			if (re.test(lCaseValue))
				return true;
			var re=/.png$/i;
			if (re.test(lCaseValue))
				return true;
			return false;
		break;
		case 'positiveInteger':
			return /^\d+$/.test(value);
		break;
		case 'integer':
			return /^-?\d+$/.test(value);
		break;
	}
	return false;
}
function restoreInteger(theField) {
	if (restoreInteger.arguments[1]) {
		switch (restoreInteger.arguments[1]) {
			case 'allowNegative':
				theField.value=theField.value.replace(/[^\d\-]/g, "");
			break;
		}
	} else {
		theField.value=theField.value.replace(/[^\d]/g, "");
	}
}
function restoreNumeric(theField) {
	theField.value=theField.value.replace(",",".");
	if (restoreNumeric.arguments[1]) {
		switch (restoreNumeric.arguments[1]) {
			case 'allowNegative':
				theField.value=theField.value.replace(/[^\d\.\-]/g, "");
			break;
		}
	} else {
		theField.value=theField.value.replace(/[^\d\.]/g, "");
	}
}
function getFieldIndexForValue(theField,theValue,fieldType) {
	if (theField.options) {
		for (var i=0;i<theField.options.length;i++) {
			if (theField.options[i].value == theValue) {
				return i;
				break;
			}
		}
	} else if (theField[1]) {
		for (var i=0;i<theField.length;i++) {
			if (theField[i].value == theValue) {
				return i;
				break;
			}
		}
	}
	return -1;
}
function getCheckedValues(theCheckbox) {
	if (getCheckedValues.arguments[1])
		theReturnType=getCheckedValues.arguments[1];
	else
		theReturnType='list';
	switch (theReturnType) {
		case 'list':
			var theList='';
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked) {
						if (theList.length > 0)
							theList=theList+',';
						theList=theList+theCheckbox[i].value;
					}
				}
			else if (theCheckbox.checked)
				theList=theCheckbox.value;
			return theList;
		break;
		case 'array':
			var theArray=new Array();
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked)
						theArray.push(theCheckbox[i].value);
				}
			else if (theCheckbox.checked)
				theArray.push(theCheckbox.value);
			return theArray;
		break;
		case 'count':
			var checkedCount=0;
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked)
						checkedCount++;
				}
			else if (theCheckbox.checked)
				checkedCount++;
			return checkedCount;
		break;
		case 'boolean':
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked) {
						return true;
						break;
					}
				}
			else if (theCheckbox.checked)
				return true;
		break;
	}
	return false;
}
function getSelectedValues(theSelect) {
	if (getSelectedValues.arguments[1])
		theReturnType=getSelectedValues.arguments[1];
	else
		theReturnType='list';
	switch (theReturnType) {
		case 'list':
			var theList='';
			for (i=0;i<theSelect.options.length;i++) {
				if (theSelect.options[i].selected) {
					if (theList.length > 0)
						theList=theList+',';
					theList=theList+theSelect.options[i].value;
				}
			}
			return theList;
		break;
		case 'array':
			var theArray=new Array();
			for (i=0;i<theSelect.options.length;i++) {
				if (theSelect.options[i].selected)
					theArray.push(theSelecttheSelect.options[i].value);
			}
			return theArray;
		break;
		case 'count':
			var selectedCount=0;
			for (i=0;i<theSelect.options.length;i++) {
				if (theSelect.options[i].selected)
					selectedCount++;
			}
			return selectedCount;
		break;
		case 'boolean':
			for (i=0;i<theSelect.options.length;i++) {
				if (theSelect.options[i].selected) {
					return true;
					break;
				}
			}
		break;
	}
	return false;
}

//A J A X
function km_loadAjax(label,url) {
	km_HttpRequestInProcess_type=(km_loadAjax.arguments[2])?km_loadAjax.arguments[2]:'xml';//probably 'text' if not 'xml';
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		HttpRequestInProcess_label=label;
		eval('km_HttpRequest_'+label+'=new XMLHttpRequest();');
		var HttpRequest=eval('km_HttpRequest_'+label);
		HttpRequest.open("GET",url,true);
		HttpRequest.onreadystatechange=km_processAjax;
		HttpRequest.send(null);
		// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		eval('km_HttpRequest_'+label+'=new ActiveXObject("Microsoft.XMLHTTP");');
		var HttpRequest=eval('km_HttpRequest_'+label);
		if (HttpRequest) {
			HttpRequestInProcess_label=label;
			HttpRequest.open("GET",url,true);
			HttpRequest.onreadystatechange=km_processAjax;
			HttpRequest.send();
		}
	}
}
function km_processAjax() {
	var theRequest=eval('km_HttpRequest_'+HttpRequestInProcess_label);
	// only if req shows "complete"
	if (theRequest.readyState == 4) {
		// only if "OK"
		if (theRequest.status == 200) {
			if (km_HttpRequestInProcess_type == 'xml') {
				var response=theRequest.responseXML.documentElement;
			} else {
				var response=theRequest.responseText;
			}
			eval('km_popAjax_'+HttpRequestInProcess_label+'(response);');
		}
	}
}
function km_clickBanner(type,bnnId,lngId) {
	var debug=false;
	if (debug)
		alert('You clicked a '+type+'-banner ('+bnnId+':'+lngId+')');
	var url='km/system/ajax/regBannerClick.'+ssc+'?wp='+wp+'&id='+bnnId+'&lg='+lngId;
	km_loadAjax('regBanner',url,'text');
	if (km_clickBanner.arguments[3])
		window.location.href=km_clickBanner.arguments[3];
}
function km_popAjax_regBanner(response) {
	var debug=false;
	if (debug) {
		var response=trim(response);
		alert(response);
	}
	//no need to handle reg click response
}


// M E N U
function km_menuKingSlaveDifferentFrames() {
	idPrefixToHide='';
	if (window.location.href.indexOf('menuKing.'+ssc) != -1)
		idPrefixToHide='subMenuLi_';
	else if (window.location.href.indexOf('menuSlave.'+ssc) != -1)
		idPrefixToHide='menuLi_';
	if (idPrefixToHide != '') {
		items=document.getElementsByTagName('li');
		for (var i=0;i<items.length;i++) {
			if (items[i].id.indexOf(idPrefixToHide) == 0)
				items[i].style.display='none';
		}
	}
}

// F R A M E S E T
function km_checkFrameset() {
//	if (top.frames.length == 0)
//		top.window.location.href='index.htm';
}

// O P E N / P O P U P S / I M A G E S
function km_tellAFriend(aTag) {
	//found pob div and pobId
	var pobDivFound=false;
	var i=0;
	var o=aTag;
	var oParent;
	var pobId=0;
	while (!pobDivFound) {
		oParent=o.parentNode;
		if (oParent.id && oParent.id.split('_')[0] == 'pob') {
			pobId=oParent.id.split('_')[1];
			pobDivFound=true;
		} else {
			o=oParent;
		}
		i++;
		if (i > 100)
			break;
	}
	var url='km/system/tellAFriend.'+ssc+'?pg='+pg+'&pr='+pr+'&lg='+lg+'&wp='+wp+'&po='+pobId;
	km_popup('tellAFriend',url,'',274,270);
}
function km_openDc(id) {
	var url='index.'+ssc;
	var newSearch=km_removeFromLocationSearch(['dc','bi']);//remove to avoid conflict
	url+=newSearch;
	url+=(newSearch == '')?'?dc='+id:'&dc='+id;
	url+='&bi=dc';
	window.location.href=url;
}
function km_removeFromLocationSearch(name_array,removeLeadingQuestionmark) {
	//returns the current window location hrefs url vars (search) witn possible variables that are sent in removed from the string
	var urlVars=location.search.split('?');
	var myRE;
	if (urlVars[1]) {
		var search_array=urlVars[1].split('&');
		var fullStringToRemove_array=new Array();
		var i,j;
		for (i=0;i<search_array.length;i++) {
			for (j=0;j<name_array.length;j++) {
				myRE=new RegExp('^'+name_array[j])
				if (search_array[i].match(myRE))
					fullStringToRemove_array.push(search_array[i]);
			}
		}
		search_array.removeItems(fullStringToRemove_array);
		var returnString='';
		for (i=0;i<search_array.length;i++) {
			returnString+=(i == 0)?'?':'&';
			returnString+=search_array[i];
		}
//		alert(returnString);
		return (removeLeadingQuestionmark)?returnString.replace(/^\?/,''):returnString;
	} else {
		return '';
	}
}
function km_setBigImage(a) {
	var smallSrc=a.firstChild.src;
	var bigImg=smallSrc.substr(0,smallSrc.lastIndexOf('_'))+'.jpg';
	get_object('big_image').src=bigImg;
}
function km_goToStartPage() {
	var url='index.'+ssc+'?pg='+startPage;
	if (km_goToStartPage.arguments[0])
		eval('top.'+km_goToStartPage.arguments+'.window.location.href="'+url+'";');
	else
		window.location.href=url;
}
function km_openItm(id,ictId) {
	window.location.href='index.'+ssc+'?x=cShopPub.viewItm&ID='+id+'&bi=shop&pg='+pg+'&pr='+pr+'&activeIctId='+ictId+'&ic='+ictId;
}
function km_popup(id,url,settings,width,height) {
	var screenSize_array=getScreenSize();
	var left=parseInt(screenSize_array[0]/2)-parseInt(width/2);
	var top=parseInt(screenSize_array[1]/2)-parseInt(height/2);
	var settings=(settings)?','+settings:'';
	settings='left='+left+',top='+top+',width='+width+',height='+height+settings;
	if (eval("window.km_popupWindow_"+id))
		eval("km_popupWindow_"+id+".close();");
	eval("km_popupWindow_"+id+"=window.open(url,'',settings);");
	eval("km_popupWindow_"+id+".focus();");
}
function getFilePath(filePath) {
	return filePath.substr(0,filePath.lastIndexOf('/'));
}
function getFileExt(filePath) {
	var temp=filePath.split('.');
	var lastIndex=temp.length-1;
	return temp[lastIndex].toLowerCase();
}
function getFile(filePath) {
	var temp=filePath.split('/');
	var lastIndex=temp.length-1;
	return file=temp[lastIndex];
}
function getFileName(filePath) {
	var temp=filePath.split('/');
	var lastIndex=temp.length-1;
	var file=temp[lastIndex];
	return file.substr(0,file.lastIndexOf('.'));
}
//  P O P U P S
function km_popupShopImage(endPath) {
	km_popupImage(wpg_url+'/'+endPath,true);
}
function km_popupImage(image) {
	var pathIsAbs=(km_popupImage.arguments[1])?true:false;
	var url='km/system/popup.'+ssc+'?image='+image+'&pathIsAbs='+pathIsAbs;
	kmPopupWindow=window.open(url,'imagePopup','directories=no,menubar=no,scrollbars=no,status=no,location=no,toolbar=no,resizable=no,top=0,left=0,width=300,height=300');
	kmPopupWindow.focus();
}
function km_openFile(file,folder,finId) {
	var url='km/system/openFile.htm?file='+file+'&folder='+folder+'&finId='+finId+'&ssc='+ssc+'&wp='+wp;
	window.open(url,'','directories=no,menubar=no,scrollbars=no,status=no,location=no,toolbar=no,resizable=no,top=40,left=40,width=800,height=600');
}
function km_popupOnload(width,height) {
	var browser=getBrowser();
	//alert(browser);
	//alert(navigator.appName);
	switch (browser) {
		case 'Safari':
			offsetX=0;
			offsetY=23;
		break;
		case 'Opera':
			offsetX=0;
			offsetY=50;
		break;
		case 'Firebird':
		case 'Firefox':
			offsetX=6;
			offsetY=94;
		break;
		case 'Netscape':
			offsetX=6;
			offsetY=29;
		break;
		case 'Internet Explorer':
			offsetX=4;
			offsetY=80;
		break;
		default:
			offsetX=10;
			offsetY=31;
	}
	var windowWidth=(width)?parseInt(width):document.images[0].width;
	windowWidth+=offsetX;
	var windowHeight=(height)?parseInt(height):document.images[0].height;
	windowHeight+=offsetY;
	window.resizeTo(windowWidth,windowHeight);
	var screenSize_array=getScreenSize();
	var popupLeft=parseInt(screenSize_array[0]/2-(windowWidth/2));
	var popupTop=parseInt(screenSize_array[1]/2-(windowHeight/2));
	window.moveTo(popupLeft,popupTop);
	if (get_object('whatToDo')) {
		o=get_object('whatToDo');
		o.style.left=parseInt((windowWidth-whatToDo_width)/2)+'px';
		o.style.top=parseInt((windowHeight-whatToDo_height)/3)+'px';
		o.style.width=whatToDo_width+'px';
		o.style.height=whatToDo_height+'px';
	}
}
function km_popupOnClick() {
	var o=get_object('whatToDo');
	o.style.visibility=(o.style.visibility == 'visible')?'hidden':'visible';
}
function km_popupPrint() {
	get_object('whatToDo').style.visibility='hidden';
	window.print();
}
function km_popupClose() {
	get_object('whatToDo').style.visibility='hidden';
	window.close();
}

// A R R A Y
Array.prototype.inArray=function (value,caseSensitive) {
	var i;
	for (i=0;i<this.length;i++) {
		if (caseSensitive) {
			if (this[i].toLowerCase() == value.toLowerCase())
				return true;
		} else {
			if (this[i] == value)
				return true;
		}
	}
	return false;
}
Array.prototype.removeItems=function(itemsToRemove) {
	if (!/Array/.test(itemsToRemove.constructor))
		itemsToRemove=[itemsToRemove];
	var j;
	for (var i=0;i<itemsToRemove.length;i++) {
		j=0;
		while (j < this.length) {
			if (this[j] == itemsToRemove[i])
				this.splice(j,1);
			else
				j++;
		}
	}
}
Array.prototype.getIndex=function(secondDimension,value) {
	for (var i=0;i<this.length;i++) {
		if (this[i][secondDimension] == value)
			return i;
	}
	return -1;
}
Array.prototype.valueCount=function(secondDimension,value) {
	var hitCount=0;
	for (var i=0;i<this.length;i++) {
		if (this[i][secondDimension] == value)
			hitCount++;
	}
	return hitCount;
}
