function checkPoll(numopts, pollid){
   var checkFlag=0;
   for (i=0;i<=numopts;i++){
     if (document.getElementById("frmpoll_answer_"+i).checked==true){
       checkFlag=1;
     }
   }
   if (checkFlag==0){
     alert("You need to select an answer!");
     return false;
   }else{
     setGraph(numopts, pollid);
     return false;
   }
}

function checkSingle(divid, message){
  if (document.getElementById(divid).value==""){
    alert(message);
    document.getElementById(divid).focus();
    return (false);
  }
}

function checkTopLogin(){
  if (document.getElementById("frm1_username").value=="username"){
    alert("You must enter a username.");
    document.getElementById("frm1_username").focus();
    return (false);
  }else if (document.getElementById("frm1_password").value=="password"){
    alert("You must enter a password.");
    document.getElementById("frm1_password").focus();
    return (false);
  }
}

function resetTradetype(startphrase,inputbox,status){
  if (status=="on"){
    if (document.getElementById(inputbox).value==startphrase){
      document.getElementById(inputbox).value="";
    }
  }else{
    if (document.getElementById(inputbox).value==""){
      document.getElementById(inputbox).value=startphrase;
    }
  }
}

function letternumber(e)
{
  var key;
  var keychar;
  
  if (window.event)
     key = window.event.keyCode;
  else if (e)
     key = e.which;
  else
     return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();
  
  // control keys
  if ((key==null) || (key==0) || (key==8) || 
      (key==9) || (key==13) || (key==27) )
     return true;
  
  // alphas and numbers
  else if ((("abcdefghijklmnopqrstuvwxyz0123456789-_.").indexOf(keychar) > -1))
     return true;
  else
     return false;
}

function echeck(str){
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);

  if (str.indexOf(at)==-1){
    return false;
  }else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    return false;
  }else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    return false;
  }else if (str.indexOf(at,(lat+1))!=-1){
    return false;
  }else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    return false;
  }else if (str.indexOf(dot,(lat+2))==-1){
    return false;
  }else if (str.indexOf(" ")!=-1){
    return false;
  }else{
    return true;
  }	
}

function setAjax(send_function, send_field1, send_value1, output_div){
  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){
      document.getElementById(output_div).innerHTML=xmlHttp.responseText;
    }
  }        
  xmlHttp.open("GET",send_function+"?"+send_field1+"="+send_value1,true);
  xmlHttp.send(null);
}