/* javascript supplied by Euro Business Enterprises Ltd - ebewebdesign.co.uk */

function loadContent(url,id,append)
{
  var xmlHttp;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }

  catch (e)
  {
    // Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }

    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }

      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }

  xmlHttp.onreadystatechange=function()
  {
    if(xmlHttp.readyState==4)
    {
      if(append==1)
      {
        var foo = document.getElementById(id);
        var option = document.createElement('div');
        option.innerHTML = xmlHttp.responseText;
        foo.appendChild(option); 

      }
      else
      {
        document.getElementById(id).innerHTML=xmlHttp.responseText;
      }
    }
  }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}



function loadImage(url,id)
{
  document.getElementById(id).src=url;
}

function selectFile(id,url) {
  document.getElementById('lf_url'+idTa).value = url;
  document.getElementById('if_url'+idTa).value = url;
  document.getElementById(id).style.visibility = "hidden";
  document.getElementById(id).style.display = "none";
}

function checkit(url)
{
  var ok=confirm('Are you sure you want to delete this item?');
  if(ok)
  {
    window.location = url;
  }
}

function checkAjax()
{
  var ok=confirm('Are you sure you want to delete this item?');
  if(ok)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function deletefile(url,id)
{
  var ok=confirm('Are you sure you want to delete this item?');
  if(ok)
  {
    loadContent(url,id);
  }
}


function loadText(newtext,id)
{
  document.getElementById(id).value = newtext;
}


function go(url)
{
    window.location = url;
}

function setFocus(id)
{
  var field = document.getElementById( id );
    if ( field ) 
    {
      field.focus();    // May throw "Permission denied" (uncatchable)
    }
}




function submitForm(formname)
{
  document.getElementById(formname).submit();
}




function checkSubmit(url,checkid)
{
if(document.getElementById(checkid).checked)
{
  var ok=confirm('Are you sure you want to send the newsletter?');
  if(ok)
  {
    return;
  }
  else
  {
    window.location = url;
    return false;
  }
}

}




function submenuOn(theDiv) 
{
  parentDiv = theDiv.substr(0,theDiv.length - 4);

  leftMargin = document.getElementById(parentDiv).offsetLeft;

  document.getElementById(theDiv).style.marginLeft = leftMargin+"px";


  if(typeof(currentdiv) != 'undefined')
  {
    var previouselem = document.getElementById(currentdiv);
    previouselem.style.visibility = "hidden";
  }

  if(typeof(currenttimeout) != 'undefined')
  {
    clearTimeout(currenttimeout);
  }

  var elem = document.getElementById(theDiv);
  elem.style.visibility = "visible";
}

function submenuOff(theDiv) 
{
  var elem = document.getElementById(theDiv);
  elem.style.visibility = "hidden";
}

function submenuOffTimer(theDiv) 
{
  currenttimeout = setTimeout("submenuOff('"+theDiv+"')", 500); // after 1 sec
  currentdiv = theDiv;
}




function showDiv(theDiv)
{
  var elem = document.getElementById(theDiv);
  elem.style.visibility = "visible";
  return;
}

function hideDiv(theDiv)
{
  var elem = document.getElementById(theDiv);
  elem.style.visibility = "hidden";
  return;
}

function showHide(id,on_off)
{
  // takes id of calling object, whether it is on or off, and also id of object to focus on when set to on

  if(typeof(on_off) != 'undefined')
  {
    imageChange = on_off;
  }
  else
  {
    imageChange = "on";
  }

  var d = document.getElementById(id);

  if (d.style.visibility == "visible") 
  {
    d.style.visibility="hidden"; d.style.display="none"; 
    d.style.height="1px";
  }
  else
  {
    d.style.visibility="visible"; d.style.display='';
    d.style.height="auto";
  }
}

function PrintContent(ctrl) 
{ 
  var dataToPrint = document.getElementById(ctrl).innerHTML; 
   
  var winprint=window.open("","","toolbar=yes,location=no,directories=yes,menubar=no,scrollbars=yes,width=560,height=400,left=100,top=25"); 
  winprint.document.open(); 
  winprint.document.write('<html><link href=scripts/styles.css rel=stylesheet><body>'); 
  winprint.document.write(dataToPrint);          
  winprint.document.write('</body></html>'); 
  winprint.document.close(); 
  winprint.focus(); 

  winprint.print();
  winprint.close();
}

