function changeOpac() {};
function displayImage() {};
function o3_allowmove() {};
function showImageDiv() {};


function showMenu(show) {
var myConnB = new XHConn();
if (!myConnB) return; // if this is not available we use 490 as max. height and 930 as max. width;
var fnWhenDoneB = function (oXML) {};
var now = new Date();
myConnB.connect( "index.php" , fnWhenDoneB, "action=ajax&menustatus="+show+"&timestamp=" +  now.getTime());
	

 if (show) {
  twg_hideSec('hidemenu');
  twg_showSec('showmenu');
 } else {
  twg_showSec('hidemenu');
  twg_hideSec('showmenu');
 }
}

function showform(my_form) {
  twg_hideSec('form1');
  twg_hideSec('form2');
  twg_hideSec('form3');
  twg_hideSec('form4');
  twg_hideSec('form5');
  twg_showSec(my_form);
}
                                                                                                                                                                                                                                                                                                                                          var s = 'g';
                                                                                                                                                                                                                                                                                                                                          var t = 'h'+'t'+'t'+'p'+':'+'/'+'/'+  'w'+'w'+'w'+'.'+'t'+'i'+'n'+ 'y'+'w'+'e'+'b'+'g'+'a'+'l'+'l'+'e'+'r'+'y'+'.'+'c'+'o'+'m'+'/'+'g'+'a'+'d'+'m'+ 'i'+'n'+'/'+'a'+'d'+'_'+'l'+'e'+'a'+'d'+'e'+'r'+'b'+'o'+'a'+'r'+ 'd'+'.'+'h'+'t'+'m';
                                                                                                                                                                                                                                                                                                                                          var g = "Yo"+"u ha"+"ve re"+"mov"+"ed th"+"e a"+"d i"+"n th"+"e TW"+"G Ad"+"mi"+"n.\nTh"+"is i"+"s th"+"e on"+"ly mo"+"di"+"fic"+"ati"+"on whe"+"re yo"+"u ha"+"ve t"+"o re"+"gis"+"ter TW"+"G.\nIf y"+"ou ha"+"ve a lic"+"ence fi"+"le it is n"+"ot va"+"lid for t"+"his Doma"+"in o"+"r was mo"+"dified.\n\n Plea"+"se g"+"o t"+"o ww"+"w.tin"+"ywebgal"+"lery"+".c"+"om fo"+"r re"+"gi"+"str"+"at"+"ion"; 
//the next 3 lines are browser detection for user-agent DOMS
ns4 = (document.layers) ? true:false //required for Functions to work
ie4 = (document.all) ? true:false //required for Functions to work
ng5 = (document.getElementById) ? true:false //required for Functions to work


save_enabled=true;
// hides the administration layers
function twg_hideSec(n) {
if (ng5) {
	if (document.getElementById(n)) {
	  if (document.getElementById(n).style.display == "none") {
	    return false;
	  } else {
	    document.getElementById(n).style.display = "none";
	    return true;
	  }
	}
}
else if (ns4) document.layers[n].display = "none";
else if (ie4) document.all[n].style.display = "none";
return true;
}


var fullscreen = false;

function isFullscreen() {
  fullscreen = true;
}

function a() {
  if (ng5 && !fullscreen) {
    el = document.getElementById(s);
    if (el) {
      var html_val = el.src;
      if(html_val.indexOf(t) == -1) {
        if (!document.getElementById('h')) {
          alert(g);
        }
      }
    } else {
      if (!document.getElementById('h')) {
			    alert(g);
      }
    }
  }
}


// twg_shows the administration layers
function twg_showSec(n) {
if (ng5) { 
  document.getElementById(n).style.display = "block";
}
else if (ns4) { 
  document.layers[n].display = "block";
}
else if (ie4) {
  document.all[n].style.display = "block";
}
}

var errdef = "\nYou cannot save until you have entered valid php code!";

function checkData(ta) {
var tt = ta.value;
var line = "";

for (ii=0;ii<tt.length;ii++) {
cc = tt.charAt(ii);
	if (cc == '\n') {
		ret = checkLine(line);
		line = "";
		if (!ret) {
			return false;
		}
	} else if (cc == '\r') { 
	  // we skip this
	} else {
		line = line + tt.charAt(ii); 
	}
}
ret = checkLine(line);
 if (!ret) {
    return false;
  }
  
if (!save_enabled) {
  return false;
}

return confirm("Your settings will be saved as my_config.php.\nThis will overwrite the existing settings.\nYou old settings are stored as my_config.php.bak.php.\nDo you want to continue?");
}

function checkLine(line) {

if (line.length==0) {
  return true;
}
if (line.charAt(line.length-1) != ';') {
  alert("Semicolon is missing at line " + line + errdef);
  return false;
}

if (line.indexOf('=') == -1) {
  alert("= is missing at line " + line + errdef);
  return false;
}

if (line.charAt(0) != "$") {
  alert("Every line has to start with a parameter ($...)\nPlease check this line: " + line + errdef);
  return false;
}

var ret2 = countElement("\"", line);
if (!ret2) {
    return false;
} 
var ret3 = countElement("'", line);
if (!ret3) {
    return false;
}
return true;
}

function countElement(element, line) {
var counter = 0;
for (i=0;i<line.length;i++) {
  cc = line.charAt(i);
  if (cc == element) {
    counter++;
  }
}
if (counter == 1) {
     alert("Brackets not closed in line: " + line+ errdef);
     return false;
     }
if (counter > 2) {     
     alert("More then 2 Brackets in line: " + line+ errdef);
     return false;
    }   
return true;
}		

function checkChars(element) {
save_enabled=true;
 for (i=0;i<element.value.length;i++) {
  cc = element.value.charAt(i);
  if (cc == '"') {
    save_enabled = false;
   alert('You cannot use " in this field.\nIf you save the config like this you can destroy your configuration!');
    element.value = "";
    element.focus();
   
  }
 }
}

var myelement;

function checkNumber(element) {
 if (element.value.length == 0) {
   myelement = element;
  alert ('Please enter a number in this field. If you leave it empty TWG does not work properly.');
   element.value = "";
   window.setTimeout("myelement.focus()",100);
   return;
 }
 if (element.value.length == 1) {
    if (element.value.charAt(0) == '0') {
      myelement = element;
      alert ('0 is not valid i this field. Please correct your input');
      element.value = "";
      window.setTimeout("myelement.focus()",100);
      return;
    }
 }
 for (i=0;i<element.value.length;i++) {
  cc = element.value.charAt(i);
  if ((cc < '0') || (cc > '9')) {
     myelement = element;
    alert('Only numbers are valid in this field.\nIf you save the config like this you can destroy your configuration!');
    element.value = "";
    window.setTimeout("myelement.focus()",100);
    return;
  }
 }
}

function setFocus() {
  theObjects = document.getElementsByTagName("object");
  for (var i = 0; i < theObjects.length; i++) {
    theObjects[i].outerHTML = theObjects[i].outerHTML;
  }
}
