 /****************************************************
 * I decided to use dojo ajax libraries  from the http://dojotoolkit.org/
 * project
 * The dojo libaries are installed in 
 ****************************************************/
//dojo.require("dojo.io.*");
//dojo.require("dojo.dom.*");

 /****************************************************
 * Function: InsertElement
 * Desricption: Insert the banner image  after the given Parent as first child
 * Parameters: parentID, childID
 * Returnvalues: none
 ****************************************************/
 function InsertElement(parentID,childID)
 {
     
     var parent = document.getElementById(parentID);
     var child = document.getElementById(childID);
	 
     if (! parent)
     {
         var tags = document.getElementsByTagName(parentID);
         var parent = tags[0];
     }
     
     if (parent.hasChildNodes())
     {
         var fc = parent.firstChild;
     }
    
     if (fc)
     {
         parent.insertBefore(child,fc);
     }else{
         parent.appendChild(child);
     }
 }
 
  /****************************************************
 * Function: BannerClick
 * Desricption: Ajax function. Insert banner clicks into the database
 * Returnvalues: none
 ****************************************************/

 function BannerClick(banner_id)
 {
    dojo.io.bind({
                       url: 'wp-content/plugins/banner/banner_clicks.php',
                       method: 'POST',
                       content: {banner_id: banner_id }
                    });

 }
 
 /****************************************************
 * Function: BannerRotate
 * Desricption: Ajax function. Changes banner without browser reload
 * Returnvalues: none
 ****************************************************/
 
 function BannerRotate()
 {
    dojo.io.bind({
                       url: 'wp-content/plugins/banner/banner.php',
                       handler: ChangeBanner
                        });
 }
 
 /****************************************************
 * Function: ChangeBanner
 * Desricption: Handler function for BannerRotate(). Changes the banner image
 * Arguments: 
 *                      type  specifies the return type e.g. error
 *                      data returns the requested data
 *                      evt is a transport-specific low-level object that provides access to the specifics of the transport state
 
 *                      see http://manual.dojotoolkit.org/io.html for more info
 * Returnvalues: none
 ****************************************************/
 
 function ChangeBanner(type, data, evt)
 {
     if (type == 'error') return false;
    
     
 }
        
