<!--
var toolTipLayerName = 'ToolTip';

var gebi = document.getElementById ? 1 : 0
var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0

if(ns){doc = "document."; sty = ""}
if(ie){doc = "document.all."; sty = ".style"}
if(gebi){doc = "document.getElementById(\""; sty = "\").style"}

var initialize = 0
var Ex, Ey, topColor, subColor, ContentInfo

if(ie){
	Ex = "event.x";
	Ey = "event.y";

	topColor = "#ffc900";
	subColor = "#fee072";
} else if(ns || gebi){
	Ex = "e.pageX";
	Ey = "e.pageY";
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove=overhere;

	topColor = "#ffc900";
	subColor = "#fee072";
}

function XHConn()
{
  var xmlhttp;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars)
  {
    if (!xmlhttp) return false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) {
        showresults(xmlhttp.responseText); }}; 
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
} 

function doTheSearch() {
	var myConn = new XHConn();
	
	if (!myConn) {
		// Do Nothing!
	}
	else {
		myConn.connect("getSearch.asp", "GET", "sok="+this.document.foo.sokOrd.value);
	}
}

function showresults(results) {
	var myArray = results.split('|');
	var content = '';
	var antal = 0;
	
	eval(doc + 'sokres' + sty + ".display = 'none'");

	   for (i=0; i<20; i++) {
	 		temp = myArray[i];
	 		if (typeof temp != "undefined" && temp != "undefined") 
	 		{
	 			antal = myArray.length-1;
	 			rTemp = temp.split('^;^');
	 			if(rTemp[1] != "undefined" && typeof rTemp[1] != "undefined") {
	 				content += '<tr class=normal_11><td class=normal_11>';
	 				content += '&nbsp;<img src=images/pil.gif border=0>&nbsp;&nbsp;<a href=default_main.asp?katId=' + rTemp[5] + '&katUnderId=' + rTemp[6] + '&detProdId=' + rTemp[0] + '>';
	 				content += rTemp[1].substring(0,70);
	 				content += '</a></td><td class=normal_11 align=left>'
	 				content += rTemp[2] + '/'+ rTemp[3];
	 				content += '</td><td class=normal_11 align=right>'
	 				content += rTemp[4];
	 				content += '</td></tr>';
	 			}
	 		}
	 	}
	 	if(content.length>0)
	 	{
	 		var defContent;
	 		var defContentBottom;
	 			
	 		defContent = "<table border=0 cellspacing=0 cellpadding=0 class=normal_12 width=650>" 
			defContent += "<tr class=normal_11>" 
			defContent += "<td class=normal_11 width=420 bgcolor=#efefef>&nbsp;<b>Produktnamn</b></td>"
			defContent += "<td class=normal_11 width=150 bgcolor=#efefef>&nbsp;<b>Kategori</b></td>"
			defContent += "<td class=normal_11 width=80 bgcolor=#efefef align=center><b>Pris</b></td>" 
			defContent += "</tr>";
			
			if(antal==20)
			{
				defContentBottom = "<tr class=normal_11>" 
				defContentBottom += "<td class=normal_11 width=650 bgcolor=#efefef colspan=3>&nbsp;> <a href='#' onClick='goSearch();'>Visa alla träffar</a> (Det finns fler resultat som inte visas)</td>" 
				defContentBottom += "</tr>";
			}else
			{
				defContentBottom = "<tr class=normal_11>" 
				defContentBottom += "<td class=normal_11 width=650 bgcolor=#efefef colspan=3>&nbsp;Hittade " + antal + " resultat</td>" 
				defContentBottom += "</tr>" 
			}
			
			defContentBottom += "<tr class=normal_11>" 
			defContentBottom += "<td class=normal_11 width=650 bgcolor=#efefef colspan=3>&nbsp;Klicka på produknamnet för att komma till detaljsidan</td>" 
			defContentBottom += "</tr>";
			
	 		document.all['sokres'].innerHTML = defContent + content + defContentBottom + '</table>';
	 		eval(doc + 'sokres' + sty + ".display = ''");
	 	}
}

function goSearch()
{
	this.document.foo.submit();
}

function MoveToolTip(layerName, FromTop, FromLeft){
	if(ie){
		eval(doc + layerName + sty + ".top = "  + (FromTop - 50 + document.body.scrollTop));
	} else {
		eval(doc + layerName + sty + ".top = "  +  FromTop);
	}
	
	if(document.body.scrollWidth-eval(FromLeft)<250){
		eval(doc + layerName + sty + ".left = " + (FromLeft- 300));
	}else{
		eval(doc + layerName + sty + ".left = " + (FromLeft+ 30));
	}
}

function ReplaceContent(layerName){
	if(ie){document.all[layerName].innerHTML = ContentInfo;}
	else if(ns){
		with(document.layers[layerName].document){ 
		   open();
		   write(ContentInfo); 
			close();
		}
	}else if (gebi) {
		document.getElementById(layerName).innerHTML = ContentInfo;
	}
}

function Activate(){initialize=1}

function deActivate(){initialize=0}

function overhere(e){
	if(initialize){
		MoveToolTip(toolTipLayerName, eval(Ey), eval(Ex));
		eval(doc + toolTipLayerName + sty + ".visibility = 'visible'");
	} else {
		MoveToolTip(toolTipLayerName, 0, 0);
		eval(doc + toolTipLayerName + sty + ".visibility = 'hidden'");
	}
}

function EnterContent(layerName, TTitle, TContent){
	ContentInfo = '<table border="0" width="320" cellspacing="0" cellpadding="0">'+
		'<tr><td width="100%" bgcolor="#000000">'+
		'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
		'<tr><td width="100%" bgcolor='+topColor+'>'+
		'<table border="0" width="90%" cellspacing="0" cellpadding="0" align="center">'+
		'<tr><td width="100%">'+
		'<font class="tooltiptitle">&nbsp;'+TTitle+'</font>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'<tr><td width="100%" bgcolor='+subColor+'>'+
		'<table border="0" width="90%" cellpadding="0" cellspacing="1" align="center">'+
		'<tr><td width="100%">'+
		'<font class="tooltipcontent">'+TContent+'</font>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'</table>'+
		'</td></tr>'+
		'</table>';
	ReplaceContent(layerName)
}

var styleer;
var layRef;
var IsLocked = 0;
var what = '';

if (document.layers) { 
	layRef='document.layers'; 
	styleer=""; 
	visVar="show"; 
	what ="ns4"; 
} 
else if(document.all) { 
	layRef='document.all'; 
	styleer='.style'; 
	visVar="visible"; 
	what ="ie4"; 
} 
else if(document.getElementById) { 
	layRef='document.getElementByID'; 
	styleer='.style'; 
	visVar="visible"; 
	what="dom1"; 
} 
else { 
	what="none"; 
	newbrowser = false; 
}

// - 2011-04-26 La till några parametrar som kan skickas direkt in till funktionen istället för att hämtas från formuläret info.
//
function putToBasket(prodId, katId, katUnderId, detProdId, sokOrd, destination) {
	var ProdName = eval('this.document.prod.ben_' + prodId).value;
	var Antal = eval('this.document.prod.antal_' + prodId).value;
	
	if (katId == undefined) {
		katId = this.document.info.katId.value;
	}
	
	if (katUnderId == undefined) {
		katUnderId = this.document.info.katUnderId.value;
	}
	
	if (detProdId == undefined) {
		detProdId = this.document.info.detProdId.value;
	}
	
	if (sokOrd == undefined) {
		sokOrd = '';
	}
	
	if (destination == undefined) {
		destination = '';
	}
		
	var bConf = confirm('Vill du lägga ' + Antal + 'st ' + ProdName + ' i varukorgen?');
	
	if (bConf) {
		this.location.href = '/shop/addToBasket.asp?prodid=' + prodId + '&katId=' + katId + '&antal=' + Antal + '&katUnderId=' + katUnderId + '&detProdId=' + detProdId + '&sokOrd=' + sokOrd + '&dest=' + destination;
	}
}

function delFromBasket(prodId, katId, sBen, antal) {
	var katUnderId = this.document.info.katUnderId.value;
	var katId = this.document.info.katId.value;
	var detProdId = this.document.info.detProdId.value;
	var action = this.document.info.action.value
		
	var bConf = confirm('Vill du ta bort ' + sBen + ' från din varukorg?');
	if(bConf){
		this.location.href='/shop/delFromBasket.asp?prodid=' + prodId + '&katId=' + katId + '&antal=' + antal + '&katUnderId=' + katUnderId + '&detProdId=' + detProdId + '&action=' + action;
	}
}

function openWin() {
	var window_width = 560;
	var window_height = 665;
	if (screen.width > 850) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbVillkor = window.open('villkor.asp','Villkor','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function openByggWin() {

	if(what!='ie4'){
		alert('Denna funktion fungerar endast med Internet Explorer 5 och nyare.');
		return;		
	}

	var window_width = 615;
	var window_height = 765;
	if (screen.width > 850) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbBygg = window.open('Byggpaket/ByggPaket.asp?action=ByggPaket','Bygg','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function openTrackWin(kolliId) {
	var window_width = 960;
	var window_height = 720;
	var myArray = kolliId.split(',');
	var strLink = '';
	if (screen.width > 1280) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}

	for (i=0; i<8; i++) {
 		temp = myArray[i];
 		if (typeof temp != 'undefined' && temp != 'undefined') {
			strLink += '&consignmentId=' + temp;
		} else {
			strLink += '&consignmentId=';
	 	}
	}
	dbKolli = window.open('http://www.posten.se/tracktrace/TrackConsignments_do.jsp?IntLinkNOCATEGORYCName=tracktrace.kundnr.searchdone&trackntraceAction=saveSearch' + strLink + '&loginHandlerImplClass=se.posten.pse.framework.security.applicationImpl.tracktrace.LoginHandlerImpl&internalPageNumber=0&doNotShowInHistory=true','Kolli','resizable=yes,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left);
}

function openFraga(prodId) {
	var window_width = 420;
	var window_height = 500;
	if (screen.width > 850) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbFraga = window.open('fragaProdukt.asp?detProdId=' + prodId,'Fraga','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function openAvbetalningHB() {
	var window_width = 465;
	var window_height = 700;
	if (screen.width > 850) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbFraga = window.open('avbet.asp','avbet','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function createPopUp(url, width, height, title) {
	var position = getPopUpPosition(width, height + 20);
	
	var divMain = document.createElement('DIV'); //height: 600px; width: 520px; position: absolute; top: 1000px; left: 200px; text-align: center; padding: 5px; border: 1px solid black; background: white;
	var divCover = document.createElement('DIV');
	var imgLeft = document.createElement('IMG');
	var imgRight = document.createElement('IMG');
	var iFrame = document.createElement('IFRAME');
	
	divMain.id = 'popUp_' + Math.random() * 1e18;
//	divMain.style.top = position[0];
//	divMain.style.left = position[1];
	divMain.style.width = width;
	divMain.style.height = height;
	divMain.style.position = 'absolute'; /* Needed for Safari */
//	divMain.style.margin = 'auto'; /* Takes care of horizontal alignment in standards compliant browsers */
	divMain.style.backgroundColor = 'white';
	divMain.style.borderWidth = '0pt';

	
	divCover.id = 'cover_' + Math.random() * 1e18;
	divCover.style.position = 'absolute';
	divCover.style.left = 0;
	divCover.style.top = 0;
	divCover.style.width = document.body.scrollWidth;
	divCover.style.height = document.body.scrollHeight;
	divCover.style.backgroundColor = '#ffffff';
	/* for IE */
	divCover.style.filter = 'alpha(opacity=60)';
	/* CSS3 standard */
	divCover.style.opacity = 0.6;
	
	var oTable	= document.createElement('TABLE');
	var oTBody	= document.createElement('TBODY');
	var oRow, oCell;
	
	oTable.appendChild(oTBody);
	
	oTable.width		= '100%';
	oTable.border		= 0;
	oTable.cellPadding	= 0;
	oTable.cellSpacing	= 0;
	oTable.bgColor		= '#FFC900';
	
	oRow = document.createElement('TR');
	oTBody.appendChild(oRow);
	
	oCell = document.createElement('TD');
	imgLeft.src		= '../images/style/1/td_left.gif';
	imgLeft.width	= 10;
	imgLeft.height	= 15;
	oCell.appendChild(imgLeft);
	oCell.width		= 10;
	oRow.appendChild(oCell);
	
	oCell = document.createElement('TD');
	oCell.innerHTML	= title;
	oCell.vAlign	= 'middle';
	oCell.align		= 'center'
	oCell.className	= 'gul'
	oCell.width		= "100%";
	oRow.appendChild(oCell);
	
	oCell = document.createElement('TD');
	oCell.innerHTML	= '<a href=\'JavaScript:hidePopUp(' + divMain.id + ', ' + divCover.id + ');\' style=\'text-decoration: none;\'>X</a>';
	oCell.style.fontSize = '7pt';
	oRow.appendChild(oCell);
	
	oCell = document.createElement('TD');
	imgRight.src	= '../images/style/1/td_right.gif';
	imgRight.width	= 10;
	imgRight.height	= 15;
	oCell.appendChild(imgRight);
	oCell.width		= 10;
	oRow.appendChild(oCell);
	
	divMain.appendChild(oTable);
	
	document.body.appendChild(divCover);
	
	iFrame.style.width = width;
	iFrame.style.height = height;
	iFrame.style.border = 'none';
	iFrame.frameBorder = 'no';
	iFrame.scrolling = 'no';
	iFrame.src = url;
	
	divMain.appendChild(iFrame);
	
	document.body.appendChild(divMain);
	
	positionPopUp(divMain.id);
	
	window.onresize = function() {
		positionPopUp(divMain.id);
	}
}

function hidePopUp(idPopUp, idCover) {
	document.body.removeChild(idCover);
	document.body.removeChild(idPopUp);
}

function positionPopUp(idPopUp) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		
		var contentElement = document.getElementById(idPopUp);
			
		if (windowHeight > 0) {
			var contentHeight = contentElement.offsetHeight;
			
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'absolute';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
		
		if (windowWidth > 0) {
			var contentWidth = contentElement.offsetWidth;
			
			if (windowWidth - contentWidth > 0) {
				contentElement.style.position = 'absolute';
				contentElement.style.left = ((windowWidth / 2) - (contentWidth / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}

function getWindowWidth() {
	var windowWidth = 0;
	
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}

function getWindowHeight() {
	var windowHeight = 0;
	
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	
	return windowHeight;
}

function getPopUpPosition(window_width, window_height) {
	var results = new Array(2);
	
	results[0] = 0; // Top
	results[1] = 0; // Left
	
	if (screen.width > window_width + 50) {
		results[0] = (screen.height - window_height) / 2;
		results[1] = (screen.width - window_width) / 2;
	}
	
	return results;
}

function openAvbetalning(window_width, window_height) {
	if (screen.width > window_width + 50) {
		var window_top = (screen.height - window_height) / 2;
		var window_left = (screen.width - window_width) / 2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbFraga = window.open('avbet_resurs.asp','avbet','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function openProdBild(prodId) {
	var window_width = 450;
	var window_height = 500;
	if (screen.width > 850) {
		var window_top = (screen.height-window_height)/2;
		var window_left = (screen.width-window_width)/2;
	} else {
		var window_top = 0;
		var window_left = 0;
	}
	dbProdBild = window.open('produktbild.asp?pid=' + prodId,'Fraga','resizable=no,menubar=0,scrollbars=0,width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
}

function navigateToIt(katid, katunderid, prodid){
	if(isNaN(prodid)){prodid=0;}
	this.document.location.href = '../default.asp?katId=' + katid + '&katUnderId='+ katunderid +'&detProdId=' + prodid;
}
//-->
