

LastImageDiv = null;
function HightlightDiv(theDiv) {
    
	if (LastImageDiv) {
		LastImageDiv.style.border = "none";		
		LastImageDiv.style.padding = "1px";
	}
	
	LastImageDiv = theDiv;
	theDiv.style.border = "2px solid whitesmoke";
	theDiv.style.padding = "2px";		
}
function HightlightDiv2(theDiv) {
    if (LastImageDiv) {
		LastImageDiv.style.border = "1px solid silver";		
		LastImageDiv.style.padding = "1px";
	}
	
	LastImageDiv = theDiv;
	theDiv.style.border = "2px solid dimgray";
	theDiv.style.padding = "2px";
			
}

function HightlightDiv_file(theDiv,filename, filename_id, fullname, fullname_id) {
    
	if (LastImageDiv) {
		LastImageDiv.style.border = "none";		
		LastImageDiv.style.padding = "1px";
	}
	
	LastImageDiv = theDiv;
	theDiv.style.border = "2px solid whitesmoke";
	theDiv.style.padding = "2px";

	document.getElementById(filename_id).value = filename;
	document.getElementById(fullname_id).value = fullname;
	
	divSelected.style.display = "inline";
	document.getElementById('divNewFolder').style.display = "none";
	document.getElementById('divNewFile').style.display = "none";
	document.getElementById('divUpdateFolder').style.display = "none";
	document.getElementById('divEmpty').style.display = "none";
}

function HightlightDiv_img(theDiv,filename, filename_id, fullname, fullname_id) {
    
    if (LastImageDiv) {
		LastImageDiv.style.border = "1px solid silver";		
		LastImageDiv.style.padding = "1px";
	}
	
	LastImageDiv = theDiv;
	theDiv.style.border = "2px solid dimgray";
	theDiv.style.padding = "2px";
			
	document.getElementById(filename_id).value = filename;
	document.getElementById(fullname_id).value = fullname;
	
	divSelected.style.display = "inline";
	document.getElementById('divNewFolder').style.display = "none";
	document.getElementById('divNewFile').style.display = "none";
	document.getElementById('divUpdateFolder').style.display = "none";
	document.getElementById('divEmpty').style.display = "none";
}

function HightlightDiv_dir(theDiv,filename, filename_id, fullname, fullname_id) {
    
    if (LastImageDiv) {
		LastImageDiv.style.border = "NONE";		
		LastImageDiv.style.padding = "1px";
	}
	
	LastImageDiv = theDiv;
	theDiv.style.border = "1px solid gainsboro";
	theDiv.style.padding = "1px";

	document.getElementById(filename_id).value = filename;
	document.getElementById(fullname_id).value = fullname;
	
	divUpdateFolder.style.display = "inline";
	document.getElementById('divSelected').style.display = "none";
	document.getElementById('divNewFolder').style.display = "none";
	document.getElementById('divNewFile').style.display = "none";
	document.getElementById('divEmpty').style.display = "none";
}



function insertFile(path,filename,clientid){           
    var editor = window.opener.document.getElementById(clientid)
    
    window.opener.document.getElementById(clientid).contentWindow.document.body.focus();
    var sel = editor.document.selection.createRange();
    if (editor.document.selection.type == 'Control') {
        return;
    }
    sel.pasteHTML("<a href=\"" + path + filename + "\" target=_blank class=file title=\"Last ned\">"+ filename + "</a>");  
    
    editor.focus();
    window.close();
}

//FreeTextEditor
function insertImage(path,filename,clientid){           
    var editor = window.opener.document.getElementById(clientid)
    
    window.opener.document.getElementById(clientid).contentWindow.document.body.focus();
    var sel = editor.document.selection.createRange();
    if (editor.document.selection.type == 'Control') {
        return;
    }
    sel.pasteHTML("<img src=\"" + path + filename + "\" >");  
    
    editor.focus();
    window.close();
}

//Andre controls, f.eks label

function insertImage2(path,filename,clientid){         
    ingressbilde = window.opener.document.getElementById(clientImgid)               
    ingressbilde.src = path + filename ;
    
    ingressbilde.focus();
    window.close();
}

function insertImage2(path,filename,clientid,clientImgid){         
    ingressbilde = window.opener.document.getElementById(clientImgid)               
    ingressbilde.src = path + filename ;
    ingress = window.opener.document.getElementById(clientid)               
    ingress.value = path + filename ;
    
    ingressbilde.focus();
    window.close();
}

function getImageUrl(clientid,owner){
    owner.src =  document.getElementById(clientid).value;    
}

function insertLink(linktext,url,name,clientid){       
	if(url != "0")
		{    
		var editor = document.getElementById(clientid)
	    
		document.getElementById(clientid).contentWindow.document.body.focus();
		var sel = editor.document.selection.createRange();
		if (editor.document.selection.type == 'Control') {
			return;
		}
	    
		name = prompt(linktext,name);
	    
		if (name != null){
			sel.pasteHTML("<a href=\""+ url + "\" class=\"link\">" + name + "</a>");  
		    
			editor.focus();
	    
		}
	}
    
    
}




/*-------------------------------------------------------
* Åpner opp et popup vindu for å vise refleksjoner
*--------------------------------------------------------*/
function popUpFiles(id){
    document.getElementById(id).focus();
	//Setter størrelses variabler
	var width = 580;
	var height = 605;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height - 100);

	//Lager en URL til document.aspx siden
	URLStr = 'unsecure/files.aspx?client=' + id;

	//Sjekker om et vindu er oppe fra før av.
	if(popUpWin)
	{
		if(!popUpWin.closed)
			popUpWin.close();
	}
	
	popUpWin =  window.open(URLStr,'Filer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'');	
	popUpWin.focus();
}
function popUpImages(id){
    document.getElementById(id).focus();
	//Setter størrelses variabler
	var width = 580;
	var height = 605;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height - 100);

	//Lager en URL til document.aspx siden
	URLStr = 'unsecure/images.aspx?client=' + id;

	//Sjekker om et vindu er oppe fra før av.
	if(popUpWin)
	{
		if(!popUpWin.closed)
			popUpWin.close();
	}
	
	popUpWin =  window.open(URLStr,'Bilder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'');	
	popUpWin.focus();
}
//Opner image miodulen for insert til vanlig kontroll
function popUpImages2(id, imgid){
    document.getElementById(id).focus();
	//Setter størrelses variabler
	var width = 580;
	var height = 605;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height - 100);

	//Lager en URL til document.aspx siden
	URLStr = 'unsecure/images.aspx?client=' + id + '&free=false&clientImg=' + imgid;

	//Sjekker om et vindu er oppe fra før av.
	if(popUpWin)
	{
		if(!popUpWin.closed)
			popUpWin.close();
	}
	
	popUpWin =  window.open(URLStr,'Bilder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'');	
	popUpWin.focus();
}

//Enok, poper opp bildet inni i en forum melding, dvs fiskerapport
					
	var wnd;					
	function visForumBilde(N,w,h) { 
		var width = w + 20;
		var height = h + 50;
		//document.write('W: ' + width + ' H: ' + height);
			
			//midtstiller bildet
		var left = (screen.width / 2) - (width / 2);
		var top = ((screen.height / 2) - (height / 2))-50;
		wnd = window.open("image.htm?Image="+N,"BildePopup","location=no,menubar=no,status=no,scrollbars=no,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
		
	}				

