//______________________________________________________________________
// GENERAL FUNCTIONS USED BY UTILITIES & INPUT FORMS




/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmark_page(url,title){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}




function openWin(url)
{
  newwindow=window.open(url,"newwindow","width=800,height=550,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
  return true;  
}

var goodName = 0;
var error_badName = 1;
var error_twoNames = 2;
var error_noName = 3;

function checkName(obj)
{
  var strName = obj.value;
  var badChars = "!,£$%^()_=[]{}@#~?><|/\'*";
  var intCharNr;

  if (!isFilled(obj))
    return error_noName;

  // check for illegal characters
  for (intCharNr = 0; intCharNr < strName.length; intCharNr++)
  {
    if (badChars.indexOf(strName.charAt(intCharNr)) != -1)
    {
      obj.select();
      obj.focus();
      return error_badName;
    }
  }

  // check for 2 names (look for the space)
  if (strName.indexOf(" ") > 0)
  {
    obj.select();
    obj.focus();
    return error_twoNames;
  }
  return goodName;
}

function isFilled(obj)
{
  if (obj.value == ""  || obj.value==null)
  {
    obj.focus();
    obj.select();
    return false;
  }
  return true;
}

function isEmail(obj)
{
  var strName = obj.value;
  if ((strName.indexOf("@") != -1 && strName.indexOf(".") != -1) && (strName.length > 5))
    return true;
  
  obj.focus();
  obj.select();
  return false;
}


function isQuestionReady(theForm)
{
  var nameChkResult;

  // check the clents first name
  if (!isFilled(theForm.firstname))
  {
    alert("Please type your first name");
    return false;
  }

  nameChkResult = 0; 
  nameChkResult = checkName(theForm.firstname);
  if (nameChkResult != goodName)
  {

    if (nameChkResult == error_twoNames)
      alert("Please just type your first name");
    if (nameChkResult == error_badName)
      alert("Please re-type your first name");
    
    theForm.firstname.focus();
    theForm.firstname.select();
    return false;
  }

  // check email address
  if (!isFilled(theForm.emailaddress))
  {
    alert("What is your business email?");
    return false;
  }
  if (!isEmail(theForm.emailaddress))
  {
    alert("Please type a valid email address");
    return false;
  }

  // check question
  if (!isFilled(theForm.clientquestion))
  {
    alert("What is your question?");
    return false;
  }

  return true;
}


//______________________________________________________________________
// THESE FUNCTIONS PROCESS THE CLIENT LOGIN FORM

function togglelogin()
{
  // if we're not showing the login form then show it
  // if we are showing it then hide it
  if (loginform.style.display=='none')
  {
    questionform.style.display='none';
    loginform.style.display='';
  }
  else
  {
    questionform.style.display='';
    loginform.style.display='none';
  } 
}

function isText(string) 
{
   if (!string) return false;
   return true;
}

function isLoginReady(form) 
{
    if (!isText(form.username.value)) 
    {
        alert("Please enter your user name.");
        form.username.focus();
        return false;
    }
    if (!isText(form.password.value)) 
    {
        alert("Please enter your password.");
        form.password.focus();
        return false;
    }
    return true;
}

//______________________________________________________________________
// THESE FUNCTIONS CONTROL THE LEFT HAND MENUS

function showwebdesign()
{
  // if we're not showing the web design menu then show it and hide the rest
  if (webdesign.style.display=='none')
  {
    // show it
    webdesign.style.display='';
    marketing.style.display='none';
    webmaster.style.display='none';  
    defaultmenu.style.display='none';   
  }
}

function showmarketing()
{
  // if we're not showing the web design menu then show it and hide the rest
  if (marketing.style.display=='none')
  {
    // show it
    webdesign.style.display='none';
    marketing.style.display='';
    webmaster.style.display='none';   
    defaultmenu.style.display='none';   
  }
}

function showwebmaster()
{
  // if we're not showing the web design menu then show it and hide the rest
  if (webmaster.style.display=='none')
  {
    // show it
    webdesign.style.display='none';
    marketing.style.display='none';
    webmaster.style.display='';   
    defaultmenu.style.display='none';   
  }
}

function showdefaultmenu()
{
  // if we're not showing the web design menu then show it and hide the rest
  if (defaultmenu.style.display=='none')
  {
    // show it
    webdesign.style.display='none';
    marketing.style.display='none';
    webmaster.style.display='none';   
    defaultmenu.style.display='';   
  }
}


//______________________________________________________________________
// THESE FUNCTIONS SHOW THE HIDDEN TABLES THROUGHOUT THE WEBSITE 

function showtable1()
{
  if (table1.style.display=='none')
  {
    // show it
    table1.style.display='';   
  }
}

function showtable2()
{
  if (table2.style.display=='none')
  {
    // show it
    table2.style.display='';   
  }
}

function showtable3()
{
  if (table3.style.display=='none')
  {
    // show it
    table3.style.display='';   
  }
}

function showtable4()
{
  if (table4.style.display=='none')
  {
    // show it
    table4.style.display='';   
  }
}

function showtable5()
{
  if (table5.style.display=='none')
  {
    // show it
    table5.style.display='';   
  }
}

function showtable6()
{
  if (table6.style.display=='none')
  {
    // show it
    table6.style.display='';   
  }
}

function showtable7()
{
  if (table7.style.display=='none')
  {
    // show it
    table7.style.display='';   
  }
}
function showtable8()
{
  if (table8.style.display=='none')
  {
    // show it
    table8.style.display='';   
  }
}
function showtable9()
{
  if (table9.style.display=='none')
  {
    // show it
    table9.style.display='';   
  }
}

function showtable10()
{
  if (table10.style.display=='none')
  {
    // show it
    table10.style.display='';   
  }
}


