function popup(sida,namn,width,height) {
	var bild = window.open(sida,namn,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width="+width+", height="+height+"");
	bild.focus();
}

// **********************************************************************
// frame recapture
// **********************************************************************

if (checkRef() == false){
	location.keyVals = location.search.substr(1).split('&');
	for (var i=0,len=location.keyVals.length;i<len;i++){
		var pair = location.keyVals[i].split('=');
		location.keyVals[pair[0]]=unescape(pair[1]);
	}

	frameRecapture = true
	if (location.keyVals.frc==0) frameRecapture = false
	if (frameRecapture) {
		varG5=window,M5=document;
		if(!parent.frames.length) {
			page = location.pathname;
			top.location.replace("index.php?page="+page+"&"+location.search.substr(1));
		}
	}
}

function checkRef() {
    var href_data=escape(location.href); 
    var ref_data=escape(document.referrer);

    this_site = href_data.substring(9);
    position = this_site.indexOf("/");
    this_site = this_site.substring(0,position);

    ref_site = ref_data.substring(9);
    position = ref_site.indexOf("/");
    ref_site = ref_site.substring(0,position);

    if(this_site == ref_site)
        return true;
    else 
        return false;
}

// **********************************************************************
// hanterar pekare
// **********************************************************************

function cursor(td) {
	td = "id_"+td;	
	var id = document.getElementById(td).style;
	var nVer = navigator.appVersion;
	var nAgt = navigator.userAgent;
	var fullVersion = parseFloat(nVer);
	var majorVersion = parseInt(nVer);

	// In Internet Explorer, the true version is after "MSIE" 
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
		fullVersionIE = parseFloat(nAgt.substring(verOffset+5,nAgt.length));
		majorVersionIE = parseInt(''+fullVersion);
		if (majorVersionIE < 6) id.cursor='hand';
		else id.cursor='pointer';
	} 
	else id.cursor='pointer';
}

// **********************************************************************
// meny-funktioner 
// **********************************************************************

function setMenuDisplay(myId, catId){
	menuDis = document.getElementById(myId).style;
	whichIm = eval("document.img_" + myId);

	if(menuDis.display == "block"){
		document.getElementById(myId).className = "menuSubLevel";
		updateMenuStructure(myId, "remove", catId); 
		menuDis.display = "none";
	}
	else{
		document.getElementById(myId).className = "menuSubLevel";
		updateMenuStructure(myId, "add", catId);
		menuDis.display = "block";
	}
}

function getElementByBrowser(myId){
	if (document.getElementById)
		menuDis = document.getElementById(myId).style;
	else if (document.all)
		menuDis = document.all[id].style;
	else if (document.layers)
		menuDis = document.layers[id].style;

	return menuDis;
}

function updateMenuStructure(myId, action, catId){
	parent.top.controller.document.forms[0].menu_tree.value = myId;
	parent.top.controller.document.forms[0].action.value = action;
	parent.top.controller.document.forms[0].submit();
}

// **********************************************************************
// tar bort vara ur varukorgen
// **********************************************************************

function deleteItem(id) {
	document.cart.delete_id.value = id;
	document.cart.cart_action.value = "delete_item";
	document.cart.submit();
}

// **********************************************************************
// fokus & blur funktion
// **********************************************************************

/*function onFocus(dumt){
	if (document.all){
		dumt.className  = "inputformfocus";
	}
}

function onBlur(dumt){
	if (document.all){
		dumt.className = "inputform";
	}
}*/

// **********************************************************************
// hanterar avgifter av ngot slag
// **********************************************************************

/*function round(number,X) {
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function addFee(sum,fee) {
	var dS = document.getElementById('total');
	obj = document.getElementsByTagName('div');
	totalt = round(parseFloat(sum) + parseFloat(fee),2);
	totalt_array = totalt.toString().split('.');
	if (totalt_array[1] != null) {
		if (totalt_array[1].length == 1)
			totalt = totalt_array[0] + "." + totalt_array[1] + "0";
		else if (totalt_array[1].length > 2)
			totalt = totalt_array[0] + "." + totalt_array[1];
	} 
	else {
		totalt = totalt_array[0] + ".00";
	}
	fee_array = fee.toString().split('.');
	if (fee_array[1] != null) {
		if (fee_array[1].length == 1)
			fee = fee_array[0] + "." + fee_array[1] + "0";
		else if (fee_array[1].length > 2)
			fee = fee_array[0] + "." + fee_array[1];
	} 
	else {
		fee = fee_array[0] + ".00";
	}
	obj['lev'].innerHTML = fee; 
	obj['total'].innerHTML = totalt; 
	document.cart.priceinfo1.value = fee;
	amount_array = totalt.toString().split('.');
	document.cart.priceinfo2.value = totalt;
}*/
