var edwindow;
var jvwindow;
var editornum;


window.onerror = errorHandler;

function errorHandler(msg,url,lno)
{
var dummy='do nothing';
  return (true);
}



function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
















miurl = window.location;
parts = explodeArray(miurl,'_wit/',5);
if(parts[1]){
sparts = explodeArray(parts[1],'/',1);
pagina=sparts[0];
for (var i=0;i<parent.frames.length;i++) {
if (parent.frames[i].name == 'formDesignFrame'){
if(parent.frames[i].location=="/"){parent.window.close();}
//parent.frames[i].location.href='http://www.tropicalyachts.com';
parent.formDesignFrame.document.forms['general'].elements['pagetoadopt'].value=pagina;
}
}
}//if parts1



function explodeArray(item,delimiter,cuant) {
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+cuant,tempString.length-tempString.indexOf(delimiter)+cuant);
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;
}







function saveItAll(){
waitAnimation();
document.panel.submit();
}



//function replacecontent(){
//var x = document.getElementById('lageneral');
//var y = document.frames['dummyFrame'].window.document.getElementById('lageneral');
//x.innerHTML = y.innerHTML;
//resetStyleValuesMenu();
//}




function checkcopydirection(cosa)  {

if(!cosa){
Show_this('copychecks','SPAN','hide');Show_this('urls','SPAN','hide');
}else{

if(cosa=='URL'){Show_this('urls','SPAN','show');}

if(cosa=='export' || cosa=='import' || cosa=='switch' || cosa=='delete'){Show_this('copychecks','SPAN','show');}

}//de else

document.panel['copysystemdirection'].value=cosa;
}//end function



function checkCopyTo(element,valor)  {  //alert(element+' '+value);
var tot;var item;
tot = document.panel['copysystem'].value;

if(valor==false){
item = "||"+element+"&&true";
tot = tot.replace(item,"");
}else{tot += "||"+element+"&&"+valor;}

document.panel['copysystem'].value=tot;

}




function Show_this(theclass,thetag,theaction)
{
var vez=0;

        var x = document.getElementsByTagName(thetag);
        for (var i=0;i<x.length;i++){ //alert(theaction);
if (x[i].className == theclass){
if(theaction=='show'){x[i].style.display = '';}
if(theaction=='hide'){x[i].style.display = 'none';}
}}}


var tagstatus=0;
var mainsintags=0;
var maincontags=0;



function Show_edittags()
{
var vez=0;
        var x = document.getElementsByTagName('DIV');
        for (var i=0;i<x.length;i++){
if (x[i].className == 'edittags'){
if(x[i].style.display == 'none'){
x[i].style.display = '';

if (window.dotborder && x[i].id=='content'){  //alert('kokoko');
prin = document.getElementById('main00');
dd.getPageXY(prin);
maincontags=dd.y;
tagstatus=1;
}//if window

}else{
x[i].style.display = 'none';
tagstatus=0;
}
}}}
















function Show_Stuff(Click_Menu){
if (Click_Menu.style.display == "none"){Click_Menu.style.display = "";}else{Click_Menu.style.display = "none";}
}









function popchat(url) {
winchat = window.open(url, "chat", 'scrollbars=yes,resizable=yes,width=380,height=500');
if(window.focus){winchat.focus();}
}


function lookforThis(termino){
var xptotal; xptotal='';
XPD = document.getElementsByTagName('span');
for(i=0;i<XPD.length;i++){
miid = XPD[i].id;
myidRE = new RegExp("xptheme","g");
if (miid.match(myidRE)) {
thecontenido = XPD[i].innerHTML;
mytermino = new RegExp(termino,"i");
if (thecontenido.match(mytermino)) {
xptotal = xptotal+thecontenido;
}//if contenido match
}//if miid match
}//for i
        if (document.getElementById){
xpv = document.getElementById('xpresultado');
xpv.innerHTML = xptotal;}
        else if (document.all){
xpv = document.all['xpresultado'];
xpv.innerHTML = xptotal;}
}





function closeUploader() { //alert('marchando');
closeEditor();
if (jvwindow && jvwindow.open && !jvwindow.closed) {jvwindow.close();}
}


function openUploader(url) {
if (jvwindow && jvwindow.open && !jvwindow.closed){jvwindow.focus();}else{
  jvwindow = window.open(url, "uploader", 'scrollbars=yes,resizable=yes,width=500,height=120');
  }
}
function closeEditor() {
  if (edwindow && edwindow.open && !edwindow.closed) edwindow.close();
}


function openEditor(url,num) {
if (edwindow && edwindow.open && !edwindow.closed) {edwindow.close();}
//if (edwindow && edwindow.open && !edwindow.closed &&editornum==num){edwindow.focus();}else{
edwindow = window.open(url, "editor", 'scrollbars=yes,resizable=yes,width=800,height=660');
//editornum=num;
//}
}


function passentry(){
if(LayerWit.style.visibility=='visible'){LayerWit.style.visibility='hidden';}else{LayerWit.style.visibility='visible';}
}


//function pass(){
//var yourpass= prompt('Password:', ' ');
//if (yourpass){document.mipass.witsite.value=yourpass;
//document.mipass.submit();}
//}

function visitorpass(pagepass){
var vispass= prompt('Password:', ' ');
if (vispass==pagepass){LayerBlocker.style.visibility='hidden';}
}



function deletePage(msg,page) { //v3.0
var agree=confirm(msg+"\n"+page);
if (agree){
document.panel.dodelete.value='yes';
saveItAll();
//window.location = url ;
}else{return false;}
}





function nohackers (ext,name,domain) {
window.document.location='mailto:'+name+'@'+domain+'.'+ext;
}
function mail(val) {
window.document.location=val;
}

function gotoURL(url) { //v3.0
window.location = url ;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}








viewport = {
  getWinWidth: function () {
    this.width = 0;
    if (window.innerWidth) this.width = window.innerWidth - 18;
    else if (document.documentElement && document.documentElement.clientWidth)
                  this.width = document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth)
                  this.width = document.body.clientWidth;
  },

  getWinHeight: function () {
    this.height = 0;
    if (window.innerHeight) this.height = window.innerHeight - 18;
          else if (document.documentElement && document.documentElement.clientHeight)
                  this.height = document.documentElement.clientHeight;
          else if (document.body && document.body.clientHeight)
                  this.height = document.body.clientHeight;
  },

  getScrollX: function () {
    this.scrollX = 0;
          if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;
          else if (document.documentElement && document.documentElement.scrollLeft)
                  this.scrollX = document.documentElement.scrollLeft;
          else if (document.body && document.body.scrollLeft)
                  this.scrollX = document.body.scrollLeft;
          else if (window.scrollX) this.scrollX = window.scrollX;
  },

  getScrollY: function () {
    this.scrollY = 0;
    if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
    else if (document.documentElement && document.documentElement.scrollTop)
                  this.scrollY = document.documentElement.scrollTop;
          else if (document.body && document.body.scrollTop)
                  this.scrollY = document.body.scrollTop;
          else if (window.scrollY) this.scrollY = window.scrollY;
  },

  getAll: function () {
    this.getWinWidth(); this.getWinHeight();
    this.getScrollX();  this.getScrollY();
  }

}



var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset
  offY: 7,   // vertical offset
  show: function(id, e) {

shutdownsubmenus();

    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);


  },

  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById)
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 1200);
  },

  position: function(mnu, e) {
    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;

    if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
      x = x - mnu.offsetWidth - this.offX;
    else x = x + this.offX;

    if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
      y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = y + this.offY;

    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    //this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
        document.getElementById(menuLayers.activeMenuID).style.visibility = 'visible';
  },

  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },

  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode )
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }

}






















function shutdownsubmenus(){  //alert('kokoko');
var x = document.getElementsByTagName('DIV');
myidRE = new RegExp("^Submn","g");
for (var i=0;i<x.length;i++){
miid=x[i].id;
if (miid.match(myidRE)){    //alert('kokoko');
document.getElementById(miid).style.visibility = 'hidden';
}}
}








var menuLayers2 = {
  timer: null,
  activeMenuID: null,
// offX: 4,   // horizontal offset
//offY: 6,   // vertical offset
  show: function(id, e) {     //alert('jijijijij');

shutdownsubmenus();

    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    viewport.getAll();
    this.position(mnu,e);




  },

  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById)
      this.timer = setTimeout("document.getElementById('"+menuLayers2.activeMenuID+"').style.visibility = 'hidden'", 1200);
  },

 position: function(mnu, e) {
  //  var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
   // var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;

   // if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
   //   x = x - mnu.offsetWidth - this.offX;
   // else x = x + this.offX;

   // if ( y + mnu.offsetHeight + this.offY > viewport.height + viewport.scrollY )
   //   y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? y - mnu.offsetHeight - this.offY : viewport.height + viewport.scrollY - mnu.offsetHeight;
   // else y = y + this.offY;

   // mnu.style.left = x + "px"; mnu.style.top = y + "px";
    //this.timer = setTimeout("document.getElementById('" + menuLayers2.activeMenuID + "').style.visibility = 'visible'", 200);
    document.getElementById(menuLayers2.activeMenuID).style.visibility = 'visible';


//var x = document.getElementsByTagName('DIV');
//myidRE = new RegExp("^Submn","g");
//for (var i=0;i<x.length;i++){
//miid=x[i].id;
//if (miid.match(myidRE) && miid!=id){
//document.getElementById(miid).style.visibility = 'hidden';
//}}




  },

  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers2.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers2.contained(toEl, mnu) ) menuLayers2.hide();
  },

  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode )
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers2.timer) clearTimeout(menuLayers2.timer);
  }

}