
  function deleteCookie(name) {
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=foto.no;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=.foto.no;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=www.foto.no;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=medlem.foto.no;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=foto.se;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=.foto.se;";
	  document.cookie = name + "=;expires=Thu, 01-Jan-70 00:00:01 GMT; path=/;domain=www.foto.se;";
   }
	

  function Set_Cookie(name,value,domain) { 
	var today = new Date(); 
	var zero_date = new Date(0,0,0); 
	today.setTime(today.getTime() - zero_date.getTime()); 
	var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000)); 
	
	var cookieString = name + "=" +escape(value) + 
	    ( (cookie_expire_date) ? ";expires=" + cookie_expire_date.toGMTString() : "") + ";path=/;domain=" + domain +";"; 
		document.cookie = cookieString;
	//alert(cookieString);
    }  
   

			var isfullscreen = 0;
			
			function togglefdnfullscreen(){
				$('#topadbanner').toggle('fast');
				$('#navigation').toggle('fast');
				$('#navigationfirstpage').toggle('fast');				
				$('#navigationfullscreen').toggle('fast');
				$('#navigationfullscreenandrightcontainer').toggle('fast');				
				$('#rightmenu').toggle('fast');
				$('#rightmenufirstpage').toggle('fast');
				$('#rightmenufullscreenandrightcontainer').toggle('fast');								
				$('#footer').toggle('fast');
				$('#content').css('marginLeft', $('#content').css('marginLeft') == '0px' ? '166px' : 0);				
				$('#contentfirstpage').css('marginLeft', $('#contentfirstpage').css('marginLeft') == '0px' ? '180px' : 0);
				$('#contentfirstpage').css('marginRight', $('#contentfirstpage').css('marginRight') == '0px' ? '190px' : 0);
				$('#contentnorightmenu').css('marginLeft', $('#contentnorightmenu').css('marginLeft') == '0px' ? '166px' : 0);
				$('#contentnorightmenufullscreen').css('marginLeft', $('#contentnorightmenufullscreen').css('marginLeft') == '0px' ? '166px' : 0);
				$('#contentfullscreenandrightcontainer').css('marginLeft', $('#contentfullscreenandrightcontainer').css('marginLeft') == '0px' ? '160px' : 0);
			}
			
			function hideelement(element){
				element = document.getElementById(element);
				if(element != null) {element.style.display='none';};
			}
			function showelement(element){
				element = document.getElementById(element);
				if(element != null) {element.style.display='block';};
			}			
			function showelementinline(element){
				element = document.getElementById(element);
				if(element != null) {element.style.display='inline';};
			}			
			function removemargins(element){
				element = document.getElementById(element);
				if(element != null) {element.style.margin='0';};
			}
			function addmargins(element, leftmargin, rightmargin){
				element = document.getElementById(element);
				if(element != null) {
					element.style.marginLeft=leftmargin;
					element.style.marginRight=rightmargin;
				};
			}

   
   
	var bkfullwin = self;
function openBildekritikkFullScreen(img, id, x, y) {
	        img="/cgi-bin/bilder/fullscreen.cgi?bilde="+img+"&x="+x+"&y="+y+"&id="+id;
	  if (bkfullwin == self || bkfullwin.closed) {
	    bkfullwin =window.open(img,'FOTOdotNO_fullscreen','scrollbars=no,location=no,menubar=no,copyhistory=no,resizable=yes,fullscreen=yes');
	        bkfullwin.focus();
	  }
	  else {
	        bkfullwin.location = img;
	        bkfullwin.focus();
	  }
	}
   
	var imgfullwin = self;
	
	function openImageFullScreen(img) {
	  img="/cgi-bin/fullscreen.cgi?bilde="+img;
	  if (imgfullwin == self || imgfullwin.closed) {
	    imgfullwin =window.open(img,'FOTOdotNO_fullscreen','scrollbars=no,location=no,menubar=no,copyhistory=no,resizable=yes,fullscreen=yes');
	        imgfullwin.focus();
	  }
	  else {
	        imgfullwin.location = img;
	        imgfullwin.focus();
	  }
	}

    var bkwin = self;

    function AapneBokmerke(theURL) {
	if (bkwin == self || bkwin.closed) {
	    bkwin =window.open(theURL,'FOTOdotNOBokmerke','scrollbars=no,location=no,menubar=no,copyhistory=no,resizable=yes,width=510,height=210');
        bkwin.moveTo(360,300);
        bkwin.focus();
  }
  else {
    bkwin.location = theURL;
        bkwin.focus();
  }  
}  

var karusellswin = self;

function openKarusellWindow(theURL) {
  if (karusellswin == self || karusellswin.closed) {
    karusellswin 
=window.open(theURL,'FotoNoKarusell','scrollbars=no,location=no,menubar=no,copyhistory=no,resizable=yes,width=700,height=600');
        karusellswin.moveTo(100,100);
        karusellswin.focus();
  }
  else {
    karusellswin.location = theURL;
        karusellswin.focus();
  }
}

var kopiertilportfoliowin = self;

function openKopiertilportfoliowindow(theURL) {
  if (kopiertilportfoliowin == self || kopiertilportfoliowin.closed) {
    kopiertilportfoliowin 
=window.open(theURL,'FotoNo_kopierTilPortfolio','scrollbars=no,location=no,menubar=no,copyhistory=no,resizable=no,width=700,height=600');
        kopiertilportfoliowin.moveTo(100,100);
        kopiertilportfoliowin.focus();
  }
  else {
    kopiertilportfoliowin.location = theURL;
        kopiertilportfoliowin.focus();
  }
}

/* To avoid 'click to activate' in ie for flash objects etc */
function skrivEmbeddedKode(id, htmlKode){
   var elem = document.getElementById(id);
   if(elem){
	elem.innerHTML = htmlKode;
   }
}

/* For diskusjonsoverview page */
function ViewMoreText(textId){
  document.getElementById('disk_' + textId).style.display='inline';
  document.getElementById('hidedisk_' + textId).style.display='none';
  document.getElementById('hidediskpunct_' + textId).style.display='none';
}


/* For valg menu */

// Copyright 2006-2007 javascript-array.com

var mTimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;

var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

// Open Hidden Layer
function mopen(n)
{
    var l  = document.getElementById("choicemenu"+n);
    var mm = document.getElementById("mmenu"+n);
    if(l)
    {
        mcancelclosetime();
        l.style.visibility='visible';
        if(currentLayer && (currentLayerNum != n))
            currentLayer.style.visibility='hidden';

        currentLayer = l;
        currentitem = mm;
        currentLayerNum = n;			
    }
    else if(currentLayer)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentitem = null;
        currentLayer = null;
	}
}

// Turn On Close Timer
function mclosetime()
{
    closeTimer = window.setTimeout(mclose, mTimeOut);
}

// Cancel Close Timer
function mcancelclosetime()
{
    if(closeTimer)
    {
        window.clearTimeout(closeTimer);
        closeTimer = null;
    }
}

// Close Showed Layer
function mclose()
{
    if(currentLayer && noClose!=1)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentLayer = null;
        currentitem = null;
    }
    else
    {
        noClose = 0;
    }

    currentLayer = null;
    currentitem = null;
}

// Close Layer Then Click-out
document.onclick = mclose; 


// for articleediting:
var seltext = null;
var repltext = null;
    

function formatText(el,tag){
	var selectedText = document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);
	if(selectedText!=''){
		var newText='<'+tag+'>'+selectedText+'</'+tag+'>';
		if(document.selection){
		    document.selection.createRange().text = newText;
		}
		else{
		    el.value = el.value.substring(0,el.selectionStart) + newText + el.value.substring(el.selectionEnd, el.value.length);
		}

	}
}


function addPrefixAndPostfixToSelectedText(el,prefix, postfix){
    var selectedText = document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);
    if(selectedText!=''){
	var newText=prefix+selectedText+postfix;
	if(document.selection){
	    document.selection.createRange().text = newText;
	}
	else{
	    el.value = el.value.substring(0,el.selectionStart) + newText + el.value.substring(el.selectionEnd, el.value.length);
	}

    }
}

function wikiInternalLink(el){
    addPrefixAndPostfixToSelectedText(el, '[LINK=',';Link tittel her]');
}

function wikiExternalLink(el){
    addPrefixAndPostfixToSelectedText(el, '[EXTLINK=',';Link tittel her]');
}
function wikiYouTubeLink(el){
    addPrefixAndPostfixToSelectedText(el, '[YOUTUBE=',']');
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

//Display a named menu at the position of another object
function display_menu(parent,named)
{
	//get the named menu
	var menu_element = document.getElementById(named);
	//override the 'display:none;' style attribute
	menu_element.style.display = "inline";
	//get the placement of the element that invoked the menu...
	var placement = findPos(parent);
	//...and put the menu there
    placement[0] += 10;
    placement[1] += 15;    
	menu_element.style.left = placement[0] + "px";
	menu_element.style.top = placement[1] + "px";
}

//Hide a named menu
function hide_menu(named)
{
	//get the named menu
	var menu_element = document.getElementById(named);
	//hide it with a style attribute
	menu_element.style.display = "none";
}

function validateemailjs(email) {
   var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.\+])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById(email).value;
   if(reg.test(address) == false) {
      return false;
   }
}

