/** Se till så att vänster-, mitten- och högerspalten har samma höjd */
var savea_EqualColumns=new Object();
savea_EqualColumns.columnswatch=["lc","rc","cw"];
savea_EqualColumns.setHeights=function(reset){var tallest=0;var resetit=(typeof reset=="string")? true:false;for(var i=0;i<this.columnswatch.length;++i){if(document.getElementById(this.columnswatch[i])!=null){if(resetit)document.getElementById(this.columnswatch[i]).style.height="auto";if(document.getElementById(this.columnswatch[i]).offsetHeight>tallest)tallest=document.getElementById(this.columnswatch[i]).offsetHeight;}};if(tallest>0){for(var i=0;i<this.columnswatch.length;++i){if(document.getElementById(this.columnswatch[i])!=null)document.getElementById(this.columnswatch[i]).style.minHeight=tallest+"px";}}}
savea_EqualColumns.resetHeights=function(){this.setHeights("reset");}
savea_EqualColumns.dotask=function(target,functionref,tasktype){var tasktype=(window.addEventListener)?tasktype:"on"+tasktype;if(target.addEventListener){target.addEventListener(tasktype,functionref,false);}else if(target.attachEvent)target.attachEvent(tasktype, functionref);}
savea_EqualColumns.dotask(window,function(){savea_EqualColumns.setHeights();},"load");

function savea_ToggleCart(    ) {return savea_ToggleBox('basket');}
function savea_ShowCart  (    ) {return savea_ShowBox('basket');}
function savea_HideCart  (    ) {return savea_HideBox('basket');}
function savea_ToggleBox ( id ) {var e=document.getElementById(id);if(e.style.display!="block"){e.style.display="block";}else{e.style.display="none";};return false;}
function savea_ShowBox   ( id ) {var e=document.getElementById(id);e.style.display="block";return false;}
function savea_HideBox   ( id ) {var e=document.getElementById(id);e.style.display="none";return false;}
function savea_GetObj    ( id ) {return document.getElementById(id);}
function savea_SetClass  ( id, class_name) {var e=document.getElementById(id);e.className = class_name;return false;}

var statics = new Array();
function savea_SetTab    ( tab_id ) {
	var e;
	if ( typeof statics[ 'old_tab_id' ] == 'undefined' ) {
		statics[ 'old_tab_id' ] = 'facts';
	}
	savea_HideBox ( 'tab_page_' + statics[ 'old_tab_id' ]           );
	savea_SetClass( 'tab_leaf_' + statics[ 'old_tab_id' ],       '' );
	savea_ShowBox ( 'tab_page_' + tab_id                            );
	savea_SetClass( 'tab_leaf_' + tab_id,                  'active' );

	e = savea_GetObj( 'tab_leaf_' + tab_id );
	e.blur();

	statics[ 'old_tab_id' ] = tab_id;

	savea_EqualColumns.resetHeights();

	return false;
}
function savea_InactivateRow( chk, id ) {
	var e = savea_GetObj( id );
	var c = chk.checked;
	var n = e.className;
	n = n.replace( / ?removed/, "" );
	if ( c ) { n += " removed"; }
	n = n.replace( /^ +/, "" );
	e.className = n;
	return true;
}
function savea_TogglePwdGroup() {
	var o = savea_GetObj( 'password_group' );
	var d = ! o.checked;
	var e = document.getElementById( 'lbl_password2' ); e.setAttribute( 'rel', d ? "disabled" : "enabled" );
	    e = document.getElementById( 'lbl_password'  ); e.setAttribute( 'rel', d ? "disabled" : "enabled" );
	    e = document.getElementById( 'password2'     );e.style.backgroundColor = d?"#ccc":"#fff"; e.disabled = d; e.value = '';
	    e = document.getElementById( 'password'      );e.style.backgroundColor = d?"#ccc":"#fff"; e.disabled = d; e.value = '';
	if ( ! d ) {
		e.focus();
	}
	return true;
}
function savea_FindPosX( obj ) {
	if (!obj) return 0;
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}
function savea_FindPosY( obj ) {
	if (!obj) return 0;
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}
function savea_ToggleBoxAttached( id, other_id ) {
	var o1=savea_GetObj(id);
	var o2=savea_GetObj(other_id);
	var y=savea_FindPosY(o2);
	var x=savea_FindPosX(o2);
	o1.style.top  = y + "px";
	o1.style.left = x + "px";
	return savea_ToggleBox(id);
}

var in_processing = false;
function savea_ProcessSubmit( form_id, continue_id, other_ids ) {
	if ( ! in_processing ) {
		in_processing = true;
		if ( ! document.getElementById )
			return true;
		var f = document.getElementById( form_id );
		if ( f ) {
			var b = document.getElementById( continue_id );
			if ( b ) {
				b.value = "Vänta...";
				b.className = b.className + " disabled";
			}
			if ( other_ids.length > 0 ) {
				for ( var i = 0; i < other_ids.length; ++ i ) {
					b = document.getElementById( other_ids[ i ] );
					if ( b ) {
						b.disabled = true;
						b.className = b.className + " disabled";
						b.style.visibility = "hidden";
					}
				}
			}
			return true;
		}
	}
	return false;
}

function savea_openPrisjaktRatingPopup( account_id ) {
	window.open(
		"http://www.prisjakt.nu/instore/etailer_reviews/form/purchase.php?ftgid=" + account_id + "&code=fdb0a43a00832c612b4f97724b67c1cd", 
		"PrisjaktRatingPopup", 
		"menubar=no,scrollbars=yes,status=no,height=600,width=650"
	);
}