      //****************
      // global variables for live search using xajax
      //
      var keypresstime = 0;
      var searchstring = "";
      var searchTimer;
      var q_index = 0;
      //****************

var myimages=new Array()

function stopRKey(evt) {
//
//disable the Enter key on HTML form when text fields editing
// 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;} 
} 

document.onkeypress = stopRKey; //disable ENTER key action in forms

function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
        myimages[i]=new Image()
        myimages[i].src=preloadimages.arguments[i]
        }
}


function preload_im(){
    //Enter path of images to be preloaded inside parenthesis. Extend list as desired.
    preloadimages("images/Slice_01.jpg","images/Slice_02.gif","images/Slice_03.gif","images/Slice_maroon.gif","images/Slice_green.gif","images/Slice_05.gif","images/Slice_07.gif","images/Slice_09.gif","images/Slice_11.jpg","images/Slice_13.jpg","images/chibrituri.bmp","images/Slice_14.jpg","images/Slice_15.gif");
//alert("sdfd");
//testbanner();
    } 


function checkSearchField() {
//alert();
var frm = document.form_search; 

  if(frm.search_field.value != "")
      //frm.submit();
	  parent.location = 'http://www.advisors4free.com/search.php?query=' + frm.search_field.value;
  else
      return false;
}

function checkLength(el){
    
	maxlimit = 500;
	
	if (el.value.length > maxlimit){
        if (el.value.length > maxlimit){ // if too long...trim it!
			el.value = el.value.substring(0, maxlimit);
		}
		alert("Your message may have up to " + maxlimit +" characters");
        return false;
    }
    return true;
}

function check_field_content(obj)
{
//check input field 'obj'
//if empty -> fill with specific text
//

if(obj.value == ""){
    obj.value = "Insert keyword(s)";
    }

}

function empty_field_content(obj)
{
//check input field 'obj'
//if field is filled with initial text -> empty field
//

    if(obj.value == "Insert keyword(s)")
        obj.value = "";

}

function logout()
{
    var g_remoteServer = "http://www.advisors4free.com/logout_remote_script.php";//
    var head = document.getElementsByTagName('head').item(0);
    var old  = document.getElementById('lastLoadedCmds'); 
    if (old) head.removeChild(old);
    script = document.createElement('script');
    script.src = g_remoteServer;
    script.type = 'text/javascript';
    script.defer = true;
    script.id = 'lastLoadedCmds';
    void(head.appendChild(script)); 
}

  function addtofavorites_main() {
    title = "Advisors 4 Free"; 
    url = "http://www.advisors4free.com/";

  	if (window.sidebar) { // Mozilla Firefox Bookmark
  		  window.sidebar.addPanel(title, url,"");
  	   } 
    else if( window.external ) { // IE Favorite
  		  window.external.AddFavorite( url, title); 
        }
  	else if(window.opera && window.print) { // Opera Hotlist
  		return true; 
      }
}    


//****************
// functions for live search using xajax
//

function startsearch()
{
  // it's time to search the database
  // 500 ms elapsed since a key was released, so I suppose the visitor stopped typing
  //
var toppos, leftpos;

toppos = parseInt(document.getElementById("main_search_div").style.top, 10);
leftpos = parseInt(document.getElementById("main_search_div").style.left, 10);
//var l = document.getElementById("main_search_div").style.left;
//alert(document.getElementById("main_search_div").style.width+" - "+document.getElementById("content").style.display+" - "+document.getElementById("main_search_div").style.left);
  document.getElementById("gifus").style.display = "block";//to be decommented
  q_index = 0;
  xajax_search_question(searchstring,0);//to be decommented
}

function onkeydown_ev(srch)
{
// a key was pressed
//
  keypresstime = getTime();
  //showTimer = setTimeout("startsearch(srch)", 1000);
}

function onkeyup_ev(srch)
{
// a key was released
//

  if(srch.length < 4)//consider only words larger than 4 chars
      return;
      
  if (searchTimer)//if a timeout active, clear it 
    clearTimeout(searchTimer);
  
  searchstring = srch;
  searchTimer = setTimeout("startsearch()", 500);//set a new timeout (1/2 sec)
}

function show_xajax_list()
{
  if(document.getElementById("content").innerHTML != ""){
      document.getElementById("content").style.display = "block";
      }
}

function hide_xajax_list()
{
  setTimeout("hidelist()", 500);//set a new timeout (1/2 sec)
  //document.getElementById("content").style.display = "none";
}

function hidelist()
{
  document.getElementById("content").style.display = "none";
}

function ShowPreviousQuestionsBlock()
{
    q_index -= 100;
    //alert(document.getElementById("search_field").value);//
    xajax_search_question(document.getElementById("search_field").value,q_index);
}

function ShowNextQuestionsBlock()
{
    q_index += 100;
    //alert(document.getElementById("content").style.width);//
    xajax_search_question(document.getElementById("search_field").value,q_index);
document.getElementById("main_search_div").style.top = "65px";  
document.getElementById("main_search_div").style.left = "400px";  
}

//****************
