var ie6 = (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1) ? true : false;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1) ? true : false;
var pho = (navigator.userAgent.toLowerCase().indexOf("phoenix") != -1) ? true : false;
var ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1) ? true : false;
var ie55 = (ie && (navigator.userAgent.toLowerCase().indexOf("5.5") != -1)) ? true : false;
var moz = (navigator.appName == "Mozilla" || (navigator.appName == "Netscape" && navigator.appVersion.indexOf("4.") == -1)) ? true : false;	

var IE6 = ie6;	
var IE = ie;

/**
 * Støtte funktion
 */

function getLayer(id) {
	if (document.layers) {
		for (i=0;i<document.layers.length;i++) {
			if (document.layers[i].name == id) {
				return document.layers[i];
			}
		}
	} else if (document.getElementById) {
		return document.getElementById(id)
	} else if (document.all) {
		return document.all[id]
	}
}

function submitPoll(obj) {
	o = -1;
	
	for (i=0; i < obj.option.length;i++) {
		if (obj.option[i].checked) {o=i};
	}
	
	if (o == -1) {
		alert('Der er ikke valgt et svar!');
	} else {
		obj.submit();
	}
}

function alertCookie(obj) {
	if (obj.checked == true) {
		var question = confirm('Brug kun autologin ved en computer som du er enebruger af!\nVil du bruge autologin?');
		if (question == '0') {
			obj.checked = false;
		}
    }
}

img = new Image;
function changeImg(imgName, target) {
	img.src = imgName;
	document[target].src = img.src;
}

function openScaleableWin(url,win_name,popUpWidth,popUpHeight,leftPos,topPos) {
	popWidthHeight = "width=" + popUpWidth + ",height=" + popUpHeight;
	poptop = "";
	popleft = "";
	features = popWidthHeight + poptop + popleft + ",scrollbars=no,status=yes,resizable=yes";
	window.open(url,win_name,features);
}

function openWindow(url,name,windowWidth,windowHeight) {
	
	if (document.all || document.layers) {
	   w = screen.availWidth;
	   h = screen.availHeight;
	} else {
		w = window.screen.availWidth;
		h = window.screen.availHeight;
	}
	
	var leftPos = Math.round((w-windowWidth)/2);
	var topPos = Math.round((h-windowHeight)/2);
	
	
	features = "width=" + windowWidth + ", height=" + windowHeight +', top='+ topPos + ', left=' + leftPos +', status=yes, resizable=yes';
	return window.open(url,name,features);
}

function openWin(url,win_name) {
	window.open(url,win_name);
}

function popupFileLink(fileId) {
	openWindow('/d/marguerite/modules/community/fileview/index.php?mid='+ fileId,'bla',300,200);
}

function playFlash(url,width,height) {
	tagStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="'+ width +'" height="'+ height +'">';
	tagStr = tagStr + '	<param name="movie" value="'+ url +'">';
	tagStr = tagStr + '	<param name="quality" value="best">';
	tagStr = tagStr + '	<param name="play" value="true">';
	tagStr = tagStr + '	<embed src="'+ url +'" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="best" play="true">';
	tagStr = tagStr + '</object>';
	
	document.write(tagStr);
}
