//- DATE GENERATOR

function p_date (vd,vl) {
 if (vd.length == 8) {
   var oY = vd.substr(0,4); var oM = vd.substr(4,2); var oD = vd.substr(6,2);
   var mon_da = ["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"];
   var oMN = mon_da[oM-1];
   if (vl == 'da_long') { 
        if (oD.indexOf('0') == 0) { oD = oD.substr(1,1); }
        document.write(oD+'. '+oMN+' '+oY);}
   else if (vl == 'da_short') {	document.write(oD+'. '+oMN.substr(0,3)+'. '+oY.substr(2,2)); }
   else if (vl == 'da_classic') { 
        if (oM.indexOf('0') == 0) { oM = oM.substr(1,1); }
        if (oD.indexOf('0') == 0) { oD = oD.substr(1,1); }
	document.write(oD+'/'+oM+'-'+oY);
   } else { document.write(oD+'-'+oM+'-'+oY); }
 } else { document.write(vd); }
}

//- MENU MOUSEOVER 

function roll_over(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
   
   
   
//- FRONTPAGE SELECT BOX SCRIPT

    var lastTimerID = 0;
    var currentVisibleSub = null;

    function showMenu1() {
      clearTimeout(lastTimerID);
      document.getElementById("privat").style.visibility = "visible";
    };
	
	function showMenu2() {
      clearTimeout(lastTimerID);
      document.getElementById("erhverv").style.visibility = "visible";
    };

    function hideMenu1() {
      lastTimerID = setTimeout("hideMenuNow1()", 500);
    };
	
	
    function hideMenu2() {
      lastTimerID = setTimeout("hideMenuNow2()", 500);
    };

    function hideMenuNow1() {
      document.getElementById("privat").style.visibility = "hidden";
    };
	
	    function hideMenuNow2() {
      document.getElementById("erhverv").style.visibility = "hidden";
    };

    function subClicked(objId) {
      var obj = document.getElementById(objId);
      if(obj.style.display != "block") {
        obj.style.display = "block";
        if(currentVisibleSub != null) currentVisibleSub.style.display = "none";
        currentVisibleSub = obj;
      } else { 
        obj.style.display = "none";
        currentVisibleSub = null;
      }
    };


// - Login UI scripts

    function registerLoginType(name) {
        var today   = new Date();
        var expires = new Date();
        expires.setTime(today.getTime() + 1000*60*60*24*365);
        setCookie("TeliaLoginType", name, expires);
    }
    
    function getCookie(Name) {
       var search = Name + "="
       if (document.cookie.length > 0) { // if there are any cookies
          offset = document.cookie.indexOf(search);
          if (offset != -1) { // if cookie exists 
             offset += search.length;
             // set index of beginning of value
             end = document.cookie.indexOf(";", offset);
             // set index of end of cookie value
             if (end == -1) 
                end = document.cookie.length;
             return unescape(document.cookie.substring(offset, end));
          } 
       }
    }
    
    function setCookie(name, value, expire) {
       document.cookie = name + "=" + escape(value)
       + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
    }
	
/* error handling for input fields */

function setError(id,status) {
	document.getElementById(id).className += " inputError";
	if (status == "missing") {
		document.getElementById(id).value = "Mangler";
	} else 	if (status == "invalid") {
		document.getElementById(id).value = "Fejl";
	}
}

