dom = ((document.getElementById))?true:false;   // ns6 etc.
ns = (document.layers)? true:false;
ie = (document.all)? true:false;
vers5 = (navigator.appVersion.indexOf('5.') != -1)? true:false;
agt = navigator.userAgent.toLowerCase();
mac = (agt.indexOf('mac') != -1)? true:false;
visible = (ns)? "show" : "visible";
hidden = (ns)? "hide" : "hidden";
screenWidth=screen.width;

if (ns){
	origWidth = innerWidth;
	origHeight = innerHeight;
	window.captureEvents(Event.RESIZE)
	window.onresize = resizeHandler;
}

function resizeHandler() {
	if (innerWidth != origWidth || innerHeight != origHeight) {
		origWidth = innerWidth;
	    origHeight = innerHeight;
		window.location.reload();
	}
}

var range = "";
var styleObj = "";
if (ie){
	range = "all.";
	styleObj = ".style" ;
}
function returnObject(obj){
	var theObj;
	if (typeof obj == "string"){
		theObj = eval("document." + range + obj + styleObj);
	}
	else if(dom)
	{
		theObj = document.getElementById(obj).style;
	}
	else {
		theObj = obj;
	}
	return theObj;
}

function upgradeDiv(id,inStr)
{
	if (ns) {
		var lyr = document.layers[id].document
		lyr.open();
		lyr.write(inStr);
		lyr.close();
	}
	else if (ie) document.all[id].innerHTML = inStr;
	else if (dom) document.getElementById(id).innerHTML  = inStr;
}

var actMenu=null;

function menuSet(inName)
{
	actMenu=inName;
	document.images(inName).src='images/'+inName+'.on.gif';
}

function menuPic(inName,inMode)
{
	if(inName!=actMenu)	document.images(inName).src='images/'+inName+'.'+inMode+'.gif';
}

function openNewWin(inSrc, inWidth, inHeight)
{
	var theParameters = "width="+inWidth+",height="+inHeight+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=100,top=100;";
	tearkPop = window.open(inSrc,"akpop",theParameters);
}

function preLoadImages(objImg,imgSrc){
	eval(objImg + ' = new Image()')
	eval(objImg + '.src = "'+imgSrc+'"')
}

function swapImage(imgName,imgSrc){
	if (ns) document.images[imgName].src='images/'+imgSrc;
	else document.images(imgName).src='images/'+imgSrc;
}

function popClick(inText){
	var startStr='<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td align="center"><img src="images/pop.top.gif"><br>\n';
	startStr+='<table cellpadding="0" cellspacing="0" border="0" width="360"><tr>\n';
	startStr+='<td width="1" bgcolor="#D2BAA6" rowspan="2"><img src="images/pix.gif" width="1" height="1"></td>\n';
	startStr+='<td width="9" bgcolor="#FAF9F1" rowspan="2"><img src="images/pix.gif" width="9" height="1"></td>\n';
	startStr+='<td width="220" bgcolor="#FAF9F1"><img src="images/pix.gif" width="220" height="1"></td>\n';
	startStr+='<td width="110" bgcolor="#FAF9F1" align="right" valign="top"><a href="javascript:popClose();" class="redlink">Stäng&nbsp;fönstret</a><br></td>\n';
	startStr+='<td width="9" bgcolor="#FAF9F1" rowspan="2"><img src="images/pix.gif" width="9" height="1"></td>\n';
	startStr+='<td width="1" bgcolor="#D2BAA6" rowspan="2"><img src="images/pix.gif" width="1" height="1"></td>\n';
	startStr+='<td width="10" bgcolor="#EDE5DA" rowspan="2"><img src="images/pix.gif" width="10" height="1"></td>\n';
	startStr+='<tr><td bgcolor="#FAF9F1" colspan="2">\n';
	var endStr='</td></tr></table><img src="images/pop.bot.gif"><br></td></tr></table>';
	
	var tempStr=startStr+'<font class="norm">' + inText +'</font>' + endStr;
	upgradeDiv('popinfo',tempStr);

	actDiv=returnObject('popinfo');
	actDiv.top= 170;
	actDiv.visibility=visible;
}

function popClose(){
	actDiv=returnObject('popinfo');
	actDiv.visibility=hidden;
}

function chkvanform()
{
	myform=document.klubbform;
	
	if (myform.namn.value.length>1 && myform.adress.value.length>1 && myform.postnr.value.length>1 && myform.postadress.value.length>1 && myform.epost.value.length>1)
	{
		myform.submit();
	}
	else
	{
		alert('Du måste fylla i alla fält.');
	}
}

function rakna()
{
	document.shopform.action.value="count";
	document.shopform.submit();
}

function changeAction(inp)
{
	document.shopform.action.value=inp;
	document.shopform.submit();
}

function checkShopForm()
{
	if(document.shopform.Namn.value.length>2 && document.shopform.Nummer.value.length>2 && document.shopform.Adress.value.length>2 && document.shopform.Postnummer.value.length>2 && document.shopform.Ort.value.length>2 && document.shopform.Epost.value.length>2)
	{
		document.shopform.submit();
	}
	else alert('Du har lämnat något obligatoriskt fält tomt.');
}