/*******************/
var newWin = null;
var popupWin=null;



function newWindow(doc){
   if (newWin != null)   {
        window.newWin.focus();
   }    
   newWin = window.open(doc, "newWin");
   window.newWin.focus();
   newWin = null;
}

function popupWindow(doc){
   if (popupWin != null)   {
        window.popupWin.focus();
   }    
   popupWin = window.open(doc, "popupWin");
   window.popupWin.focus();
   popupWin= null;
}

function tilmeld_idx(what){
var win=null;
   win = window.open("tilmeld/"+what + ".html", what, "scrollbars,width=630,height=460");
   win.focus();
}

function popup(what, when, w, h){
var win=null;
   win = window.open("/popups/"+what + ".html", when, "scrollbars,width="+w+",height="+h);
   win.focus();
}


function homepage_popup(what, when, w, h){
var win=null;
   win = window.open("popups/"+what + ".html", when, "scrollbars,width="+w+",height="+h);
   win.focus();
}

/*
function popup(what, w, h){
var win=null;
   win = window.open("../popups/"+what + ".html", what, "scrollbars,width="+w+",height="+h);
   win.focus();
}
*/

function tilmeld(what){
var win=null;
   win = window.open("../tilmeld/"+what + ".html", what, "scrollbars,width=630,height=460");
   win.focus();
}

function tilmeld2(what, w, h){
var win=null;
   win = window.open("/tilmeld/"+what + ".html", what, "scrollbars,resizable,width=" + w + ",height=" + h);
   win.focus();
}



function whatis(what){
//var winName="whatis" + what;
var win=null;
//alert(winName);
   win = window.open("../whatis/"+what + ".html", what, "scrollbars,width=520,height=500");
   win.focus();
//   winName = null;
}

function switchLanguage(lang){
	var thePath="";
	var is_homepage;
	if (!(is_homepage=(pathname==""))){
		thePath="../"
	}
	if (lang == "da"){
		thePath+="../";
	}
	else{
		thePath+="eng/";
	}
	return (thePath + (is_homepage?'':(pathname + '/')) + docname + '.html');
}


function setTextSizePrefs(prefSize){
	if (prefSize != txtsize){
		deleteCookie('txtsize');
		if (pathname == "") {//ie. we are at the homepage
			return "/changeFontSize.asp?txt=" + prefSize + "&doc=" + sitename + docname + ".html";
		}
		return "/changeFontSize.asp?txt=" + prefSize + "&doc=" + sitename + pathname + "/" + docname + ".html";
	}
	return "#";
}

function isCurrentTxtSize(txt_size){
	if (txtsize==txt_size)
		return CUR_SETTING; // " (Aktuel indstilling).";
	return "";
}
//test:

function getTextSizePrefs(){
   if (document.cookie=="")
	return 'm';
   var t_size= fetchNamedCookie('txtsize');
   if (t_size.length ==0)
      return 'm';
   return t_size;
}

// These functions provide a clean method of dealing with cookies

//
// This function sets a document cookie that will expire
//  in one year from the time it was set.
//
function setDocumentCookie( oDoc, sName, sValue )
{
    if ( sName.length < 1 )
        return;

    if ( 0 < sValue.length )
    {
        // create a date for a year from now
var expDate = new Date();
        expDate.setTime( expDate.getTime() + 365*24*60*60*1000 );

        // Notice that the cookie is actually two assignment strings.
//  The first is "cookiename=value" and the second is
//  "expires=date".  The two assignments are  separated by a
//  semicolon.  If you do not have the "expires" assignment
//  the cookie will disappear when the visitor's browser exits.
//
oDoc.cookie = ""
                        + sName + "=" + sValue + "; "
                        + "expires=" + expDate.toGMTString();
    }
    else
    {
        //  this will cause the named cookie to be deleted.
oDoc.cookie = sName + "=";
    }
}

function setNamedCookie( sName, sValue )
{
    setDocumentCookie( document, sName, sValue );
}

function deleteDocumentCookie( oDoc, sName )
{
    oDoc.cookie = sName + "=";
}

function deleteCookie( sName )
{
    deleteDocumentCookie( document, sName );
}

//
//  This function will fetch a named cookie
//
function fetchDocumentCookie( oDoc, sName )
{
    var sValue = "";
    var index = 0;

    //  The "cookie" property on the document is actually a
//  single string of the form "name=value; name2=value2; ..."
//  As a result we must search through the cookie string
//  to find the name=value pair that we are looking for.
//
if( oDoc.cookie )
        index = oDoc.cookie.indexOf( sName + "=" );
    else
        index = -1;

    if ( index < 0 )
    {
        sValue = "";
    }
    else
    {
        var countbegin = (oDoc.cookie.indexOf( "=", index ) + 1);
        if ( 0 < countbegin )
        {
            var countend = oDoc.cookie.indexOf( ";", countbegin );
            if ( countend < 0 )
                countend = oDoc.cookie.length;
            sValue = oDoc.cookie.substring( countbegin, countend );
        }
        else
        {
            sValue = "";
        }
    }
    return sValue;
}

function fetchNamedCookie( sName )
{
    return fetchDocumentCookie( document, sName );
}

/***** Meetings *****/

var DATO=0, MEETING=1, CITY=0, ADR=1, HALL=2, START=3, FEE=4, WINNAME=5, NOTE=6;

/*
	var weekDays = 
		new Array(
			'S&oslash;ndag',
			'Mandag',
			'Tirsdag',
			'Onsdag',
			'Torsdag',
			'Fredag',
			'L&oslash;rdag'
	);
	var monthNames = 
		new Array(
			'jan.',
			'febr.',
			'marts',
			'april',
			'maj',
			'juni',
			'juli',
			'aug.',
			'sept.',
			'okt.',
			'nov.',
			'dec.'
	);
*/
var rightnow = new Date();

// 10.04.04 - to be able to show prices that are not whole kr.:
function formatPrice(price){
	var priceStr = '' + price;
	var parts = priceStr.split('.');
	if (parts.length==1) {
		// don't show øre when price is in whole kroner:
		return priceStr + '.-';
	}
	else{
		// make sure there are two digits if we show øre:
		if (parts[1].length==1){
			parts[1] += '0';
		}
		return parts[0] + '.' + parts[1];
	}

}
