var menu_timeout;
var npp_select_timeout;
var search_timeout;
var request;

var fs;
var ct;
var px;
var ar;
var sx;
var mx;
var so;
var st = 0;
var rp = 20;
var gc;
var idn;
var ed;

/*--------------------------------------------------------------*/


function HighlightItemHover(id_to_light)
  {
  clearTimeout(menu_timeout);
  var id_segment = id_to_light.match(/(\w+)(\d+)/);
  for (var loop = 3; loop < 7; loop++)
    {
    var run_toplink =  "topmenulink" + loop;
    if (loop != id_segment[2])
      {
      document.getElementById(run_toplink).className = 'topmenulink';
      }
    else
      {
      document.getElementById(run_toplink).className = 'topmenulinkhover';
      }
    var run_submenu =  "topmenusubmenu" + loop;
    if (document.getElementById(run_submenu))
      {
      if (loop != id_segment[2])
        {
        document.getElementById(run_submenu).className = 'topmenusubmenu';
        }
      else
        {
        document.getElementById(run_submenu).className = 'topmenusubmenuvisible';
        }
      }
    }
  }

function TimeItemOut(id_to_out)
  {
  var id_segment = id_to_out.match(/(\w+)(\d+)/);
  menu_timeout = setTimeout("TurnoffItemOut(" + id_segment[2] + ")", 700);
  }

function TurnoffItemOut(id_nr_out)
  {
  var id_toplink = "topmenulink" + id_nr_out;
  var id_submenu = "topmenusubmenu" + id_nr_out;
    if (document.getElementById(id_submenu))
      {
      document.getElementById(id_submenu).className = 'topmenusubmenu';
      document.getElementById(id_toplink).className = 'topmenulink';
      }
    else
      {
      document.getElementById(id_toplink).className = 'topmenulink';
      }
  }

/*--------------------------------------------------------------*/

function HighlightSearch(id_to_light)
  {
  clearTimeout(search_timeout);
  var id_segment = id_to_light.match(/(\w+)(\d+)/);
  for (var loop = 0; loop < 6; loop++)
    {
    var run_search =  "search" + loop;
    if (loop != id_segment[2])
      {
      document.getElementById(run_search).className = 'searchtd';
      }
    else
      {
      document.getElementById(run_search).className = 'searchtdhover';
      }
    var run_subsearch =  "subsearch" + loop;
    if (document.getElementById(run_subsearch))
      {
      if (loop != id_segment[2])
        {
        document.getElementById(run_subsearch).className = 'subsearchtable';
        }
      else
        {
        document.getElementById(run_subsearch).className = 'subsearchtablevisible';
        }
      }
    }
  }

function KeepOnSearch(id_light_on)
  {
  var id_segment = id_light_on.match(/(\w+)(\d+)/);
  var id_subsearch =  "subsearch" + id_segment[2];
  if (document.getElementById(id_subsearch).className == 'subsearchtablevisible')
    clearTimeout(search_timeout);
  }

function TimeSearchOut(id_to_out)
  {
  var id_segment = id_to_out.match(/(\w+)(\d+)/);
  search_timeout = setTimeout("TurnoffSearchOut(" + id_segment[2] + ")", 700);
  }

function TurnoffSearchOut(id_nr_out)
  {
  var id_search = "search" + id_nr_out;
  var id_subsearch = "subsearch" + id_nr_out;
  document.getElementById(id_subsearch).className = 'subsearchtable';
  document.getElementById(id_search).className = 'searchtd';
  }

/*--------------------------------------------------------------*/

function ChangeLanguage(file)
  {
  var param_attach = '';
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  if (st > 0)
    param_attach += '&st=' + st;
  if (rp != 20)
    param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

  window.location.href = file + param_attach;
  }

/*-------------------------------------------------------------*/
function GoToFullView(language)
  {
  var param_attach = '?lang=' + language;
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;
  if (idn || ed)
    window.location.href = '../action/item.php' + param_attach;
  }
/*-------------------------------------------------------------*/
function GoToSearch(language,filepath)
  {
  var param_attach = '?lang=' + language;
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

    window.location.href = filepath + param_attach;
  }


/*-------------------------------------------------------------*/

function BackToSearch(language)
  {
  var param_attach = '?lang=' + language;
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  if (st > 0)
    param_attach += '&st=' + st;
  if (rp != 20)
    param_attach += '&rp=' + rp;

    window.location.href = '../action/search.php' + param_attach;
  }

/*-------------------------------------------------------------*/

function GetFileDoFunction(uri_name, the_function)
  {
  if (window.XMLHttpRequest && !(window.ActiveXObject))
    {
    try {request = new XMLHttpRequest();}
    catch(e) {request = false;}
    }
  else if(window.ActiveXObject)
    {
    try {request = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e)
      {
      try {request = new ActiveXObject("Microsoft.XMLHTTP");}
      catch(e) {request = false;}
      }
		}
  else if (!request && window.createRequest)
    {
    try {request = window.createRequest();}
    catch (e) {request=false;}
    }
    
  var theurl = uri_name + '&t=' + new Date().getTime();
  if (request)
    {
    request.open("GET", theurl, true);
    request.onreadystatechange = the_function;
    request.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeSearchListing(file_string)
  {
  var lang = file_string.match(/.*lang=(.{2}).*/);
  GetFileDoFunction(file_string,
    function()
      {
      if (request.readyState == 4)
        {
        if (request.status == 200)
          {
          document.getElementById('maincorerightcore').getElementsByTagName('td')[0].innerHTML =
            request.responseText;
          gc = request.getResponseHeader("gc");
          if (request.getResponseHeader("st"))
            st = request.getResponseHeader("st");
          UpdatePager(lang[1]);
          }
        else alert('Problems with the server');
        }
      else
        {
        document.getElementById('maincorerightcore').getElementsByTagName('td')[0].innerHTML =
          "<br>&nbsp;<br><img src='../images/loading.gif' border='0'/><br>&nbsp;<br><div><em>Loading...</em></div>";
        document.getElementById('maincorerightbottom').getElementsByTagName('td')[0].innerHTML = "&nbsp;";
        }
      });
  }



/*-------------------------------------------------------------*/

function SubmitAdvSearch(language)
  {
  var param_attach = '?lang=' + language;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  st = 0;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;

  MakeSearchListing('../action/write_search.php' + param_attach);
  }

/*-------------------------------------------------------------*/

function MostRecentSearch(language)
  {
  var param_attach = '?lang=' + language;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  so = '10d';
    param_attach += '&so=' + so;
  st = 0;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;

  MakeSearchListing('../action/write_search.php' + param_attach);
  }

/*-------------------------------------------------------------*/


function SubmitChosenPage(file_string)
  {
  var param_attach = '&rp=' + rp;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;

  MakeSearchListing(file_string + param_attach);
  }

/*-------------------------------------------------------------*/

function UpdatePager(language)
  {
  var param_attach = '?lang=' + language;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  param_attach += '&gc=' + gc;

  GetFileDoFunction('../action/write_pager.php' + param_attach,
    function()
      {
      if (request.readyState == 4)
        {
        if (request.status == 200)
          {
          document.getElementById('maincorerightbottom').getElementsByTagName('td')[0].innerHTML =
            request.responseText;
          }
        else alert('Problems with the server');
        }
      else
        {
        document.getElementById('maincorerightbottom').getElementsByTagName('td')[0].innerHTML = "...";
        }
      });
  }

/* ------------------------------------------------------------ */

function ToggleFontSize()
  {
  if (document.getElementById('body1').style.fontSize == '15px')
    {
    fs = '17px';
    document.getElementById('body1').style.fontSize = '17px';
    document.getElementById('topfontsize').firstChild.innerHTML =
      "<small>Font:&nbsp;</small>a&nbsp;<small>&#x2192;&nbsp;a</small>";
    document.getElementById('bottomfontsize').firstChild.innerHTML =
      "<small>Font:&nbsp;</small>a&nbsp;<small>&#x2192;&nbsp;a</small>";
    }
  else
    {
    fs = '';
    document.getElementById('body1').style.fontSize = '15px';
    document.getElementById('topfontsize').firstChild.innerHTML =
      "<small>Font:&nbsp;a&nbsp;&#x2192;</small>&nbsp;a";
    document.getElementById('bottomfontsize').firstChild.innerHTML =
      "<small>Font:&nbsp;a&nbsp;&#x2192;</small>&nbsp;a";
    }
  }
/* ------------------------------------------------------------ */

function ToggleItemSearch(close_str,open_str)
  {
  if (document.getElementById('itemsearch').className == 'itemsresulttable')
    {
    document.getElementById('itemsearch').className = 'itemsresulttablevisible';
    document.getElementById("togglesearchtable").innerHTML =close_str;
    }
  else if (document.getElementById('itemsearch').className == 'itemsresulttablevisible')
    {
    document.getElementById('itemsearch').className = 'itemsresulttable';
    document.getElementById("togglesearchtable").innerHTML =open_str;
    }
  }
/* ------------------------------------------------------------ */

function CreateRequest(req)
  {
  if (window.XMLHttpRequest && !(window.ActiveXObject))
    {
    try {req = new XMLHttpRequest();}
    catch(e) {req = false;}
    }
  else if(window.ActiveXObject)
    {
    try {req = new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e)
      {
      try {req = new ActiveXObject("Microsoft.XMLHTTP");}
      catch(e) {req = false;}
      }
		}
  else if (!req && window.createRequest)
    {
    try {req = window.createRequest();}
    catch (e) {req=false;}
    }
  return req;
  }

/* ------------------------------------------------------------ */


function MakeSearchItems(file_string)
  {
  var req1;
  req1 = CreateRequest(req1);

  var param_attach = '';
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

  var theurl = file_string + param_attach + '&t=' + new Date().getTime();
  if (req1)
    {
    req1.open("GET", theurl, true);
    req1.onreadystatechange = function()
      {
      if (req1.readyState == 4)
        {
        if (req1.status == 200)
          {
          document.getElementById('mainopening').getElementsByTagName('td')[0].innerHTML =
            req1.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req1.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeItemRow(file_string)
  {
  var req2;
  req2 = CreateRequest(req2);

  var param_attach = '';
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

  var theurl = file_string + param_attach + '&t=' + new Date().getTime();
  if (req2)
    {
    req2.open("GET", theurl, true);
    req2.onreadystatechange = function()
      {
      if (req2.readyState == 4)
        {
        if (req2.status == 200)
          {
          document.getElementById('maincorerighttop').getElementsByTagName('td')[0].innerHTML =
            req2.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req2.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/


function MakeCompRow(file_string)
  {
  var req3;
  req3 = CreateRequest(req3);

  var param_attach = '';
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

  var theurl = file_string + param_attach + '&t=' + new Date().getTime();
  if (req3)
    {
    req3.open("GET", theurl, true);
    req3.onreadystatechange = function()
      {
      if (req3.readyState == 4)
        {
        if (req3.status == 200)
          {
          document.getElementById('maincorerightcore').getElementsByTagName('td')[0].innerHTML =
            req3.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req3.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeFullView(file_string)
  {
  var req4;
  req4 = CreateRequest(req4);

  var param_attach = '';
  if (fs)
    param_attach += '&fs=' + fs;
  if (ct)
    param_attach += '&ct=' + ct;
  if (px)
    param_attach += '&px=' + px;
  if (ar)
    param_attach += '&ar=' + ar;
  if (sx)
    param_attach += '&sx=' + sx;
  if (mx)
    param_attach += '&mx=' + mx;
  if (so)
    param_attach += '&so=' + so;
  param_attach += '&st=' + st;
  param_attach += '&rp=' + rp;
  if (idn)
    param_attach += '&idn=' + idn;
  if (ed)
    param_attach += '&ed=' + ed;

  var theurl = file_string + param_attach + '&t=' + new Date().getTime();
  if (req4)
    {
    req4.open("GET", theurl, true);
    req4.onreadystatechange = function()
      {
      if (req4.readyState == 4)
        {
        if (req4.status == 200)
          {
          document.getElementById('maincorerightbottom').getElementsByTagName('td')[0].innerHTML =
            req4.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req4.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeItemImages(pn,language)
  {
  var req5;
  req5 = CreateRequest(req5);

  param_attach = '?lang=' + language + '&idn=' + idn;
  if (pn) param_attach += '&pn=' + pn;

  var theurl = '../action/write_item_images.php' + param_attach + '&t=' + new Date().getTime();
  if (req5)
    {
    req5.open("GET", theurl, true);
    req5.onreadystatechange = function()
      {
      if (req5.readyState == 4)
        {
        if (req5.status == 200)
          {
          document.getElementById('maincoreleft').getElementsByTagName('td')[0].innerHTML =
            req5.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req5.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeGallery(language)
  {
  var req6;
  req6 = CreateRequest(req6);

  param_attach = '?lang=' + language;
  if (idn) param_attach += '&idn=' + idn;

  var theurl = '../action/write_gallery.php' + param_attach + '&t=' + new Date().getTime();
  if (req6)
    {
    req6.open("GET", theurl, true);
    req6.onreadystatechange = function()
      {
      if (req6.readyState == 4)
        {
        if (req6.status == 200)
          {
          document.getElementById('mainopening').getElementsByTagName('td')[0].innerHTML =
            req6.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req6.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeRpp(file_string)
  {
  var req7;
  req7 = CreateRequest(req7);

  var theurl = file_string + '&rp=' + rp +'&t=' + new Date().getTime();
  if (req7)
    {
    req7.open("GET", theurl, true);
    req7.onreadystatechange = function()
      {
      if (req7.readyState == 4)
        {
        if (req7.status == 200)
          {
          document.getElementById('maincorerighttop').getElementsByTagName('td')[0].innerHTML =
            req7.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req7.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeLeftSearch(file_string)
  {
  var req8;
  req8 = CreateRequest(req8);

  var theurl = file_string + '&t=' + new Date().getTime();
  if (req8)
    {
    req8.open("GET", theurl, true);
    req8.onreadystatechange = function()
      {
      if (req8.readyState == 4)
        {
        if (req8.status == 200)
          {
          document.getElementById('maincoreleft').getElementsByTagName('td')[0].innerHTML =
            req8.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req8.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function MakeContacts(language)
  {
  var req9;
  req9 = CreateRequest(req9);
  var theurl = '../action/write_contacts.php?lang=' + language + '&t=' + new Date().getTime();
  if (req9)
    {
    req9.open("GET", theurl, true);
    req9.onreadystatechange = function()
      {
      if (req9.readyState == 4)
        {
        if (req9.status == 200)
          {
          document.getElementById('mainopening').getElementsByTagName('td')[0].innerHTML =
            req9.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req9.send("");
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/

function CallEmailWrite(name,email,message,lang)
  {
  var req11;
  req11 = CreateRequest(req11);
  var mex = 'lang=' + lang + '&nam=' + name + '&eml=' + email + '&msg=' + message;
  var theurl = '../action/write_contacts_email.php';
  if (req11)
    {
    req11.open("POST", theurl, true);
    req11.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
    req11.onreadystatechange = function()
      {
      if (req11.readyState == 4)
        {
        if (req11.status == 200)
          {
          document.getElementById('maincorerightbottom').getElementsByTagName('td')[0].innerHTML =
            req11.responseText;
          }
        else alert('Problems with the server');
        }
      };
    req11.send(mex);
    }
  else
    {
    alert('Ajax not working');
    }
  }

/*-------------------------------------------------------------*/




