var format="HTML";
var stat=1;
var bdcolor="white";  // for html mode
var txtcolor="black"; // for html mode
var html_object;
var chobj=new Array();
var obj_name=new Array();
var obj_parent_count=new Array();
var obj_parameters=new Array();
var pre='';
var sel=0;
var parents=new Array();
var TopMenuArr=new Array();
var ContextMenuArr=new Array();
var TagsArray=new Array();
var prevSelectedTD=0;
var prevSelectedTABLE=0;
var prevCheckedTD=0;
var prevCheckedTR=0;
var prevCheckedTABLE=0;
var openMenusID=new Array();
var openMenusName=new Array();
var lastOpenedMenu=false;
var element=false;
var fields = [];
var compactMode=false;
var external=false;
var unique_id='';
var mail_id='';
var rich_id='';
var datePop=window.createPopup();
var selDate;

var global = window.document;
global.fo_shadows = new Array;
var MENU_SHADOW_COLOR = '#666666';
var MENU_SHADOW_SIZE = 5;
var defaultTopMenu='';
var menuTABLE='';
var menuTD='';
var activeElementID;
var activeElementBorder;
if(!compactMode){
  defaultTopMenu+='<img src="../img/none.gif" class="delimiter">';
}
if(!mail_id){
  defaultTopMenu+='<INPUT alt="Save" TYPE="image" src="../img/save.gif" border="0" height=20 width=20 ONCLICK="saveData();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  defaultTopMenu+='<INPUT alt="Properties" TYPE="image" src="../img/properties.gif" border="0" height=20 width=20 ONCLICK="parent.getProperties(\'../admin/doc_options.php?id=26814&compact_mode=&external=&unique_id=\',\'Kontaktai properties\',0);" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
}else{
  defaultTopMenu+='<INPUT alt="Send" TYPE="image" src="../img/send.gif" border="0" height=20 width=20 ONCLICK="saveData(\'mail\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
}
defaultTopMenu+='<INPUT alt="Reload" TYPE="image" src="../img/reload.gif" border="0" height=20 width=20 ONCLICK="parent.window.open(parent.window.location,\'frmain\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
defaultTopMenu+='<img src="../img/none.gif" class="delimiter">';

menuTABLE+='<span disabled style="background-color:buttonface;border:none;height:20px;width:35px">Table</span>';
menuTABLE+='<INPUT alt="Properties" TYPE="image" src="images/table/prop.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.table_properties();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTABLE+='<INPUT alt="Delete" TYPE="image" src="images/table/del.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.table_delete();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTABLE+='<INPUT alt="Duplicate" TYPE="image" src="images/table/dup.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.table_duplicate();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';

menuTD+='<img src="../img/none.gif" class="delimiter">';
menuTD+='<span disabled style="background-color:buttonface;border:none;height:20px;width:30px">Row</span>';
menuTD+='<INPUT alt="Properties" TYPE="image" src="images/table/prop.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_properties();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Insert" TYPE="image" src="images/table/row_prev.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_insert();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Append" TYPE="image" src="images/table/row_aft.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_append();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Move up" TYPE="image" src="images/table/up.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_move_up();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Move down" TYPE="image" src="images/table/down.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_move_down();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Delete" TYPE="image" src="images/table/del.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.tr_delete();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';

menuTD+='<img src="../img/none.gif" class="delimiter">';
menuTD+='<span disabled style="background-color:buttonface;border:none;height:20px;width:50px">Column</span>';
menuTD+='<INPUT alt="Insert" TYPE="image" src="images/table/col_prev.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.col_insert();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Append" TYPE="image" src="images/table/col_aft.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.col_append();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Move left" TYPE="image" src="images/table/left.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.col_move_left();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Move right" TYPE="image" src="images/table/right.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.col_move_right();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
menuTD+='<INPUT alt="Delete" TYPE="image" src="images/table/del.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.col_delete();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';

menuTD+='<img src="../img/none.gif" class="delimiter">';
menuTD+='<span disabled style="background-color:buttonface;border:none;height:20px;width:35px">Cells</span>';
menuTD+='<INPUT alt="Properties" TYPE="image" src="images/table/prop.gif" border="0" height=20 width=20 ONCLICK="parent.myEditor.td_properties();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';

createTopMenu();
createContextMenu();
createTagsArray();

if (window.navigator.appName=='Netscape' | (window.navigator.appName=='Microsoft Internet Explorer' && window.navigator.appVersion.substring(0,window.navigator.appVersion.indexOf(".")))<4) {
  alert('You need at least IE4 !');
  parent.window.location='http://www.microsoft.com/ie/';
}

function getDialogOpen(type,inp,url,title, w, h, namefr){
    var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?btm="+namefr+"&frame="+url+"&title="+title,window,"dialogWidth:"+w+"px; dialogHeight:"+h+"px; status:off; scroll:no;help:off;dialogTop:20px;");
}

function alxSetCookie(sName, sValue){
  document.cookie = sName + "=" + escape(sValue) + "; expires=Mon, 31 Dec 2001 23:59:59 UTC;";
}

function alxGetCookie(sName){
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++){
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]){
      return unescape(aCrumb[1]);
    }
  }
  return null;
}

function doFormat(what) {
  var tr = parent.myEditor.document.selection.createRange()
    tr.execCommand(what, arguments[1],arguments[2])
    tr.select()
    parent.myEditor.focus()
    tr.select();
  if(what=='Undo' || what=='Redo'){
    parent.myEditor.document.execCommand(what);
  }
}

function swapModes(st){
 if(parent.myEditor.format=="HTML" && st==2){
   bdcolor=parent.myEditor.document.body.style.backgroundColor;
   txtcolor=parent.myEditor.document.body.style.color;
   //parent.myEditor.document.body.style.backgroundColor="white";
   parent.myEditor.document.body.style.color="black";
   parent.myEditor.showSpansHTML();
   stat=2;
   parent.myEditor.highlightEditable();
 }
 if(parent.myEditor.format=="Text" && st==1){
   parent.myEditor.document.body.style.backgroundColor=bdcolor;
   parent.myEditor.document.body.style.color=txtcolor;
   parent.myEditor.showSpansText();
   stat=1;
   parent.myEditor.highlightEditable();
 }
 if(parent.myEditor.format=="HTML" && st==3){
   parent.myEditor.document.body.style.backgroundColor=bdcolor;
   parent.myEditor.document.body.style.color=txtcolor;
   stat=3;
   parent.myEditor.unhighlightEditable();
 }
 if(parent.myEditor.format=="Text" && st==3){
   parent.myEditor.document.body.style.backgroundColor=bdcolor;
   parent.myEditor.document.body.style.color=txtcolor;
   parent.myEditor.showSpansText();
   stat=3;
   parent.myEditor.unhighlightEditable();
 }
 if(parent.myEditor.format=="HTML" && st==1 && stat==3){
   parent.myEditor.document.body.style.backgroundColor=bdcolor;
   parent.myEditor.document.body.style.color=txtcolor;
   stat=1;
   parent.myEditor.highlightEditable();
 }
 hideChecked();
 parent.myEditor.focus()
 var s = parent.myEditor.document.body.createTextRange()
 s.collapse(false)
 s.select()
 parent.myEditor.document.body.children(0).focus();
}

function convHTML(){
  parent.myEditor.document.all["content"].innerText = parent.myEditor.document.all["content"].innerHTML;
  parent.myEditor.document.all["content"].style.fontFamily = "monospace";
  parent.myEditor.document.all["content"].style.fontSize = "10pt";
  format="Text";
}

function convText(){
   parent.myEditor.document.all["content"].innerHTML = parent.myEditor.document.all["content"].innerText;
   parent.myEditor.document.all["content"].style.fontFamily = "";
   parent.myEditor.document.all["content"].style.fontSize ="";
   format="HTML";
}

function InsertTable() {
  var tr = parent.myEditor.document.selection.createRange()
  var arr = null;
  var args = new Array();
  arr = null;
  arr = showModalDialog("http://www.airbaltic.com/editor/table.htm",args,"dialogWidth:310px; dialogHeight:155px; status:off; scroll:no;help:no");
  if (arr != null) {
    val="<table name=myTable ";
    if (arr["TableBord"]!=''){
      val=val+" border="+arr["TableBord"];
    }
    if (arr["TableSpac"]!=''){
      val=val+" cellspacing="+arr["TableSpac"];
    }
    if (arr["TablePadd"]!=''){
      val=val+" cellpadding="+arr["TablePadd"];
    }
    if (arr["TableAlign"]!=''){
      val=val+" align="+arr["TableAlign"];
    }
    val=val+">";
    if (arr != null){
     for (i=0; i<arr["NumRows"]; i++){
       val=val+"<tr>";
       for (j=0; j<arr["NumCols"];j++){
         val=val+"<td></td>";
       }
       val=val+"</tr>";
     }
    val=val+"</table>";
    tr.pasteHTML(val);
    }
  }
}

function setColor(what){
  var arr = showModalDialog("http://www.airbaltic.com/editor/color.php","","dialogWidth:310px; dialogHeight:265px; status:off; scroll:no");
  if (arr != null) {
    doFormat(what,true,arr);
  }
}

function backgroundColor(){
  var arr = showModalDialog("http://www.airbaltic.com/editor/color.php","","dialogWidth:310px; dialogHeight:265px; status:off; scroll:no");
  if (arr != null) {
    parent.myEditor.document.body.style.backgroundColor=arr;
    bdcolor=arr;
    window.parent.frames[2].bdcolor=arr;
    window.parent.frames[2].document.all["st1"].style.backgroundColor='menu';
    window.parent.frames[2].document.all["st2"].style.backgroundColor='menu';
    window.parent.frames[2].document.all["st3"].style.backgroundColor='menu';
    evl_string='window.parent.frames[2].document.all["st'+stat+'"].style.backgroundColor="'+arr+'";';
    eval(evl_string);
  }
}

function show_tree(){
  ww=window.open();
  ww.document.write('<font size="2">');
  for(i=0;i<parent.myEditor.document.all.length;i++){
    obj=parent.myEditor.document.all[i];
    obj_name[obj.sourceIndex]=obj.tagName;
    obj_parent_count[obj.sourceIndex]=0;
    parent_count(obj.sourceIndex,obj.sourceIndex);
    pre='';
    if(obj_parent_count[obj.sourceIndex]){
      for(k=1;k<obj_parent_count[obj.sourceIndex];k++){
        pre+='&nbsp;&nbsp;';
      }
    }
    check_params(obj);
    ww.document.write(pre+'<b>'+obj_name[obj.sourceIndex]+'</b> ('+obj.sourceIndex+')');
    ww.document.write(obj_parameters[obj.sourceIndex]);
    ww.document.write('<br>');
  }
//show_styles();
}

function parent_count(num,par){
  obj1=parent.myEditor.document.all.item(par);
  if(obj1.parentNode){
    obj_parent_count[num]++;
    parent_count(num,obj1.parentNode.sourceIndex);
  }
}

function prompt_url(){
  url=prompt('Location : ')
  if(url){
    ww=window.open(url);
    parent.myEditor.document.body.innerHTML=ww.document.body.innerHTML;
    ww.close();
  }
}

function show_styles(){
  for(i=0; i<parent.myEditor.document.styleSheets.length;i++){
    alert("Style sheet " + i + " is titled " + parent.myEditor.document.styleSheets(i).title);
  }
}

function get_color(what){
  var arr = showModalDialog("http://www.airbaltic.com/editor/color.php","","dialogWidth:310px; dialogHeight:265px; status:off; scroll:no;help:off;");
  if (arr != null) {
    evl_str='document.forms[0].'+what+'.style.backgroundColor="'+arr+'";';
    eval(evl_str);
    evl_str='hid=document.forms[0].'+what+'_hidden;'
    eval(evl_str);
    if(hid){
      evl_str='document.forms[0].'+what+'_hidden.value="'+arr+'";';
      eval(evl_str);
    }
  }
}

function get_picture(what,id){
  if(id){
    var arr = showModalDialog("http://www.airbaltic.com/editor/pic_frames.php?id="+id,"","dialogWidth:35em; dialogHeight:35em; status:off; scroll:no;help:off");
    if (arr != null) {
      if(arr['file']){
        evl_str='document.forms[0].'+what+'.value="'+arr['file']+'";';
        eval(evl_str);
      }else{
        evl_str='document.forms[0].'+what+'.value="";';
        eval(evl_str);
      }
    }
  }
}

function IsDigit(){
  return ((event.keyCode >= 48) && (event.keyCode <= 57))
}

function context_menu(){
try{
  obj=event.srcElement;
  otxt='<table border="0" cellpadding="0" cellspacing="0" class="root" id="root" width="100%">';
  itxt='';
  tn='';
  tname='';
  tbl_cnt=1;
  cl_cnt=1;
  rw_cnt=1;
  in_cnt=0;
  spn_cnt=1;
  simple_html_cnt=0;
  ocnt=0;
  ro=0;
  tr_menu='';
  oth_menu='';
  var addMenu=new Array();
  var addMenuIntro=new Array();
  var addMenuCnt=0;
  parents[obj.sourceIndex]='';
  get_parents(obj.sourceIndex,obj.sourceIndex);
  par_arr=parents[obj.sourceIndex].split("\n");
  for(r=0;r<par_arr.length;r++){
    ri=par_arr[r];
    evl_str='tn=parent.myEditor.document.all.item('+ri+').tagName;';
    eval(evl_str);
    evl_str='tname=parent.myEditor.document.all.item('+ri+').name;';
    eval(evl_str);
    evl_str='tedit=parent.myEditor.document.all.item('+ri+').edit;';
    eval(evl_str);
    evl_str='object_id=parent.myEditor.document.all.item('+ri+').object_id;';
    eval(evl_str);
    evl_str='ro=parent.myEditor.document.all.item('+ri+');';
    eval(evl_str);
    if(tn=='TD'||tn=='TH'||tn=='TR'||tn=='TABLE'||tn=='IMG'||tn=='P'||tn=='A'||tn=='BODY'||tn=='SPAN'||tn=='BDO'){
      if(tn=='TABLE'&&tbl_cnt<2 && ro.name=='myTable'){
        otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.table_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Table '+(tbl_cnt>1?tbl_cnt:'')+' properties...</td><td></td></tr>';
        tbl_cnt++;
        ocnt++;
        simple_html_cnt++;
      }
      if(tn=='TR'&&rw_cnt<2){
        if(ro.parentNode.name=='myTable' || ro.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.name=='myTable'){
          otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Row '+(rw_cnt>1?rw_cnt:'')+' properties...</td><td></td></tr>';
          rw_cnt++;
          ocnt++;
          simple_html_cnt++;
        }
      }
      if(tn=='TR' && !in_cnt && in_cnt<2){
        if(ro.parentNode.name=='myTable' || ro.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.name=='myTable'){
          evl_str='rindex=parent.myEditor.document.all.item('+ri+').rowIndex;';
          eval(evl_str);
          evl_str='pnode=parent.myEditor.document.all.item('+ri+').parentNode.sourceIndex;';
          eval(evl_str);
          addMenu[addMenuCnt]='<table border="0" cellpadding="0" cellspacing="0" class="root" id="addMenu'+addMenuCnt+'" style="position:absolute;float:right;visibility:hidden">';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_insert('+rindex+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/insert.gif" border="0"></td><td nowrap class="textplace">Insert</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlght" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_append('+rindex+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/append.gif" border="0"></td><td nowrap class="textplace">Append</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_move_up('+rindex+','+pnode+');"><td class="iconplace"><font face="Webdings" size="3pt">5</font></td><td nowrap class="textplace">Move up</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_move_down('+rindex+','+pnode+');"><td class="iconplace"><font face="Webdings" size="3pt">6</font></td><td nowrap class="textplace">Move down</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.tr_delete('+rindex+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/delete.gif" border="0"></td><td nowrap class="textplace">Delete</td><td></td></tr>';
          addMenu[addMenuCnt]+='</table>';
          addMenuIntro[addMenuCnt]='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.show_menu(\'addMenu'+addMenuCnt+'\',co.document.all(\'addMenu'+addMenuCnt+'\').sourceIndex,window);" onmouseout="this.className=\'nohighlight\'"><td class="iconplace">&nbsp;</td><td class="more" nowrap class="textplace">Row...</td><td style="font: 12pt Marlett;height: 8pt;">4</td></tr>';
          addMenuCnt++;
          rw_cnt++;
          ocnt++;
          in_cnt++;
          simple_html_cnt++;
        }
      }
      if((tn=='TD'||tn=='TH')&&cl_cnt<2){
        if(ro.parentNode.name=='myTable' || ro.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.parentNode.name=='myTable'){
          evl_str='pnode1=parent.myEditor.document.all.item('+ri+').parentNode.sourceIndex;';
          eval(evl_str);
          evl_str='pnode2=parent.myEditor.document.all.item('+pnode1+').parentNode.sourceIndex;';
          eval(evl_str);
          if(parent.myEditor.document.all.item(pnode2).tagName=='TBODY'){
            evl_str='pnode=parent.myEditor.document.all.item('+pnode2+').parentNode.sourceIndex;';
            eval(evl_str);
          }else{
            pnode=pnode2;
          }
          addMenu[addMenuCnt]='<table border="0" cellpadding="0" cellspacing="0" class="root" id="addMenu'+addMenuCnt+'" style="position:absolute;float:right;visibility:hidden">';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.col_insert('+ri+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/col_insert.gif" border="0"></td><td nowrap class="textplace">Insert</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlght" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.col_append('+ri+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/col_append.gif" border="0"></td><td nowrap class="textplace">Append</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.col_move_left('+ri+','+pnode+');"><td class="iconplace"><font face="Webdings" size="3pt">3</font></td><td nowrap class="textplace">Move left</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.col_move_right('+ri+','+pnode+');"><td class="iconplace"><font face="Webdings" size="3pt">4</font></td><td nowrap class="textplace">Move right</td><td></td></tr>';
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.col_delete('+ri+','+pnode+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/delete.gif" border="0"></td><td nowrap class="textplace">Delete</td><td></td></tr>';
          addMenu[addMenuCnt]+='</table>';
          addMenuIntro[addMenuCnt]='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.show_menu(\'addMenu'+addMenuCnt+'\',co.document.all(\'addMenu'+addMenuCnt+'\').sourceIndex,window);" onmouseout="this.className=\'nohighlight\'"><td class="iconplace">&nbsp;</td><td class="more" nowrap class="textplace">Column...</td><td style="font: 12pt Marlett;height: 8pt;">4</td></tr>';
          addMenuCnt++;
        }
      }
      if((tn=='TD'||tn=='TH')&&cl_cnt<2){
        if(ro.parentNode.name=='myTable' || ro.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.name=='myTable' || ro.parentNode.parentNode.parentNode.parentNode.name=='myTable'){
          otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.td_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Cell '+(cl_cnt>1?cl_cnt:'')+' properties...</td><td></td></tr>';
          cl_cnt++;
          ocnt++;
          simple_html_cnt++;
        }
      }
      if(tn=='IMG'){
        otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.img_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Picture properties...</td><td></td></tr>';
        ocnt++;
        simple_html_cnt++;
      }
      if(tn=='BODY'){
      //  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.body_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Page properties...</td><td></td></tr>';
      //  ocnt++;
      //  simple_html_cnt++;
      }
      if(tn=='P'){
        otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.p_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Paragraph...</td><td></td></tr>';
        ocnt++;
        simple_html_cnt++;
      }
      if(tn=='A'){
        otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.a_properties('+ri+');"><td class="iconplace">&nbsp;</td><td nowrap class="textplace">Hyperlink properties...</td><td></td></tr>';
        ocnt++;
        simple_html_cnt++;
      }
      if(tn=='SPAN'&&ro.name&&spn_cnt<2){
        if(parent.parent.selectedModule && tedit=='moduls'){
          otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.getModule('+ri+');"><td class="iconplace"></td><td nowrap class="textplace">Paste Module</td><td></td></tr>';
          spn_cnt++;
        }
        addMenu[addMenuCnt]='<table border="0" cellpadding="0" cellspacing="0" class="root" id="addMenu'+addMenuCnt+'" style="position:absolute;float:right;visibility:hidden">';
        addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.span_properties('+object_id+','+ro.doc_id+',\''+escape('"'+ro.name+'"')+'\');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/properties.gif" border="0"></td><td nowrap class="textplace">Properties...</td><td></td></tr>';
        if(ro.moveable){
          if(span_canMoveUp(ri)){
            addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.span_moveUp('+ri+');"><td class="iconplace"><font face="Webdings" size="3pt">5</font></td><td nowrap class="textplace">Move up</td><td></td></tr>';
          }
          if(span_canMoveDown(ri)){
            addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.span_moveDown('+ri+');"><td class="iconplace"><font face="Webdings" size="3pt">6</font></td><td nowrap class="textplace">Move down</td><td></td></tr>';
          }
        }
        if(ro.deletable){
          addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.span_delete('+ri+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/delete.gif" border="0"></td><td nowrap class="textplace">Delete</td><td></td></tr>';
        }
        addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.show_properties('+ri+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/properties.gif" border="0"></td><td nowrap class="textplace">Show additional properties...</td><td></td></tr>';

        addMenu[addMenuCnt]+='</table>';
        addMenuIntro[addMenuCnt]='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.show_menu(\'addMenu'+addMenuCnt+'\',co.document.all(\'addMenu'+addMenuCnt+'\').sourceIndex,window);" onmouseout="this.className=\'nohighlight\'"><td class="iconplace">&nbsp;</td><td class="more" nowrap class="textplace">"'+ro.name+'" ...</td><td style="font: 12pt Marlett;height: 8pt;">4</td></tr>';
        addMenuCnt++;
        ocnt++;
      }
      if(tn=='BDO'&&ro.className=='insertedBDO'&&ro.real_id.search('@')==-1 && ro.id){
        addMenu[addMenuCnt]='<table border="0" cellpadding="0" cellspacing="0" class="root" id="addMenu'+addMenuCnt+'" style="position:absolute;float:right;visibility:hidden">';
        addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.hidemenu();co.parent.myEditor.parent.parent.frames[0].getProperties(\''+ro.url_properties+'?id='+ro.real_id+'\',\''+escape('"'+ro.name+'"')+' properties\');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/properties.gif" border="0"></td><td nowrap class="textplace">Properties...</td><td></td></tr>';
        addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.span_delete('+ri+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/delete.gif" border="0"></td><td nowrap class="textplace">Delete</td><td></td></tr>';
        addMenu[addMenuCnt]+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.show_properties('+ri+');"><td class="iconplace"><img src="http://www.airbaltic.com/editor/images/table/properties.gif" border="0"></td><td nowrap class="textplace">Show additional properties...</td><td></td></tr>';
        addMenu[addMenuCnt]+='</table>';
        addMenuIntro[addMenuCnt]='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.show_menu(\'addMenu'+addMenuCnt+'\',co.document.all(\'addMenu'+addMenuCnt+'\').sourceIndex,window);" onmouseout="this.className=\'nohighlight\'"><td class="iconplace"></td><td class="more" nowrap class="textplace">"'+ro.name+'" ...</td><td style="font: 12pt Marlett;height: 8pt;">4</td></tr>';
        addMenuCnt++;
        ocnt++;
      }
      if(tn=='LI'||tn=='OL'||tn=='UL'||tn=='MARQUEE'||tn=='HR'||tn=='DL'||tn=='DD'||tn=='DIR'||tn=='MENU'||tn=='H1'||tn=='H2'||tn=='H3'||tn=='H4'){
        otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.show_html('+ri+');"><td class="iconplace"></td><td nowrap class="textplace">'+tn+' source</td><td></td></tr>';
        ocnt++;
        simple_html_cnt++;
      }
    }
  }
  if(itxt){
    otxt+='<TR><TD colspan="3" id="break"><img src="../img/none.gif" class="delimiter"></TD></TR>';
    otxt+=itxt;
  }

  if(addMenuCnt){
    if(simple_html_cnt){
      otxt+='<TR><TD colspan="3" id="break"><img src="../img/none.gif" class="delimiter"></TD></TR>';
    }
    for(i=0;i<addMenu.length;i++){
      otxt+=addMenuIntro[i];
    }
    otxt+='<TR><TD colspan="3" id="break"><img src="../img/none.gif" class="delimiter"></TD></TR>';
  }

  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.zoomIn();"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/zoomplus.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Zoom in</td><td></td></tr>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.zoomOut();"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/zoomminus.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Zoom out</td><td></td></tr>';

  otxt+='<TR><TD colspan="3" id="break"><img src="../img/none.gif" class="delimiter"></TD></TR>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.doFormat(\'Cut\');"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/cut.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Cut</td><td></td></tr>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.doFormat(\'Copy\');"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/copy.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Copy</td><td></td></tr>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.doFormat(\'Paste\');"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/paste.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Paste</td><td></td></tr>';
  otxt+='<TR><TD colspan="3" id="break"><img src="../img/none.gif" class="delimiter"></TD></TR>';

  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.buildHTMLTree();"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/htmltree.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Visual HTML tree (slowly)</td><td></td></tr>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.view_source();"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/viewsource.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">View source</td><td></td></tr>';
  otxt+='<tr class="nohighlight" onmouseover="this.className=\'highlight\';co.parent.myEditor.lastOpenedMenu=\'\';co.parent.myEditor.hide_menu(\'all\');" onmouseout="this.className=\'nohighlight\'" onclick="co.parent.myEditor.parent.window.location.reload();"><td style="padding-left:3px" class="iconplace"><img src="http://www.airbaltic.com/editor/images/reload.gif" border="0" width="16" height="15"></td><td nowrap class="textplace">Refresh</td><td></td></tr>';
  otxt+='</table>';

  if(document.all('c_menu')){
    c_menu.innerHTML=otxt;
    if(addMenuCnt){
      for(i=0;i<addMenu.length;i++){
        c_menu.innerHTML+=addMenu[i];
      }
    }
    gomenu();
  }
  return false;
}
catch(e){
  alert('context_menu'+e);
}
}

function get_parents(num,par){
  obj2=parent.myEditor.document.all.item(par);
  if(obj2.parentNode){
    parents[num]+=obj2.sourceIndex+"\n";
    if(obj2.parentNode.sourceIndex){
      get_parents(num,obj2.parentNode.sourceIndex);
    }
  }
}

function gomenu(){
  hidemenu();
  if (c_menu!=null){
    if(document.body.style.zoom){
      zoom=document.body.style.zoom;
    }else{
      zoom=1;
    }
    if(document.body.scrollLeft+event.clientX+root.clientWidth>document.body.clientWidth){
      c_menu.style.left=(document.body.scrollLeft+event.clientX-root.clientWidth)*(1/zoom);
    }else{
      c_menu.style.left=(document.body.scrollLeft+event.clientX)*(1/zoom);
    }
    if(document.body.scrollTop+event.clientY+root.clientHeight>document.body.clientHeight){
      if(document.body.scrollTop +event.clientY-root.clientHeight>=1){
        c_menu.style.top=(document.body.scrollTop +event.clientY-root.clientHeight)*(1/zoom);
      }else{
        c_menu.style.top=0;
      }
    }else{
      c_menu.style.top=(document.body.scrollTop +event.clientY)*(1/zoom);
    }

    menuLeft=event.screenX;
    menuTop=event.screenY;
    menuWidth=root.offsetWidth;
    menuHeight=root.offsetHeight;
    if(menuLeft+menuWidth>screen.availWidth){
      menuLeft=menuLeft-menuWidth;
    }
    if(menuTop+menuHeight>screen.availHeight){
      menuTop=menuTop-menuHeight;
    }
    if(!inArray('c_menu')){
      openMenusID[openMenusID.length]=showModelessDialog("http://www.airbaltic.com/editor/options.php?what=c_menu",window,"dialogLeft:"+menuLeft+";dialogTop:"+menuTop+";dialogWidth:"+menuWidth+"px;dialogHeight:"+menuHeight+"px;status:off;scroll:off;help:off;unadorned:yes;center:off");
      openMenusName[openMenusName.length]='c_menu';
      lastOpenedMenu=openMenusID[openMenusID.length-1];
    }
    //c_menu.style.visibility="visible";
  }
}

function inArray(name){
  for(i=0;i<openMenusName.length;i++){
    if(openMenusName[i]==name){
      return true;
    }
  }
}

function show_menu(mn_name,mn_id,obj){
try{
  hide_menu(mn_name);
  if(obj.event.srcElement.parentNode.tagName=='TR'){
    menuLeft=obj.event.srcElement.parentNode.offsetWidth+parseInt(obj.dialogLeft);
    menuTop=obj.event.srcElement.parentNode.offsetTop+parseInt(obj.dialogTop);
    menuWidth=document.all(mn_name).offsetWidth;
    menuHeight=document.all(mn_name).offsetHeight;
    if(menuLeft+menuWidth>screen.availWidth){
      menuLeft=menuLeft-menuWidth-obj.event.srcElement.parentNode.offsetWidth+4;
    }
    if(menuTop+menuHeight>screen.availHeight){
      menuTop=menuTop-menuHeight-obj.event.srcElement.parentNode.offsetTop;
    }
    if(!inArray(mn_name)){
      openMenusID[openMenusID.length]=showModelessDialog("http://www.airbaltic.com/editor/options.php?what="+mn_name,window,"dialogLeft:"+menuLeft+";dialogTop:"+menuTop+";dialogWidth:"+menuWidth+"px;dialogHeight:"+menuHeight+"px;status:off;scroll:off;help:off;unadorned:yes;center:off");
      openMenusName[openMenusName.length]=mn_name;
      lastOpenedMenu=openMenusID[openMenusID.length-1];
    }
  }
  hide_menu(mn_name);
}
catch(e){
  alert('show_menu:'+e);
}
}

function hide_menu(mn_name){
try{
  for(i=0;i<openMenusID.length;i++){
    if(openMenusName[i]!='c_menu' && openMenusID[i]!=lastOpenedMenu){
      openMenusID[i].close();
      openMenusName[i]='';
    }
  }
}
catch(e){
  alert('hide_menu:'+e);
}
}

function hidemenu(){
try{
  if (document.all('c_menu')){
    if(c_menu.style){
      c_menu.style.visibility="hidden";
      c_menu.style.left=-500;
      c_menu.style.top=-500;
    }
  }

  for(i=0;i<openMenusID.length;i++){
    openMenusID[i].close();
    openMenusName[i]='';
  }

  fr=parent.frames;
  if(fr){
    frp=fr.parent.frames;
    if(frp.length>0){
      frp.item(0).hidemenu2();
    }
  }
}
catch(e){
//  alert('hidemenu:'+e);
}
}

function table_properties(tbl){
  hidemenu();
  if(!tbl){
    tbl=prevCheckedTABLE;
  }
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/tbl.htm?id='+tbl+'",window,"dialogWidth:350px; dialogHeight:260px;status:off;scroll:off;help:off");',100);
}

function table_delete(tbl){
  hidemenu();
  if(!tbl){
    tbl=prevCheckedTABLE;
  }
  if(confirm('Are you sure?')){
    evl_str='co=parent.myEditor.document.all.item('+tbl+').outerHTML="";';
    eval(evl_str);
    prevCheckedTABLE=0;
    prevCheckedTR=0;
    prevCheckedTD=0;
    hideMenuTABLE();
    hideMenuTD();
  }
}

function table_duplicate(tbl){
  hidemenu();
  if(!tbl){
    tbl=prevCheckedTABLE;
  }
  evl_str='co=parent.myEditor.document.all.item('+tbl+').outerHTML+="<br>"+parent.myEditor.document.all.item('+tbl+').outerHTML;';
  eval(evl_str);
}

function img_properties(img){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+img+');';
  eval(evl_str);
  evl_str='cp=parent.myEditor.document.all.item('+(parseInt(img)-1)+');';
  eval(evl_str);
  if(cp.tagName=='BDO' && cp.id){
    hidemenu();
    str=cp.id;
    str=str.replace('{','');
    str=str.replace('}','');
    setTimeout('parent.parent.frames[0].getProperties("../graphic/properties.php?id='+str+'&popup=true","Graphic properties");',100);
  }else{
    setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/img.htm?id='+img+'",window,"dialogWidth:350px; dialogHeight:240px;status:off;scroll:off;help:off;");',100);
  }
}

function tr_properties(tbl){
hidemenu();
  if(!tbl){
    tbl=prevCheckedTR;
  }
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/tr.htm?id='+tbl+'",window,"dialogWidth:350px; dialogHeight:200px;status:off;scroll:off;help:off;");',100);
}

function td_properties(tbl){
  hidemenu();
  if(!tbl){
    tbl=prevCheckedTD;
  }
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/td.htm?id='+tbl+'",window,"dialogWidth:350px; dialogHeight:260px;status:off;scroll:off;help:off;");',100);
}

function body_properties(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  var arr = showModalDialog("http://www.airbaltic.com/editor/body.htm?id="+tbl,window,"dialogWidth:350px; dialogHeight:240px;status:off;scroll:off;help:off;");
}

function p_properties(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/p.htm?id='+tbl+'",window,"dialogWidth:350px; dialogHeight:180px;status:off;scroll:off;help:off;");',100);
}

function a_properties(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  setTimeout('var arr = showModalDialog("http://www.airbaltic.com/editor/a.htm?id='+tbl+'",window,"dialogWidth:350px; dialogHeight:115px;status:off;scroll:off;help:off;");',100);
}

function span_properties(tbl,doc_id,title){
  try{
    parent.getProperties('module_options.php?id='+tbl+'&compact_mode=&external=&unique_id=',title+' properties',doc_id);
  }
    catch(e){
  }
}

function span_delete(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  if(confirm('Are you sure?')){
    co.outerHTML='';
  }
}

function span_canMoveUp(tbl){
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  p=co.parentNode.childNodes;
  if(p.item(0).sourceIndex!=tbl){
    return true;
  }
}

function span_moveUp(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  p=co.parentNode.childNodes;
  for(i=0;i<p.length;i++){
    if(p.item(i).sourceIndex==tbl){
      tmp_val=p.item(i-1).outerHTML;
      p.item(i-1).outerHTML=p.item(i).outerHTML;
      p.item(i).outerHTML=tmp_val;
    }
  }
}

function span_canMoveDown(tbl){
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  p=co.parentNode.childNodes;
  if(p.item(p.length-1).sourceIndex!=tbl){
    return true;
  }
}

function span_moveDown(tbl){
  hidemenu();
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  p=co.parentNode.childNodes;
  for(i=0;i<p.length;i++){
    if(p.item(i).sourceIndex==tbl){
      tmp_val=p.item(i+1).outerHTML;
      p.item(i+1).outerHTML=p.item(i).outerHTML;
      p.item(i).outerHTML=tmp_val;
    }
  }
}

function show_properties(tbl){
  evl_str='co=parent.myEditor.document.all.item('+tbl+');';
  eval(evl_str);
  var attr=co.attributes;
  txt='';
  for(i=0;i<attr.length;i++){
  var oAttrib = attr[i];
    if(oAttrib.specified){
      txt+=oAttrib.nodeName+' = '+oAttrib.nodeValue+'\n';
    }
  }
  if(txt){
    setTimeout('alert(txt);',100);
  }
}

function view_source(){
  ww=window.open();
  ww.document.write('<html><body></body></html>');
  ww.document.body.innerText='Please wait...';
  ww.document.body.innerHTML='<font face="Courier New" size="3"><pre><div id="bdy"></div></pre></font>';
  ww.document.all('bdy').innerText= parent.frames[1].document.all.item(0).outerHTML;
}

function show_html(hobj){
  hidemenu();
  window.parent.frames[0].html_object=hobj;
  var arr = showModalDialog("http://www.airbaltic.com/editor/html.htm?id="+hobj,window,"dialogWidth:615px; dialogHeight:430px;status:off;scroll:off;help:off;");
}

function tr_insert(id1,id2){
  if(!id1){
    evl_str='id1=parent.myEditor.document.all.item('+prevCheckedTR+').rowIndex;';
    eval(evl_str);
    evl_str='id2=parent.myEditor.document.all.item('+prevCheckedTR+').parentNode.sourceIndex;';
    eval(evl_str);
  }
  nrow=parent.myEditor.document.all.item(id2).insertRow(id1);
  for(g=1;g<=parent.myEditor.document.all.item(id2).lastChild.childNodes.length;g++){
    tt=nrow.insertCell();
    //tt.innerHTML='&nbsp;';
    tt.className=parent.myEditor.document.all.item(id2).lastChild.childNodes.item(g-1).className;
  }
}

function tr_append(id1,id2){
  if(!id2){
    evl_str='id1=parent.myEditor.document.all.item('+prevCheckedTR+').rowIndex;';
    eval(evl_str);
    evl_str='id2=parent.myEditor.document.all.item('+prevCheckedTR+').parentNode.sourceIndex;';
    eval(evl_str);
  }
  if(parent.myEditor.document.all.item(id2).rows[id1].nextSibling){
    nxt_row=parent.myEditor.document.all.item(id2).rows[id1].nextSibling;
    nrow=parent.myEditor.document.all.item(id2).insertRow(nxt_row.rowIndex);
  }else{
    nrow=parent.myEditor.document.all.item(id2).insertRow();
  }
  for(g=1;g<=parent.myEditor.document.all.item(id2).firstChild.childNodes.length;g++){
    tt=nrow.insertCell();
    //tt.innerHTML='&nbsp;';
    tt.className=parent.myEditor.document.all.item(id2).firstChild.childNodes.item(g-1).className;
  }
}

function tr_delete(id1,id2){
  if(!id2){
    evl_str='id1=parent.myEditor.document.all.item('+prevCheckedTR+').rowIndex;';
    eval(evl_str);
    evl_str='id2=parent.myEditor.document.all.item('+prevCheckedTR+').parentNode.sourceIndex;';
    eval(evl_str);
  }
  parent.myEditor.document.all.item(id2).deleteRow(id1);
}

function tr_move_up(id1,id2){
  if(!id1){
    evl_str='id1=parent.myEditor.document.all.item('+prevCheckedTR+').rowIndex;';
    eval(evl_str);
    evl_str='id2=parent.myEditor.document.all.item('+prevCheckedTR+').parentNode.sourceIndex;';
    eval(evl_str);
  }
  if(parent.myEditor.document.all.item(id2).rows[id1].previousSibling){
    prv_row=parent.myEditor.document.all.item(id2).rows[id1].previousSibling;
    parent.myEditor.document.all.item(id2).moveRow(prv_row.rowIndex,id1);
  }
}

function tr_move_down(id1,id2){
  if(!id1){
    evl_str='id1=parent.myEditor.document.all.item('+prevCheckedTR+').rowIndex;';
    eval(evl_str);
    evl_str='id2=parent.myEditor.document.all.item('+prevCheckedTR+').parentNode.sourceIndex;';
    eval(evl_str);
  }
  if(parent.myEditor.document.all.item(id2).rows[id1].nextSibling){
    nxt_row=parent.myEditor.document.all.item(id2).rows[id1].nextSibling;
    parent.myEditor.document.all.item(id2).moveRow(id1,nxt_row.rowIndex);
  }
}

function getParentNode(ri){
  evl_str='pnode1=parent.myEditor.document.all.item('+ri+').parentNode.sourceIndex;';
  eval(evl_str);
  evl_str='pnode2=parent.myEditor.document.all.item('+pnode1+').parentNode.sourceIndex;';
  eval(evl_str);
  if(parent.myEditor.document.all.item(pnode2).tagName=='TBODY'){
    evl_str='pnode=parent.myEditor.document.all.item('+pnode2+').parentNode.sourceIndex;';
    eval(evl_str);
  }else{
    pnode=pnode2;
  }
  return pnode;
}

function col_insert(num,id2){
  colindex=0;
  if(!num){
    num=prevCheckedTD;
    id2=getParentNode(num);
  }
  id1=parent.myEditor.document.all.item(num);
  tbl=parent.myEditor.document.all.item(id2);
  for(y=0;y<id1.parentNode.childNodes.length;y++){
    if(id1.sourceIndex==id1.parentNode.childNodes.item(y).sourceIndex){
      colindex=y;
    }
  }
  for(y=0;y<tbl.childNodes.item(0).childNodes.length;y++){
    ch1=tbl.childNodes.item(0).childNodes.item(y);
    for(u=0;u<ch1.childNodes.length;u++){
      if(u==colindex){
        newcell=ch1.insertCell(ch1.childNodes.item(u).cellIndex);
        newcell.innerHTML='&nbsp;';
        newcell.className=ch1.childNodes.item(u+1).className;
      }
    }
  }
}

function col_append(num,id2){
  colindex=0;
  if(!num){
    num=prevCheckedTD;
    id2=getParentNode(num);
  }
  id1=parent.myEditor.document.all.item(num);
  tbl=parent.myEditor.document.all.item(id2);
  for(y=0;y<id1.parentNode.childNodes.length;y++){
    if(id1.sourceIndex==id1.parentNode.childNodes.item(y).sourceIndex){
      colindex=y;
    }
  }
  for(y=0;y<tbl.childNodes.item(0).childNodes.length;y++){
    ch1=tbl.childNodes.item(0).childNodes.item(y);
    for(u=0;u<ch1.childNodes.length;u++){
      if(u==colindex){
        newcell=ch1.insertCell(ch1.childNodes.item(u).cellIndex+1);
        newcell.innerHTML='&nbsp;';
        newcell.className=ch1.childNodes.item(u).className;
      }
    }
  }
}

function col_delete(num,id2){
  colindex=0;
  if(!num){
    num=prevCheckedTD;
    id2=getParentNode(num);
  }
  id1=parent.myEditor.document.all.item(num);
  tbl=parent.myEditor.document.all.item(id2);
  for(y=0;y<id1.parentNode.childNodes.length;y++){
    if(id1.sourceIndex==id1.parentNode.childNodes.item(y).sourceIndex){
      colindex=y;
    }
  }
  for(y=0;y<tbl.childNodes.item(0).childNodes.length;y++){
    ch1=tbl.childNodes.item(0).childNodes.item(y);
    for(u=0;u<ch1.childNodes.length;u++){
      if(u==colindex){
        ch1.deleteCell(ch1.childNodes.item(u).cellIndex);
      }
    }
  }
}

function col_move_left(num,id2){
  colindex=0;
  if(!num){
    num=prevCheckedTD;
    id2=getParentNode(num);
  }
  id1=parent.myEditor.document.all.item(num);
  tbl=parent.myEditor.document.all.item(id2);
  for(y=0;y<id1.parentNode.childNodes.length;y++){
    if(id1.sourceIndex==id1.parentNode.childNodes.item(y).sourceIndex){
      colindex=y;
    }
  }
  for(y=0;y<tbl.childNodes.item(0).childNodes.length;y++){
    ch1=tbl.childNodes.item(0).childNodes.item(y);
    for(u=0;u<ch1.childNodes.length;u++){
      if(u==colindex && colindex>0){
        newcell1=ch1.insertCell(ch1.childNodes.item(u).cellIndex);
        newcell2=ch1.insertCell(ch1.childNodes.item(u).cellIndex);
        oldcell1=ch1.cells(ch1.childNodes.item(u).cellIndex-1);
        oldcell2=ch1.cells(ch1.childNodes.item(u).cellIndex+2);

        newcell1.innerHTML=oldcell1.innerHTML;
        newcell1.id=oldcell1.id;
        newcell1.className=oldcell1.className;
        newcell1.align=oldcell1.align;
        newcell1.vAlign=oldcell1.vAlign;
        newcell1.height=oldcell1.height;
        newcell1.width=oldcell1.width;
        newcell1.rowSpan=oldcell1.rowSpan;
        newcell1.colSpan=oldcell1.colSpan;
        newcell1.bgColor=oldcell1.bgColor;
        newcell1.borderColor=oldcell1.borderColor;
        newcell1.borderColorLight=oldcell1.borderColorLight;
        newcell1.borderColorDark=oldcell1.borderColorDark;

        newcell2.innerHTML=oldcell2.innerHTML;
        newcell2.id=oldcell2.id;
        newcell2.className=oldcell2.className;
        newcell2.align=oldcell2.align;
        newcell2.vAlign=oldcell2.vAlign;
        newcell2.height=oldcell2.height;
        newcell2.width=oldcell2.width;
        newcell2.rowSpan=oldcell2.rowSpan;
        newcell2.colSpan=oldcell2.colSpan;
        newcell2.bgColor=oldcell2.bgColor;
        newcell2.borderColor=oldcell2.borderColor;
        newcell2.borderColorLight=oldcell2.borderColorLight;
        newcell2.borderColorDark=oldcell2.borderColorDark;

        ch1.deleteCell(ch1.childNodes.item(u).cellIndex-1);
        ch1.deleteCell(ch1.childNodes.item(u).cellIndex+1);
      }
    }
  }
}

function col_move_right(num,id2){
  colindex=0;
  if(!num){
    num=prevCheckedTD;
    id2=getParentNode(num);
  }
  id1=parent.myEditor.document.all.item(num);
  tbl=parent.myEditor.document.all.item(id2);
  for(y=0;y<id1.parentNode.childNodes.length;y++){
    if(id1.sourceIndex==id1.parentNode.childNodes.item(y).sourceIndex){
      colindex=y;
    }
  }
  for(y=0;y<tbl.childNodes.item(0).childNodes.length;y++){
    ch1=tbl.childNodes.item(0).childNodes.item(y);
    max_col=ch1.childNodes.length;
    for(u=0;u<ch1.childNodes.length;u++){
      if(u==colindex && colindex<max_col-1){
        newcell1=ch1.insertCell(ch1.childNodes.item(u).cellIndex+1);
        newcell2=ch1.insertCell(ch1.childNodes.item(u).cellIndex+1);
        oldcell1=ch1.cells(ch1.childNodes.item(u).cellIndex);
        oldcell2=ch1.cells(ch1.childNodes.item(u).cellIndex+3);

        newcell1.innerHTML=oldcell1.innerHTML;
        newcell1.id=oldcell1.id;
        newcell1.className=oldcell1.className;
        newcell1.align=oldcell1.align;
        newcell1.vAlign=oldcell1.vAlign;
        newcell1.height=oldcell1.height;
        newcell1.width=oldcell1.width;
        newcell1.rowSpan=oldcell1.rowSpan;
        newcell1.colSpan=oldcell1.colSpan;
        newcell1.bgColor=oldcell1.bgColor;
        newcell1.borderColor=oldcell1.borderColor;
        newcell1.borderColorLight=oldcell1.borderColorLight;
        newcell1.borderColorDark=oldcell1.borderColorDark;

        newcell2.innerHTML=oldcell2.innerHTML;
        newcell2.id=oldcell2.id;
        newcell2.className=oldcell2.className;
        newcell2.align=oldcell2.align;
        newcell2.vAlign=oldcell2.vAlign;
        newcell2.height=oldcell2.height;
        newcell2.width=oldcell2.width;
        newcell2.rowSpan=oldcell2.rowSpan;
        newcell2.colSpan=oldcell2.colSpan;
        newcell2.bgColor=oldcell2.bgColor;
        newcell2.borderColor=oldcell2.borderColor;
        newcell2.borderColorLight=oldcell2.borderColorLight;
        newcell2.borderColorDark=oldcell2.borderColorDark;

        ch1.deleteCell(ch1.childNodes.item(u).cellIndex);
        ch1.deleteCell(ch1.childNodes.item(u).cellIndex+2);
      }
    }
  }
}


function checkTD() {
  try{
  el=window.event.srcElement;
  prevCheckedTD=0;
  prevCheckedTR=0;
  prevCheckedTABLE=0;
  if (el.tagName == "TD" && window.event.altKey){
    if(el.parentNode.name=='myTable' || el.parentNode.parentNode.name=='myTable' || el.parentNode.parentNode.parentNode.name=='myTable' || el.parentNode.parentNode.parentNode.parentNode.name=='myTable'){
      if(!el.sel){
        el.sel=true;
      }else{
        el.removeAttribute('sel');
      }
    }
  }else{
    var e=window.event.srcElement;
    if(e.tagName=='IMG'){
      ep=e.parentNode;
      ep.focus();
    }
  }
  if(parent.myEditor.myTableInParents(el,'click')){
    if(prevCheckedTABLE){
      showMenuTABLE();
    }else{
      hideMenuTABLE();
    }
    if(prevCheckedTD){
      showMenuTD();
    }else{
      hideMenuTD();
    }
  }
  if(!parent.myEditor.myTableInParents(el,'click')){
    prevCheckedTD=0;
    prevCheckedTR=0;
    prevCheckedTABLE=0;
    hideMenuTABLE();
    hideMenuTD();
    hideChecked();
  }
  parent.edit_header.showTopMenu(window.event.srcElement.sourceIndex,window.event.altKey);
  hidemenu();
  }
  catch(e){
    alert('checkTD');
  }
}

function hideChecked(){
  els=parent.myEditor.document.all;
  for(k=0;k<els.length;k++){
    if(els.item(k).sel){
      els.item(k).removeAttribute('sel');
      els.item(k).runtimeStyle.backgroundColor='';
      els.item(k).runtimeStyle.color='';
    }
  }
}

function myTableInParents(el,action){
  parents[el.sourceIndex]='';
  get_parents(el.sourceIndex,el.sourceIndex);
  el_arr=parents[el.sourceIndex].split("\n");
  for(r=0;r<el_arr.length;r++){
    ri=el_arr[r];
    evl_str='ro=parent.myEditor.document.all.item('+ri+');';
    eval(evl_str);
    if(action=='click'){
      if(ro.tagName=='TD' && !prevCheckedTD){
        prevCheckedTD=ro.sourceIndex;
      }
      if(ro.tagName=='TR' && !prevCheckedTR){
        prevCheckedTR=ro.sourceIndex;
      }
      if(ro.tagName=='TABLE' && !prevCheckedTABLE){
        prevCheckedTABLE=ro.sourceIndex;
      }
    }
    if(ro.name=='myTable'){
      return true;
    }
  }
}

function checkTDover() {
  el=window.event.srcElement;
  if (el.tagName == "TD" && window.event.shiftKey && window.event.altKey){
    if(el.parentNode.name=='myTable' || el.parentNode.parentNode.name=='myTable' || el.parentNode.parentNode.parentNode.name=='myTable' || el.parentNode.parentNode.parentNode.parentNode.name=='myTable'){
      el.sel=true;
    }
  }
  if((el.tagName == "TD" || el.tagName == "TABLE") && parent.myEditor.myTableInParents(el,'move')){
    if(el.tagName=="TD"){
      if(prevSelectedTD && !elementChecked(prevSelectedTD)){
        //parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.backgroundColor="";
        //parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.color="";
	parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.border="";
      }
      //el.runtimeStyle.backgroundColor="highlight";
      //el.runtimeStyle.color="highlighttext";
      el.runtimeStyle.border="1px dotted black";
      prevSelectedTD=el.sourceIndex;
    }
    if(el.tagName=="TABLE"){
      el.runtimeStyle.backgroundColor="#FBFBFB";
      prevSelectedTABLE=el.sourceIndex;
    }
  }
  if(!parent.myEditor.myTableInParents(el,'move')){
    if(prevSelectedTD && !elementChecked(prevSelectedTD)){
      //parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.backgroundColor="";
      //parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.color="";
      parent.myEditor.document.all.item(prevSelectedTD).runtimeStyle.border="";
    }
    if(prevSelectedTABLE){
      parent.myEditor.document.all.item(prevSelectedTABLE).runtimeStyle.backgroundColor="";
    }
  }
 //   parent.parent.frstatus.index_status.innerText=el.tagName+';table:'+prevCheckedTABLE+';tr:'+prevCheckedTR+';td:'+prevCheckedTD;

}

function elementChecked(el){
  return parent.myEditor.document.all.item(prevSelectedTD).sel;
}

function highlightEditable(){
try{
  o=document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    switch(o.item(i).edit){
      case 'true':
        o.item(i).className='editable obj_'+o.item(i).object_id;
        o.item(i).contentEditable='true';
        break;
      case 'false':
        o.item(i).className='notEditable obj_'+o.item(i).object_id;
        o.item(i).contentEditable='false';
        break;
      case 'hidden':
        o.item(i).className='spanHide obj_'+o.item(i).object_id;
        o.item(i).contentEditable='false';
        break;
      case 'moduls':
        o.item(i).className='modulVieta obj_'+o.item(i).object_id;
        o.item(i).contentEditable='false';
        break;
    }
  }
  o=document.all.tags('BDO');
  for(i=0;i<o.length;i++){
    if(o.item(i).id){
      o.item(i).contentEditable=false;
      o.item(i).className='insertedBDO';
    }
  }
}
catch(e){
  alert('highlightEditable:'+e);
}
}


function unhighlightEditable(){
try{
  o=document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    o.item(i).className='';
    o.item(i).contentEditable='false';
    o.item(i).runtimeStyle.backgroundColor='';
  }
  o=document.all.tags('BDO');
  for(i=0;i<o.length;i++){
    if(o.item(i).id){
      o.item(i).contentEditable=false;
      o.item(i).className='';
    }
  }
}
catch(e){
  alert('unhighlightEditable:'+e);
}
}

function showSpansHTML(){
try{
  o=document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    switch(o.item(i).edit){
      case 'true':
        o.item(i).className='editable';
        o.item(i).contentEditable='true';
        o.item(i).innerText = o.item(i).innerHTML;
        o.item(i).style.fontFamily = "monospace";
        o.item(i).fontSize = "10pt";
        format="Text";
        parent.myEditor.format="Text";
        break;
      case 'false':
        o.item(i).className='notEditable';
        o.item(i).contentEditable='false';
        break;
      case 'hidden':
        o.item(i).className='spanHide';
        o.item(i).contentEditable='false';
        break;
      case 'moduls':
        o.item(i).className='modulVieta';
        o.item(i).contentEditable='false';
        break;
    }
  }
}
catch(e){
  alert('showSpansHTML:'+e);
}
}

function showSpansText(){
try{
  o=document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    switch(o.item(i).edit){
      case 'true':
        o.item(i).className='editable';
        o.item(i).contentEditable='true';
        o.item(i).innerHTML = o.item(i).innerText;
        o.item(i).style.fontFamily = "";
        o.item(i).style.fontSize ="";
        format="HTML";
        parent.myEditor.format="HTML";
        break;
      case 'false':
        o.item(i).className='notEditable';
        o.item(i).contentEditable='false';
        break;
      case 'hidden':
        o.item(i).className='spanHide';
        o.item(i).contentEditable='false';
        break;
      case 'moduls':
        o.item(i).className='modulVieta';
        o.item(i).contentEditable='false';
        break;
    }
  }
}
catch(e){
  alert('showSpansText:'+e);
}
}

function containsEditableSpan(num){
  ttag='';
  tedit='';
  get_parents(num,num);
  par_arr=parents[num].split("\n");
  for(r=0;r<par_arr.length;r++){
    ri=par_arr[r];
    evl_str='ttag=parent.myEditor.document.all.item('+ri+').tagName;';
    eval(evl_str);
    evl_str='tedit=parent.myEditor.document.all.item('+ri+').contentEditable;';
    eval(evl_str);
  }
}

function createTopMenu(){
  TopMenuArr["1"]='<img src="../img/none.gif" class="delimiter">';
  TopMenuArr["2"]='<INPUT alt="Bold" TYPE="image" src="../img/b.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Bold\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["3"]='<INPUT alt="Italic" TYPE="image" src="../img/i.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Italic\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["4"]='<INPUT alt="Underline" TYPE="image" src="../img/u.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Underline\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["5"]='<INPUT alt="Align Left" TYPE="image" src="../img/left.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'JustifyLeft\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["6"]='<INPUT alt="Center" TYPE="image" src="../img/cent.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'JustifyCenter\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["7"]='<INPUT alt="Align Right" TYPE="image" src="../img/right.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'JustifyRight\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["8"]='<INPUT alt="Increase Indent" TYPE="image" src="../img/ind.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Indent\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["9"]='<INPUT alt="Decrease Indent" TYPE="image" src="../img/und.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Outdent\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["10"]='<INPUT alt="Numbered List" TYPE="image" src="../img/ol.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'InsertOrderedList\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["11"]='<INPUT alt="Bulleted List" TYPE="image" src="../img/uol.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'InsertUnorderedList\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["12"]='<INPUT alt="Cut" TYPE="image" src="../img/cut.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Cut\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["13"]='<INPUT alt="Copy" TYPE="image" src="../img/copy.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Copy\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["14"]='<INPUT alt="Paste" TYPE="image" src="../img/paste.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Paste\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["15"]='<INPUT alt="Hyperlink" TYPE="image" src="../img/ins_link.gif" border="0" height=20 width=20 ONCLICK="newLink();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["16"]='<INPUT alt="Insert Graphic" TYPE="image" src="../img/ins_picture.gif" border="0" height=20 width=20 ONCLICK="getGraphic();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["17"]='<INPUT alt="Insert Table" TYPE="image" src="../img/ins_table.gif" border="0" height=20 width=20 ONCLICK="getTable();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["18"]='<INPUT alt="Insert Module" TYPE="image" src="../img/ins_modul.gif" border="0" height=20 width=20 ONCLICK="getModule();this.blur();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["19"]='<INPUT alt="Insert Text" TYPE="image" src="../img/ins_text.gif" border="0" height=20 width=20 ONCLICK="getText();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["20"]='<INPUT alt="SuperScript" TYPE="image" src="../img/superscript.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'SuperScript\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["21"]='<INPUT alt="SubScript" TYPE="image" src="../img/subscript.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'SubScript\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["24"]='<INPUT alt="Insert Form" TYPE="image" src="../img/ins_form.gif" border="0" height=20 width=20 ONCLICK="getForm();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["25"]='<INPUT alt="Insert picture" TYPE="image" src="../img/pic.gif" border="0" height=20 width=20 ONCLICK="getPicture();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["26"]='<INPUT alt="Insert external table" TYPE="image" src="../img/table.gif" border="0" height=20 width=20 ONCLICK="InsertTable();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["27"]='<INPUT alt="Insert file attachment" TYPE="image" src="../img/file.gif" border="0" height=20 width=20 ONCLICK="getFile();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["30"]='<INPUT alt="Title (Heading 1)" TYPE="image" src="../img/title1.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'FormatBlock\',false,\'<h1>\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["31"]='<INPUT alt="Justify" TYPE="image" src="../img/full.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'JustifyFull\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["32"]='<INPUT alt="Title (Heading 2)" TYPE="image" src="../img/title2.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'FormatBlock\',false,\'<h2>\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["33"]='<INPUT alt="Title (Heading 3)" TYPE="image" src="../img/title3.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'FormatBlock\',false,\'<h3>\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["34"]='<INPUT alt="Remove Heading" TYPE="image" src="../img/title_remove.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'FormatBlock\',false,\'<p>\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["35"]='<INPUT alt="Add bookmark" TYPE="image" src="../img/bookmark.gif" border="0" height=20 width=20 ONCLICK="addBookmark();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["36"]='<INPUT alt="Remove hyperlink" TYPE="image" src="../img/unlink.gif" border="0" height=20 width=20 ONCLICK="doFormat(\'Unlink\');" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["37"]='<INPUT alt="Insert Poll" TYPE="image" src="../img/ins_form.gif" border="0" height=20 width=20 ONCLICK="getPoll();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["38"]='<INPUT alt="Insert Banner Zone" TYPE="image" src="../img/ins_form.gif" border="0" height=20 width=20 ONCLICK="getBanner();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["40"]='<INPUT alt="Insert Macros" TYPE="image" src="../img/ins_macro.gif" border="0" height=20 width=20 ONCLICK="insertMacros();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["39"]='<INPUT alt="Image popup" TYPE="image" src="../img/link_pic.gif" border="0" height=20 width=20 ONCLICK="picLink();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
  TopMenuArr["41"]='<INPUT alt="Insert AMADEUS mail" TYPE="image" src="../img/ins_amadeus.gif" border="0" height=20 width=20 ONCLICK="insertAmadeus();" class="menuItem" onmouseover="this.className=\'menuItemOver\'" onmouseout="this.className=\'menuItem\'">';
}

function createTagsArray(){
  TagsArray["1"]='A';
  TagsArray["2"]='TD,TH,TR,TBODY,TABLE,THEAD,TFOOT';
  TagsArray["3"]='P';
  TagsArray["16"]='H1';
  TagsArray["5"]='IMG';
  TagsArray["6"]='LI,OL,UL,DT,DD,DL,MENU,DIR';
  TagsArray["7"]='BR';
  TagsArray["8"]='B,STRONG';
  TagsArray["9"]='I,EM';
  TagsArray["10"]='U';
  TagsArray["11"]='BLOCKQUOTE';
  TagsArray["12"]='MARQUEE';
  TagsArray["13"]='EMBED,PARAM,OBJECT';
  TagsArray["14"]='PRE';
  TagsArray["15"]='FONT';
  TagsArray["17"]='H2';
  TagsArray["18"]='H3';
  TagsArray["19"]='SUB,SUP';
  TagsArray["20"]='IMG,MAP,AREA';
  TagsArray["21"]='HR';
  TagsArray["22"]='SCRIPT';
  TagsArray["23"]='IFRAME';
  TagsArray["24"]='INPUT';
  TagsArray["25"]='BACKGROUND';
  TagsArray["26"]='DIV';
  TagsArray["27"]='COL';
}

function createContextMenu(){

}

function showTopMenu(ind,alt){
try{
  var tm='';
  var step=0;
  parents[ind]='';
  get_parents(ind,ind);
  par_arr=parents[ind].split("\n");
  for(r=0;r<par_arr.length;r++){
    if(par_arr[r]){
      evl='itm=parent.myEditor.document.all.item('+par_arr[r]+');';
      eval(evl);
      if(itm.selectable){
        if(!step){
          if(sel){
            sel1=sel;
            animate(sel,false);
            sel=0;
            step=1;
          }else{
            sel1=0;
          }
          animate(itm.sourceIndex,true);
          sel=itm.sourceIndex;
          step=1;
        }
      }
      if(itm.top_menu && !tm){
        evl='arr=new Array('+itm.top_menu+');';
        eval(evl);
        parent.parent.selectedEditorModule=itm.sourceIndex;
        for(i=0;i<arr.length;i++){
          if(arr[i]){
            tm+=TopMenuArr[arr[i]];
          }
        }
      }
    }
  }
document.all('menu').innerHTML='<table border="0" cellspacing="0" cellpadding="0" width="100%" height="20"><tr><td nowrap>&nbsp;'+parent.edit_header.defaultTopMenu+tm+'</td><td align="right" width="100%" nowrap></td></tr></table>';
parent.editorFrameset.rows=topTable.clientHeight+",*,23";
}
catch(e){
  alert('showTopMenu:'+e);
}
}

function showMenuTD(){
try{
  if(parent.edit_header.menuTab){
    if(parent.edit_header.pagemenuTab.style.display!="block"){
      parent.edit_header.pagemenuTab.style.display="block";
      //parent.edit_header.activatePage('menuTab');
    }
    parent.edit_header.menuTab.innerHTML='<table border="0" cellspacing="0" cellpadding="0" width="100%" height="20"><tr><td nowrap>&nbsp;'+parent.edit_header.defaultTopMenu+menuTABLE+menuTD+'</td><td align="right" width="100%" nowrap></td></tr></table>';
  }
}
catch(e){}
}

function hideMenuTD(){
}

function showMenuTABLE(){
try{
  if(parent.edit_header.menuTab){
    if(parent.edit_header.pagemenuTab.style.display!="block"){
      parent.edit_header.pagemenuTab.style.display="block";
      //parent.edit_header.activatePage('menuTab');
    }
    parent.edit_header.menuTab.innerHTML='<table border="0" cellspacing="0" cellpadding="0" width="100%" height="20"><tr><td nowrap>&nbsp;'+defaultTopMenu+menuTABLE+'</td><td align="right" width="100%" nowrap></td></tr></table>';
  }
}
catch(e){}
}

function hideMenuTABLE(){
try{
  if(parent.edit_header.pagemenuTab){
    parent.edit_header.pagemenuTab.style.display="none";
    parent.edit_header.activateSmallPage('menu');
  }
}
catch(e){}
}

function animate(el,action){
  if(!action){
    //window.clearInterval(activeElementID);
    //parent.myEditor.document.all.item(el).runtimeStyle.border="1px solid";

    parent.myEditor.document.all.item(el).runtimeStyle.backgroundColor="";
    parent.myEditor.document.all.item(el).runtimeStyle.color="";
  }else{
    bg=parent.myEditor.document.all.item(el).selected_background;
    fn=parent.myEditor.document.all.item(el).selected_font;
    if(bg){
      parent.myEditor.document.all.item(el).runtimeStyle.backgroundColor=bg;
    }
    if(fn){
      parent.myEditor.document.all.item(el).runtimeStyle.color=fn;
    }

   //parent.myEditor.document.all.item(el).runtimeStyle.backgroundColor='';
   //activeElementID=window.setInterval("switchBorder("+el+");", 200);
  }
}

function switchBorder(el){
  if(parent.myEditor.document.all.item(el).runtimeStyle.borderStyle=="solid"){
    parent.myEditor.document.all.item(el).runtimeStyle.borderStyle="dotted";
    parent.myEditor.document.all.item(el).runtimeStyle.borderWidth="1px";
  }else{
    parent.myEditor.document.all.item(el).runtimeStyle.borderStyle="solid";
    parent.myEditor.document.all.item(el).runtimeStyle.borderWidth="1px";
  }
}

function saveData(type){
try{
  if(parent.myEditor.format=="Text"){
    parent.myEditor.showSpansText();
    parent.myEditor.highlightEditable();
  }
  hideChecked();
  removeBDOParams();
  doc=parent.myEditor.document;
  var saveForm=doc.createElement("FORM");
  doc.body.appendChild(saveForm);
  if(doc.all('content').url){
    saveForm.action='http://www.airbaltic.com/admin/module_save.php';
    saveForm.method='POST';
    saveForm.encoding='multipart/form-data';
    itm=doc.createElement("INPUT");
    itm.name="filename";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').url;
    itm=doc.createElement("INPUT");
    itm.name="text";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').innerText;
    itm=doc.createElement("INPUT");
    itm.name="doc_id";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').doc_id;
  }else{
    if(type=='mail'){
      saveForm.action='http://www.airbaltic.com/admin/doc_mail.php';
    }else{
      saveForm.action='http://www.airbaltic.com/admin/doc_save.php';
    }
    saveForm.method='POST';
    saveForm.encoding='multipart/form-data';
    itm=doc.createElement("INPUT");
    itm.name="doc_id";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').doc_id;
    itm=doc.createElement("INPUT");
    itm.name="compact_mode";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').compact_mode;
    itm=doc.createElement("INPUT");
    itm.name="external";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').external;
    itm=doc.createElement("INPUT");
    itm.name="unique_id";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').unique_id;
    itm=doc.createElement("INPUT");
    itm.name="mail_id";
    itm.type='hidden';
    saveForm.appendChild(itm);
    itm.value=doc.all('content').mail_id;
    o=doc.all.tags('SPAN');
    for(i=0;i<o.length;i++){
      if(o.item(i).edit=='true'){
        itm=doc.createElement("INPUT");
        itm.name="o"+o.item(i).object_id;
        itm.type='hidden';
        saveForm.appendChild(itm);
        itm.value=o.item(i).innerHTML;
      }
      if(o.item(i).edit=='moduls'){
        ch=o.item(i).children;
        chtxt='';
        for(j=0;j<ch.length;j++){
          if(ch.item(j).object_id){
            chtxt+=ch.item(j).object_id+",";
          }
        }
        chtxt=chtxt.substr(0,chtxt.length-1);
        itm=doc.createElement("INPUT");
        itm.name="o"+o.item(i).object_id;
        itm.type='hidden';
        saveForm.appendChild(itm);
        itm.value=chtxt;
      }
    }
  }

  f=doc.all.tags('FORM');
  for(k=0;k<f.length;k++){
  if(f.item(k).name=='customForm'){
    fel=f.item(k).elements;
      for(j=fel.length-1;j>=0;j--){
        if(fel.item(j).type!='checkbox'){
          fel.item(j).name='_'+fel.item(j).name;
          saveForm.appendChild(fel.item(j));
        }else{
          if(fel.item(j).checked){
            itm=doc.createElement("INPUT");
            itm.name='_'+fel.item(j).name;
            itm.type='hidden';
            saveForm.appendChild(itm);
            itm.value=fel.item(j).value;
          }
        }
      }
    }
  }

  f=parent.edit_header.document.all.tags('FORM');
  for(k=0;k<f.length;k++){
    if(f.item(k).name=='additionalForm'){
      error_txt='';
      //error check here
      if(error_txt){
        alert(error_txt);
        return;
      }
      fel=f.item(k).elements;
      for(j=fel.length-1;j>=0;j--){
        itm=doc.createElement("INPUT");
        itm.name='a'+fel.item(j).name;
        itm.type='hidden';
        saveForm.appendChild(itm);
        if(fel.item(j).type=='checkbox'){
          if(fel.item(j).checked){
            itm.value=fel.item(j).value;
          }
        }
        if(fel.item(j).type=='select-multiple'){
          tm='';
          for(s=0;s<fel.item(j).length;s++){
            if(fel.item(j).item(s).selected){
              tm+=fel.item(j).item(s).value+',';
            }
          }
          itm.value=tm.substr(0,tm.length-1);
        }
        if(fel.item(j).type!='checkbox' && fel.item(j).type!='select-multiple'){
          itm.value=fel.item(j).value;
        }
      }
    }
  }
  saveForm.submit();
}
catch(e){
  alert('saveData:'+e);
}
}

function removeBDOParams(){
  o=parent.myEditor.document.all.tags('BDO');
  for(i=o.length-1;i>=0;i--){
    id=o.item(i).id;
    type=o.item(i).type;
    htm=o.item(i).innerHTML;
    o.item(i).outerHTML='<bdo id='+id+'>'+htm+'</bdo>';
  }
}

function removetags(){
  event.srcElement.innerHTML=event.srcElement.innerText;
}

function addh1(){
  event.srcElement.innerHTML='<h1>'+event.srcElement.innerText+'</h1>';
}

drag=false;
function dragMe(){
  drag=true;
  ctop=parseInt(window.dialogTop)-event.screenY;
  cleft=parseInt(window.dialogLeft)-event.screenX;
}

function moveDrag(){
  if(drag){
    window.dialogTop=parseInt(event.screenY)+ctop;
    window.dialogLeft=parseInt(event.screenX)+cleft;
  }
}

function releaseDrag(){
  drag=false;
  ctop=parseInt(window.dialogTop);
  cleft=parseInt(window.dialogLeft);
}

function getModule(srcIndex){
  doc_id=0;
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(i).doc_id){
      doc_id=o.item(i).doc_id;
    }
  }
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
  if(!parent.parent.selectedModule){
    var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=999&title=Insert module',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
    if(ret){
      parent.parent.selectedModule=ret['id'];
    }
  }
  if( parent.parent.selectedModule){
    parent.myEditor.window.open("http://www.airbaltic.com/include/inc_object_html.php?id="+parent.parent.selectedModule+'&doc_id='+doc_id,"objHTML");
  }
}

function getBDOModule(srcIndex){
  doc_id=0;
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(i).doc_id){
      doc_id=o.item(i).doc_id;
    }
  }
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?title=Insert module',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
   if(ret){
     parent.parent.selectedModuleBDO=ret['id'];
   }
   if (parent.parent.selectedModuleBDO){
     parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO+'&doc_id='+doc_id,"objHTMLBDO");
   }
}

function getGraphic(srcIndex){
  doc_id=0;
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(i).doc_id){
      doc_id=o.item(i).doc_id;
    }
  }
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
  var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=7&title=Insert graphic',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
  if (parent.parent.selectedModuleBDO){
    parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO+'&doc_id='+doc_id,"objHTMLBDO");
  }
}

function getForm(srcIndex){
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=8&title=Insert form',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
   if (parent.parent.selectedModuleBDO){
     parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO,"objHTMLBDO");
   }
}

function getPoll(srcIndex){
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=4&title=Insert poll',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
   if (parent.parent.selectedModuleBDO){
     parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO,"objHTMLBDO");
   }
}

function getBanner(srcIndex){
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=17&title=Insert Banner Zone',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
   if (parent.parent.selectedModuleBDO){
     parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO,"objHTMLBDO");
   }
}

function getTable(srcIndex){
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=12&title=Insert Table',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
  if (parent.parent.selectedModuleBDO){
    parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO,"objHTMLBDO");
  }
}

function getPicture(){
  doc_id=0;
  var tr = parent.myEditor.document.selection.createRange();
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(0).doc_id){
      doc_id=o.item(0).doc_id;
    }
  }
  var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=pic_explorer.php&title=Get picture (gif,jpg,swf)&id="+doc_id,window,"dialogWidth:800px; dialogHeight:500px; status:off;scroll:no;help:off;");
  if(ret){
    if(ret['id'].substr(ret['id'].length-4,4)=='.swf'){
      tr.pasteHTML('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH='+ret['w']+' HEIGHT='+ret['h']+'><PARAM NAME=movie VALUE="/upload_pic/'+ret['id']+'"> <PARAM NAME=quality VALUE=high><PARAM NAME=menu VALUE=false><EMBED src="/upload_pic/'+ret['id']+'" quality=high bgcolor=#FFFFFF  WIDTH='+ret['w']+' HEIGHT='+ret['h']+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>');
    }else{
      tr.pasteHTML('<img src="/upload_pic/'+ret['id']+'" border="0" width="'+ret['w']+'" height="'+ret['h']+'">');
    }
    tr.select();
    parent.myEditor.focus();
  }
}

function getFile(){
  doc_id=0;
  var tr = parent.myEditor.document.selection.createRange();
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(0).doc_id){
      doc_id=o.item(0).doc_id;
    }
  }
  var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=file_explorer.php&title=Get file (doc,xls,zip,pdf,ppt,pps)&id="+doc_id,window,"dialogWidth:500px; dialogHeight:500px; status:off;scroll:no;help:off;");
  if(ret){
    txt='';
    if(tr.text){
      txt=tr.text;
    }else{
      txt=ret['id'];
    }
    //target="_new"
    tr.pasteHTML('<a href="/upload_file/'+ret['id']+'"><img src="/templates/img/file'+ret['type']+'.gif" border="0"></a>&nbsp;<a href="/upload_file/'+ret['id']+'">'+txt+' ('+ret['size']+')</a>');
    tr.select();
    parent.myEditor.focus();
  }
}

function getText(srcIndex){
  parent.parent.selectedModuleBDO=false;
  if(!srcIndex){
    itemId=parent.parent.selectedEditorModule;
  }else{
    itemId=parent.myEditor.document.all.item(srcIndex).sourceIndex;
    parent.parent.selectedEditorModule=itemId;
  }
   var ret=showModalDialog('http://www.airbaltic.com/admin/text_frames.php?ot=1',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.parent.selectedModuleBDO=ret['id'];
  }
  if (parent.parent.selectedModuleBDO){
    parent.myEditor.window.open("../include/inc_object_html.php?id="+parent.parent.selectedModuleBDO,"objHTMLBDO");
  }
}

function objHTMLpaste(){
  itemId=parent.parent.selectedEditorModule;
  if(itemId && parent.parent.selectedModule){
    if(parent.myEditor.document.all.item(itemId)){
      check=false;
      name='';
      o=parent.myEditor.document.all.tags('SPAN');
      for(i=0;i<o.length;i++){
        if(o.item(i).object_id==parent.parent.selectedModule){
          check=true;
          name=o.item(i).name;
        }
      }
      if(!check){
        parent.myEditor.document.all.item(itemId).innerHTML+=objHTML.document.body.innerHTML;
      }else{
        alert('Sorry, module "'+name+'" already exists');
      }
      objHTML.document.body.innerHTML="";
      parent.parent.selectedModule=false;
      //parent.myEditor.getSpanOptions();
      parent.myEditor.highlightEditable();
    }
  }
return true;
}

function objHTMLBDOpaste(){
  itemId=parent.parent.selectedEditorModule;
  if(itemId && parent.parent.selectedModuleBDO){
    var tr = parent.myEditor.document.selection.createRange();
    if(parent.myEditor.document.all.item(itemId)){
      txt=parent.parent.selectedModuleBDO;
      insText=objHTMLBDO.document.body.innerHTML;
      if(txt.search('@')!= -1){
        spn=objHTMLBDO.document.all.tags('SPAN');
        if(spn.length){
          insText=spn.item(0).innerHTML;
        }
      }
      tr.pasteHTML(insText);
      objHTMLBDO.document.body.innerHTML="";
      parent.parent.selectedModuleBDO=false;
      //parent.myEditor.getSpanOptions();
      parent.myEditor.highlightEditable();
    }
  }
  if(tr){
    tr.select()
    parent.myEditor.focus()
  }
return true;
}

function addIframes(){
  parent.myEditor.document.body.innerHTML+='<iframe onload="objHTMLpaste();" name="objHTML" id="objHTML" style="display:none"></iframe>';
  parent.myEditor.document.body.innerHTML+='<iframe onload="objHTMLBDOpaste();" name="objHTMLBDO" id="objHTMLBDO" style="display:none"></iframe>';
  parent.myEditor.document.body.innerHTML+='<iframe onload="mailPaste();" name="mailDiv" id="mailDiv" style="display:none"></iframe>';
}

function checkDblClick(){
  ind=event.srcElement.sourceIndex;
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(0).doc_id){
      doc_id=o.item(0).doc_id;
    }
  }
  var show=false;
  parents[ind]='';
  get_parents(ind,ind);
  par_arr=parents[ind].split("\n");
  for(r=0;r<par_arr.length;r++){
    if(par_arr[r]){
      evl='itm=parent.myEditor.document.all.item('+par_arr[r]+');';
      eval(evl);
      if(itm.url_properties && !show){
        show=true;
        if(itm.tagName=='BDO'){
          if(itm.real_id.search('@')==-1){
            parent.parent.frames[0].getProperties(itm.url_properties+'?id='+itm.real_id,escape('"'+itm.name+'"')+' properties',doc_id);
          }
        }else if(itm.tagName=='SPAN'){
          str=itm.object_id;
          if(str.search('@')==-1){
            parent.parent.frames[0].getProperties(itm.url_properties+'?id='+itm.object_id,escape('"'+itm.name+'"')+' properties',doc_id);
          }
        }
      }
    }
  }
}

function returnfalse(){
  return false;
}

function newLink(){
  var tp=parent.myEditor.document.selection.type;
  var tr = parent.myEditor.document.selection.createRange()
  var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=1&title=Set hyperlink',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(tp=='Text'){
    if (ret != null) {
      if(ret['url']=='http://' || ret['url']=='ftp://' || ret['url']=='mailto:'){
        ret['url']='';
      }
      tr.execCommand('Unlink',false,0)
      if(ret['id'] && !ret['url']){
        tr.pasteHTML('<a id={'+ret['id']+(ret['bookmark']?'#'+ret['bookmark']:'')+'} href="http://www.airbaltic.com/editor/center.php?doc_id='+ret['id']+'" title="'+ret['title']+'">'+tr.text+'</a>');
      }
      if(ret['url']){
        tr.pasteHTML('<a href="'+ret['url']+'" target="'+ret['target']+'" title="'+ret['title']+'">'+tr.text+'</a>');
      }
      tr.select();
    }
  }
  if(tp=='Control'){
    if (ret != null) {
      if(ret['url']=='http://' || ret['url']=='ftp://' || ret['url']=='mailto:'){
        ret['url']='';
      }
      itm=tr.item(0);
      itmp=itm.parentNode;
      if((itm.tagName+' '+itmp.tagName=='BDO A')||(itm.tagName+' '+itmp.tagName=='IMG A')){
        itmp.removeNode();
        itmp=itm.parentNode;
      }
      if((itm.tagName=='BDO' && itm.className=='insertedBDO')||itm.tagName=='IMG'){
        if(ret['id'] && !ret['url']){
          itm.outerHTML='<a id={'+ret['id']+(ret['bookmark']?'#'+ret['bookmark']:'')+'} href="http://www.airbaltic.com/editor/center.php?doc_id='+ret['id']+'" title="'+ret['title']+'">'+itm.outerHTML+'</a>';
        }
      if(ret['url']){
          itm.outerHTML='<a href="'+ret['url']+'" target="'+ret['target']+'" title="'+ret['title']+'">'+itm.outerHTML+'</a>';
        }
      }else{
        alert(itm.tagName+' '+itmp.tagName+' : Link unavailable ');
      }
    }
  }
}

function addBookmark(){
  var ancs = parent.myEditor.document.anchors;
  var tr = parent.myEditor.document.selection.createRange()
  var args = new Array();
  for (i=0;i<parent.myEditor.document.anchors.length;i++){
    args[i]=parent.myEditor.document.anchors(i).name
  }
  var arr = null;
  if (tr.text!=''){
    arr = showModalDialog("bookmark.htm",args,"dialogWidth:18em; dialogHeight:15em; status:off; scroll:no;help:off");
      if (arr != null) {
        tr.execCommand('CreateLink',false,"javascript:goBookmark('"+arr+"')")
        tr.select()
        parent.myEditor.focus()
      }
  } else {
    arr = showModalDialog("bookmark_new.htm",args,"dialogWidth:18em; dialogHeight:6em; status:off; scroll:no;help:off");
      if (arr != null){
        tr.execCommand('CreateBookmark', arguments[1],arr)
        tr.select()
        parent.myEditor.focus()
      }
  }
}

function zoomIn(){
if(parent.myEditor.document.body.style.zoom!=0){
  parent.myEditor.document.body.style.zoom*=1.6;
}else{
  parent.myEditor.document.body.style.zoom=1.6;
}
}

function zoomOut(){
if(parent.myEditor.document.body.style.zoom!=0){
  parent.myEditor.document.body.style.zoom*=0.625;
}else{parent.myEditor.document.body.style.zoom=0.625;
}
}

function makeRectangularDropShadow(el, color, size, name){
  var i;
  for (i=size; i>0; i--){
    var rect = document.createElement('div');
    var rs = rect.style;
    rs.position = 'absolute';
    rs.left = (el.offsetLeft + i) + 'px';
    rs.top = (el.offsetTop + i) + 'px';
    rs.width = el.offsetWidth + 'px';
    rs.height = el.offsetHeight + 'px';
    rs.zIndex = el.style.zIndex - i;
    rs.backgroundColor = color;
    rect.shadow_name=name;
    var opacity = 1 - i / (i + 1);
    rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
    rect=el.insertAdjacentElement('afterEnd', rect);
    global.fo_shadows[global.fo_shadows.length] = rect.sourceIndex;
  }
}

function remove_shadow(name){
  d=parent.myEditor.document.all.tags('DIV');
  for(i=0;i<d.length;i++){
    if(d.item(i).shadow_name && d.item(i).shadow_name!='root'){
      d.item(i).style.display='none';
    }
  }
}

function checkDragStart(){
  event.dropEffect='move';
  event.dataTransfer.effectAllowed='copyMove';
  src=event.dataTransfer.getData('Text');
  if(!src){
    return false;
  }
}

function checkDragEnd(){
  var tr = parent.myEditor.document.selection.createRange();
  var tp = parent.myEditor.document.selection.type;
  event.dropEffect='move';
  event.dataTransfer.effectAllowed='copyMove';
  src=event.dataTransfer.getData('Text');
  if(src){
    if(tp=='Text'){
      tr.pasteHTML(src);
      tr.select();
      parent.myEditor.focus();
    }
  }
  event.dataTransfer.clearData();
  event.returnValue=false;
  return false;
}

function goHistory(id,doc_id){
  window.open('http://www.airbaltic.com/editor/?doc_id='+doc_id+'&history='+id,'frmain');
}

function buildHTMLTree(){
  var intParents = 0;
  var intIndent = 0;
  var strStruct = "<HTML><TITLE>Document Tree</TITLE>" +
    "<BODY style='background:menu'><TABLE BORDER=0 CELLPADDING=5><TR>";
  var elParent;
  for (var intLoop = 0; intLoop < parent.myEditor.document.all.length;intLoop++) {
    elParent = parent.myEditor.document.all[intLoop];
    while (elParent.tagName != "HTML") {
      intParents++;
      elParent = elParent.parentElement;
    }
    if (intParents > intIndent)
      strStruct +="<TABLE CELLPADDING='0' BORDER='0' CELLSPACING='0' style='1px solid black; '><TR>";
    else if (intParents < intIndent) {
      for (var intClose = intParents;intClose < intIndent; intClose++)
        strStruct += "</TABLE>";
    }
    intIndent = intParents;
    intParents = 0;
    strStruct += "<TD style='width:10px; font-family:verdana; font-size:8pt; color:#336699; text-transform:capitalize; border:1px solid black; padding:5px; background:white'";
    if(parent.myEditor.document.all[intLoop].attributes){
      var attr=parent.myEditor.document.all[intLoop].attributes;
      txt='<table>';
      txt+='<tr><td colspan=2 style="font-family:verdana; font-size:8pt; color:black;background-color:moccasin;"><b>'+parent.myEditor.document.all[intLoop].tagName+'</b></td></tr>';
      for(i=0;i<attr.length;i++){
        var oAttrib = attr[i];
        if(oAttrib.specified){
          txt+='<tr><td nowrap style="font-family:verdana; font-size:8pt; color:#336699;"><b>'+oAttrib.nodeName+'</b></td><td nowrap style="font-family:verdana; font-size:8pt; color:#336699;">'+oAttrib.nodeValue+'</td></tr>';
        }
      }
      txt+='</table>';
      strStruct +=" params='"+escape(txt)+"' onclick='paramsDiv.innerHTML=unescape(this.params);paramsDiv.style.top=event.clientY+document.body.scrollTop;paramsDiv.style.left=event.clientX+document.body.scrollLeft;event.cancelBubble=true;'";
    }
    strStruct +=">" +parent.myEditor.document.all[intLoop].tagName;
    strStruct +=(parent.myEditor.document.all[intLoop].tagName=='IMG'?" <img src='"+parent.myEditor.document.all[intLoop].src+"'>":'');
  }
  for (var intClose = intParents; intClose < intIndent;intClose++)
    strStruct += "</TD></TR></TABLE>";
  strStruct += "</BODY></HTML>";
  strStruct += "<div id='paramsDiv' style='position:absolute;border:1px solid black;background-color:white;padding:5px'></div>";
  var w = window.open("", "tree");
  w.document.open();
  w.document.write(strStruct);
  w.document.close();
}

function filterTags(){
try{
  tr=parent.myEditor.document.selection.createRange();
  srcElement=event.srcElement;
  parents[event.srcElement.sourceIndex]='';
  get_parents(event.srcElement.sourceIndex,event.srcElement.sourceIndex);
  par_arr=parents[event.srcElement.sourceIndex].split("\n");
  allow_tags='';
  for(r=0;r<par_arr.length;r++){
    ri=par_arr[r];
    if(!allow_tags){
      evl_str='allow_tags=parent.myEditor.document.all.item('+ri+').allow_tags;';
      eval(evl_str);
    }
  }
  doc=parent.myEditor.document;
  itm=doc.createElement("SPAN");
  itm.name="clipBoardInput";
  itm.style.position='absolute';
  itm.style.top='-1000px';
  itm.style.left='-1000px';
  itm.contentEditable='true';
  doc.body.appendChild(itm);
  itm.focus();
  doc.execCommand('Paste',false,null);
  itm.style.display='none';
  for(i=0;i<itm.all.length;i++){
    itm.all.item(i).removeAttribute('style');
    itm.all.item(i).removeAttribute('className');
    itm.all.item(i).removeAttribute('width');
    itm.all.item(i).removeAttribute('height');
    if(itm.all.item(i).tagName=='TABLE'){
      itm.all.item(i).name='myTable';
    }
  }
  for(i=itm.all.length-1;i>=0;i--){
    if(!foundTag(itm.all(i).tagName,allow_tags)){
      itm.all(i).removeNode();
    }
  }
  event.returnValue=false;
  event.cancelBubble=true;
  tr.pasteHTML(itm.innerHTML);
  itm.outerHTML='';
}
catch(e){
  alert('filterTags'+e);
}
}

function foundTag(tag,taglist){
  evl='tags=new Array('+taglist+');';
  eval(evl);
  arr='';
  for(k=0;k<tags.length;k++){
    arr+=TagsArray[tags[k]]+',';
    if(k<tags.length-k){
      arr+=',';
    }
  }
  filter=arr.split(',');
  for(j=0;j<filter.length;j++){
    if(tag==filter[j]){
      return true;
    }
  }
}

function moveArchive(){
  if(!firstTime){
    span=archData.window.document.all.tags('SPAN');
    root=parent.myEditor.window.document.all.tags('SPAN');
    for(i=0;i<span.length;i++){
      for(j=0;j<root.length;j++){
        if(root[j].name==span[i].name){
          root[j].innerHTML=span[i].innerHTML;
        }
      }
    }
    //parent.myEditor.getSpanOptions();
    parent.myEditor.highlightEditable();
  }else{
    firstTime=0;
  }
}

function removetags_selected(){
  tr=parent.myEditor.document.selection.createRange();
  tr.pasteHTML(tr.text);
}

function checkKeyDown(){
try{
  var del_elem=false;
  if(parent.myEditor.document.selection.type!='Control'){
    tr=parent.myEditor.document.selection.createRange();
    pr=tr.parentElement();
    if(pr.tagName=='TD' && window.event.keyCode==9){     // tab key
      if(pr.cellIndex==(pr.parentElement.cells.length-1) && pr.parentElement.rowIndex==(pr.parentElement.parentElement.rows.length-1)){
        tr_append(pr.parentElement.rowIndex,pr.parentElement.parentNode.sourceIndex);
        element=pr.parentElement.nextSibling.firstChild;
      }else{
        if(pr.nextSibling){
          element=pr.nextSibling;
        }else{
          element=pr.parentElement.nextSibling.firstChild;
        }
      }
    }
    if(pr.tagName=='TD' && window.event.keyCode==8){     // backspace key
      if(pr.cellIndex==0){
        txt=pr.parentElement.innerText;
        if(!txt && pr.parentElement.tagName=='TR'){
          element=pr.parentElement.previousSibling.firstChild;
          del_elem=pr.parentElement.parentElement.parentElement;
        }
      }
    }
    if(element){
      element.fireEvent('onmousemove');
      oInp=document.createElement("INPUT");
      oInp.type="text";
      oInp.style.position="absolute";
      oInp.style.top="-100px";
      element.appendChild(oInp);
      oInp.focus();
      oInp.removeNode();
      window.event.cancelBubble=true;
      window.event.returnValue=false;
      element=false;
    }
    if(del_elem){
      del_elem.deleteRow(pr.parentElement.rowIndex);
    }
  }
}
catch(e){
  alert('checkKeyDown:'+e);
}
}

function checkKeyUp(){
  if(parent.myEditor.document.selection.type!='Control'){
    tr=parent.myEditor.document.selection.createRange();
    pr=tr.parentElement();
    if(pr.tagName=='TD' && (window.event.keyCode==37 || window.event.keyCode==38 || window.event.keyCode==39 || window.event.keyCode==40)){
      pr.fireEvent('onmousemove');
    }
  }
}

function deleteFile(id,type,el){
  fel=parent.myEditor.document.forms['customForm'];
  doc=parent.myEditor.document;
  tags=parent.myEditor.document.forms['customForm'].tags('INPUT');
  found=false;
  remove=false;
  for(i=0;i<tags.length;i++){
    if(tags.item(i).name=='del_'+id){
      remove=tags.item(i);
      found=true;
      el.parentElement.runtimeStyle.backgroundColor="";
    }
  }
  if(remove){
    remove.removeNode();
  }
  if(!found){
    el.parentElement.runtimeStyle.backgroundColor="darkgray";
    itm=doc.createElement("INPUT");
    itm.name='del_'+id;
    itm.type='hidden';
    fel.appendChild(itm);
    itm.value=id;
  }
}

function moveFile(tp,el,type){
  el1=el.parentElement.parentElement;
  if(tp=='up'){
    el2=el.parentElement.parentElement.previousSibling;
  }
  if(tp=='down'){
    el2=el.parentElement.parentElement.nextSibling;
  }
  txt1=el1.childNodes.item(1).innerHTML;
  txt2=el2.childNodes.item(1).innerHTML;
  el1.swapNode(el2);
  el2.childNodes.item(1).innerHTML=txt1;
  el1.childNodes.item(1).innerHTML=txt2;
  fel=parent.myEditor.document.forms['customForm'];
  tags=fel.tags('INPUT');
  txt='';
  for(i=0;i<tags.length;i++){
    if(tags.item(i).id=='id'+type){
      txt+=tags.item(i).value+',';
    }
  }
  txt=txt.substr(0,txt.length-1);
  eval_str="parent.myEditor.document.forms['customForm'].ids"+type+".value='"+txt+"';";
  eval(eval_str);
}

function trim(val) {
  var cnt=val.length;
  var begin=0;
  for(i=0;i<cnt;i++) {if(val.substr(i,1)!=' ') {begin=i;break;}}
  for(i=cnt;i<0;i--) {if(val.substr(i,1)!=' ') {cnt=i;break;}}
  return val.substring(begin,cnt);
}

function getDiscuss(inp){
  var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=6&title=Choose+discussion&id='+inp.value,"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret && document.forms[0].discuss_text){
    document.forms[0].discuss_text.value=ret['name'];
  }
  if(ret){
    inp.value=ret['id'];
  }
}

function getDialog(type,inp,url,id){
  if(type=='picture'){
    var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=pic_explorer.php&title=Get picture (gif,jpg,swf)",window,"dialogWidth:800px; dialogHeight:500px; status:off;scroll:no;help:off;");
  }
  if(type=='file'){
    doc_id=0;
    o=parent.myEditor.document.all.tags('SPAN');
    for(i=0;i<o.length;i++){
      if(o.item(0).doc_id){
        doc_id=o.item(0).doc_id;
      }
    }
    var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=file_explorer.php&title=Get file (doc,xls,zip,pdf,ppt,pps)&id="+doc_id,window,"dialogWidth:500px; dialogHeight:500px; status:off;scroll:no;help:off;");
  }
  if(type=='link'){
    var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=1&title=Insert link&id='+id,"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
    if(ret && document.all[inp.name+'_description']){
      val=ret['name'];
      val=val.substr(1,val.length-1);
      document.all[inp.name+'_description'].value=val;
    }
  }
  if(type=='richtext'){
    width=inp.parentElement.parentElement.parentElement.parentElement.parentElement.pwidth;
    height=inp.parentElement.parentElement.parentElement.parentElement.parentElement.pheight;
    field=inp.parentElement.parentElement.parentElement.parentElement.parentElement.field;
    var ret=showModalDialog('http://www.airbaltic.com/editor/richtext_popup.php?compact_mode=true&external=true&rich_id=26814&field='+field,window,"dialogWidth:"+width+"px; dialogHeight:"+height+"px; status:off; scroll:no;help:off;");
  }
  if(type=='custom_options'){
    var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame="+url,window,"dialogWidth:24em; dialogHeight:14em; status:off; scroll:no;help:off;");
  }
  if(type=='date'){
    var oDay=inp.all.tags('INPUT').item(0);
    var oMonth=inp.all.tags('INPUT').item(1);
    var oYear=inp.all.tags('INPUT').item(2);
    if(!oDay.value || !oMonth.value || !oYear.value){
      oDate=new Date();
    }else{
      oDate=new Date(oYear.value,oMonth.value-1,oDay.value);
    }
    selDate=inp;
    var oPopupBody = datePop.document.body;
    oPopupBody.innerHTML = getCal(oDate.getDate(),oDate.getMonth(),oDate.getYear());
    datePop.show(0, 20, 166, 150, inp);
  }
  if(ret){
    inp.value=ret['id'];
  }
}

function showCal(day, mon, year){
  if(mon==-1){
    mon=11;
    year--;
  }
  if(mon==12){
    mon=0;
    year++;
  }
  if(year<200){year+=1900;}
  if(selDate){
    selDate.all.tags('INPUT').item(0).value=addNull(day);
    selDate.all.tags('INPUT').item(1).value=addNull(mon+1);
    selDate.all.tags('INPUT').item(2).value=year;
  }
  try{
    datePop.document.body.innerHTML = getCal(day,mon,year);
  }
  catch(e){
  }
}

function addNull(str){
  if(str.toString().length==1){
    return '0'+str;
  }else{
    return str;
  }
}

function getCal(selectedDay,mn,yr){
  if(yr<100){yr+=1900;}

  var today=new Date();
  oDate=new Date(yr,mn,selectedDay);

  var aMon=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  var aDays=new Array ("Mon","Tue","Wed","Thu","Fri","Sat","Sun");

  var style1='background-color:buttonface;border:1px solid buttonshadow;font-family:Verdana;font-size:14px;font-weight:bold;text-align:center;width:20px;cursor:hand';
  var style2='background-color:buttonshadow;color:white;font-family:Verdana;font-size:12px';
  var style3='background-color:buttonface;border:1px solid buttonshadow;font-family:Verdana;font-size:12px;width:80px;cursor:hand';
  var style4='font-family:Verdana;font-size:10px;cursor:hand;text-align:center';
  var mouseAct=' onmouseover="this.style.backgroundColor=\'buttonface\'" onmouseout="this.style.backgroundColor=\'\'"';
  var mouseActTop=' onmouseover="this.style.backgroundColor=\'buttonhighlight\'" onmouseout="this.style.backgroundColor=\'buttonface\'"';

  var ret_txt='<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" bgcolor="buttonhighlight" style="border:1px solid buttonshadow" onselectstart="return false;"><tr><td valign="top">';
  ret_txt+='<table border="0" cellspacing="0" cellpadding="0" width="100%">';
  ret_txt+='<tr><th colspan="5" align="middle" style="'+style2+'">'+oDate.getDate()+' '+aMon[oDate.getMonth()]+', '+oDate.getYear()+'</th></tr>';
  ret_txt+='<tr><td style="'+style1+'" title="Previeous year" '+mouseActTop+' onclick="parent.window.showCal('+oDate.getDate()+','+oDate.getMonth()+','+(oDate.getYear()-1)+')">«</td>';
  ret_txt+='<td align="center" style="'+style1+'" title="Previeous month"'+mouseActTop+' onclick="parent.window.showCal('+oDate.getDate()+','+(oDate.getMonth()-1)+','+oDate.getYear()+')">‹</td>';
  ret_txt+='<td align="center" style="'+style3+'"'+mouseActTop+' onclick="parent.window.showCal('+today.getDate()+','+today.getMonth()+','+today.getYear()+')">today</td>';
  ret_txt+='<td style="'+style1+'" title="Next month"'+mouseActTop+' onclick="parent.window.showCal('+oDate.getDate()+','+(oDate.getMonth()+1)+','+oDate.getYear()+')">›</td>';
  ret_txt+='<td style="'+style1+'" title="Next year"'+mouseActTop+' onclick="parent.window.showCal('+oDate.getDate()+','+oDate.getMonth()+','+(oDate.getYear()+1)+')">»</td></tr>';
  ret_txt+='<tr><td colspan="5">';
  ret_txt+='<table border="0" cellspacing="0" cellpadding="1">'+"\n<tr>\n";
  for(i=0;i<7;i++){
    ret_txt+='<td width="20" style="'+style4+'"><b>'+aDays[i]+'</b><br><img src="../img/none.gif" width="20" height="1"></td>'+"\n";
  }
  ret_txt+="</tr>\n";
  start=new Date(yr,mn,1);
  startday=start.getDay();
  if(startday==0){startday=7;}
  nxt_yr=yr;
  nxt_mon=mn+1;
  if(nxt_mon>11){nxt_mon=0;nxt_yr++;}
  end=new Date(nxt_yr,nxt_mon,1);
  dayCount=Math.round((parseInt(end.valueOf())-parseInt(start.valueOf()))/(1000*60*60*24));
  ret_txt+="<tr>\n";
  if(startday<=7){
    for(i=1;i<startday;i++){
      ret_txt+="<td style=\""+style4+"\">&nbsp;</td>\n";
    }
  }
  counter=startday;
  for(i=1;i<=dayCount;i++){
    counter++;
    ret_txt+='<td style="'+style4+'"'+mouseAct+' onclick="parent.window.showCal('+i+','+oDate.getMonth()+','+oDate.getYear()+')">'+((counter==7 || counter==8)?'<font color="red">':'')+(selectedDay==i?'<b>'+i+'</b>':i)+((counter==7 || counter==8)?'</font>':'')+"</td>\n";
    if(counter>=8){
      counter=1;
      ret_txt+="</tr><tr>\n";
    }
  }
  for(i=1;i<=(8-counter);i++){
    ret_txt+="<td style=\""+style4+"\">&nbsp;</td>\n";
  }
  ret_txt+='</tr></table>';
  ret_txt+='</td></tr>';
  ret_txt+='</table>';
  ret_txt+='</td></tr></table>';
  return ret_txt;
}

function load(){
  dpd=document.all.tags('SELECT');
  for(i=0;i<dpd.length;i++){
    if(dpd.item(i).subselect){
      dpd.item(i).style.top=(dpd.item(i).offsetTop-3)+'px';
      dpd.item(i).style.left=(dpd.item(i).offsetLeft-1)+'px';
      dpd.item(i).style.display='none';
    }
  }
}
function showDropdown(inp){
  document.all(inp+'_select').value=document.all(inp).value;
  document.all(inp+'_select').style.display='inline';
  document.all(inp+'_select').focus();
}
function hideDropdown(inp){
  document.all(inp).value=document.all(inp+'_select').value;
  document.all(inp+'_select').style.display='none';
}

function picLink(){
  var tp=parent.myEditor.document.selection.type;
  var tr = parent.myEditor.document.selection.createRange()
  o=parent.myEditor.document.all.tags('SPAN');
  for(i=0;i<o.length;i++){
    if(o.item(0).doc_id){
      doc_id=o.item(0).doc_id;
    }
  }
  var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=pic_explorer.php&title=Get popup picture (gif,jpg,swf)&id="+doc_id,window,"dialogWidth:800px; dialogHeight:500px; status:off;scroll:no;help:off;");
  if(tp=='Text'){
    if (ret != null) {
      tr.execCommand('Unlink',false,0)
      if(ret['id']){
        tr.pasteHTML('<a href="javascript:void(0)" onclick="window.open(\'/upload_pic/'+ret['id']+'\',\'imgpopup\',\'width='+(parseInt(ret['w'])+20)+',height='+(parseInt(ret['h'])+20)+',resizable=no,status=no,toolbar=no,menubar=no,location=no\');">'+tr.text+'</a>');
      }
      tr.select();
    }
  }
  if(tp=='Control'){
    if (ret != null) {
      itm=tr.item(0);
      itmp=itm.parentNode;
      if((itm.tagName+' '+itmp.tagName=='BDO A')||(itm.tagName+' '+itmp.tagName=='IMG A')){
        itmp.removeNode();
        itmp=itm.parentNode;
      }
      if((itm.tagName=='BDO' && itm.className=='insertedBDO')||itm.tagName=='IMG'){
        if(ret['id']){
          itm.outerHTML='<a href="javascript:void(0)" onclick="window.open(\'/upload_pic/'+ret['id']+'\',\'imgpopup\',\'width='+(parseInt(ret['w'])+20)+',height='+(parseInt(ret['h'])+20)+',resizable=no,status=no,toolbar=no,menubar=no,location=no\');">'+itm.outerHTML+'</a>';
        }
      }else{
        alert(itm.tagName+' '+itmp.tagName+' : Link unavailable ');
      }
    }
  }
}

function getEditorPopup(id,width,height){
  var ret=showModalDialog('http://www.airbaltic.com/editor/popup.php?doc_id='+id+"&compact_mode=true&external=true",window,"dialogWidth:"+(width+4)+"px; dialogHeight:"+(height+4)+"px; status:off; scroll:no;help:off;");
}

function insertMacros(){
  var tr = parent.myEditor.document.selection.createRange();
  var ret=showModalDialog("http://www.airbaltic.com/admin/dialog_frames.php?frame=macro_explorer.php&title=Insert macros",window,"dialogWidth:400px; dialogHeight:300px; status:off;scroll:no;help:off;");
  if(ret){
    tr.pasteHTML('<BDO class="insertedBDO" type="macro" contenteditable="false" real_id="">'+ret['code']+'</BDO>');
    tr.select();
    parent.myEditor.focus();
  }
}

function insertAmadeus(){
  var tr = parent.myEditor.document.selection.createRange();
  var ret=showModalDialog('http://www.airbaltic.com/admin/block_frames.php?ot=2&title=Insert mail',"","dialogWidth:35em; dialogHeight:20em; status:off; scroll:no;help:off;");
  if(ret){
    parent.myEditor.window.open("http://www.airbaltic.com/admin/mail_show.php?id="+ret['id'],"mailDiv");
  }
}


function mailPaste(){
try{
    var tr = parent.myEditor.document.selection.createRange();
    tr.pasteHTML(mailDiv.document.body.innerHTML);
    tr.select();
    parent.myEditor.focus();
}
catch(e){}
}

function activatePage(div){
  pages=pageSet.all.tags('TD');
  for(i=0;i<pages.length;i++){
    if(pages.item(i).relatedDiv){
      tds=pages.item(i).all.tags('TD');
      if(pages.item(i).relatedDiv!=div){
        eval(pages.item(i).relatedDiv+'.style.display="none";');
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).className="pageTab";
          }
          if(tds.item(j).name=="bottom"){
            tds.item(j).className="pageLightShadow";
          }
        }
      }else{
        eval(pages.item(i).relatedDiv+'.style.display="block";');
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).className="pageTabActive";
          }
          if(tds.item(j).name=="bottom"){
            tds.item(j).className="pageLightShadowActive";
          }
        }
      }
    }
  }
  for(i=0;i<pages.length;i++){
    if(pages.item(i).editor){
      tds=pages.item(i).all.tags('TD');
      if('tab'+pages.item(i).editor!=div){
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).className="pageTabEditor";
          }
          if(tds.item(j).name=="bottom"){
            tds.item(j).className="pageLightShadow";
          }
        }
      }else{
        try{
          parent.myEditor.swapModes(pages.item(i).editor);
        }
        catch(e){}
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).className="pageTabEditorActive";
          }
          if(tds.item(j).name=="bottom"){
            tds.item(j).className="pageLightShadowActive";
          }
        }
      }
    }
  }
}

function activateSmallPage(div){
  pages=pageSet.all.tags('TD');
  for(i=0;i<pages.length;i++){
    if(pages.item(i).relatedDiv){
      tds=pages.item(i).all.tags('TD');
      if(pages.item(i).relatedDiv!=div){
        eval(pages.item(i).relatedDiv+'.style.display="none";');
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).style.borderBottom='2px groove';
            tds.item(j).className="pageTab";
          }
        }
      }else{
        eval(pages.item(i).relatedDiv+'.style.display="block";');
        for(j=0;j<tds.length;j++){
          if(tds.item(j).name=="tab"){
            tds.item(j).className="pageTabActive";
            tds.item(j).style.borderBottom='2px solid menu';
          }
          if(tds.item(j).name=="bottom"){
            tds.item(j).className="pageLightShadowActive";
          }
        }
      }
    }
  }
}