
/* Rounded corner global parameters
 */
corners_settings = {
  tl: { radius: 10 },
  tr: { radius: 10 },
  bl: { radius: 10 },
  br: { radius: 10 },
  antiAlias: true,
  autoPad: true
} 

function isInt(x) {
  return /^[^\d]*/.test(x);
}

var Rules = {
  'a.ajax_fragment_caller:mouseover' : function(element){
    /* Update an html div by placing a given html fragment in it
     * Used to do some onmouseover update of a part of the page
     * the link must have an id containing the name of the fragment and the class ajax_fragment_caller
     * ex : id="dolbox" class="ajax_fragment_caller"
     * the div with id ajax_fragment_display is updated
     */
    new Ajax.Updater({ success: 'ajax_fragment_display' },
                      '/site/fragment/' + element.id
                      );
  },
  
  '#nav li a:mouseover' : function(element){
    /* Eye candy on the menu bar
     */
    new Effect.Highlight(element.parentNode, {endcolor:'#007ae7', startcolor:'#57b0ff', restorecolor:'#007ae7', queue: {position:'end', scope: element.href, limit:1} 
    });
  },

  /*
   * input fields customisation
   */
  'input:blur' : function(element) {
   // Eye candy on input fields
   //  
    if(! element.hasClassName("astra_product_count") ) {
      var color = $(element).getStyle('background-color');
      new Effect.Highlight(element, {startcolor:color, endcolor:'#ffffff', restorecolor:'#ffffff', duration: 0.5});
    }
  }, 
  'input:focus' : function(element) {
    /* Eye candy on input fields
     */
    if(! element.hasClassName("astra_product_count") ) {
      new Effect.Highlight(element, {endcolor:'#c1d3e7', startcolor:'#ffffff', restorecolor:'#c1d3e7', duration: 0.5});
    }
  },
  'input.numeric:keypress' : function(element, event){
    /* numeric key filter event for an input field having class 'numeric' 
     * TODO : let pass navigation keys
     */

    var key = event.which || event.keyCode;
    if( ! (key >= 48 && key <= 57 )
        && ! (key >= 96 && key <= 105 && Prototype.Browser.IE )
        && key != Event.KEY_BACKSPACE
        && key != Event.KEY_TAB) {
        Event.stop(event);
      }
    return;
  }
}

