

function popWinOpen(winW,winH,sUrl,sName,iResize,iScroll,iStatus) {
	if (screen) {
		if ((screen.height - winH) < 150) {
			var winX = (screen.width - winW) / 2;
			var winY = 0;
		} else {
			var winX = (screen.width - winW) / 2;
			var winY = (screen.height - winH) / 2;
		}
		var popWindow = window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH + ",top=" + winY + ",left=" + winX + "");
		if (popWindow) popWindow.focus();
	} else {
		window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH);
	}
}


function addEvent(catId) {
	popWinOpen(495,550,"/jsp/calendar/" + (catId != "" ? "?event_type=" + catId : ""),"addEventWin",1,0,1) ;
}

function viewImage(id, showSmall) {
	popWinOpen(750,600,"/jsp/member/view_image.jsp?id=" + id + (showSmall ? "&small=true" : ""),"albumImageWin",1,0,1) ;
}


function openForum(idx) {
	var oSel = document.getElementById("forumSelect" + idx) ;
	var path = oSel.options[oSel.selectedIndex].value ;
	if (path != "") {
		document.location = path ;
	}
}

function submitForm(formId) {
	document.getElementById(formId).submit() ;
}

function addFieldAndsubmitForm(formId, fieldId) {
	var form = document.getElementById(formId);

	var el = document.createElement("input");
   	el.type = "hidden";
   	el.name = fieldId+".x";
   	el.value = "1";

	form.appendChild(el);

	form.submit() ;
}

function removeSearchText(){
	searchInput = document.getElementById("search_input") ;
	if (searchInput.value == "Sök här") {
		searchInput.value = "";
	}
}

function appendSearchText(){
	searchInput = document.getElementById("search_input") ;
	if (searchInput.value == "") {
		searchInput.value = "Sök här";
	}
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=";
}
