/* $Id: functions.js,v 2.10 2004/09/16 10:01:09 garvinhicking Exp $ */
//if (typeof help_popup == 'undefined') { var ob_win = null; }
var help_pop=null;
var detalje_pop=null;
var Win1=null;
function openPopUp(inURL, inWidth, inHeight, win_objekt){
	var win_pop=null;
	var inTmpWidth=inWidth;
	var inTmpHeight=inHeight;
	var tmpMinus=0;
	if (!win_pop || win_pop.closed){
		if ((screen.availWidth>700)&&(screen.availWidth<1020)) tmpMinus=100;
		else if((screen.availWidth>1020)&&(screen.availWidth<1150)) tmpMinus=200;
		else if((screen.availWidth>1150)&&(screen.availWidth<1270)) tmpMinus=300;
		else if((screen.availWidth>1270)&&(screen.availWidth<1590)) tmpMinus=500;
		else if(screen.availWidth>1590) tmpMinus=700;
		if (inWidth==0) inTmpWidth=screen.availWidth-tmpMinus;
		if (inHeight==0) inTmpHeight=screen.availHeight-(tmpMinus/2);
		
		var posX = (screen.availHeight - inTmpHeight) / 1.2;
		var posY = (screen.availWidth - inTmpWidth) / 1.2;
		if ((inWidth==0)||(inHeight==0)){
			var strParams = 'width=' + inTmpWidth + ',height=' + inTmpHeight + ',top=' + posX + ',left=' + posY +',statusbar=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,hotkeys=no';
		}else{
			var strParams = 'width=' + inTmpWidth + ',height=' + inTmpHeight + ',top=' + posX + ',left=' + posY +',statusbar=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,hotkeys=no';	
		}
		//alert('adresse er: ' + inURL);
		win_pop = window.open( inURL, win_objekt, strParams);
		if( !win_pop ) { alert('Du har aktiveret windows pop-up blok for denne site. ');return true; }
	}else{
		//alert('PopUp vindue er allerede startet.');	
	}
	if (window.focus) {win_pop.focus();}
}
function AvlRefresh(ServeKald)
{
    window.location.reload( ServeKald );
}
function openPopUpObjekt(inURL, inWidth, inHeight, win_objekt){
	var win_pop=null;
	if (!win_pop || win_pop.closed){
		var posX = (screen.availHeight - inHeight) / 1.2;
		var posY = (screen.availWidth - inWidth) / 1.2;
		var strParams = 'width=' + inWidth + ',height=' + inHeight + ',top=' + posX + ',left=' + posY +',statusbar=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes,hotkeys=no';
		//alert('adresse er: ' + inURL);
		win_pop = window.open( inURL, win_objekt, strParams);
		if( !win_pop ) { alert('Du har aktiveret windows pop-up blok for denne site. ');return true; }
	}else{
		
		//alert('PopUp vindue er allerede startet.');	
	}
	if (window.focus) {win_pop.focus();}
}
function openTavlePopUp(inURL, inWidth, inHeight, win_objekt){
	var win_pop=null;
	var str=inURL;
	var pos=str.indexOf("?");
    var prefix="&";
	if (pos<0){
		prefix="?";	
	}
	if (!win_pop || win_pop.closed){
		var posX = (screen.availHeight - inHeight) / 1.2;
		var posY = (screen.availWidth - inWidth) / 1.2;
		var strParams = 'width=' + inWidth + ',height=' + inHeight + ',top=' + posX + ',left=' + posY +',location=no,statusbar=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,hotkeys=no,modal=yes ';
		//alert('adresse er: ' + inURL);
		win_pop = window.open( inURL, win_objekt, strParams);	
		if( !win_pop ) { 
			alert('Du har aktiveret windows pop-up blok for denne site. ');
			sletDelstring(inURL, 'blocked');
			window.location = inURL + prefix + 'blocked=1';
			
		}
		//if( !win_pop ) { window.location = "http://honza.avl/test/stamtavle/getliste.php"; return true; }
		//win_pop.document.title = 'DanAvl - PopUp'; 
	}else{
		
		//alert('PopUp vindue er allerede startet.');	
	}
	if (window.focus) {win_pop.focus();}
	
}
function openBlockPopUp(inURL, inWidth, inHeight, win_objekt, tmpURL){
	
	var win_pop=null;
	var str=tmpURL;
	var pos=str.indexOf("?");
    var prefix="&";
	if (pos<0){
		prefix="?";	
	}
	if (!win_pop || win_pop.closed){
		var posX = (screen.availHeight - inHeight) / 1.2;
		var posY = (screen.availWidth - inWidth) / 1.2;
		var strParams = 'width=' + inWidth + ',height=' + inHeight + ',top=' + posX + ',left=' + posY +',location=no,statusbar=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,hotkeys=no ';
		//alert('adresse er: ' + inURL);
		win_pop = window.open( inURL, win_objekt, strParams);	
		if( !win_pop ) { 
			//alert('Du har aktiveret windows pop-up blok for denne site. ');
			sletDelstring(tmpURL, 'blocked');
			window.location = tmpURL + prefix + 'blocked=1';
			//return true; 
		}
		//if( !win_pop ) { window.location = "http://honza.avl/test/stamtavle/getliste.php"; return true; }
		//win_pop.document.title = 'DanAvl - PopUp'; 
	}else{
		
		//alert('PopUp vindue er allerede startet.');	
	}
	if (window.focus) {win_pop.focus();}
	//return true;
}
function openModalPopUp(inURL, inWidth, inHeight, win_objekt, onfokus){
	
		var posX = (screen.availHeight - inHeight) / 1.2;
		var posY = (screen.availWidth - inWidth) / 1.2;
		//var strParams = 'dialogWidth: ' + inWidth + ';dialogHeight: ' + inHeight + ';dialogTop: ' + posX + ';dialogLeft:' + posY +';center: yes; help: no ;resizable: yes;scroll: yes;status: yes;unadorned: no';
		var strParams = 'dialogWidth: 800;dialogHeight: 600;dialogTop: 20;dialogLeft:20';
		//alert('adresse er: ' + inURL);
 
		if (onfokus){
			window.showModalDialog( inURL);
		}else{
			window.showModelessDialog( inURL, '', strParams);
		}
	
}
function modalWin(inURL, inWidth, inHeight, win_objekt) {
	var win_pop=null;
	if (window.showModalDialog) {
		window.showModalDialog( inURL,win_objekt,"dialogWidth:255px;dialogHeight:250px");
	} else {
		if (!win_pop || win_pop.closed){
			var posX = (screen.availHeight - inHeight) / 1.2;
			var posY = (screen.availWidth - inWidth) / 1.2;
			var strParams = 'width=' + inWidth + ',height=' + inHeight + ',top=' + posX + ',left=' + posY +',location=no,statusbar=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,hotkeys=no,modal=yes';
			//alert('adresse er: ' + inURL);
			win_pop = window.open( inURL, win_objekt, strParams);	
			
		}
		if (window.focus) {win_pop.focus();}
	}
} 
function AvlWinOpen(inURL, win_objekt){
	var win_pop=null;
	if (!win_pop || win_pop.closed){
		win_pop = window.open( inURL, win_objekt, strParams);
		win_pop = window.open(inURL,win_objekt)
		
	}else{	
		//alert('PopUp vindue er allerede startet.');	
	}
	if (window.focus) {win_pop.focus();}
}
function refresh_username(selected_username, formsnavn, elemnavn)
{	//afleverer den valgte værdi tilbage til formets navn og dens variabel navn
	opener.document.forms[formsnavn].elements[elemnavn].value = selected_username;
	opener.focus();
	window.close();
}
/**
 *
 * @param  
 * @param   
 *
 * @return  
 */
function formSubmit(formnavn,formoperation)
{
	//tilføj en skjult felt til at identificere diverse submit muligheder
	//echo "<INPUT ID=fld_submit TYPE=hidden NAME='f_submit' VALUE=''>";
	document.forms[formnavn].operation=formoperation; 
	if (document.forms[formnavn].elements['f_submit'])
			document.forms[formnavn].elements['f_submit'].value = formoperation;
	document.forms[formnavn].submit();
}

