var strPageName

function relocateMe(strPageName) {
	self.location = strPageName;
}

function relocateMeWithConfirm(strPageName,strQuestion) {
	var x = window.confirm(strQuestion)
	
	if (x) 
		self.location = strPageName;
}

function myOpenWindow() {
    window.open('blank.asp','myWindowName','width=300,height=200');
}

function showpic(strUrl,intWindowWidth,intWindowHeight){
	var strOptions = 'toolbar=0,location=0,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + intWindowWidth + ',height=' + intWindowHeight;
	PicWin = window.open(strUrl,'Myndir',strOptions);
}
	
function closePopup() {
    window.close();
    return true;
}

function openSenda() {
window.open('http://www.nkf-chefs.com/norway/Tellafriend/tellafriend.asp?strURL=' + escape(document.URL),'Send','height=400,width=400,resizable=no,location=no,menubar=no,scrollbars=no,status=no,titlebar=yes');
}

window.onerror = null;

var winp=null;var win=null;
var isHTMLMode=false
var colour;

function cmdExec(cmd,opt)
	{
  	if (isHTMLMode){alert("xxx");return;}
	frmPublication.focus();
  	frmPublication.document.execCommand(cmd,"",opt);
	frmPublication.focus();
	}
function setMode(bMode)
	{
	var sTmp;
  	isHTMLMode = bMode;
  	if (isHTMLMode)
	{
		sTmp=frmPublication.innerHTML;
		frmPublication.innerText=sTmp;
	}
	else
	{
			sTmp=frmPublication.innerText;
			frmPublication.innerHTML=sTmp;
	}
  	frmPublication.focus();
	}

function foreColor()

       {

       var arr = showModalDialog("files/selcolor.htm","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em: status=no" );

       if (arr != null) cmdExec("ForeColor",arr);

       }
       
 function help()
 
        {
 
        var arr = showModalDialog("files/help.htm","","font-family:Verdana; font-size:12; dialogWidth:60em; dialogHeight:50em: status=no" );
 
        if (arr != null) cmdExec("help",arr);
 
        }
        
function files()
  
    	{
    window.open('http://www.nkf-chefs.com/norway/files/uploadTester.asp?strURL=' + escape(document.URL),'Send','height=550,width=450,resizable=no,location=no,menubar=no,scrollbars=no,status=no,titlebar=yes');
    	}
    	
   function viewfiles()
   
     	{
     window.open('http://www.nkf-chefs.com/norway/files/dirlisttile.asp?strURL=' + escape(document.URL),'Send','height=300,width=400,resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,titlebar=yes');
     	} 	
    	
    function deletefiles()
    
      	{
      window.open('http://www.nkf-chefs.com/norway/files/deletefiles.asp?strURL=' + escape(document.URL),'Send','height=300,width=400,resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,titlebar=yes');
      	} 	

  function insertSmileys()
   	{
	var cursor = editableStrPublMaintext.document.selection.createRange();
	var myTitle = "";
   	var myText  = showModalDialog("files/smiley_select.asp",
    	myTitle, "target is new Window: status=no");
	if (myText) { cursor.pasteHTML(unescape( myText) ); }
 
	}
	
function insertChar()
	{
	
	var cursor = editableStrPublMaintext.document.selection.createRange();
	var myText = showModalDialog("files/insert_char.html", '', "dialogWidth:500px; dialogHeight: 155px; resizable: no; help: no; status: no; scroll: no;");
	if (myText) { cursor.pasteHTML(unescape( myText) ); }
  }
                  
  function insertImage()
  
     
            {
            var arr = showModalDialog("files/insert_image.asp","","font-family:Verdana; font-size:12; dialogWidth:40em; dialogHeight:60em: status=no" );
     
            if (arr != null) cmdExec("insertImage",arr);
     
          }

  function about()
  
         {
  
         var arr = showModalDialog("files/about.htm","","font-family:Verdana; font-size:12; dialogWidth:35em; dialogHeight:22em; status=no" );
  
         if (arr != null) cmdExec("about",arr);
  
         }
         

function createlink() 

	{
	var cursor = editableStrPublMaintext.document.selection.createRange();
	var myTitle = "";
	var myText = showModalDialog("files/links.asp",
	myTitle, "target is new Window: status=no");
	if (myText) { cursor.pasteHTML(unescape( myText) ); }
	
 }
 
 function createlink2()    
       {
          	var theRange = editableStrPublMaintext.selection.createRange();
          	
          	var highlightedText = "";
      	var linkText = '';
          	
          	var href_attribute = '';
          	var tar_attribute = '';
          	
          	var elmSelectedImage;
          	var htmlSelectionControl = "Control";
          	if (editdoc.selection.type == htmlSelectionControl) {
          		// actully we have an image.
          		elmSelectedImage = theRange.item(0);
          		highlightedText = elmSelectedImage.outerHTML;
          		
          		//convert the ControlRange to a TextRange
          		theRange = editdoc.body.createTextRange();
      		theRange.moveToElementText(elmSelectedImage);
          		theRange.select();
          		
          		fullElement = theRange.htmlText;
          	} else {
          		if (theRange.text != '') {
          			highlightedText = theRange.htmlText;
          		}
          		fullElement = theRange.parentElement().outerHTML;
      	}
      	
      	//in case we happen to select the link itself!
      	if (highlightedText.search(/^\<[A|a]/) != -1) {
      		fullElement = highlightedText;
      	}
      	
      	//extrect attributes from HTML
      	if (fullElement.search(/^\<[A|a]/) != -1) {
      
      		fullElement = fullElement.replace(/\"/g, "");
      		fullElement = fullElement.replace(/\'/g, "");
      
      		// here, we have an <a> tag. Now let's extract... 
      		// 1. the href attribute
      		var href_value = fullElement.split(/href=/);
      		href_value2 = href_value[1].split(/\s|>/);
      		href_attribute = href_value2[0];
      
      		// 2. the target attribute
      		if (fullElement.search(/target=/) != -1) {
      			var tar = fullElement.split(/target=/);
      			tar2 = tar[1].split(/\s|>/);
      			tar_attribute = tar2[0];
      		}
      
      		// 3. the link text (more robust as includes all html code aswell)
      		pos1 = fullElement.indexOf(">");
      		pos2 = fullElement.lastIndexOf("<");
      		linkText = fullElement.substring(pos1+1,pos2);
      	}
          	
          	var myValues = new Object();
          	myValues.highlightedText = highlightedText;
          	myValues.tar_attribute = tar_attribute;
          	myValues.href_attribute = href_attribute;
          	myValues.linkText = linkText;
          
          	var myText = showModalDialog("files/insert_file.html", myValues, "status=no; scroll=no");
          
          	if (linkText != '') { 
          		if (myText) { 
          			theRange.parentElement().outerHTML = '';
          			insertHTML(objname, unescape( myText) );
          		}
          	} else {
          		if (myText) { 
          			//if (editdoc.selection.type == htmlSelectionControl) {
          			//	theRange.execCommand('Delete');
          			//}
          			insertHTML(objname, unescape(myText) ); // this function ALWAYS puts in an absolute link 
          		} 
          	}
          
          }
		
function tableDialog()
{
   //----- Creates A Table Dialog And Passes Values To createTable() -----
   var rtNumRows = null;
   var rtNumCols = null;
   var rtTblAlign = null;
   var rtTblWidth = null;
   showModalDialog("files/table.htm",window,"status:false;dialogWidth:20em;dialogHeight:18em");
}

function createTable()
{
   //----- Creates User Defined Tables -----
   var cursor = editableStrPublMaintext.document.selection.createRange();
   if (rtNumRows == "" || rtNumRows == "0")
   {
      rtNumRows = "1";
   }
   if (rtNumCols == "" || rtNumCols == "0")
   {
      rtNumCols = "1";
   }
   var rttrnum=1
   var rttdnum=1
   var rtNewTable = "<table border='1' align='" + rtTblAlign + "' cellpadding='0' cellspacing='0' width='" + rtTblWidth + "'>"
   while (rttrnum <= rtNumRows)
   {
      rttrnum=rttrnum+1
      rtNewTable = rtNewTable + "<tr>"
      while (rttdnum <= rtNumCols)
      {
         rtNewTable = rtNewTable + "<td>&nbsp;</td>"
         rttdnum=rttdnum+1
      }
      rttdnum=1
      rtNewTable = rtNewTable + "</tr>"
   }
   rtNewTable = rtNewTable + "</table>"
   editableStrPublMaintext.focus();
   cursor.pasteHTML(rtNewTable);
}

