// JavaScript Document 070326
var SgAvailWidth = screen.availWidth;
var SgAvailHeight = screen.availHeight-24;
var SgDOM;
var SgUpWin;
SgIsLoaded = false;

function SgBrowserobj(){
	this.ver = navigator.appVersion.toLowerCase();
	this.agent = navigator.userAgent.toLowerCase();
	this.name = navigator.appName.toLowerCase();
	this.byid = document.getElementById;
	this.opera = (this.agent.indexOf("opera")>-1);
	this.ie = (this.name == 'microsoft internet explorer' && !this.opera);
	this.ie4 = (this.ie && ( this.ver.indexOf("msie 4")>-1 || this.agent.indexOf("msie 4")>-1 ) );
	// ie5 didn't exist in production
    this.ie5 = (this.ie && ( this.ver.indexOf("msie 5")>-1 || this.agent.indexOf("msie 5")>-1 ) );
	this.ns = (this.name == 'netscape' && !this.opera);
	this.ns4 = (this.ns && document.layers);
	this.mac = (this.agent.indexOf("mac")>-1);
	this.windows = (this.agent.indexOf("windows")>-1);
return this;
}
if(!SgDOM){
	SgDOM = new SgBrowserobj();
}
//rensabort
function SgTrim(inputString) {
	if (typeof inputString != "string") {
		return inputString;
	}
	var theReturn = inputString.replace(/^\s*([\S\s]*)$/,'$1');
	theReturn = theReturn.replace(/\s+$/,'');
	theReturn = theReturn.replace(/\s\s+/g,' ');
	return theReturn;
}
function SgTrimUScore(inputString) {
	var theReturn = SgTrim(inputString);
	theReturn = theReturn.replace(/\s/g,'_');
	return theReturn;
}
//öppnare
function SgOpenArgs(url,name,w_width,w_height,args) {
	SgOpenWindow(url,SgTrimUScore(name),w_width,w_height,args);
}
// Base function to handle SgUpWindows (do not call directly)
// kollare
function SgOpenWindow(url, name, w_width, w_height, args, placeWindow) {
	name = SgTrim(name);
	args = SgTrim(args);
	if(args !== ''){
		args = args + ',';
	}
	if (!SgUpWin || SgUpWin.closed) {
		center_of_screen_X=Math.floor(SgAvailWidth/2)-Math.floor(w_width/2);
		center_of_screen_Y=Math.floor(SgAvailHeight/2)-Math.floor(w_height/2);
		placeWindow = (SgDOM.opera) ? "" : ",left=" + center_of_screen_X + ",top=" + center_of_screen_Y;
	}
	SgUpWin = window.open(url,name, args + 'width='+w_width+',height='+w_height + placeWindow);
	if(SgUpWin){
		SgUpWin.focus();
	} else {
		//alert("Fönstret som skulle öppnas blockerades! Ändra inställningar i din popup-blockerare.");
		//skicka vidare
		window.location.replace(url)
	}
}
/*URL - Fixare*/
function PutHref(href) {
	document.title = href;
}
