﻿var mCursorX, mCursorY;
var NoOfMainMenu = 3;

       
     function getXY(e) {
        try {
        mCursorX = (window.Event) ? e.pageX - document.documentElement.scrollLeft: event.clientX + document.documentElement.scrollLeft;
        mCursorY = (window.Event) ? e.pageY - document.documentElement.scrollTop : event.clientY ;
        } catch (err) {mCursorX = event.layerX; mCursorY=event.layerY;};

    }
 

	function customImageLinks() {
	
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName('a');
		for (var i=0;  i<anchors.length;  i++) {
			anchor = anchors[i];
			var images = anchor.getElementsByTagName('img');
			if (images[0] != null) {
				anchor.className = "image";
			} 
		}
	} 

	function addMyEventListener() {
	
		if (window.addEventListener)
			window.addEventListener("load", customImageLinks, false)
		else if (window.attachEvent)
			window.attachEvent("onload", customImageLinks)
		else if (document.getElementById)
			window.onload=customImageLinks
	}
	
	addMyEventListener();
	
	function ConfirmDelete (iUrl, iTxt) {

var dialogen = showModalDialog('ConfirmDelete.aspx?txt='+iTxt,'','dialogHeight: 200px; dialogWidth: 260px; scroll: no; status: no;');
	if (dialogen) {
		location.href=iUrl;
		return true;
	} else {
		return false;
	}
}

var startOffsetX = 0, startOffsetY = 0

function PopWin(url,h,w) { 
var ww = 480, wh = 340, leftPos = null, topPos = null; 


IE=(document.all)?true:false; 
var wh = (IE)?document.body.clientHeight : window.innerHeight; 
var ww = (IE)?document.body.clientWidth : window.innerWidth; 
var aRand = 0 //(Math.round((Math.random()*100000)+1));
var aWindowOffsetX = (IE)? screenLeft : window.screenX;
var aWindowOffsetY = (IE)? screenTop : window.screenY;

  //  if (!IE) {alert (document.body.scrollTop); }

	if (top.screen){ 
		if (screen.width){ 
		    leftPos = mCursorX + aWindowOffsetX - (w /2); //screenLeft + 50 + startOffsetX;
		    topPos = mCursorY + aWindowOffsetY - (h + 75); //screenTop + 50 + startOffsetY;
		} else { 
			leftPos = 50; 
			topPos = 50; 
		} 
	}  
	try {popupWin.close();} catch (err) {};   
   	popupWin = window.open(url, 'popup'+aRand, 'resizable,scrollbars=yes,height=' + h + ',width=' + w + ',top=' + topPos + ',left=' + leftPos + '') 
    popupWin.focus();
} 


function OpenWin (Name, pic, Wwidth, Wheight) {
		
		
		image1 = new Image(); 
		image1.src = pic;
		
				
		//alert (image1.width);
			
		var PosTop = screen.height/2 - Wheight;
		var PosLeft = screen.width/2 - Wwidth;
		var myHeight = Wheight 
		var myWidth = Wwidth 
		var myWin;
		//myWin = window.open('picwindow.aspx?pic='+pic+'&width='+myWidth+'&height='+myHeight+'&navn='+Name,'valhalpic','left='+PosLeft+',top='+PosTop+',width='+myWidth+',height='+myHeight+',scrollbars=yes,resizable=no',true);
		myWin = window.open(pic,'billede','left='+PosTop+',top='+PosTop+',width='+myWidth+',height='+myHeight+',scrollbars=yes,resizable=yes',true);
		myWin.focus();
		document.cursor = 'hand';
		
}

function SetElementOpacity (element, opacity) {

try {
		document.getElementById(element).style.filter="alpha(opacity=0)";
		document.getElementById(element).filters.alpha.opacity = opacity;
		} catch (err) {}

}

var myWidth = 0, myHeight = 0;

function GetWindowsize() {
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  /* window.alert( 'Width = ' + myWidth );Left 
  window.alert( 'Height = ' + myHeight ); */
}

function AdjustMaxWidth() {
    GetWindowsize();
    if (myWidth > 1180) {
        document.getElementById('contenttbl').style.width='1180px';
    } else {
        document.getElementById('contenttbl').style.width='100%';
    }
}

function SetElementOpacity (element, opacity) {

try {
        aObj = document.getElementById(element);
        
        if (aObj.filters) {
		    aObj.style.filter="alpha(opacity=0)";
		    aObj.filters.alpha.opacity = opacity;
		} else {
		    aObj.style.opacity = opacity * 0.01;
		}
		
		} catch (err) {}

}

/* FØLGENDE FUNKTIONER ER TIL MENUSTYRING - START --->>> */
 
var MenuOverItems = 0;
/* var CheckInterval = 100; */
var currentmenu;

 function RegisterMenuEvent (iEvnt) {

   if (iEvnt=='over') {
      MenuOverItems += 1;
  } else if (iEvnt=='out') {
      MenuOverItems -= 1;
  }
  
  CheckNoOfMenuOverItems();
}   

 

function CheckNoOfMenuOverItems() {

   if (MenuOverItems <= 0) {
       hidecurrentmenu();
   }
}

 

function setcurrentmenu(id) {
   
   if (id){ 
      if (currentmenu) hidecurrentmenu(); 
      currentmenu = id;
      document.getElementById(id).style.display='block';
      document.getElementById(id+'dt').style.color='#ffffff';
   }
}

 

function hidecurrentmenu() {

   if (currentmenu) {
      MenuOverItems = 0;
      document.getElementById(currentmenu).style.display='none';
      document.getElementById(currentmenu+'dt').style.color='#6c674d';
   }   
}

/* FØLGENDE FUNKTIONER ER TIL MENUSTYRING - SLUT <<<--- */

