<?php
/**
* provides a function to create autocomplete aware input on forms
* besides calling am_autocomplete with the id and mod, the mod (ie. class)
* must provide a method with name function autocomplete_$eName where $eName is the
* id attribute for input tag on form (usually it is same as name attribute)
* 
* @copyright Amit Deo Panwar
* @version 1.0 May 2011
*/


$g=&$GLOBALS;
//$g['HEADER']->addscriptfile(AM_PLUGIN_URL.'/jquery/am_autocomplete_jquery.js');

//$g['HEADER']->addstylesheet(AM_PLUGIN_URL.'/jquery/css/ui-lightness/jquery-ui-1.8.13.custom.css');  
//$g['HEADER']->addstylesheet(AM_PLUGIN_URL.'/jquery/css/am_autocomplete_jquery.css'); 

//dbug($g['HEADER']);
//$HEADER->addstylesheet(AM_PLUGIN_URL.'/jquery/css/am_autocomplete_jquery.css'); 

function am_autocomplete($eName,$mod)
{    
    $g=&$GLOBALS;
    if($g['AUTO_COMPLETE_JQUERY']!=1)
    {
        $g['AUTO_COMPLETE_JQUERY']=1;
        echo "\r\n
        <script language=\"javascript\" src=\"".AM_PLUGIN_URL."/jquery/am_autocomplete_jquery.js\"></script>";
    }
    echo "
    <script language='javascript'>\$(document).ready(function(){;am_autocomplete('$eName','$mod');});</script>\r\n"; 
    /*$g[HEADER]->addfunction('autocomplete_'.$eName,"
    \$(document).ready(function(){am_autocomplete('$eName','$mod');}); 
    ");*/
}
