function checkForm(form) {
  var name= form.filename.value;
  if (name == null || name == "") {
    alert("No website name given");
    return false;
  }

  for (var i=0; i<names.length; i++) {
    if (name == names[i]) { 
        return confirm("Do you want to rewrite website "+name);
    }
  }

  if (names.length > 5) {
    alert("You cannot have more than 5 websites saved");
    return false;
  }
  return true;
}

function loadImages() {
  var im;
  for (var i=0; i<loadedSrc.length; i++) {
    im = new Image();
    im.src = loadedSrc[i];
  }
}


function swap(image_name, src_id) {
      if (states[src_id]==0) states[src_id]=1;
      else states[src_id]=0;
      document.images[image_name].src=loadedSrc[src_id*2+states[src_id]];
}

function showImage(image_name, src) {
      document.images[image_name].src=src;
}

function openWindow(url, target, features) {
   window.open(url, target, features);
}

function setImage(name, src) {
  document.images[name].src=src;
}

  function startPlugin(form, url, target) {
        form.plugin_url.value=url;
        form.action.value = 'plugin';
        if (target) form.target=target;
        form.submit();
  }

var isEdit = true;
function setPage(url) {
        sPlugin(url);
}

function sPlugin1(url) {
        if (this.document.forms[0]) { 
          this.document.forms[0].target="_parent"; 
        }
        return sPlugin(url);
}

function sPlugin2(url,name) {
  if (this.document.forms[name]) {
    if (this.checkForm_default != null) {
        if (!this.checkForm_default(true)) return;
    }
    return startPlugin(this.document.forms[name],url);
  }
  alert('leva');
  document.location.replace(url);
//  document.location.reload(true);
}

function sPlugin(url) {
  if (this.document.forms[0]) {
    if (this.checkForm_default != null) {
        if (!this.checkForm_default(true)) return;
    }
    return startPlugin(this.document.forms[0],url);
  }
  document.location.replace(url);
//  document.location.reload(true);
}

function mySubmit(page) {
  if (page.checkForm_default != null) {
        if (!page.checkForm_default(true)) return;
  } 
  page.document.forms[0].submit();
}


function pickColor(picker, name) {
  win = window.open(picker,'ColorPicker','alwaysRaised=yes,resizable=no,height=163,width=255,top=400,left=400,screenX=400,screenY=400,dependent=true');
  varname = name;
}

Number.prototype.toColor = function (num) {
  var d = num ? num.toString(16) : this.toString(16);
  while (d.length < 6) d = '0' + d;
  return '#' + d;
}

Number.prototype.invertColor = function () {
  if (this == 0xFFFFFF) {
      return '#000000';
  }
  var res = 0xFFFFFF ^ this;
  var sum = 0;
  for (var i = 0; i < 3; i++) {
       sum += Math.abs(((this >> (i*8)) & 0xFF) - ((res >> (i*8)) & 0xFF))
  }
  if (sum < 8) res = res & 0x0269CF;
  return this.toColor(res);
}

function setColor(name, value) {
  var f = document.forms[0][name];
  var c = Number('0x' + value.substring(1));
  f.value = value;
  f.style.color = c.invertColor();
  f.style.backgroundColor = value;
  var el = document.getElementById(name.replace(/\./g,'_')+'link');
  if (el) el.title = el.title.split(' ')[0] + ' ' + value;
}

function setBold(path, name) {
   swapSettings(name, path+"/head/icons/b_1.gif",
                        path+"/head/icons/b_2.gif")
}

function setItal(path, name) {
   swapSettings(name, path+"/head/icons/ital_1.gif",
                        path+"/head/icons/ital_2.gif")
}


      function oldBrowser() {
      if (navigator.appVersion[0]<4)
          return 1;      
      else
          return 0;
      }

      function explorer() {
      if (navigator.appName == "Microsoft Internet Explorer")
          return 1;
      else
          return 0;
      }

      function netscape() {
      if (navigator.appName == "Netscape")
          return 1;
      else
          return 0;
      }

function popup(page, name, w, h) {
      oldBrowser();
      var x=0,y=0,xo=0,yo=0;
      if (oldBrowser()) {
           return window.open(page,name,"directories=0,status=0,menubar=1,height="+h+
             ",width="+w+",resizable=0,scrollbars=1");
      }
      else if (netscape()) {
          x=window.outerWidth;
          y=window.outerHeight;      
          xo=Math.round((x-w)/2 + window.screenX);
          yo=Math.round((y-h)/2 + window.screenY);
          return window.open(page,name,"directories=0,status=0,menubar=0,height="+h+
             ",width="+w+",resizable=0,scrollbars=1,screenX="+xo+",screenY="+yo);
      }
      else if (explorer()) {
          x=document.body.clientWidth;
          y=document.body.clientHeight;
          xo=Math.round((x-w)/2 + window.screenLeft);
          yo=Math.round((y-h)/2 + window.screenTop);
          return window.open(page,name,"directories=0,status=0,menubar=0,height="+h+",width="+w+",resizable=0,scrollbars=1,left="+xo+",top="+yo);
      }
}

function showHelp(url) {
var win = popup(url, "HELP", 600,460);
if (win != null) win.focus();
}

function setUnder(path, name) {
   swapSettings(name, path+"/head/icons/under_1.gif",
                        path+"/head/icons/under_2.gif")
}

function setFontSize(path, name, position) {
  var el = document.forms[0][name];
  if (el.value == position) {
    document.images["img_"+name+position].src=path+"/head/icons/a"+position+"_1.gif";
    el.value="";
  } else {
    document.images["img_"+name+position].src=path+"/head/icons/a"+position+"_2.gif";
    if (el.value != "") document.images["img_"+name+el.value].src=path+"/head/icons/a"+el.value+"_1.gif";
    el.value = position;
  }
}
function swapSettings(name, src1, src2) {
  var im = document.images["img_"+name];
  var el = document.forms[0][name];
  if (el.value == "") {
        im.src=src2;
        el.value = "1";
  } else {
        im.src=src1;
        el.value = ""; 
  }
}

////////////////// Added by Max. ////////////// patched for netscape 6 and mozilla by Vova (09122001)
var browserName = navigator.appName;
var browserVer  = parseFloat(navigator.appVersion);
var NN = true;
var FTest = true;

if( ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)) || (browserVer >= 5)){
        NN = false;
}

function setText_skindefault(text){
	document.write('<span style="font-family: Tahoma, Arial, Helvetica, sans-serif;font-size: 11px;	color: #0068b9;vertical-align: 7px;" id="replaceme">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+text+'</span>');
}
function setText(text){
if (!NN) {
    document.write('<span id="replaceme">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+text+'</span>');
}
else {
    document.write('<layer name="replaceme"; left=100; top=72; width=300; height=20;><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+text+'</p></layer>');
}
};

function changeText(text){
if (!NN) {
        replacemeElement = document.getElementById("replaceme");
        replacemeElement.innerHTML='<span id="replaceme">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+text+'</span>';
}
 else {
        document.replaceme.document.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+text);
        document.replaceme.document.close();
}  
}

////////////////// Added by Max
