var emailwindow;
function openEpost(mailId, replyRequest, replyId)
{
	var url = "../../../adm/openPage/epostviewer/view.html?MAIL_ID=" + mailId;
	if (replyRequest) url += "&replyRequest=" + replyRequest;
	if (replyId) url += "&replyId=" + replyId;
	emailwindow = window.open(url,'epostview',"HEIGHT=700,WIDTH=1024,titlebar=no,scrollbars=yes,resizable=yes");				
	emailwindow.focus();
}

function setCaretToEnd (control)
{
  if (control.createTextRange) 
  {
    var range = control.createTextRange();
    range.collapse(false);
    range.select();
  }
  else if (control.setSelectionRange) 
  {
    control.focus();
    var length = control.value.length;
    control.setSelectionRange(length, length);
  }
}

var hundwindow;
function openHund(huid, tab)
{
	var url = "../../../adm/openPage/admin/hundIndex.html?HUID=" + huid;
	if (tab)
	{
		url += "&TAB=" + tab;
	}
	hundwindow = window.open(url,'hundadm',"HEIGHT=700,WIDTH=1024,titlebar=no,scrollbars=yes,resizable=yes");				
	hundwindow.focus();
}
var personwindow;
function openPerson(peid, tab)
{
	var url = "../../openPage/personAdm/personIndex.html?PEID=" + peid;
	if (tab)
	{
		url += "&TAB=" + tab;
	}	
	personwindow = window.open(url,'personadm',"HEIGHT=700,WIDTH=1024,titlebar=no,scrollbars=yes,resizable=yes");		
	personwindow.focus();
}
var kullwindow;
function openKull(kuid, tab)
{
	var url = "../../openPage/kullAdm/kullIndex.html?KUID=" + kuid;
	if (tab)
	{
		url += "&TAB=" + tab;
	}		
	kullwindow = window.open(url,'kulladm',"HEIGHT=800,WIDTH=1200,titlebar=no,scrollbars=yes,resizable=yes");				
	kullwindow.focus();
}
var kullpendingwindow;
function openKullPending(kpid)
{
	var url = "../../openPage/kullAdm/kullpendingIndex.html?KPID=" + kpid;
	kullpendingwindow = window.open(url,'kullpendingadm',"HEIGHT=800,WIDTH=1200,titlebar=no,scrollbars=yes,resizable=yes");				
	kullpendingwindow.focus();
}
var klubbadmwindow;
function openKlubbAdmin(kuid)
{
	var url = "../../openPage/klubbAdm/klubbIndex.html?KUID=" + kuid;
	klubbadmwindow = window.open(url,'kullpendingadm',"HEIGHT=700,WIDTH=1200,titlebar=no,scrollbars=yes,resizable=yes");				
	klubbadmwindow.focus();
}
var mineSakerWindow;
function openMineSaker(initialer)
{
	var url = "minesaker.html?_exp=0";
	if (initialer && initialer != '')
	{
		url += "&Initialer=" + initialer;
	}
	mineSakerWindow = window.open(url,'minesaker',"HEIGHT=700,WIDTH=1024,titlebar=no,scrollbars=yes,resizable=yes");			
	mineSakerWindow.focus();								
}
var omregwindow;
function openOmreg(omregId)
{
	var url = "../../openPage/kullAdm/omreg_edit.html?OMREGID=" + omregId;
	omregwindow = window.open(url,'omreg',"HEIGHT=900,WIDTH=950,titlebar=no,scrollbars=yes,resizable=yes");				
	omregwindow.focus();
}
var eswindow;
function openEierskifte(esId, huid)
{
	var url = "../../openPage/admin/eierskifte_edit.html?EIERSKIFTE_ID=" + esId + "&HUID=" + huid;
	eswindow = window.open(url,'es',"HEIGHT=825,WIDTH=850,titlebar=no,scrollbars=yes,resizable=yes");				
	eswindow.focus();	
}
var searchEierskiftewindow;
function searchEierskiftePending()
{
	var url = "../../openPage/admin/searchEierskiftePending.html"
	searchEierskiftewindow = window.open(url,'searchEierskiftewindow',"HEIGHT=600,WIDTH=850,titlebar=no,scrollbars=yes,resizable=yes");				
	searchEierskiftewindow.focus();	
}

var vaskwindow;
function openPersonVask(peid)
{
	var url = "../../openPage/personAdm/person_vask.html?PEID=" + peid;
	vaskwindow = window.open(url,'personVask',"HEIGHT=800,WIDTH=850,titlebar=no,scrollbars=yes,resizable=yes");				
	vaskwindow.focus();		
}
var hundSearchSrc;
var hundSearchWindow; 
function openHundSearch(src)
{
	hundSearchSrc = src;
	var url = "../../../adm/openPage/admin/hundsearch.html?HUIDRETURN=y";
	hundSearchWindow = window.open(url,'hundsearch',"HEIGHT=750,WIDTH=750,titlebar=no,scrollbars=yes,resizable=yes,dependent=yes");			
	hundSearchWindow.focus();			
}
function getHundSearchSrc()
{
	return hundSearchSrc;
}
var personSearchSrc;
var personSearchWindow; 
function openPersonSearch(src, viewPersonHist, keepServletName)
{
	personSearchSrc = src;
	var urlStart = "../../../adm/";
	if (keepServletName)
	{
		urlStart = "../../";
	}	
	var url = urlStart + "openPage/personAdm/search.html?PEIDRETURN=y";	
	if (viewPersonHist)
	{
		url = urlStart + "openPage/personAdm/searchAll.html?PEIDRETURN=y";	
	}
	personSearchWindow = window.open(url,'PERSONsearch',"HEIGHT=650,WIDTH=750,titlebar=no,scrollbars=yes,resizable=yes,dependent=yes");			
	personSearchWindow.focus();			
}
function getPersonSearchSrc()
{
	return personSearchSrc;
}
var kennelSearchSrc;
var kennelSearchWindow; 
function openKennelSearch(src)
{
	kennelSearchSrc = src;
	var url = "../admin/kennelsearch.html";
	kennelSearchWindow = window.open(url,'kennelsearch',"HEIGHT=650,WIDTH=750,titlebar=no,scrollbars=yes,resizable=yes,dependent=yes");			
	kennelSearchWindow.focus();			
}
function getKennelSearchSrc()
{
	return kennelSearchSrc;
}
var kullSearchWindow; 
function openKullSearch()
{	
	var url = "../kullAdm/search.html";
	kullSearchWindow = window.open(url,'KULLsearch',"HEIGHT=800,WIDTH=1000,titlebar=no,scrollbars=yes,resizable=yes,dependent=yes");			
	kullSearchWindow.focus();			
}

var omregSearchWindow; 
function openOmregSearch()
{	
	var url = "../kullAdm/searchOmregPending.html";
	omregSearchWindow = window.open(url,'OMREGsearch',"HEIGHT=800,WIDTH=1000,titlebar=no,scrollbars=yes,resizable=yes,dependent=yes");			
	omregSearchWindow.focus();			
}


var kravbetalingwindow;
function openKravBetaling(kravnummer)
{
	var url = "../../openPage/medlemskrav/betaling_krav.html?KRAVNUMMER=" + kravnummer; 
	kravbetalingwindow = window.open(url,'kb',"HEIGHT=800,WIDTH=800,titlebar=no,scrollbars=yes,resizable=yes");				
	kravbetalingwindow.focus();	
}





// Cookie handling
function setCookie( sName, sValue, nDays ) 
{
	var expires = "";
	if ( nDays ) {
		var d = new Date();
		d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 );
		expires = "; expires=" + d.toGMTString();
	}
	document.cookie = sName + "=" + sValue + expires + "; path=/";
}

function getCookie (sName) 
{
	var re = new RegExp( "(\;|^)[^;]*(" + sName + ")\=([^;]*)(;|$)" );
	var res = re.exec( document.cookie );
	return res != null ? res[3] : null;
}

function removeCookie ( name ) 
{
	setCookie( name, "", -1 );
}


function toggleVisibility(id)
{
	var element = document.getElementById(id);
	var currentStyle = element.style.display;

	if(currentStyle == 'none')
	{
		showVisibility(element);	
	}
	else
	{
		hideVisibility(element);
	}
}

function hideVisibility(element)
{
	element.style.display = 'none' ;	
}

function showVisibility(element)
{
	element.style.display = 'block' ;
	
}





