/*eventcallbacks*/
/**
 * @author Romain GUILLOT
 * @date 26/07/09
 * @version 0.1
 */

/* global variable named after project  */
var PlemiProject = {}; 

PlemiProject.callbacks = new Array();  // a global array to easier callbacks manipulations

/** 
 * Class callback : manipulates 'persistent' js callback functions (accessible even after page reload)
 */  

PlemiProject.callback = function(event, fn, args)  
{   
    /*this.id = id; @fixme : id feature */
    this.event = event;
    this.fn = fn;
    this.args = args;
      
    PlemiProject.callbacks.push(this);  
    this.init();  
};  

/* Public methods of the 'callback' class */

 PlemiProject.callback.prototype =  
 {  
    /** 
     * Initialization
     */  
    init: function()  
    {   
    	if (!this.fn)
        {
        	alert("js error : missing argument fn !");
        	return false;	
        }	       
    	/* args set ? */
        if (this.args)
        {
        	/* yes : we can store the callback as a symfony flash variable : */      	
        	set_flash(this.fn, this.args);
        } else
        {	
        	/* no : we have to catch values from an existent symfony flash var  */
        	this.args = get_flash(this.fn);
        }
        return true;
    },  
    /** 
     * Method set : store new callback as a symfony flash variable
     */  
    set: function()  
    {  
        if (this.checkproperties())
        {	
        	set_flash(this.fn, this.args);
        }	
    },  
     /** 
     * Method checkproperties : check needed properties
     */  
    checkproperties: function()  
    {  
        if (!this.fn)
        {
        	alert("js error : missing property fn !");
        	return false;	
        }	
        if (!this.args)
        {
        	alert("js error : missing property args !");
        	return false;	
        }	
        return true;
    },   
    /** 
     * Execute method : run the callback function (if function exists ...)
     */  
    execute: function()  
    {   
    	var type;
    	eval('type = typeof('+this.fn+')');
        if (this.checkproperties() && (type == 'function'))
        {	
        	var reg = new RegExp('_\!_', "g");
    		eval(this.fn+'('+ this.args.replace(reg, ",")+')');
        }	
		
    }       
    
 };   


PlemiProject.eventcallbacks = new Array();  

/** 
 * Class eventcallback : manage callbacks according to event trigering
 */  

PlemiProject.eventcallback = function()  
{         
    this.ecb = new Array();
    this.jscb = "";
	PlemiProject.eventcallbacks.push(this);  
    this.init();  
}; 

// Méthodes publiques de la classe eventcallback  

 PlemiProject.eventcallback.prototype =  
 {  
    /** 
     * Initialization : catch and parse 'jscallbacks', a 'central' symfony flash variable 
     * that keep the list of callbacks stored as flash variables.
     */  
    init: function()  
    {  
	 	this.jscb = get_flash('jscallbacks');
        if (this.jscb != "")
        {	
	        var tab_ecb = this.jscb.split('_!_'); /* callback string separator */
	        var ecb;
	        /* instantiate every callback */
	        for (var i = 0; tab_ecb[i]; i++) 
	        {   
	        	if (tab_ecb[i] != '')
	        	{	
		        	ecb = tab_ecb[i].split('__'); /* event / function string separator */
		        	if (!this.ecb[ecb[ 0]])
		        	{
		        		this.ecb[ecb[ 0]] = new Array();
		        	}
		        	this.ecb[ecb[ 0]][ecb[ 1]] = new PlemiProject.callback(ecb[ 0], ecb[ 1]);
	        	}	
	        }	 
        }
    },  
    /** 
     * add method 
     */  
    add: function(event, fn, args)  
    {	
    	if (!this.ecb[event])
    	{
    		this.ecb[event] = new Array();
    	}
    	this.ecb[event][fn] = new PlemiProject.callback(event, fn, args);
    	this.jscb = set_flash('jscallbacks', get_flash('jscallbacks') + event + '__' + fn + '_!_');  
    },  
    /** 
     * remove method : remove a callback
     */  
    remove: function(event, fn)
    {
    	if (this.ecb[event] && this.ecb[event][fn])
    	{	
    		delete this.ecb[event][fn];   	
    	}
    	if (this.jscb != "")
    	{
        	var jscb = this.jscb;
        	var reg = new RegExp(event + '__' + fn + '_\!_', "g");
        	jscb = jscb.replace(reg, "");
        	if (jscb != this.jscb)
        	{	
        		this.jscb = set_flash('jscallbacks', jscb);   
    		}
    	}
    },
    /** 
     * cleanup method : remove all callback
     */  
    cleanup: function()
    {
    	for (event in this.ecb)
    	{	
    		for (fn in this.ecb[event])
    		{	
    			delete this.ecb[event][fn];   	
    		}
    	}
    	if (this.jscb != "")
    	{
        	this.jscb = set_flash('jscallbacks', "");   
    	}
    },    
    /** 
     * trigerevent method : triger an event and execute corresponding callbacks
     */  
    trigerevent: function(event)  
    {  
    	var cb;
    	for (cb in this.ecb[event])
    	{
    		this.ecb[event][cb].execute();
    		this.remove(event, this.ecb[event][cb].fn);
    	}
    }    
};  


/* Static methods */  

/** 
 * catch a callback object from his function name :
 */  
PlemiProject.callback.getByFunctionName = function(fn)  
{  
    for (var i = 0; PlemiProject.callbacks[i]; i++)  
    {  
        if (PlemiProject.callbacks[i].fn == fn)  
        {  
            return PlemiProject.callbacks[i];  
        }  
    }  
    return false;  
};  

  
/* Ajax functions */

/** 
 * a generic function to store a js value as a symfony flash variable
 */  
set_flash = function(name, value) {
	var r;
	$.ajax({
	   async: false,		
	   type: 'GET',
	   url: '/fr/ajax/setflash?name='+name+'&value='+value,
	   success: function(isok){
			r = isok;
		   }
     }); /* end of ajax */
	return r;
};

/** 
 * a generic function to get a js value from a symfony flash variable
 */  
get_flash = function(name, del) {
	var r;
	var d = del || "";
	if (d) d = '&del='+d; 
	$.ajax({
	   async: false,	
	   type: 'GET',
	   url: '/fr/ajax/getflash?name='+name+d,
	   success: function(value){
			r =  value;
		   }
     }); /* end of ajax */	
	return r;
};

/* Instantiation */

var myeventcallback = new PlemiProject.eventcallback();



/*plemiGlobal*/
/*
 * GLOBAL JAVASCRIPT LAYOUT BEHAVIORS
 * (boxes, lightboxes, geolocation etc.)
 * PS : More generic functions can be found in plemiLibrary.js 
 * @todo : i18n
 */

/* ***************************
 * BASIC STRING & VAR HANDLING 
 *************************** */

var isInteger = function (string) {

	 /* Digits from start to end */
	 var reg_isinteger = /^\d+$/
	 if( reg_isinteger.test(string))
	 	return true;
	 else
	 	return false;
}

var trim  = function (string) {
  return string.replace(/^\s+/g,'').replace(/\s+$/g,'');
};

var empty = function ( mixed_var ) {
  var key;

  if (mixed_var === "" ||
      mixed_var === 0 ||
      mixed_var === "0" ||
      mixed_var === null ||
      mixed_var === false ||
      mixed_var === undefined
  ) {
    return true;
  }

  if (typeof mixed_var == 'object') {
    for (key in mixed_var) {
      return false;
    }

    return true;
  }

  return false;
}

// ADDSLASHES & STRIPSLASHES JS EQUIVALENT
add_slashes = function(str) {
  return str.replace(/("|'|\\)/g, "\\$1");
};
strip_slashes = function(str) {
  return str.replace(/\\("|'|\\)/g, "$1");
};

// Replaces all occurrences of search in haystack with replace
function str_replace(search, replace, subject, count) {
    
    //
    // version: 905.3122
    // discuss at: http://phpjs.org/functions/str_replace
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}


// Count the number of elements in a variable (usually an array)
function count( mixed_var, mode ) {
    
    //
    // version: 905.412
    // discuss at: http://phpjs.org/functions/count
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Waldo Malqui Silva
    // +      bugfixed by: Soren Hansen
    // *     example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
    // *     returns 1: 6
    // *     example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
    // *     returns 2: 6
    var key, cnt = 0;

    if (mixed_var === null){
        return 0;
    } else if (mixed_var.constructor !== Array && mixed_var.constructor !== Object){
        return 1;
    }

    if( mode === 'COUNT_RECURSIVE' ) {
        mode = 1;
    }
    if( mode != 1 ) {
        mode = 0;
    }

    for (key in mixed_var){
        cnt++;
        if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
            cnt += count(mixed_var[key], 1);
        }
    }

    return cnt;
}


/* ***************
 * RATING RELATED
 *************** */

var openNotation = function() {
  $(this).next().show('fast');
  $(this).hide('fast');
  $(this).unbind('click', openNotation);
};


/* **********
 * FORM RESET
 *********** */

$.fn.clearForm = function() {
    return this.each(function() {
   var type = this.type, tag = this.tagName.toLowerCase();
   if (tag == 'form')
     return $(':input',this).clearForm();
   if (type == 'text' || type == 'password' || tag == 'textarea')
     this.value = '';
   else if (type == 'checkbox' || type == 'radio')
     this.checked = false;
   else if (tag == 'select')
     this.selectedIndex = -1;
    });
  };

/* *******************************
 * ONLOAD EVENT HANDLING FUNCTIONS
 ******************************* */

  // Loading scripts storing
  FuncOL = new Array();
  function StkFunc(Obj) {
      FuncOL[FuncOL.length] = Obj;
  };

  // Loading scripts launching
  window.onload = function() {
    var i = 0;
      for(i=0; i<FuncOL.length; i++)
          {FuncOL[i]();}
  };

/* **************
 * LOADING PAGES
 *************** */
  
  LoadEventParam = function(func, param) {
    var param = param || null;
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = func;
    } else {
      window.onload = function() {
        if (oldonload) {
          oldonload();
        }
        if (param) func(param);
        else func();
      };
    }
  };


/* *****************************
 * GEOLOCATION TOGGLE SEARCH MODE
 ******************************* */

  // Toggle search mode : simple or advanced
  var toggleGeolocSearchMode = function(){
    $('#geolocalisationSearchResults').empty();
    $('#advanced_search_block, #simple_search_block').toggle();
    var mode = $('#geolocalisationSearch #mode').val();
    if(mode == 'simple'){
      $('#geolocalisationSearch #mode').val('advanced');
      $('#citySearch', $('#geoloc_select_choice')).trigger('focus');
    }
    else if(mode == 'advanced') 
    {
      $('#geolocalisationSearch #mode').val('simple');
      $('#address', $('#geoloc_select_choice')).trigger('focus');
    }
    $(this).text($('#'+mode+'_search_block').attr('title'));
    return false;
  };
  

/* **************************************************************
 * ---------------------- DOCUMENT READY ---------------------- *
 ************************************************************** */

  // RG NOTE : PLEASE ONLY ONE DOCUMENT.READY BLOCK !
  
$(document).ready(function() {


    /* ************
     * LAYOUT LINKS
     **************/
    $('a[href=vide]').click(function(){
      return false;
    });


    /* *********************************
     * SHOWHIDE FUNCTIONS (deprecated ?)
     ********************************* */
    showhide = function() {
	    var namediv = arguments[0];
	    var tohide = arguments[1];
	    if (tohide) $('.'+tohide).hide('normal');
	    if ($('#'+namediv).css('display')=='none') {
        $('#'+namediv).show('normal');
	    } else {
        $('#'+namediv).hide('normal');
	    }
    };

    show = function(namediv) {
      var csscat = arguments[1] || '#';
      var effect = arguments[2] || 'normal';
      if (effect == 'none') {
        $(csscat+namediv).css('display','block');
      }
      else {
        //if ($(csscat+namediv).css('display')=='none') {
        $(csscat+namediv).show(effect);
        //}
      }
    };

    hide = function(namediv) {
      var csscat = arguments[1] || '#';
      var effect = arguments[2] || 'normal';
      if (effect == 'none') {
        $(csscat+namediv).css('display','none');
      }
      else {
        //if ($(csscat+namediv).css('display')!='none') {
        $(csscat+namediv).hide(effect);
        //}
      }
    };

    /* ******************
     *  GENERIC AJAX CALL
     ******************* */
    // do a simple phpside action
    // that do not require any layout
    doAction = function(action) {
      var calltype = arguments[1] || 'GET';
      var callsync = arguments[2] || false;
      var calldata = arguments[3] || null;
      var calldatatype = arguments[4] || 'json';
      $.ajax({
         type: calltype,
         async: callsync,
         data: calldata,
         datatype: calldatatype,
         url: action,
         error: function(err){
          alert('oups ! looks like there is a problem !');
          r = err;
         },
         success: function(ret){
	      r = ret   
         }
       });
      return r;
    };


    /* *****************
     * GENERIC LIGHTBOX
     ***************** */
    
    /*
     * Open a lightbox (with optional cancel button)
     * @param element: class or id of the element to display
     * @param h: height (disabled)
     * @param w: width
     * @param t: title
     * @param cancel: display a cancel button ? (boolean)
     * @param buttons: buttons to display at the bottom (json) ex: {Annuler:function(){$('#ID_OF_THE_BOX').dialog('close');}}
     **/
    openLBox = function(element, h, w, t, cancel, buttons) {
      var options = {};

      options.dialogClass = 'buttonsLightBox';
//      options.height = h;
      options.modal = true;
      options.position = ['50%', $('#header_content').height()];
      options.resizable = true;
      options.title = t;
      options.width = w;

      if (buttons != undefined) {
        options.buttons = buttons;
      }
      else {
        options.buttons = {};
      }
      if (cancel) {
        options.buttons.Annuler = function() {
          $(this).dialog('close');
        };
      }

      var d = plemiLibrary.dialog(element, null, options);
      $('.ui-dialog').css({'position':'fixed', 'top':$('#header_content').height()});
      
      return d;
    };


    /* **********************
     * GOOGLESURVEY LIGHTBOX 
    *********************** */
    /*
     *  @todo : i18n
     */
    $('#GoogleSurveyButton').click(function() {
      openLBox('#GoogleSurvey', '450px', '580px', 'Votre avis sur cette page !');
    });
    $('#GoogleSurveyButtonNotAuth').click(function() {
      openLBox('#GoogleSurvey', '200px', '460px', 'Votre avis sur cette page !');
    });
    $('#GoogleSurveyLink').click(function() {
      openLBox('#GoogleSurvey', '450px', '580px', 'Votre avis sur cette page !');
    });
    $('#GoogleSurveyLinkNotAuth').click(function() {
      openLBox('#GoogleSurvey', '200px', '460px', 'Votre avis sur cette page !');
    });

    
    /* ************************
     * BUGTRACKING LIGHTBOX 
     ************************ */
    /*
     * @todo : i18n
     * Reprise des declaration css pour ce form
     * temporaire, car je ne sais pas si simple form s'applique ailleur ou non
     * mycolonnegauche.css, ligne 256
     */
    $('#FormBugTrackingButton').click(function() {
      openLBox('#FormBugTracking', '400px', '585px', 'Rapport de Bug !');
    });
    $('#FormBugTrackingLink').click(function() {
      openLBox('#FormBugTracking', '400px', '585px', 'Rapport de Bug !');
    });
    $('#FormBugTrackingLinkNotAuth').click(function() {
      openLBox('#FormBugTracking', '200px', '460px', 'Rapport de Bug !');
    });
    $('#FormBugTrackingLink2').click(function() {
      openLBox('#FormBugTracking', '400px', '585px', 'Rapport de Bug !');
    });
    $('#FormBugTrackingLink3').click(function() {
      openLBox('#FormBugTracking', '400px', '585px', 'Rapport de Bug !');
    });
    closeBugTracking = function() {
      $('#FormBugTracking').dialog('close');
    };

    $('#EnvoyerBugTracking').click(function() {
      var donneesbug = $('#FormBugTracking form').serialize();
      $.ajax({
        type: 'POST',
        url: '/fr/main/sendBugTracking',
        data: donneesbug,
        success: function(retour){
          $('#FormBugTracking').empty();
          $('<p></p>')
            .html(retour)
            .hide()
            .appendTo('#FormBugTracking')
            .show('normal');
          setTimeout(closeBugTracking,15000);
        }
      });
    });


    /* **************************
     * NOT READY FEATURE LIGHTBOX
     ************************** */
    // @todo : i18n
    $('.pasencorefait').click(function() {
      openLBox('#BoitePasEncoreLa', 160, 400, 'En développement', false, {
        'En parler sur le forum': function() {
          $('#BoitePasEncoreLa').dialog('close');
          window.location='/fr/forum';
        },
        'Fermer cette boîte': function() {
          $('#BoitePasEncoreLa').dialog('close');
        }
      });
      return false;
    });


    /* ****************************************************
     * OPEN & CLOSE RIGHTCOL BOXES BEHAVIORS (with cookies)
    ****************************************************** */

    //1 - On teste la presence du cookie, et si absent, on le crée (valable 7 jours)
    if(!$.cookie('cookie_plemi_javascript')){
      $.cookie('cookie_plemi_javascript', 'present', { expires: 7, domain: 'plemi.com', secure: false });
    }

    // 2 - Au clic, on remplit le cookie et on inverse le contenu
    $('#col3_content .bloc_header_showhidebloc a').click(function(){
      var id = $(this).parents(".bloc").attr('id');
      if($(this).hasClass("currentIsShown")){
        $(this).parents(".bloc").find('.bloc_content').slideUp('fast');
        $(this).addClass('currentIsHidden').removeClass('currentIsShown');
        $.cookie(id, 'closed', { expires: 7});
      }
      else {
        $(this).parents(".bloc").find('.bloc_content').slideDown('fast');
        $(this).addClass('currentIsShown').removeClass('currentIsHidden');
        $.cookie(id, 'open', { expires: 7});
      }
      return false;
    });

    // 3 - Maintenant à chaque chargement de page, on teste les cookies, pour tous les id de boite
    $('#col3_content .bloc_header_showhidebloc a').each(function() {
      var id = $(this).parents(".bloc").attr('id');
      var status = $.cookie(id);
      if (status == 'closed') {
        $(this).parents(".bloc").find('.bloc_content').hide();
        $(this).addClass('currentIsHidden').removeClass('currentIsShown');
      }
    });


    /* **************************************
     * MORE DETAILS RIGHT COL BOXES BEHAVIORS
    *************************************** */
    
    //D'abord, on teste les boites droite, pour voir si elles ont une comportement "plus",
    //et si oui, on ajoute le lien plus, et on creer la boite d'ouverture
    $('#col3_content .auto').each(function() {
      if($(this).find('div.contenu_cache').length) {
        var id = $(this).attr('id')+'_plus';
        $(this).find('div.content').append('<span class="openplus">En savoir plus </span>');
        var contentTemp = '<div id="'+id+'" class="boite_droite_plus"><div class="wait"><img src="/css/screen/images/ajax-loader2.gif" alt="Plemi" /></div><p>Boite en savoir plus de la boite '+id+'<p></div>';
        $('#col1_content').prepend(contentTemp);
        }
      });

    $('#col3_content .module .content span.openplus').click(function() {
      var id = '#'+$(this).parent().parent().attr('id')+'_plus'; //on choppe l'id de la boite complete
      var hauteur_col1 = $('#col1').height(); // On prend la hauteur de la colonne gauche
      var hauteur_col3 = $('#col3').height(); // On prend la hauteur de la colonne droite
      if (hauteur_col1 << hauteur_col3) {
        var newHauteur = hauteur_col3;
        $('#col1').css({'height': newHauteur});
        }
      var $panneau = $(id); //On choppe le panneau gauche correspondant à la boite droite
      if ($('#col1 div.header')) { //On fait apparaitre la boite sous le titre de la page, si il y'en a un !!!
        var hauteur_titre = $('#col1 div.header').height();
        newHauteur = newHauteur - hauteur_titre;
        var top = hauteur_titre + 'px';
        $panneau.css({'top': top});
        }
      var hauteur_boite = $(this).parent().height(); // On prend la hauteur de la boite gauche
      $panneau.css({'height': newHauteur}).animate({'left':'0'}, 'slow'); //On lui met la hauteur de la colonne gauche, et on le fait apparaitre
      $(this).parent().find('.contenu_cache').css({'height': hauteur_boite}).animate({'left':'0'}, 'slow'); //idem dans la boite droite


      $('#col3_content .module .header a.btnshowhide').animate({'opacity' : '0'},'slow'); //On fait disparaitre les bouton +- des boite droites
      $('#col3_content .module .content span.openplus').animate({'opacity' : '0'},'slow'); // On cache les en savoir plus des boites droites
      $(this).parent().css({'border-color':'#0089E7'}); //On met les bord content de gris bleu

      //On applique le comportement de fermeture de la boite droite
      $(this).parent().find('.contenu_cache').bind('click', function() {
       var id = '#'+$(this).parent().parent().attr('id')+'_plus';
       var $panneau = $(id);
       $panneau.animate({'left':'671px'}, 'slow');
       $(this).animate({'left':'301px'}, 'slow');
       $('#col3_content .module .header a.btnshowhide').animate({'opacity' : '1'},'slow');
       $('#col3_content .module .content span.openplus').animate({'opacity' : '1'},'slow');
       $(this).parent().css({'border-color':'grey'});
       });

     });

    /* *********************
     * AUTHENTICATION MODULE
    ********************** */
    $('#topnav a.gbox').click(function(){
      $('#topnav').find('.menu').slideUp('normal').end().find('.connexion').slideDown('normal');
      return false;
    });


    /* ***********************
     * CENTRAL TAB VIEW SYSTEM
    ************************ */

    hauteurOnglets = function(){
      var nbBoite = $('ul#onglets li').size();
      //var hauteurOnglet = $('ul#onglets li:nth(1)').css('height');
      //var hauteurOnglet = $('ul#onglets').height();
      var hauteurOnglet = nbBoite * 28;
      //var hauteur_fiche = $('#contenufiche_content').height();
      var hauteurFiche = $('div#contenufiche_content').height();
      //$('#contenufiche_content').css({'height': hauteur_fiche});
      //$('#contenufiche_content').css({'border': '1px solid red'});
      //alert('hauteur onglet : '+hauteurOnglet+'/ hauteur fiche : '+hauteurFiche+' / il y a '+nbBoite+' boites');
      if (hauteurOnglet >= hauteurFiche) {
        //alert('onglets plus haut !');
        var newHauteur = hauteurOnglet * 1.5;
        $('#contenufiche_content').css({'height': newHauteur});
      }
    };

    hauteurOnglets();

    /* **************************************
     * CLOSING HEADER PROFILE IF NOT SUMMARY
    ************************************** */
     $('ul#onglet li.first').toggle(function() {
      $(this).addClass('on').removeClass('off');
      $(this).parent().parent().find('.profilDetails').slideUp('normal');
      }, function () {
      $(this).addClass('off').removeClass('on');
      $(this).parent().parent().find('.profilDetails').slideDown('normal');
     });

     fermeCartouche = function(){
      //$('ul#onglets li.first').css({'border':'1px solid red'});
      //alert($('ul#onglets li.first').attr('class'));
      if ($('ul#onglets li.first').attr('class') != 'first current') {
        $('#cartouche_profil_membre .profilDetails').hide();
        $('#cartouche_profil_membre .titre .switch').trigger('click');
      }
    };

    fermeCartouche();

	
    /* ***********************************
     * GEOLOCATION SEARCH OR EDIT ACTIONS
    ************************************ */
    	
      $('a.locbox').click(function() {
        // Set custom parameters
        var header_height = $('#header_content').height();
        var type_session = $(this).attr('rel');
        var type_lightbox = $(this).attr('title');
        var mode = $('#geolocalisationSearch #mode').val();
        if(mode == 'simple'){
          $('#address',$('#geoloc_select_choice')).trigger('focus');
        }
        else if(mode == 'advanced') {
          $('#citySearch',$('#geoloc_select_choice')).trigger('focus');
        }
        // Set lightbox settings
        $('#geoloc_select_choice').dialog({
          autoOpen: false,
          autoResize: true,
          close: function(event, ui) {
            $('#reset_search').trigger('click');
          },
          dialogClass : 'geoLightbox',
//           height: 470,
          modal: true,
          open : function(event, ui){
            $('#type_session').val(type_session);
          },
          position: ['50%',header_height],
          resizable: true,
          title: type_lightbox,
          width: 550
        }).dialog('open');
        $('.geoLightbox.ui-dialog').css({'position':'fixed', 'top':header_height});
        loadGeolocLbox();
        return false;
      });

      // Restore suggestions on reset
      $('#reset_search').click(function(){
        $('#geolocalisationSearchResults').empty().fadeOut();
        $('#shortListVilles').fadeIn();
        $('#autoSuggestCity').empty();
      });


      // Set autocomplete on city field in geo search
      var autocomplete_mousedown;
      $('#geolocalisationSearch #citySearch').keyup(function(){
        if($(this).attr('rev') != $(this).val()){
          $(this).attr('rev', $(this).val());
          autoSuggestCityName($(this).val(), '#autoSuggestCity');
        }
      }).blur(function(){
        if(!autocomplete_mousedown){
          window.setTimeout(
            function(){
              $('#autoSuggestCity').hide();
            },
            500
          );
        }
      }).focus(function(){
        if($('#autoSuggestCity').is(':parent')){
          $('#autoSuggestCity').show();
        }
      });
      $('#autoSuggestCity').mousedown(function() {
        autocomplete_mousedown = true;
      }).mouseup(function() {
        autocomplete_mousedown = false;
        $('#geolocalisationSearch #citySearch').trigger('focus');
      }).blur(function(){
        $('#geolocalisationSearch #citySearch').trigger('blur');
      });
      
  	
  	/* *****************************
  	 * CONNEXIONS ACTIONS AND EVENTS
  	 ***************************** */
  	
    // Standard connector
    $('a.plDemandConnector').live('click', function() {
      var node = $(this);
      $.ajax({
        dataType: 'html',
        type: 'GET',
        url: $(this).attr('href'),
        beforeSend: function(){
          $('img', node).attr('rel', $('img', node).attr('src'));
          $('img', node).attr('src', '/css/images/icons/indicator_bg_white.gif')
        },
        success: function(data){
          plemiLibrary.dialog("mylbox_demand", 'Plemi', data, false);
          $('img', node).attr('src', $('img', node).attr('rel'));
        }
      });
      return false;
    });

    $('a.plConnector').live('click', function() {
      var node = $(this);
      $.ajax({
        dataType: 'json',
        type: 'GET',
        url: $(this).attr('href'),
        beforeSend: function(){
          $('img', node).attr('rel', $('img', node).attr('src'));
          $('img', node).attr('src', '/css/images/icons/indicator_bg_white.gif')
        },
        success: function(data){
          if(data.method == 'custom')
          {
            plemiLibrary.dialog(null, 'Plemi', data.html, false);
            plemiLibrary._activeDialogNodeCaller = node;
            $('img', node).attr('src', $('img', node).attr('rel'));
          }
          else if (plemiLibrary._activeDialogNodeCaller != '')
          {
            $('#'+plemiLibrary.val('dialog_class')+plemiLibrary._activeDialogId).dialog('close');
            var update = $(plemiLibrary._activeDialogNodeCaller).replaceWith(data.html);
            if (update) {
              plemiLibrary.notify(
                plemiLibrary.val('manageConnexionTitle'),
                plemiLibrary.val('manageConnexionSuccessMsg'),
                '/css/images/icons/notification_done.png'
              );
              plemiLibrary._activeDialogNodeCaller = '';
            }

          }
          else
          {
            var update = $(node).replaceWith(data.html);
            if (update) {
              plemiLibrary.notify(
                plemiLibrary.val('manageConnexionTitle'),
                plemiLibrary.val('manageConnexionSuccessMsg'),
                '/css/images/icons/notification_done.png'
              );
            }
          }
        },
        error: function(){
          $('img', node).attr('src', $('img', node).attr('rel'));
          plemiLibrary.notify(
            plemiLibrary.val('manageConnexionTitle'),
            plemiLibrary.val('manageConnexionErrorMsg'),
            '/css/images/icons/notification_error.png'
          );
        }
      });
      return false;
    });

    // Cancel asked friendship
    $('a.cancelfriendship').click(function() {
      var slug = $(this).attr('id');
      if(slug){
        $.ajax({
         type: 'GET',
         url: '/fr/user/cancelaskfriend/'+slug,
         success: function(retour){
           if (retour=='ok') {
             location.reload()
           }
         }
        });
      }
      return false;
    });
    
    // Validate friendship
    $('a.validatefriendship').click(function() {
      var slug = $(this).attr('id');
      if(slug){
        $.ajax({
         type: 'GET',
         url: '/fr/user/acceptaskfriend/'+slug,
         success: function(retour){
           if (retour=='ok') {
             location.reload()
           }
         }
        });
      }
      return false;
    });
    
    // Refuse friendship
    $('a.refusefriendship').click(function() {
      var slug = $(this).attr('id');
      if(slug){
        $.ajax({
         type: 'GET',
         url: '/fr/user/removeaskfriend/'+slug,
         success: function(retour){
           if (retour=='ok') {
             location.reload()
           }
         }
        });
      }
      return false;
    });
    
    // Remove friendship
    $('a.removefriendship').click(function() {
      var slug = $(this).attr('id');
      if(slug){
        $.ajax({
         type: 'GET',
         url: '/fr/user/removefriendship/'+slug,
         success: function(retour){
           if (retour=='ok') {
             location.reload()
           }
         }
        });
      }
      return false;
    });
    
  /* FINDERS */
  /** TAGS **/
  jQuery('#widget-tags').find('input[type=checkbox]')
    .hide()
    .click(function(){
      var parent = jQuery(this).parent('.widget-element');
      parent.toggleClass('widget-element-active');
      if (jQuery('#widget-tags .widget-element-active').length == 0) {
        jQuery('#widget-tags .tag-alltags')
          .addClass('widget-element-active')
          .find('input[type=checkbox]').attr('checked', 'checked');
      }
      else if (parent.hasClass('tag-alltags')) {
        jQuery('#widget-tags .widget-element-active:not(.tag-alltags)')
          .removeClass('widget-element-active')
          .find('input[type=checkbox]').removeAttr('checked');
      }
      else {
        jQuery('#widget-tags .tag-alltags')
          .removeClass('widget-element-active')
          .find('input[type=checkbox]').removeAttr('checked');
      }
    });

  /** SUBMIT **/
  $("#livefinder form, #bandfinder form, #stagefinder form")
    .bind("submit", function(){
      plemiLibrary.openLoader(plemiLibrary.val('search_loader_text'));
    });
    
}); // ------------- CLOSING DOCUMENT READY ! -----------------------

/*plemiCarousel*/
/**
 * @author Aurélien MANCA
 * @extends infinite carousel from Stéphane Roucheray
 * @extends jquery
 */

var plemiCarousel = {
  _settings : new Array(),
  val : function(k,v) {
    var t = this;
    if (!v){
      return t._settings[k];
    }
    else {
      return t._settings[k] = v;
    }
  },
  removeVal : function(k) {
    var t = this;
      return delete t._settings[k];
  },
  getSettings : function(e) {
    var t = this, a = 'ALL SETTINGS :\n';
    for (k in t._settings){
      a += '- '+k+' = '+t._settings[k]+'\n';
    }
    alert(a);
  },
  deleteWithHash : function(s) {
    var t = this, a = 'ALL SETTINGS :\n', r = new RegExp(s), w;
    for (k in t._settings){
      if (r.test(k)){
        t.removeVal(k);
      }
    }
  },
  init : function(element, options){
    var t = this, carousel = jQuery('.carousel',jQuery(element)),
    sliderList = carousel.children()[0];

    if (sliderList) {
      var elmnts = jQuery(sliderList).children(),
      previous = jQuery('.prev',jQuery(element)),
      next = jQuery('.next',jQuery(element)),
      pause = jQuery('.pause',jQuery(element)),
      play = jQuery('.play',jQuery(element)),
      stop = jQuery('.stop',jQuery(element));

      // Override if exists
      t.stop(element, play, pause, previous, next);

      t.val('numElmts['+element+']', elmnts.length)
      if (elmnts.length > 1){
        // Set params and check options
        if (options['effect']){
          t.val('effect['+element+']',options['effect']);
        }
        else {
          t.val('effect['+element+']','swing');
        }
        if (options['layout'] == 'vertical'){
          t.val('layout['+element+']', 'vertical');
          t.val('layout_dim['+element+']', 'height');
          t.val('layout_dir['+element+']', 'top');
          t.val('increment['+element+']', jQuery(sliderList).children().outerHeight("true"));
          t.val('sliderSize['+element+']', carousel.height());
        }
        else {
          t.val('layout['+element+']', 'horizontal');
          t.val('layout_dim['+element+']', 'width');
          t.val('layout_dir['+element+']', 'left');
          t.val('increment['+element+']', jQuery(sliderList).children().outerWidth("true"));
          t.val('sliderSize['+element+']', carousel.width());
        }

        // Objects
        t.val('shownInViewport['+element+']', Math.round(t.val('sliderSize['+element+']') / t.val('increment['+element+']')));
        t.val('firstElementOnViewPort['+element+']', 1);
        t.val('isAnimating['+element+']', 'false');
        t.val('autoScroll['+element+']', 'false');

        // Infinite trick
        for (i = 0; i < t.val('numElmts['+element+']'); i++) {
          jQuery(elmnts[i]).attr('rel','carouselItem'+i);
          if (i < t.val('shownInViewport['+element+']')){
            jQuery(sliderList).css(t.val('layout_dim['+element+']'),(t.val('numElmts['+element+']')+t.val('shownInViewport['+element+']'))*t.val('increment['+element+']') + t.val('increment['+element+']') + "px");
            jQuery(sliderList).append(jQuery(elmnts[i]).clone());
          }
        }

        // Button PREVIOUS
        previous.show().unbind('click').click(function(event){
          t.previous(element, sliderList);
          return false;
        });

        // Button NEXT
        next.show().unbind('click').click(function(event){
          t.next(element, sliderList);
          return false;
        });

        // AutoScroll
        if (options['autoscroll'] > 0){
          t.val('autoScroll['+element+']', 'true');
          t.val('autoScrollDelay['+element+']', options['autoscroll']);
          t.val('autoScrollPause['+element+']', 'false');
          
          // Launch the scroll with delay
          t.start(element, sliderList, play, pause);

          // Pause the scroll on mouse over
          jQuery(element).hover(
            function(){
              t.mouseIn(element);
            },
            function(){
              t.mouseOut(element);
            }
          );
          // Or on pause button
          pause.unbind('click').click(function(){
            t.pause(element, play, pause);
            return false;
          });

          // And Play again
          play.unbind('click').click(function(){
            t.play(element, play, pause);
            return false;
          });

          // Deactivate the scroll on stop button
          stop.unbind('click').click(function(){
            t.stop(element, play, pause, previous, next);
            return false;
          });
        }
      }
    }
    return true;
  },
  previous : function(element, sliderList){
    var t = this, i = t.val('firstElementOnViewPort['+element+']');
    if (t.val('isAnimating['+element+']') == 'false') {
      if (i == 1) {
        jQuery(sliderList, jQuery(element)).css(t.val('layout_dir['+element+']'), "-" + t.val('numElmts['+element+']') * t.val('increment['+element+']') + "px");
        t.val('firstElementOnViewPort['+element+']', t.val('numElmts['+element+']'));
      }
      else {
        t.val('firstElementOnViewPort['+element+']', --i);
      }
      
      if (t.val('layout['+element+']') == 'horizontal'){
        jQuery(sliderList, jQuery(element)).animate({
          "left" : "+=" + t.val('increment['+element+']') + "px",
          y: 0,
          queue: true
        }, t.val('effect['+element+']'), function(){
          t.val('isAnimating['+element+']', 'false');
        });
      }
      else if (t.val('layout['+element+']') == 'vertical'){
        jQuery(sliderList, jQuery(element)).animate({
          "top" : "+=" + t.val('increment['+element+']') + "px",
          x: 0,
          queue: true
        }, t.val('effect['+element+']'), function(){
          t.val('isAnimating['+element+']', 'false');
        });
      }
      t.val('isAnimating['+element+']', 'true');
    }
    return true;
  },
  next : function(element, sliderList){
    var t = this, i = t.val('firstElementOnViewPort['+element+']');
    if (t.val('isAnimating['+element+']') == 'false') {
      if (i > t.val('numElmts['+element+']')) {
        t.val('firstElementOnViewPort['+element+']', 2);
        jQuery(sliderList, jQuery(element)).css(t.val('layout_dir['+element+']'), "0px");
      }
      else {
        t.val('firstElementOnViewPort['+element+']', ++i);
      }

      if (t.val('layout['+element+']') == 'horizontal'){
        jQuery(sliderList, jQuery(element)).animate({
          "left" : "-=" + t.val('increment['+element+']') + "px",
          y: 0,
          queue: true
        }, t.val('effect['+element+']'), function(){
          t.val('isAnimating['+element+']', 'false');
        });
      }
      else if (t.val('layout['+element+']') == 'vertical'){
        jQuery(sliderList, jQuery(element)).animate({
          "top" : "-=" + t.val('increment['+element+']') + "px",
          x: 0,
          queue: true
        }, t.val('effect['+element+']'), function(){
          t.val('isAnimating['+element+']', 'false');
        });
      }
      t.val('isAnimating['+element+']', 'true');
    }
    return true;
  },
  mouseIn : function(element){
    var t = this;
    t.val('autoScroll['+element+']', 'false');
    return true;
  },
  mouseOut : function(element){
    var t = this;
    if (t.val('autoScrollPause['+element+']') == 'false'){
      t.val('autoScroll['+element+']', 'true');
    }
    return true;
  },
  start : function(element, sliderList, play, pause){
    var t = this;
    t.val('intervalId['+element+']', window.setInterval(
      function(){
        if ((t.val('autoScroll['+element+']') != 'false') && (t.val('autoScrollPause['+element+']') != 'true')){
          t.next(element, sliderList);
        }
      },
      t.val('autoScrollDelay['+element+']')
    ));
    play.hide();
    pause.show();
    return true;
  },
  play : function(element, play, pause){
    var t = this;
    t.val('autoScroll['+element+']', 'true');
    t.val('autoScrollPause['+element+']', 'false');
    play.hide();
    pause.show();
    return true;
  },
  pause : function(element, play, pause){
    var t = this;
    t.val('autoScroll['+element+']', 'false');
    t.val('autoScrollPause['+element+']', 'true');
    play.show();
    pause.hide();
    return true;
  },
  stop : function(element, play, pause, previous, next){
    var t = this;
    // Stop autoScroll
    window.clearInterval(t.val('intervalId['+element+']'));
    // Remove all variables
    t.deleteWithHash(element);
    // Unactivate carousel
    jQuery(element).unbind();
    play.hide();
    pause.hide();
    previous.hide();
    next.hide();
    return true;
  }
}

/*plemiLibrary*/
/**
 * plemiLibrary : JavaScript library to enhance PLEMI.COM
**/
var plemiLibrary = {
  // Attributes
  _settings : new Array(),
  _activeDialogId : 0,
  _activeDialogNodeCaller : '',
  _activeLoader : '',
  // Initial actions
  init : function() {
    var t = this;
    // Set here your custom params
    t.val('autocompleter_minChars', 3);
    t.val('autocompleter_delay', 400);
    t.val('current_hidden_block', 'currentIsHidden');
    t.val('current_shown_block', 'currentIsShown');
    t.val('dialog_name', 'plemiLibraryDialog');
    t.val('dialog_width', 450);
    t.val('loader_id', 'plemiLibraryLoader');
    t.val('loader_img_form', '/css/images/icons/indicator.gif');
    t.val('loader_img_action', '/css/images/icons/ajax-loader.gif');
    t.val('loader_img_global', '/css/images/icons/loader-big.gif');
    t.val('loader_height_global', 150);
    t.val('loader_width_global', 250);
  },
  // Initial actions when DOM is ready
  initOnDomReady : function() {
    // Define vars
    var t = this;
    // Pre-load loader images
    jQuery("body").append(
      '<img src="' + t.val('loader_img_form') + '" style="display:none;" />'
       + '<img src="' + t.val('loader_img_action') + '" style="display:none;" />'
       + '<img src="' + t.val('loader_img_global') + '" style="display:none;" />'
    );
    // Simple class & display switch
    jQuery('.modalSwitch').click(function() {
      plemiLibrary.modalSwitch(this);
      if ($(this).is('a')) {
        return false;
      }
    });
    // Dual class & display switch
    jQuery('.modalDualSwitch').click(function() {
      if (jQuery(this).hasClass('.' + t.val('current_hidden_block'))) {
        plemiLibrary.modalSwitch(this, true);
      }
      if ($(this).is('a')) {
        return false;
      }
    });
  },
  // Set a variable
  val : function(k,v) {
    var t = this;
    if (!v) {
      return t._settings[k];
    }
    else {
      return t._settings[k] = v;
    }
  },
  // Remove a variable
  removeVal : function(k) {
    var t = this;
      return delete t._settings[k];
  },
  // Return a count of the settings
  countSettings : function(e) {
    var t = this, i = 0;
    for (k in t._settings) {
      i++;
    }
    return i;
  },
  // Return an alert with all the settings
  getSettings : function(e) {
    var t = this, a = 'ALL SETTINGS :\n';
    for (k in t._settings) {
      a  += '- ' + k + ' = ' + t._settings[k] + '\n';
    }
    alert(a);
  },
  // Ajax request : create a managed ajax request and return 
  ajax : function() {
    
  },
  /*
   * Dialog method
   * @param e String : optionnal element which would be generated if null (don't forget the dot or the comma)
   * @param data String : optionnal content to insert
   * @param options Array : options
   *
   * Custom params:
   * @param options.wide Boolean : make dialog width nearly the width of the body
   */
  dialog : function(e, data, options) {
    // Define vars
    var t = this, i = t._activeDialogId;

    if (!e) {
      t._activeDialogId = + + i;
      e = '#' + t.val('dialog_name') + i;
      jQuery('body').append('<div id="' + e + '" style="display:none;">' + data + '</div>');
    }
    else if ((jQuery(e).length > 0) && (data != null))
    {
      jQuery(e).empty().append(data);
    }
    else if (jQuery(e).length == 0)
    {
      jQuery('body').append('<div id="' + e.substr(1, e.length) + '" style="display:none;">' + data + '</div>');
      options.close = function(event, ui) {
        jQuery(e).dialog('destroy').remove();
      }
    }

    // Settings
    options.autoOpen = false;
    options.autoResize = true;
    if (options.dialogClass) {
      options.dialogClass  += ' ' + t.val('dialog_name');
    }
    else {
      options.dialogClass = t.val('dialog_name');
    }
    if (!options.position) {
      options.position = ['50%', t.val('loader_height_global')];
    }
    if (options.wide) {
      options.width = jQuery("body").width()-50;
      delete options.wide;
    }
    else if (!options.width) {
      options.width = t.val('dialog_width');
    }

    jQuery(e)
      .dialog(jQuery.extend({}, options))
      .show()
      .dialog('open');
  },
  // Autocompleter
  autocompleter : function(e, u, m, d, h) {
    // string e : element ID or class
    // string u : url or data
    // integer m : minimum number of characters before search
    // integer d : delay after each keystroke before search
    // function h : handler
    jQuery(e).autocomplete(u, jQuery.extend({}, {
      dataType: 'json',
      parse : function(data) {
        var parsed = [];
        for (key in data) {
          parsed[parsed.length] = {data: [ data[key], key ], value: data[key], result: data[key]};
        }
        return parsed;
      },
      minChars : m ? m : t.val('autocompleter_minChars'),
      delay : d ? d : t.val('autocompleter_delay')
    }, u))
    .result(function(event, data) {
      jQuery(e).val(data[1]);
    });
  },
  // openLoader : display a loading image
  openLoader : function(c,l,a,f) {
    // string c : content to display
    // string l : type of layout {global,form,action}
    // boolean a : display abort link
    // function f : ajax function managed with ajaxmanager to cancel on close
    // Define vars
    var t = this, el, elTop;
    // Get the type of loader
    if (!l) {
      l = 'global';
    }
    // Create the main element
    if (t._activeLoader == '') {
      el = jQuery('<div id="plemiLibraryLoader"></div>').appendTo('body');
    }
    else {
      el = jQuery('#plemiLibraryLoader').empty();
    }
    // Insert the image
    el.append('<div class="loader"><img src="' + t.val('loader_img_' + l) + '" /></div>');
    // Insert content if exists
    if (c) {
      el.append('<div class="content">' + c + '</div>');
    }
    // Insert close button
    if (a) {
      el.append('<div class="close"><a href="/">Annuler / Fermer</a></div>');
    }
    //
    elTop = (jQuery(window).height()-t.val('loader_height_global'))/2;
    // Display the loader
    t._activeLoader = el.dialog({
      autoOpen: false,
      close : function(event, ui) {
        if (a && f) {
          jQuery.manageAjax.abort(f);
        }
      },
      dialogClass: 'plemiLibraryLoader plemiLibraryLoader_' + l,
      draggable: false,
      height : t.val('loader_height_global'),
      modal: true,
      position: ['50%', elTop],
      resizable: false,
      width : t.val('loader_width_global')
    }).dialog('open');
    jQuery('.plemiLibraryLoader.ui-dialog').css({'position':'fixed', 'top':elTop});
    jQuery('.close',el).click(function() {
      t.closeLoader(t._activeLoader);
      return false;
    });
    return true;
  },
  // closeLoader : close the displayed loading image
  closeLoader : function(d) {
    // object d : dialog to close
    // Define vars
    var t = this;
    if (!d) {
      d = t._activeLoader;
    }
    d.dialog('destroy');
  },
  // switch hidden block
  modalSwitch : function(a, b) {
    // string a : DOM element
    // boolean b : is dual switch
    // Define vars
    var t = this;
    // Switch classes
    t.toggleClasses(a, t.val('current_hidden_block'), t.val('current_shown_block'));
    if (b) {
      t.toggleClasses(jQuery(a).attr('rev'), t.val('current_hidden_block'), t.val('current_shown_block'));
    }
    // Switch display
    jQuery(jQuery(a).attr('rel')).slideToggle();
    if (b) {
      jQuery(jQuery(jQuery(a).attr('rev')).attr('rel')).slideToggle();
    }
  },
  // Toggle
  toggleClasses : function(a, b, c) {
    // string a : DOM element
    // string b : class #1
    // string c : class #2
    // Define vars
    var t = this;
    if (jQuery(a).hasClass(b)) {
      jQuery(a).removeClass(b).addClass(c);
    }
    else{
      jQuery(a).removeClass(c).addClass(b);
    }
  },
  // new Carousel
  newCarousel : function(wrapper, options) {
    // string wrapper : element ID or class of the list
    // array options : options
    // Define vars
    var t = this;
    // Init the carousel
    t.val('carousel[' + wrapper + ']', plemiCarousel.init(wrapper, options));
  },
  /*
   * Notify with Gritter library
   * @params String title : title
   * @params String text : content
   * @params String img : image absolute url
   */
  notify : function(title, text, img) {
    jQuery.gritter.add({
      title : title,
      text : text,
      image : img
    });
  }
}

// Init now
plemiLibrary.init();

// init when dom is ready
jQuery(document).ready(function() {
  plemiLibrary.initOnDomReady();
});

// Log function
jQuery.fn.log = function (msg) {
    console.log("%s: %o", msg, this);
    return this;
};
/*autocomplete*/
/*
 * Autocomplete - jQuery plugin 1.0.2
 *
 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if (!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if (k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.31.1o({12:3(b,d){5 c=Y b=="1w";d=$.1o({},$.D.1L,{11:c?b:14,w:c?14:b,1D:c?$.D.1L.1D:10,Z:d&&!d.1x?10:3U},d);d.1t=d.1t||3(a){6 a};d.1q=d.1q||d.1K;6 I.K(3(){1E $.D(I,d)})},M:3(a){6 I.X("M",a)},1y:3(a){6 I.15("1y",[a])},20:3(){6 I.15("20")},1Y:3(a){6 I.15("1Y",[a])},1X:3(){6 I.15("1X")}});$.D=3(o,r){5 t={2N:38,2I:40,2D:46,2x:9,2v:13,2q:27,2d:3x,2j:33,2o:34,2e:8};5 u=$(o).3f("12","3c").P(r.24);5 p;5 m="";5 n=$.D.2W(r);5 s=0;5 k;5 h={1z:B};5 l=$.D.2Q(r,o,1U,h);5 j;$.1T.2L&&$(o.2K).X("3S.12",3(){4(j){j=B;6 B}});u.X(($.1T.2L?"3Q":"3N")+".12",3(a){k=a.2F;3L(a.2F){Q t.2N:a.1d();4(l.L()){l.2y()}A{W(0,C)}N;Q t.2I:a.1d();4(l.L()){l.2u()}A{W(0,C)}N;Q t.2j:a.1d();4(l.L()){l.2t()}A{W(0,C)}N;Q t.2o:a.1d();4(l.L()){l.2s()}A{W(0,C)}N;Q r.19&&$.1p(r.R)==","&&t.2d:Q t.2x:Q t.2v:4(1U()){a.1d();j=C;6 B}N;Q t.2q:l.U();N;3A:1I(p);p=1H(W,r.1D);N}}).1G(3(){s++}).3v(3(){s=0;4(!h.1z){2k()}}).2i(3(){4(s++>1&&!l.L()){W(0,C)}}).X("1y",3(){5 c=(1n.7>1)?1n[1]:14;3 23(q,a){5 b;4(a&&a.7){16(5 i=0;i<a.7;i++){4(a[i].M.O()==q.O()){b=a[i];N}}}4(Y c=="3")c(b);A u.15("M",b&&[b.w,b.H])}$.K(1g(u.J()),3(i,a){1R(a,23,23)})}).X("20",3(){n.18()}).X("1Y",3(){$.1o(r,1n[1]);4("w"2G 1n[1])n.1f()}).X("1X",3(){l.1u();u.1u();$(o.2K).1u(".12")});3 1U(){5 b=l.26();4(!b)6 B;5 v=b.M;m=v;4(r.19){5 a=1g(u.J());4(a.7>1){v=a.17(0,a.7-1).2Z(r.R)+r.R+v}v+=r.R}u.J(v);1l();u.15("M",[b.w,b.H]);6 C}3 W(b,c){4(k==t.2D){l.U();6}5 a=u.J();4(!c&&a==m)6;m=a;a=1k(a);4(a.7>=r.22){u.P(r.21);4(!r.1C)a=a.O();1R(a,2V,1l)}A{1B();l.U()}};3 1g(b){4(!b){6[""]}5 d=b.1Z(r.R);5 c=[];$.K(d,3(i,a){4($.1p(a))c[i]=$.1p(a)});6 c}3 1k(a){4(!r.19)6 a;5 b=1g(a);6 b[b.7-1]}3 1A(q,a){4(r.1A&&(1k(u.J()).O()==q.O())&&k!=t.2e){u.J(u.J()+a.48(1k(m).7));$.D.1N(o,m.7,m.7+a.7)}};3 2k(){1I(p);p=1H(1l,47)};3 1l(){5 c=l.L();l.U();1I(p);1B();4(r.2U){u.1y(3(a){4(!a){4(r.19){5 b=1g(u.J()).17(0,-1);u.J(b.2Z(r.R)+(b.7?r.R:""))}A u.J("")}})}4(c)$.D.1N(o,o.H.7,o.H.7)};3 2V(q,a){4(a&&a.7&&s){1B();l.2T(a,q);1A(q,a[0].H);l.1W()}A{1l()}};3 1R(f,d,g){4(!r.1C)f=f.O();5 e=n.2S(f);4(e&&e.7){d(f,e)}A 4((Y r.11=="1w")&&(r.11.7>0)){5 c={45:+1E 44()};$.K(r.2R,3(a,b){c[a]=Y b=="3"?b():b});$.43({42:"41",3Z:"12"+o.3Y,2M:r.2M,11:r.11,w:$.1o({q:1k(f),3X:r.Z},c),3W:3(a){5 b=r.1r&&r.1r(a)||1r(a);n.1h(f,b);d(f,b)}})}A{l.2J();g(f)}};3 1r(c){5 d=[];5 b=c.1Z("\\n");16(5 i=0;i<b.7;i++){5 a=$.1p(b[i]);4(a){a=a.1Z("|");d[d.7]={w:a,H:a[0],M:r.1v&&r.1v(a,a[0])||a[0]}}}6 d};3 1B(){u.1e(r.21)}};$.D.1L={24:"3R",2H:"3P",21:"3O",22:1,1D:3M,1C:B,1a:C,1V:B,1j:10,Z:3K,2U:B,2R:{},1S:C,1K:3(a){6 a[0]},1q:14,1A:B,E:0,19:B,R:", ",1t:3(b,a){6 b.2C(1E 3J("(?![^&;]+;)(?!<[^<>]*)("+a.2C(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2A,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2A"),"<2z>$1</2z>")},1x:C,1s:3I};$.D.2W=3(g){5 h={};5 j=0;3 1a(s,a){4(!g.1C)s=s.O();5 i=s.3H(a);4(i==-1)6 B;6 i==0||g.1V};3 1h(q,a){4(j>g.1j){18()}4(!h[q]){j++}h[q]=a}3 1f(){4(!g.w)6 B;5 f={},2w=0;4(!g.11)g.1j=1;f[""]=[];16(5 i=0,30=g.w.7;i<30;i++){5 c=g.w[i];c=(Y c=="1w")?[c]:c;5 d=g.1q(c,i+1,g.w.7);4(d===B)1P;5 e=d.3G(0).O();4(!f[e])f[e]=[];5 b={H:d,w:c,M:g.1v&&g.1v(c)||d};f[e].1O(b);4(2w++<g.Z){f[""].1O(b)}};$.K(f,3(i,a){g.1j++;1h(i,a)})}1H(1f,25);3 18(){h={};j=0}6{18:18,1h:1h,1f:1f,2S:3(q){4(!g.1j||!j)6 14;4(!g.11&&g.1V){5 a=[];16(5 k 2G h){4(k.7>0){5 c=h[k];$.K(c,3(i,x){4(1a(x.H,q)){a.1O(x)}})}}6 a}A 4(h[q]){6 h[q]}A 4(g.1a){16(5 i=q.7-1;i>=g.22;i--){5 c=h[q.3F(0,i)];4(c){5 a=[];$.K(c,3(i,x){4(1a(x.H,q)){a[a.7]=x}});6 a}}}6 14}}};$.D.2Q=3(e,g,f,k){5 h={G:"3E"};5 j,y=-1,w,1m="",1M=C,F,z;3 2r(){4(!1M)6;F=$("<3D/>").U().P(e.2H).T("3C","3B").1J(2p.2n);z=$("<3z/>").1J(F).3y(3(a){4(V(a).2m&&V(a).2m.3w()==\'2l\'){y=$("1F",z).1e(h.G).3u(V(a));$(V(a)).P(h.G)}}).2i(3(a){$(V(a)).P(h.G);f();g.1G();6 B}).3t(3(){k.1z=C}).3s(3(){k.1z=B});4(e.E>0)F.T("E",e.E);1M=B}3 V(a){5 b=a.V;3r(b&&b.3q!="2l")b=b.3p;4(!b)6[];6 b}3 S(b){j.17(y,y+1).1e(h.G);2h(b);5 a=j.17(y,y+1).P(h.G);4(e.1x){5 c=0;j.17(0,y).K(3(){c+=I.1i});4((c+a[0].1i-z.1c())>z[0].3o){z.1c(c+a[0].1i-z.3n())}A 4(c<z.1c()){z.1c(c)}}};3 2h(a){y+=a;4(y<0){y=j.1b()-1}A 4(y>=j.1b()){y=0}}3 2g(a){6 e.Z&&e.Z<a?e.Z:a}3 2f(){z.2B();5 b=2g(w.7);16(5 i=0;i<b;i++){4(!w[i])1P;5 a=e.1K(w[i].w,i+1,b,w[i].H,1m);4(a===B)1P;5 c=$("<1F/>").3m(e.1t(a,1m)).P(i%2==0?"3l":"3k").1J(z)[0];$.w(c,"2c",w[i])}j=z.3j("1F");4(e.1S){j.17(0,1).P(h.G);y=0}4($.31.2b)z.2b()}6{2T:3(d,q){2r();w=d;1m=q;2f()},2u:3(){S(1)},2y:3(){S(-1)},2t:3(){4(y!=0&&y-8<0){S(-y)}A{S(-8)}},2s:3(){4(y!=j.1b()-1&&y+8>j.1b()){S(j.1b()-1-y)}A{S(8)}},U:3(){F&&F.U();j&&j.1e(h.G);y=-1},L:3(){6 F&&F.3i(":L")},3h:3(){6 I.L()&&(j.2a("."+h.G)[0]||e.1S&&j[0])},1W:3(){5 a=$(g).3g();F.T({E:Y e.E=="1w"||e.E>0?e.E:$(g).E(),2E:a.2E+g.1i,1Q:a.1Q}).1W();4(e.1x){z.1c(0);z.T({29:e.1s,3e:\'3d\'});4($.1T.3b&&Y 2p.2n.3T.29==="3a"){5 c=0;j.K(3(){c+=I.1i});5 b=c>e.1s;z.T(\'3V\',b?e.1s:c);4(!b){j.E(z.E()-28(j.T("32-1Q"))-28(j.T("32-39")))}}}},26:3(){5 a=j&&j.2a("."+h.G).1e(h.G);6 a&&a.7&&$.w(a[0],"2c")},2J:3(){z&&z.2B()},1u:3(){F&&F.37()}}};$.D.1N=3(b,a,c){4(b.2O){5 d=b.2O();d.36(C);d.35("2P",a);d.4c("2P",c);d.4b()}A 4(b.2Y){b.2Y(a,c)}A{4(b.2X){b.2X=a;b.4a=c}}b.1G()}})(49);',62,261,'|||function|if|var|return|length|||||||||||||||||||||||||data||active|list|else|false|true|Autocompleter|width|element|ACTIVE|value|this|val|each|visible|result|break|toLowerCase|addClass|case|multipleSeparator|moveSelect|css|hide|target|onChange|bind|typeof|max||url|autocomplete||null|trigger|for|slice|flush|multiple|matchSubset|size|scrollTop|preventDefault|removeClass|populate|trimWords|add|offsetHeight|cacheLength|lastWord|hideResultsNow|term|arguments|extend|trim|formatMatch|parse|scrollHeight|highlight|unbind|formatResult|string|scroll|search|mouseDownOnSelect|autoFill|stopLoading|matchCase|delay|new|li|focus|setTimeout|clearTimeout|appendTo|formatItem|defaults|needsInit|Selection|push|continue|left|request|selectFirst|browser|selectCurrent|matchContains|show|unautocomplete|setOptions|split|flushCache|loadingClass|minChars|findValueCallback|inputClass||selected||parseInt|maxHeight|filter|bgiframe|ac_data|COMMA|BACKSPACE|fillList|limitNumberOfItems|movePosition|click|PAGEUP|hideResults|LI|nodeName|body|PAGEDOWN|document|ESC|init|pageDown|pageUp|next|RETURN|nullData|TAB|prev|strong|gi|empty|replace|DEL|top|keyCode|in|resultsClass|DOWN|emptyList|form|opera|dataType|UP|createTextRange|character|Select|extraParams|load|display|mustMatch|receiveData|Cache|selectionStart|setSelectionRange|join|ol|fn|padding|||moveStart|collapse|remove||right|undefined|msie|off|auto|overflow|attr|offset|current|is|find|ac_odd|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|188|mouseover|ul|default|absolute|position|div|ac_over|substr|charAt|indexOf|180|RegExp|100|switch|400|keydown|ac_loading|ac_results|keypress|ac_input|submit|style|150|height|success|limit|name|port||abort|mode|ajax|Date|timestamp||200|substring|jQuery|selectionEnd|select|moveEnd'.split('|'),0,{}));

/*dimensions*/
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
(function($){$.dimensions={version:'1.2'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;};})(jQuery);
/*cookie*/
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
/*ajaxmanager*/
/**
 * @author alexander.farkas
 * 
 * @version 2.5
 * project site: http://plugins.jquery.com/project/AjaxManager
 */
(function($){
	
	$.manageAjax = (function(){
		var cache 			= {},
			queues			= {},
			presets 		= {},
			activeRequest 	= {},
			allRequests 	= {},
			triggerEndCache = {},
			defaults 		= {
						queue: true, //clear
						maxRequests: 1,
						abortOld: false,
						preventDoubbleRequests: true,
						cacheResponse: false,
						complete: function(){},
						error: function(ahr, status){
							var opts = this;
							if (status &&  status.indexOf('error') != -1){
								setTimeout(function(){
									var errStr = status +': ';
									if (ahr.status){
										errStr += 'status: '+ ahr.status +' | ';
									}
									errStr += 'URL: '+ opts.url;
									throw new Error(errStr);
								}, 1);
							}
						},
						success: function(){},
						abort: function(){}
				}
		;
		
		function create(name, settings){
			var publicMethods = {};
			presets[name] = presets[name] ||
				{};
			
			$.extend(true, presets[name], $.ajaxSettings, defaults, settings);
			if (!allRequests[name]){
				allRequests[name] 	= {};
				activeRequest[name] = {};
				activeRequest[name].queue = [];
				queues[name] 		= [];
				triggerEndCache[name] = [];
			}
			$.each($.manageAjax, function(fnName, fn){
				if ($.isFunction(fn) && fnName.indexOf('_') !== 0){
					publicMethods[fnName] = function(param, param2){
						if (param2 && typeof param === 'string'){
							param = param2;
						}
						fn(name, param);
					};
				}
			});
			return publicMethods;
		}
		
		function complete(opts, args){
			
			if (args[1] == 'success' || args[1] == 'notmodified'){
				opts.success.apply(opts, [args[0].successData, args[1]]);
				if (opts.global) {
					$.event.trigger("ajaxSuccess", args);
				}
			}
			
			if (args[1] === 'abort'){
				opts.abort.apply(opts, args);
				if (opts.global){
					$.active--;
					$.event.trigger("ajaxAbort", args);
				}
			}
			
			opts.complete.apply(opts, args);
			
			if (opts.global) {
				$.event.trigger("ajaxComplete", args);
			}
			
			if (opts.global && ! $.active){
				$.event.trigger("ajaxStop");
			}
			//args[0] = null; 
		}
		
		function proxy(oldFn, fn){
			return function(xhr, s, e){
				fn.call(this, xhr, s, e);
				oldFn.call(this, xhr, s, e);
				xhr = null;
				e = null;
			};
		}
		
					
		function callQueueFn(name){
			var q = queues[name];
			if (q && q.length){
				var fn = q.shift();
				if (fn){
					fn();
				}
			}
		}

		
		function add(name, opts){
			if (!presets[name]){
				create(name, opts);
			}
			opts = $.extend({}, presets[name], opts);
			//aliases
			var allR 	= allRequests[name],
				activeR = activeRequest[name],
				queue	= queues[name];
			
			var id 				= opts.type +'_'+ opts.url.replace(/\./g, '_'),
				triggerStart 	= true,
				oldComplete 	= opts.complete,
				ajaxFn 			= function(){
									activeR[id] = {
										xhr: $.ajax(opts),
										ajaxManagerOpts: opts
									};
									activeR.queue.push(id);
									return id;
								}
				;
				
			if (opts.data){
				id += (typeof opts.data == 'string') ? opts.data : $.param(opts.data);
			}
			
			if (opts.preventDoubbleRequests && allRequests[name][id]){
				return false;
			}
			
			allR[id] = true;
			
			opts.complete = function(xhr, s, e){
				var triggerEnd = true;
				if (opts.abortOld){
					$.each(activeR.queue, function(i, activeID){
						if (activeID == id){
							return false;
						}
						abort(name, activeID);
						return activeID;
					});
				}
				oldComplete.call(this, xhr, s, e);
				//stop memory leak
				if (activeRequest[name][id]){
					if (activeRequest[name][id] && activeRequest[name][id].xhr){
						activeRequest[name][id].xhr = null;
					} 
					activeRequest[name][id] = null;
				}
				triggerEndCache[name].push({xhr: xhr, status: s});
				xhr = null;
				activeRequest[name].queue = $.grep(activeRequest[name].queue, function(qid){
					return (qid !== id);
				});
				allR[id] = false;
				
				e = null;
				
				delete activeRequest[name][id];
				
				$.each(activeR, function(id, queueRunning){
					if (id !== 'queue' || queueRunning.length){
						triggerEnd = false;
						return false;
					}
				});
				
				if (triggerEnd){
					$.event.trigger(name +'End', [triggerEndCache[name]]);
					$.each(triggerEndCache[name], function(i, cached){
						cached.xhr = null; //memory leak
					});
					triggerEndCache[name] = [];
				}
			};
			
			if (cache[id]){
				ajaxFn = function(){
					activeR.queue.push(id);
					complete(opts, cache[id]);
					return id;
				};
			} else if (opts.cacheResponse){
				 opts.complete = proxy(opts.complete, function(xhr, s){
					if ( s !== "success" && s !== "notmodified" ){
						return false;
					}
					cache[id][0].responseXML 	= xhr.responseXML;
					cache[id][0].responseText 	= xhr.responseText;
					cache[id][1] 				= s;
					//stop memory leak
					xhr = null;
					return id; //strict
				});
				
				opts.success = proxy(opts.success, function(data, s){
					cache[id] = [{
						successData: data,
						ajaxManagerOpts: opts
					}, s];
					data = null;
				});
			}
			
			ajaxFn.ajaxID = id;
			
			$.each(activeR, function(id, queueRunning){
				if (id !== 'queue' || queueRunning.length){
					triggerStart = false;
					return false;
				}
			});
			
			if (triggerStart){
				$.event.trigger(name +'Start');
			}
			if (opts.queue){
				opts.complete = proxy(opts.complete, function(){
					
					callQueueFn(name);
				});
				 
				if (opts.queue === 'clear'){
					queue = clear(name);
				}
				
				queue.push(ajaxFn);
				
				if (activeR.queue.length < opts.maxRequests){
					callQueueFn(name); 
				}
				return id;
			}
			
			
			
			return ajaxFn();
		}
		
		function clear(name, shouldAbort){
			$.each(queues[name], function(i, fn){
				allRequests[name][fn.ajaxID] = false;
			});
			queues[name] = [];
			
			if (shouldAbort){
				abort(name);
			}
			return queues[name];
		}
		
		function getXHR(name, id){
			var ar = activeRequest[name];
			if (!ar || !allRequests[name][id]){
				return false;
			}
			if (ar[id]){
				return ar[id].xhr;
			}
			var queue = queues[name],
				xhrFn;
			$.each(queue, function(i, fn){
				if (fn.ajaxID == id){
					xhrFn = [fn, i];
					return false;
				}
				return xhrFn;
			});
			return xhrFn;
		}
		
		function abort(name, id){
			var ar = activeRequest[name];
			if (!ar){
				return false;
			}
			function abortID(qid){
				if (qid !== 'queue' && ar[qid] && typeof ar[qid].xhr !== 'unedfiend' && typeof ar[qid].xhr.abort !== 'unedfiend'){
					ar[qid].xhr.abort();
					complete(ar[qid].ajaxManagerOpts, [ar[qid].xhr, 'abort']);
				}
				return null;
			}
			if (id){
				return abortID(id);
			}
			return $.each(ar, abortID);
		}
		
		function unload(){
			$.each(presets, function(name){
				clear(name, true);
			});
			cache = {};
		}
		
		return {
			defaults: 		defaults,
			add: 			add,
			create: 		create,
			cache: 			cache,
			abort: 			abort,
			clear: 			clear,
			getXHR: 		getXHR,
			_activeRequest: activeRequest,
			_complete: 		complete,
			_allRequests: 	allRequests,
			_unload: 		unload
		};
	})();
	//stop memory leaks
	$(window).unload($.manageAjax._unload);
})(jQuery);
/*markitup*/
// ----------------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// v 1.1.5
// Dual licensed under the MIT and GPL licenses.
// ----------------------------------------------------------------------------
// Copyright (C) 2007-2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if (!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if (k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){$.24.T=3(f,g){E k,v,A,F;v=A=F=7;k={C:\'\',12:\'\',U:\'\',1j:\'\',1A:8,25:\'26\',1k:\'~/2Q/1B.1C\',1b:\'\',27:\'28\',1l:8,1D:\'\',1E:\'\',1F:{},1G:{},1H:{},1I:{},29:[{}]};$.V(k,f,g);2(!k.U){$(\'2R\').1c(3(a,b){1J=$(b).14(0).2S.2T(/(.*)2U\\.2V(\\.2W)?\\.2X$/);2(1J!==2a){k.U=1J[1]}})}4 G.1c(3(){E d,u,15,16,p,H,L,P,17,1m,w,1n,M,18;d=$(G);u=G;15=[];18=7;16=p=0;H=-1;k.1b=1d(k.1b);k.1k=1d(k.1k);3 1d(a,b){2(b){4 a.W(/("|\')~\\//g,"$1"+k.U)}4 a.W(/^~\\//,k.U)}3 2b(){C=\'\';12=\'\';2(k.C){C=\'C="\'+k.C+\'"\'}l 2(d.1K("C")){C=\'C="T\'+(d.1K("C").2c(0,1).2Y())+(d.1K("C").2c(1))+\'"\'}2(k.12){12=\'N="\'+k.12+\'"\'}d.1L(\'<z \'+12+\'></z>\');d.1L(\'<z \'+C+\' N="T"></z>\');d.1L(\'<z N="2Z"></z>\');d.2d("2e");17=$(\'<z N="30"></z>\').2f(d);$(1M(k.29)).1N(17);1m=$(\'<z N="31"></z>\').1O(d);2(k.1l===8&&$.X.32!==8){1l=$(\'<z N="33"></z>\').1O(d).1e("34",3(e){E h=d.2g(),y=e.2h,1o,1p;1o=3(e){d.2i("2g",35.36(20,e.2h+h-y)+"37");4 7};1p=3(e){$("1C").1P("2j",1o).1P("1q",1p);4 7};$("1C").1e("2j",1o).1e("1q",1p)});1m.2k(1l)}d.2l(1Q).38(1Q);d.1e("1R",3(e,a){2(a.1r!==7){14()}2(u===$.T.2m){Y(a)}});d.1f(3(){$.T.2m=G})}3 1M(b){E c=$(\'<Z></Z>\'),i=0;$(\'B:2n > Z\',c).2i(\'39\',\'q\');$.1c(b,3(){E a=G,t=\'\',1s,B,j;1s=(a.19)?(a.1S||\'\')+\' [3a+\'+a.19+\']\':(a.1S||\'\');19=(a.19)?\'2o="\'+a.19+\'"\':\'\';2(a.2p){B=$(\'<B N="3b">\'+(a.2p||\'\')+\'</B>\').1N(c)}l{i++;2q(j=15.6-1;j>=0;j--){t+=15[j]+"-"}B=$(\'<B N="2r 2r\'+t+(i)+\' \'+(a.3c||\'\')+\'"><a 3d="" \'+19+\' 1s="\'+1s+\'">\'+(a.1S||\'\')+\'</a></B>\').1e("3e",3(){4 7}).2s(3(){4 7}).1q(3(){2(a.2t){3f(a.2t)()}Y(a);4 7}).2n(3(){$(\'> Z\',G).3g();$(D).3h(\'2s\',3(){$(\'Z Z\',17).2u()})},3(){$(\'> Z\',G).2u()}).1N(c);2(a.2v){15.3i(i);$(B).2d(\'3j\').2k(1M(a.2v))}}});15.3k();4 c}3 2w(c){2(c){c=c.3l();c=c.W(/\\(\\!\\(([\\s\\S]*?)\\)\\!\\)/g,3(x,a){E b=a.1T(\'|!|\');2(F===8){4(b[1]!==2x)?b[1]:b[0]}l{4(b[1]===2x)?"":b[0]}});c=c.W(/\\[\\!\\[([\\s\\S]*?)\\]\\!\\]/g,3(x,a){E b=a.1T(\':!:\');2(18===8){4 7}1U=3m(b[0],(b[1])?b[1]:\'\');2(1U===2a){18=8}4 1U});4 c}4""}3 I(a){2($.3n(a)){a=a(P)}4 2w(a)}3 1g(a){J=I(L.J);1a=I(L.1a);Q=I(L.Q);O=I(L.O);2(Q!==""){q=J+Q+O}l 2(m===\'\'&&1a!==\'\'){q=J+1a+O}l{q=J+(a||m)+O}4{q:q,J:J,Q:Q,1a:1a,O:O}}3 Y(a){E b,j,n,i;P=L=a;14();$.V(P,{1t:"",U:k.U,u:u,m:(m||\'\'),p:p,v:v,A:A,F:F});I(k.1D);I(L.1D);2(v===8&&A===8){I(L.3o)}$.V(P,{1t:1});2(v===8&&A===8){R=m.1T(/\\r?\\n/);2q(j=0,n=R.6,i=0;i<n;i++){2($.3p(R[i])!==\'\'){$.V(P,{1t:++j,m:R[i]});R[i]=1g(R[i]).q}l{R[i]=""}}o={q:R.3q(\'\\n\')};11=p;b=o.q.6+(($.X.1V)?n:0)}l 2(v===8){o=1g(m);11=p+o.J.6;b=o.q.6-o.J.6-o.O.6;b-=1u(o.q)}l 2(A===8){o=1g(m);11=p;b=o.q.6;b-=1u(o.q)}l{o=1g(m);11=p+o.q.6;b=0;11-=1u(o.q)}2((m===\'\'&&o.Q===\'\')){H+=1W(o.q);11=p+o.J.6;b=o.q.6-o.J.6-o.O.6;H=d.K().1h(p,d.K().6).6;H-=1W(d.K().1h(0,p))}$.V(P,{p:p,16:16});2(o.q!==m&&18===7){2y(o.q);1X(11,b)}l{H=-1}14();$.V(P,{1t:\'\',m:m});2(v===8&&A===8){I(L.3r)}I(L.1E);I(k.1E);2(w&&k.1A){1Y()}A=F=v=18=7}3 1W(a){2($.X.1V){4 a.6-a.W(/\\n*/g,\'\').6}4 0}3 1u(a){2($.X.2z){4 a.6-a.W(/\\r*/g,\'\').6}4 0}3 2y(a){2(D.m){E b=D.m.1Z();b.2A=a}l{d.K(d.K().1h(0,p)+a+d.K().1h(p+m.6,d.K().6))}}3 1X(a,b){2(u.2B){2($.X.1V&&$.X.3s>=9.5&&b==0){4 7}1i=u.2B();1i.3t(8);1i.2C(\'21\',a);1i.3u(\'21\',b);1i.3v()}l 2(u.2D){u.2D(a,a+b)}u.1v=16;u.1f()}3 14(){u.1f();16=u.1v;2(D.m){m=D.m.1Z().2A;2($.X.2z){E a=D.m.1Z(),1w=a.3w();1w.3x(u);p=-1;3y(1w.3z(a)){1w.2C(\'21\');p++}}l{p=u.2E}}l{p=u.2E;m=d.K().1h(p,u.3A)}4 m}3 1B(){2(!w||w.3B){2(k.1j){w=3C.2F(\'\',\'1B\',k.1j)}l{M=$(\'<2G N="3D"></2G>\');2(k.25==\'26\'){M.1O(1m)}l{M.2f(17)}w=M[M.6-1].3E||3F[M.6-1]}}l 2(F===8){2(M){M.3G()}w.2H();w=M=7}2(!k.1A){1Y()}}3 1Y(){2(w.D){3H{22=w.D.2I.1v}3I(e){22=0}w.D.2F();w.D.3J(2J());w.D.2H();w.D.2I.1v=22}2(k.1j){w.1f()}}3 2J(){2(k.1b!==\'\'){$.2K({2L:\'3K\',2M:7,2N:k.1b,28:k.27+\'=\'+3L(d.K()),2O:3(a){23=1d(a,1)}})}l{2(!1n){$.2K({2M:7,2N:k.1k,2O:3(a){1n=1d(a,1)}})}23=1n.W(/<!-- 3M -->/g,d.K())}4 23}3 1Q(e){A=e.A;F=e.F;v=(!(e.F&&e.v))?e.v:7;2(e.2L===\'2l\'){2(v===8){B=$("a[2o="+3N.3O(e.1x)+"]",17).1y(\'B\');2(B.6!==0){v=7;B.3P(\'1q\');4 7}}2(e.1x===13||e.1x===10){2(v===8){v=7;Y(k.1H);4 k.1H.1z}l 2(A===8){A=7;Y(k.1G);4 k.1G.1z}l{Y(k.1F);4 k.1F.1z}}2(e.1x===9){2(A==8||v==8||F==8){4 7}2(H!==-1){14();H=d.K().6-H;1X(H,0);H=-1;4 7}l{Y(k.1I);4 k.1I.1z}}}}2b()})};$.24.3Q=3(){4 G.1c(3(){$$=$(G).1P().3R(\'2e\');$$.1y(\'z\').1y(\'z.T\').1y(\'z\').Q($$)})};$.T=3(a){E b={1r:7};$.V(b,a);2(b.1r){4 $(b.1r).1c(3(){$(G).1f();$(G).2P(\'1R\',[b])})}l{$(\'u\').2P(\'1R\',[b])}}})(3S);',62,241,'||if|function|return||length|false|true|||||||||||||else|selection||string|caretPosition|block||||textarea|ctrlKey|previewWindow|||div|shiftKey|li|id|document|var|altKey|this|caretOffset|prepare|openWith|val|clicked|iFrame|class|closeWith|hash|replaceWith|lines||markItUp|root|extend|replace|browser|markup|ul||start|nameSpace||get|levels|scrollPosition|header|abort|key|placeHolder|previewParserPath|each|localize|bind|focus|build|substring|range|previewInWindow|previewTemplatePath|resizeHandle|footer|template|mouseMove|mouseUp|mouseup|target|title|line|fixIeBug|scrollTop|rangeCopy|keyCode|parent|keepDefault|previewAutoRefresh|preview|html|beforeInsert|afterInsert|onEnter|onShiftEnter|onCtrlEnter|onTab|miuScript|attr|wrap|dropMenus|appendTo|insertAfter|unbind|keyPressed|insertion|name|split|value|opera|fixOperaBug|set|refreshPreview|createRange||character|sp|phtml|fn|previewPosition|after|previewParserVar|data|markupSet|null|init|substr|addClass|markItUpEditor|insertBefore|height|clientY|css|mousemove|append|keydown|focused|hover|accesskey|separator|for|markItUpButton|click|call|hide|dropMenu|magicMarkups|undefined|insert|msie|text|createTextRange|moveStart|setSelectionRange|selectionStart|open|iframe|close|documentElement|renderPreview|ajax|type|async|url|success|trigger|templates|script|src|match|jquery|markitup|pack|js|toUpperCase|markItUpContainer|markItUpHeader|markItUpFooter|safari|markItUpResizeHandle|mousedown|Math|max|px|keyup|display|Ctrl|markItUpSeparator|className|href|contextmenu|eval|show|one|push|markItUpDropMenu|pop|toString|prompt|isFunction|beforeMultiInsert|trim|join|afterMultiInsert|version|collapse|moveEnd|select|duplicate|moveToElementText|while|inRange|selectionEnd|closed|window|markItUpPreviewFrame|contentWindow|frame|remove|try|catch|write|POST|encodeURIComponent|content|String|fromCharCode|triggerHandler|markItUpRemove|removeClass|jQuery'.split('|'),0,{}))
/*set*/
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
myBbcodeSettings = {
  previewParserPath:  "/fr/previewBbcode",
  //previewInWindow: 'width=800, height=600, resizable=yes, scrollbars=yes',
  markupSet: [
      {name:'Bold', key:'B', openWith:'[b]', closeWith:'[/b]'}, 
      {name:'Italic', key:'I', openWith:'[i]', closeWith:'[/i]'}, 
      {name:'Underline', key:'U', openWith:'[u]', closeWith:'[/u]'}, 
      {name:'Bulleted list', openWith:'[list]\n', closeWith:'\n[/list]'},
      {name:'Clean', className:"clean", replaceWith:function(h) { return h.selection.replace(/\[(.*?)\]/g, "") } },
      {name:'Preview', className:"preview", call:'preview' }
   ]
};

myCommentairesSettings = {
		  nameSpace:'markitcommentaires',
		  previewParserPath:  "/fr/previewBbcode",
		  //previewInWindow: 'width=300, height=300, resizable=no, scrollbars=yes',
		  markupSet: [
		      {name:'Bold', key:'B', openWith:'[b]', closeWith:'[/b]'}, 
		      {name:'Italic', key:'I', openWith:'[i]', closeWith:'[/i]'}, 
		      {name:'Underline', key:'U', openWith:'[u]', closeWith:'[/u]'}, 
		      {name:'Bulleted list', openWith:'[list]\n', closeWith:'\n[/list]'},
		      {name:'Clean', className:"clean", replaceWith:function(h) { return h.selection.replace(/\[(.*?)\]/g, "") } },
		      {name:'Preview', className:"preview", call:'preview' }
		   ]
		};
/*/ui/jquery.ui.stars-2.1/ui.stars.min.js*/
/*
 * jQuery UI Stars v2.1.1
 * http://plugins.jquery.com/project/Star_Rating_widget
 *
 * Copyright (c) 2009 Orkan (orkans@gmail.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * $Rev: 114 $
 * $Date:: 2009-06-12 #$
 * $Build: 32 (2009-06-12)
 *
 * Depends:
 *  ui.core.js
 *
 */
(function(A){A.widget("ui.stars",{_init:function(){var B=this,E=this.options,F=0;E.isSelect=E.inputType=="select";this.$form=A(this.element).closest("form");this.$selec=E.isSelect?A("select",this.element):null;this.$rboxs=E.isSelect?A("option",this.$selec):A(":radio",this.element);this.$stars=this.$rboxs.map(function(I){var J={value:this.value,title:(E.isSelect?this.text:this.title)||this.value,isDefault:(E.isSelect&&this.defaultSelected)||this.defaultChecked};if (I==0){E.split=typeof E.split!="number"?0:E.split;E.val2id=[];E.id2val=[];E.id2title=[];E.name=E.isSelect?B.$selec.get(0).name:this.name;E.disabled=E.disabled||(E.isSelect?A(B.$selec).attr("disabled"):A(this).attr("disabled"))}if (J.value==E.cancelValue){E.cancelTitle=J.title;return null}E.val2id[J.value]=F;E.id2val[F]=J.value;E.id2title[F]=J.title;if (J.isDefault){E.checked=F;E.value=E.defaultValue=J.value;E.title=J.title}var H=A("<div/>").addClass(E.starClass);var K=A("<a/>").attr("title",E.showTitles?J.title:"").text(J.value);if (E.split){var G=(F%E.split);var L=Math.floor(E.starWidth/E.split);H.width(L);K.css("margin-left","-"+(G*L)+"px")}F++;return H.append(K).get(0)});E.items=F;E.isSelect?this.$selec.remove():this.$rboxs.remove();this.$cancel=A("<div/>").addClass(E.cancelClass).append(A("<a/>").attr("title",E.showTitles?E.cancelTitle:"").text(E.cancelValue));E.cancelShow&=!E.disabled&&!E.oneVoteOnly;E.cancelShow&&this.element.append(this.$cancel);this.element.append(this.$stars);if (E.checked===undefined){E.checked=-1;E.value=E.defaultValue=E.cancelValue;E.title=""}this.$value=A('<input type="hidden" name="'+E.name+'" value="'+E.value+'" />');this.element.append(this.$value);this.$stars.bind("click.stars",function(H){if (!E.forceSelect&&E.disabled){return false}var G=B.$stars.index(this);E.checked=G;E.value=E.id2val[G];E.title=E.id2title[G];B.$value.attr({disabled:E.disabled?"disabled":"",value:E.value});C(G,false);B._disableCancel();!E.forceSelect&&B.callback(H,"star")}).bind("mouseover.stars",function(){if (E.disabled){return false}var G=B.$stars.index(this);C(G,true)}).bind("mouseout.stars",function(){if (E.disabled){return false}C(B.options.checked,false)});this.$cancel.bind("click.stars",function(G){if (!E.forceSelect&&(E.disabled||E.value==E.cancelValue)){return false}E.checked=-1;E.value=E.cancelValue;E.title="";B.$value.val(E.value).attr({disabled:"disabled"});D();B._disableCancel();!E.forceSelect&&B.callback(G,"cancel")}).bind("mouseover.stars",function(){if (B._disableCancel()){return false}B.$cancel.addClass(E.cancelHoverClass);D();B._showCap(E.cancelTitle)}).bind("mouseout.stars",function(){if (B._disableCancel()){return false}B.$cancel.removeClass(E.cancelHoverClass);B.$stars.triggerHandler("mouseout.stars")});this.$form.bind("reset.stars",function(){!E.disabled&&B.select(E.defaultValue)});A(window).unload(function(){B.$cancel.unbind(".stars");B.$stars.unbind(".stars");B.$form.unbind(".stars");B.$selec=B.$rboxs=B.$stars=B.$value=B.$cancel=B.$form=null});function C(G,I){if (G!=-1){var J=I?E.starHoverClass:E.starOnClass;var H=I?E.starOnClass:E.starHoverClass;B.$stars.eq(G).prevAll("."+E.starClass).andSelf().removeClass(H).addClass(J);B.$stars.eq(G).nextAll("."+E.starClass).removeClass(E.starHoverClass+" "+E.starOnClass);B._showCap(E.id2title[G])}else{D()}}function D(){B.$stars.removeClass(E.starOnClass+" "+E.starHoverClass);B._showCap("")}this.select(E.value);E.disabled&&this.disable()},_disableCancel:function(){var C=this.options,B=C.disabled||C.oneVoteOnly||(C.value==C.cancelValue);if (B){this.$cancel.removeClass(C.cancelHoverClass).addClass(C.cancelDisabledClass)}else{this.$cancel.removeClass(C.cancelDisabledClass)}this.$cancel.css("opacity",B?0.5:1);return B},_disableAll:function(){var B=this.options;this._disableCancel();if (B.disabled){this.$stars.filter("div").addClass(B.starDisabledClass)}else{this.$stars.filter("div").removeClass(B.starDisabledClass)}},_showCap:function(B){var C=this.options;if (C.captionEl){C.captionEl.text(B)}},value:function(){return this.options.value},select:function(D){var C=this.options,B=(D==C.cancelValue)?this.$cancel:this.$stars.eq(C.val2id[D]);C.forceSelect=true;B.triggerHandler("click.stars");C.forceSelect=false},selectID:function(D){var C=this.options,B=(D==-1)?this.$cancel:this.$stars.eq(D);C.forceSelect=true;B.triggerHandler("click.stars");C.forceSelect=false},enable:function(){this.options.disabled=false;this._disableAll()},disable:function(){this.options.disabled=true;this._disableAll()},destroy:function(){this.options.isSelect?this.$selec.appendTo(this.element):this.$rboxs.appendTo(this.element);this.$form.unbind(".stars");this.$cancel.unbind(".stars").remove();this.$stars.unbind(".stars").remove();this.$value.remove();this.element.unbind(".stars").removeData("stars")},callback:function(C,B){var D=this.options;D.callback&&D.callback(this,B,D.value,C);D.oneVoteOnly&&!D.disabled&&this.disable()}});A.extend(A.ui.stars,{version:"2.1.1",getter:"value",defaults:{inputType:"radio",split:0,disabled:false,cancelTitle:"Cancel Rating",cancelValue:0,cancelShow:true,oneVoteOnly:false,showTitles:false,captionEl:null,callback:null,starWidth:16,cancelClass:"ui-stars-cancel",starClass:"ui-stars-star",starOnClass:"ui-stars-star-on",starHoverClass:"ui-stars-star-hover",starDisabledClass:"ui-stars-star-disabled",cancelHoverClass:"ui-stars-cancel-hover",cancelDisabledClass:"ui-stars-cancel-disabled"}})})(jQuery);
/*jquery.selectboxes.min.js*/
/*
 *
 * Copyright (c) 2006-2008 Sam Collett (http://www.texotela.co.uk)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version 2.2.4
 * Demo: http://www.texotela.co.uk/code/jquery/select/
 *
 * $LastChangedDate: 2008-06-17 17:27:25 +0100 (Tue, 17 Jun 2008) $
 * $Rev: 5727 $
 *
 */
;(function(h){h.fn.addOption=function(){var j=function(a,f,c,g){var d=document.createElement("option");d.value=f,d.text=c;var b=a.options;var e=b.length;if(!a.cache){a.cache={};for(var i=0;i<e;i++){a.cache[b[i].value]=i}}if(typeof a.cache[f]=="undefined")a.cache[f]=e;a.options[a.cache[f]]=d;if(g){d.selected=true}};var k=arguments;if(k.length==0)return this;var l=true;var m=false;var n,o,p;if(typeof(k[0])=="object"){m=true;n=k[0]}if(k.length>=2){if(typeof(k[1])=="boolean")l=k[1];else if(typeof(k[2])=="boolean")l=k[2];if(!m){o=k[0];p=k[1]}}this.each(function(){if(this.nodeName.toLowerCase()!="select")return;if(m){for(var a in n){j(this,a,n[a],l)}}else{j(this,o,p,l)}});return this};h.fn.ajaxAddOption=function(c,g,d,b,e){if(typeof(c)!="string")return this;if(typeof(g)!="object")g={};if(typeof(d)!="boolean")d=true;this.each(function(){var f=this;h.getJSON(c,g,function(a){h(f).addOption(a,d);if(typeof b=="function"){if(typeof e=="object"){b.apply(f,e)}else{b.call(f)}}})});return this};h.fn.removeOption=function(){var d=arguments;if(d.length==0)return this;var b=typeof(d[0]);var e,i;if(b=="string"||b=="object"||b=="function"){e=d[0];if(e.constructor==Array){var j=e.length;for(var k=0;k<j;k++){this.removeOption(e[k],d[1])}return this}}else if(b=="number")i=d[0];else return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return;if(this.cache)this.cache=null;var a=false;var f=this.options;if(!!e){var c=f.length;for(var g=c-1;g>=0;g--){if(e.constructor==RegExp){if(f[g].value.match(e)){a=true}}else if(f[g].value==e){a=true}if(a&&d[1]===true)a=f[g].selected;if(a){f[g]=null}a=false}}else{if(d[1]===true){a=f[i].selected}else{a=true}if(a){this.remove(i)}}});return this};h.fn.sortOptions=function(e){var i=h(this).selectedValues();var j=typeof(e)=="undefined"?true:!!e;this.each(function(){if(this.nodeName.toLowerCase()!="select")return;var c=this.options;var g=c.length;var d=[];for(var b=0;b<g;b++){d[b]={v:c[b].value,t:c[b].text}}d.sort(function(a,f){o1t=a.t.toLowerCase(),o2t=f.t.toLowerCase();if(o1t==o2t)return 0;if(j){return o1t<o2t?-1:1}else{return o1t>o2t?-1:1}});for(var b=0;b<g;b++){c[b].text=d[b].t;c[b].value=d[b].v}}).selectOptions(i,true);return this};h.fn.selectOptions=function(g,d){var b=g;var e=typeof(g);if(e=="object"&&b.constructor==Array){var i=this;h.each(b,function(){i.selectOptions(this,d)})};var j=d||false;if(e!="string"&&e!="function"&&e!="object")return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(b.constructor==RegExp){if(a[c].value.match(b)){a[c].selected=true}else if(j){a[c].selected=false}}else{if(a[c].value==b){a[c].selected=true}else if(j){a[c].selected=false}}}});return this};h.fn.copyOptions=function(g,d){var b=d||"selected";if(h(g).size()==0)return this;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(b=="all"||(b=="selected"&&a[c].selected)){h(g).addOption(a[c].value,a[c].text)}}});return this};h.fn.containsOption=function(g,d){var b=false;var e=g;var i=typeof(e);var j=typeof(d);if(i!="string"&&i!="function"&&i!="object")return j=="function"?this:b;this.each(function(){if(this.nodeName.toLowerCase()!="select")return this;if(b&&j!="function")return false;var a=this.options;var f=a.length;for(var c=0;c<f;c++){if(e.constructor==RegExp){if(a[c].value.match(e)){b=true;if(j=="function")d.call(a[c],c)}}else{if(a[c].value==e){b=true;if(j=="function")d.call(a[c],c)}}}});return j=="function"?this:b};h.fn.selectedValues=function(){var a=[];this.selectedOptions().each(function(){a[a.length]=this.value});return a};h.fn.selectedTexts=function(){var a=[];this.selectedOptions().each(function(){a[a.length]=this.text});return a};h.fn.selectedOptions=function(){return this.find("option:selected")}})(jQuery);
/*qtip*/
/*
 * jquery.qtip. The jQuery tooltip plugin
 *
 * Copyright (c) 2009 Craig Thompson
 * http://craigsworks.com
 *
 * Licensed under MIT
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Launch  : February 2009
 * Version : 1.0.0-rc3
 * Released: Tuesday 12th May, 2009 - 00:00
 * Debug: jquery.qtip.debug.js
 */
(function(f){f.fn.qtip=function(B,u){var y,t,A,s,x,w,v,z;if(typeof B=="string"){if(typeof f(this).data("qtip")!=="object"){f.fn.qtip.log.error.call(self,1,f.fn.qtip.constants.NO_TOOLTIP_PRESENT,false)}if(B=="api"){return f(this).data("qtip").interfaces[f(this).data("qtip").current]}else{if(B=="interfaces"){return f(this).data("qtip").interfaces}}}else{if(!B){B={}}if(typeof B.content!=="object"||(B.content.jquery&&B.content.length>0)){B.content={text:B.content}}if(typeof B.content.title!=="object"){B.content.title={text:B.content.title}}if(typeof B.position!=="object"){B.position={corner:B.position}}if(typeof B.position.corner!=="object"){B.position.corner={target:B.position.corner,tooltip:B.position.corner}}if(typeof B.show!=="object"){B.show={when:B.show}}if(typeof B.show.when!=="object"){B.show.when={event:B.show.when}}if(typeof B.show.effect!=="object"){B.show.effect={type:B.show.effect}}if(typeof B.hide!=="object"){B.hide={when:B.hide}}if(typeof B.hide.when!=="object"){B.hide.when={event:B.hide.when}}if(typeof B.hide.effect!=="object"){B.hide.effect={type:B.hide.effect}}if(typeof B.style!=="object"){B.style={name:B.style}}B.style=c(B.style);s=f.extend(true,{},f.fn.qtip.defaults,B);s.style=a.call({options:s},s.style);s.user=f.extend(true,{},B)}return f(this).each(function(){if(typeof B=="string"){w=B.toLowerCase();A=f(this).qtip("interfaces");if(typeof A=="object"){if(u===true&&w=="destroy"){while(A.length>0){A[A.length-1].destroy()}}else{if(u!==true){A=[f(this).qtip("api")]}for(y=0;y<A.length;y++){if(w=="destroy"){A[y].destroy()}else{if(A[y].status.rendered===true){if(w=="show"){A[y].show()}else{if(w=="hide"){A[y].hide()}else{if(w=="focus"){A[y].focus()}else{if(w=="disable"){A[y].disable(true)}else{if(w=="enable"){A[y].disable(false)}}}}}}}}}}}else{v=f.extend(true,{},s);v.hide.effect.length=s.hide.effect.length;v.show.effect.length=s.show.effect.length;if(v.position.container===false){v.position.container=f(document.body)}if(v.position.target===false){v.position.target=f(this)}if(v.show.when.target===false){v.show.when.target=f(this)}if(v.hide.when.target===false){v.hide.when.target=f(this)}t=f.fn.qtip.interfaces.length;for(y=0;y<t;y++){if(typeof f.fn.qtip.interfaces[y]=="undefined"){t=y;break}}x=new d(f(this),v,t);f.fn.qtip.interfaces[t]=x;if(typeof f(this).data("qtip")=="object"){if(typeof f(this).attr("qtip")==="undefined"){f(this).data("qtip").current=f(this).data("qtip").interfaces.length}f(this).data("qtip").interfaces.push(x)}else{f(this).data("qtip",{current:0,interfaces:[x]})}if(v.content.prerender===false&&v.show.when.event!==false&&v.show.ready!==true){v.show.when.target.bind(v.show.when.event+".qtip-"+t+"-create",{qtip:t},function(C){z=f.fn.qtip.interfaces[C.data.qtip];z.options.show.when.target.unbind(z.options.show.when.event+".qtip-"+C.data.qtip+"-create");z.cache.mouse={x:C.pageX,y:C.pageY};p.call(z);z.options.show.when.target.trigger(z.options.show.when.event)})}else{x.cache.mouse={x:v.show.when.target.offset().left,y:v.show.when.target.offset().top};p.call(x)}}})};function d(u,t,v){var s=this;s.id=v;s.options=t;s.status={animated:false,rendered:false,disabled:false,focused:false};s.elements={target:u.addClass(s.options.style.classes.target),tooltip:null,wrapper:null,content:null,contentWrapper:null,title:null,button:null,tip:null,bgiframe:null};s.cache={mouse:{},position:{},toggle:0};s.timers={};f.extend(s,s.options.api,{show:function(y){var x,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"show")}if(s.elements.tooltip.css("display")!=="none"){return s}s.elements.tooltip.stop(true,false);x=s.beforeShow.call(s,y);if(x===false){return s}function w(){if(s.options.position.type!=="static"){s.focus()}s.onShow.call(s,y);if(f.browser.msie){s.elements.tooltip.get(0).style.removeAttribute("filter")}}s.cache.toggle=1;if(s.options.position.type!=="static"){s.updatePosition(y,(s.options.show.effect.length>0))}if(typeof s.options.show.solo=="object"){z=f(s.options.show.solo)}else{if(s.options.show.solo===true){z=f("div.qtip").not(s.elements.tooltip)}}if(z){z.each(function(){if(f(this).qtip("api").status.rendered===true){f(this).qtip("api").hide()}})}if(typeof s.options.show.effect.type=="function"){s.options.show.effect.type.call(s.elements.tooltip,s.options.show.effect.length);s.elements.tooltip.queue(function(){w();f(this).dequeue()})}else{switch(s.options.show.effect.type.toLowerCase()){case"fade":s.elements.tooltip.fadeIn(s.options.show.effect.length,w);break;case"slide":s.elements.tooltip.slideDown(s.options.show.effect.length,function(){w();if(s.options.position.type!=="static"){s.updatePosition(y,true)}});break;case"grow":s.elements.tooltip.show(s.options.show.effect.length,w);break;default:s.elements.tooltip.show(null,w);break}s.elements.tooltip.addClass(s.options.style.classes.active)}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_SHOWN,"show")},hide:function(y){var x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"hide")}else{if(s.elements.tooltip.css("display")==="none"){return s}}clearTimeout(s.timers.show);s.elements.tooltip.stop(true,false);x=s.beforeHide.call(s,y);if(x===false){return s}function w(){s.onHide.call(s,y)}s.cache.toggle=0;if(typeof s.options.hide.effect.type=="function"){s.options.hide.effect.type.call(s.elements.tooltip,s.options.hide.effect.length);s.elements.tooltip.queue(function(){w();f(this).dequeue()})}else{switch(s.options.hide.effect.type.toLowerCase()){case"fade":s.elements.tooltip.fadeOut(s.options.hide.effect.length,w);break;case"slide":s.elements.tooltip.slideUp(s.options.hide.effect.length,w);break;case"grow":s.elements.tooltip.hide(s.options.hide.effect.length,w);break;default:s.elements.tooltip.hide(null,w);break}s.elements.tooltip.removeClass(s.options.style.classes.active)}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_HIDDEN,"hide")},updatePosition:function(w,x){var C,G,L,J,H,E,y,I,B,D,K,A,F,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updatePosition")}else{if(s.options.position.type=="static"){return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.CANNOT_POSITION_STATIC,"updatePosition")}}G={position:{left:0,top:0},dimensions:{height:0,width:0},corner:s.options.position.corner.target};L={position:s.getPosition(),dimensions:s.getDimensions(),corner:s.options.position.corner.tooltip};if(s.options.position.target!=="mouse"){if(s.options.position.target.get(0).nodeName.toLowerCase()=="area"){J=s.options.position.target.attr("coords").split(",");for(C=0;C<J.length;C++){J[C]=parseInt(J[C])}H=s.options.position.target.parent("map").attr("name");E=f('img[usemap="#'+H+'"]:first').offset();G.position={left:Math.floor(E.left+J[0]),top:Math.floor(E.top+J[1])};switch(s.options.position.target.attr("shape").toLowerCase()){case"rect":G.dimensions={width:Math.ceil(Math.abs(J[2]-J[0])),height:Math.ceil(Math.abs(J[3]-J[1]))};break;case"circle":G.dimensions={width:J[2]+1,height:J[2]+1};break;case"poly":G.dimensions={width:J[0],height:J[1]};for(C=0;C<J.length;C++){if(C%2==0){if(J[C]>G.dimensions.width){G.dimensions.width=J[C]}if(J[C]<J[0]){G.position.left=Math.floor(E.left+J[C])}}else{if(J[C]>G.dimensions.height){G.dimensions.height=J[C]}if(J[C]<J[1]){G.position.top=Math.floor(E.top+J[C])}}}G.dimensions.width=G.dimensions.width-(G.position.left-E.left);G.dimensions.height=G.dimensions.height-(G.position.top-E.top);break;default:return f.fn.qtip.log.error.call(s,4,f.fn.qtip.constants.INVALID_AREA_SHAPE,"updatePosition");break}G.dimensions.width-=2;G.dimensions.height-=2}else{if(s.options.position.target.add(document.body).length===1){G.position={left:f(document).scrollLeft(),top:f(document).scrollTop()};G.dimensions={height:f(window).height(),width:f(window).width()}}else{if(typeof s.options.position.target.attr("qtip")!=="undefined"){G.position=s.options.position.target.qtip("api").cache.position}else{G.position=s.options.position.target.offset()}G.dimensions={height:s.options.position.target.outerHeight(),width:s.options.position.target.outerWidth()}}}y=f.extend({},G.position);if(G.corner.search(/right/i)!==-1){y.left+=G.dimensions.width}if(G.corner.search(/bottom/i)!==-1){y.top+=G.dimensions.height}if(G.corner.search(/((top|bottom)Middle)|center/)!==-1){y.left+=(G.dimensions.width/2)}if(G.corner.search(/((left|right)Middle)|center/)!==-1){y.top+=(G.dimensions.height/2)}}else{G.position=y={left:s.cache.mouse.x,top:s.cache.mouse.y};G.dimensions={height:1,width:1}}if(L.corner.search(/right/i)!==-1){y.left-=L.dimensions.width}if(L.corner.search(/bottom/i)!==-1){y.top-=L.dimensions.height}if(L.corner.search(/((top|bottom)Middle)|center/)!==-1){y.left-=(L.dimensions.width/2)}if(L.corner.search(/((left|right)Middle)|center/)!==-1){y.top-=(L.dimensions.height/2)}I=(f.browser.msie)?1:0;B=(f.browser.msie&&parseInt(f.browser.version.charAt(0))===6)?1:0;if(s.options.style.border.radius>0){if(L.corner.search(/Left/)!==-1){y.left-=s.options.style.border.radius}else{if(L.corner.search(/Right/)!==-1){y.left+=s.options.style.border.radius}}if(L.corner.search(/Top/)!==-1){y.top-=s.options.style.border.radius}else{if(L.corner.search(/Bottom/)!==-1){y.top+=s.options.style.border.radius}}}if(I){if(L.corner.search(/top/)!==-1){y.top-=I}else{if(L.corner.search(/bottom/)!==-1){y.top+=I}}if(L.corner.search(/left/)!==-1){y.left-=I}else{if(L.corner.search(/right/)!==-1){y.left+=I}}if(L.corner.search(/leftMiddle|rightMiddle/)!==-1){y.top-=1}}if(s.options.position.adjust.screen===true){y=o.call(s,y,G,L)}if(s.options.position.target==="mouse"&&s.options.position.adjust.mouse===true){if(s.options.position.adjust.screen===true&&s.elements.tip){K=s.elements.tip.attr("rel")}else{K=s.options.position.corner.tooltip}y.left+=(K.search(/right/i)!==-1)?-6:6;y.top+=(K.search(/bottom/i)!==-1)?-6:6}if(!s.elements.bgiframe&&f.browser.msie&&parseInt(f.browser.version.charAt(0))==6){f("select, object").each(function(){A=f(this).offset();A.bottom=A.top+f(this).height();A.right=A.left+f(this).width();if(y.top+L.dimensions.height>=A.top&&y.left+L.dimensions.width>=A.left){k.call(s)}})}y.left+=s.options.position.adjust.x;y.top+=s.options.position.adjust.y;F=s.getPosition();if(y.left!=F.left||y.top!=F.top){z=s.beforePositionUpdate.call(s,w);if(z===false){return s}s.cache.position=y;if(x===true){s.status.animated=true;s.elements.tooltip.animate(y,200,"swing",function(){s.status.animated=false})}else{s.elements.tooltip.css(y)}s.onPositionUpdate.call(s,w);if(typeof w!=="undefined"&&w.type&&w.type!=="mousemove"){f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_POSITION_UPDATED,"updatePosition")}}return s},updateWidth:function(w){var x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateWidth")}else{if(w&&typeof w!=="number"){return f.fn.qtip.log.error.call(s,2,"newWidth must be of type number","updateWidth")}}x=s.elements.contentWrapper.siblings().add(s.elements.tip).add(s.elements.button);if(!w){if(typeof s.options.style.width.value=="number"){w=s.options.style.width.value}else{s.elements.tooltip.css({width:"auto"});x.hide();if(f.browser.msie){s.elements.wrapper.add(s.elements.contentWrapper.children()).css({zoom:"normal"})}w=s.getDimensions().width+1;if(!s.options.style.width.value){if(w>s.options.style.width.max){w=s.options.style.width.max}if(w<s.options.style.width.min){w=s.options.style.width.min}}}}if(w%2!==0){w-=1}s.elements.tooltip.width(w);x.show();if(s.options.style.border.radius){s.elements.tooltip.find(".qtip-betweenCorners").each(function(y){f(this).width(w-(s.options.style.border.radius*2))})}if(f.browser.msie){s.elements.wrapper.add(s.elements.contentWrapper.children()).css({zoom:"1"});s.elements.wrapper.width(w);if(s.elements.bgiframe){s.elements.bgiframe.width(w).height(s.getDimensions.height)}}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_WIDTH_UPDATED,"updateWidth")},updateStyle:function(w){var z,A,x,y,B;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateStyle")}else{if(typeof w!=="string"||!f.fn.qtip.styles[w]){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.STYLE_NOT_DEFINED,"updateStyle")}}s.options.style=a.call(s,f.fn.qtip.styles[w],s.options.user.style);s.elements.content.css(q(s.options.style));if(s.options.content.title.text!==false){s.elements.title.css(q(s.options.style.title,true))}s.elements.contentWrapper.css({borderColor:s.options.style.border.color});if(s.options.style.tip.corner!==false){if(f("<canvas>").get(0).getContext){z=s.elements.tooltip.find(".qtip-tip canvas:first");x=z.get(0).getContext("2d");x.clearRect(0,0,300,300);y=z.parent("div[rel]:first").attr("rel");B=b(y,s.options.style.tip.size.width,s.options.style.tip.size.height);h.call(s,z,B,s.options.style.tip.color||s.options.style.border.color)}else{if(f.browser.msie){z=s.elements.tooltip.find('.qtip-tip [nodeName="shape"]');z.attr("fillcolor",s.options.style.tip.color||s.options.style.border.color)}}}if(s.options.style.border.radius>0){s.elements.tooltip.find(".qtip-betweenCorners").css({backgroundColor:s.options.style.border.color});if(f("<canvas>").get(0).getContext){A=g(s.options.style.border.radius);s.elements.tooltip.find(".qtip-wrapper canvas").each(function(){x=f(this).get(0).getContext("2d");x.clearRect(0,0,300,300);y=f(this).parent("div[rel]:first").attr("rel");r.call(s,f(this),A[y],s.options.style.border.radius,s.options.style.border.color)})}else{if(f.browser.msie){s.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function(){f(this).attr("fillcolor",s.options.style.border.color)})}}}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_STYLE_UPDATED,"updateStyle")},updateContent:function(A,y){var z,x,w;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateContent")}else{if(!A){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateContent")}}z=s.beforeContentUpdate.call(s,A);if(typeof z=="string"){A=z}else{if(z===false){return}}if(f.browser.msie){s.elements.contentWrapper.children().css({zoom:"normal"})}if(A.jquery&&A.length>0){A.clone(true).appendTo(s.elements.content).show()}else{s.elements.content.html(A)}x=s.elements.content.find("img[complete=false]");if(x.length>0){w=0;x.each(function(C){f('<img src="'+f(this).attr("src")+'" />').load(function(){if(++w==x.length){B()}})})}else{B()}function B(){s.updateWidth();if(y!==false){if(s.options.position.type!=="static"){s.updatePosition(s.elements.tooltip.is(":visible"),true)}if(s.options.style.tip.corner!==false){n.call(s)}}}s.onContentUpdate.call(s);return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_CONTENT_UPDATED,"loadContent")},loadContent:function(w,z,A){var y;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"loadContent")}y=s.beforeContentLoad.call(s);if(y===false){return s}if(A=="post"){f.post(w,z,x)}else{f.get(w,z,x)}function x(B){s.onContentLoad.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_CONTENT_LOADED,"loadContent");s.updateContent(B)}return s},updateTitle:function(w){if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateTitle")}else{if(!w){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateTitle")}}returned=s.beforeTitleUpdate.call(s);if(returned===false){return s}if(s.elements.button){s.elements.button=s.elements.button.clone(true)}s.elements.title.html(w);if(s.elements.button){s.elements.title.prepend(s.elements.button)}s.onTitleUpdate.call(s);return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_TITLE_UPDATED,"updateTitle")},focus:function(A){var y,x,w,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"focus")}else{if(s.options.position.type=="static"){return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.CANNOT_FOCUS_STATIC,"focus")}}y=parseInt(s.elements.tooltip.css("z-index"));x=6000+f("div.qtip[qtip]").length-1;if(!s.status.focused&&y!==x){z=s.beforeFocus.call(s,A);if(z===false){return s}f("div.qtip[qtip]").not(s.elements.tooltip).each(function(){if(f(this).qtip("api").status.rendered===true){w=parseInt(f(this).css("z-index"));if(typeof w=="number"&&w>-1){f(this).css({zIndex:parseInt(f(this).css("z-index"))-1})}f(this).qtip("api").status.focused=false}});s.elements.tooltip.css({zIndex:x});s.status.focused=true;s.onFocus.call(s,A);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_FOCUSED,"focus")}return s},disable:function(w){if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"disable")}if(w){if(!s.status.disabled){s.status.disabled=true;f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_DISABLED,"disable")}else{f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED,"disable")}}else{if(s.status.disabled){s.status.disabled=false;f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_ENABLED,"disable")}else{f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED,"disable")}}return s},destroy:function(){var w,x,y;x=s.beforeDestroy.call(s);if(x===false){return s}if(s.status.rendered){s.options.show.when.target.unbind("mousemove.qtip",s.updatePosition);s.options.show.when.target.unbind("mouseout.qtip",s.hide);s.options.show.when.target.unbind(s.options.show.when.event+".qtip");s.options.hide.when.target.unbind(s.options.hide.when.event+".qtip");s.elements.tooltip.unbind(s.options.hide.when.event+".qtip");s.elements.tooltip.unbind("mouseover.qtip",s.focus);s.elements.tooltip.remove()}else{s.options.show.when.target.unbind(s.options.show.when.event+".qtip-create")}if(typeof s.elements.target.data("qtip")=="object"){y=s.elements.target.data("qtip").interfaces;if(typeof y=="object"&&y.length>0){for(w=0;w<y.length-1;w++){if(y[w].id==s.id){y.splice(w,1)}}}}delete f.fn.qtip.interfaces[s.id];if(typeof y=="object"&&y.length>0){s.elements.target.data("qtip").current=y.length-1}else{s.elements.target.removeData("qtip")}s.onDestroy.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_DESTROYED,"destroy");return s.elements.target},getPosition:function(){var w,x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getPosition")}w=(s.elements.tooltip.css("display")!=="none")?false:true;if(w){s.elements.tooltip.css({visiblity:"hidden"}).show()}x=s.elements.tooltip.offset();if(w){s.elements.tooltip.css({visiblity:"visible"}).hide()}return x},getDimensions:function(){var w,x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getDimensions")}w=(!s.elements.tooltip.is(":visible"))?true:false;if(w){s.elements.tooltip.css({visiblity:"hidden"}).show()}x={height:s.elements.tooltip.outerHeight(),width:s.elements.tooltip.outerWidth()};if(w){s.elements.tooltip.css({visiblity:"visible"}).hide()}return x}})}function p(){var s,w,u,t,v,y,x;s=this;s.beforeRender.call(s);s.status.rendered=true;s.elements.tooltip='<div qtip="'+s.id+'" class="qtip '+(s.options.style.classes.tooltip||s.options.style)+'"style="display:none; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0;position:'+s.options.position.type+';">  <div class="qtip-wrapper" style="position:relative; overflow:hidden; text-align:left;">    <div class="qtip-contentWrapper" style="overflow:hidden;">       <div class="qtip-content '+s.options.style.classes.content+'"></div></div></div></div>';s.elements.tooltip=f(s.elements.tooltip);s.elements.tooltip.appendTo(s.options.position.container);s.elements.tooltip.data("qtip",{current:0,interfaces:[s]});s.elements.wrapper=s.elements.tooltip.children("div:first");s.elements.contentWrapper=s.elements.wrapper.children("div:first").css({background:s.options.style.background});s.elements.content=s.elements.contentWrapper.children("div:first").css(q(s.options.style));if(f.browser.msie){s.elements.wrapper.add(s.elements.content).css({zoom:1})}if(s.options.hide.when.event=="unfocus"){s.elements.tooltip.attr("unfocus",true)}if(typeof s.options.style.width.value=="number"){s.updateWidth()}if(f("<canvas>").get(0).getContext||f.browser.msie){if(s.options.style.border.radius>0){m.call(s)}else{s.elements.contentWrapper.css({border:s.options.style.border.width+"px solid "+s.options.style.border.color})}if(s.options.style.tip.corner!==false){e.call(s)}}else{s.elements.contentWrapper.css({border:s.options.style.border.width+"px solid "+s.options.style.border.color});s.options.style.border.radius=0;s.options.style.tip.corner=false;f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED,"render")}if((typeof s.options.content.text=="string"&&s.options.content.text.length>0)||(s.options.content.text.jquery&&s.options.content.text.length>0)){u=s.options.content.text}else{if(typeof s.elements.target.attr("title")=="string"&&s.elements.target.attr("title").length>0){u=s.elements.target.attr("title").replace("\\n","<br />");s.elements.target.attr("title","")}else{if(typeof s.elements.target.attr("alt")=="string"&&s.elements.target.attr("alt").length>0){u=s.elements.target.attr("alt").replace("\\n","<br />");s.elements.target.attr("alt","")}else{u=" ";f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.NO_VALID_CONTENT,"render")}}}if(s.options.content.title.text!==false){j.call(s)}s.updateContent(u);l.call(s);if(s.options.show.ready===true){s.show()}if(s.options.content.url!==false){t=s.options.content.url;v=s.options.content.data;y=s.options.content.method||"get";s.loadContent(t,v,y)}s.onRender.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_RENDERED,"render")}function m(){var F,z,t,B,x,E,u,G,D,y,w,C,A,s,v;F=this;F.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();t=F.options.style.border.width;B=F.options.style.border.radius;x=F.options.style.border.color||F.options.style.tip.color;E=g(B);u={};for(z in E){u[z]='<div rel="'+z+'" style="'+((z.search(/Left/)!==-1)?"left":"right")+":0; position:absolute; height:"+B+"px; width:"+B+'px; overflow:hidden; line-height:0.1px; font-size:1px">';if(f("<canvas>").get(0).getContext){u[z]+='<canvas height="'+B+'" width="'+B+'" style="vertical-align: top"></canvas>'}else{if(f.browser.msie){G=B*2+3;u[z]+='<v:arc stroked="false" fillcolor="'+x+'" startangle="'+E[z][0]+'" endangle="'+E[z][1]+'" style="width:'+G+"px; height:"+G+"px; margin-top:"+((z.search(/bottom/)!==-1)?-2:-1)+"px; margin-left:"+((z.search(/Right/)!==-1)?E[z][2]-3.5:-1)+'px; vertical-align:top; display:inline-block; behavior:url(#default#VML)"></v:arc>'}}u[z]+="</div>"}D=F.getDimensions().width-(Math.max(t,B)*2);y='<div class="qtip-betweenCorners" style="height:'+B+"px; width:"+D+"px; overflow:hidden; background-color:"+x+'; line-height:0.1px; font-size:1px;">';w='<div class="qtip-borderTop" dir="ltr" style="height:'+B+"px; margin-left:"+B+'px; line-height:0.1px; font-size:1px; padding:0;">'+u.topLeft+u.topRight+y;F.elements.wrapper.prepend(w);C='<div class="qtip-borderBottom" dir="ltr" style="height:'+B+"px; margin-left:"+B+'px; line-height:0.1px; font-size:1px; padding:0;">'+u.bottomLeft+u.bottomRight+y;F.elements.wrapper.append(C);if(f("<canvas>").get(0).getContext){F.elements.wrapper.find("canvas").each(function(){A=E[f(this).parent("[rel]:first").attr("rel")];r.call(F,f(this),A,B,x)})}else{if(f.browser.msie){F.elements.tooltip.append('<v:image style="behavior:url(#default#VML);"></v:image>')}}s=Math.max(B,(B+(t-B)));v=Math.max(t-B,0);F.elements.contentWrapper.css({border:"0px solid "+x,borderWidth:v+"px "+s+"px"})}function r(u,w,s,t){var v=u.get(0).getContext("2d");v.fillStyle=t;v.beginPath();v.arc(w[0],w[1],s,0,Math.PI*2,false);v.fill()}function e(v){var t,s,x,u,w;t=this;if(t.elements.tip!==null){t.elements.tip.remove()}s=t.options.style.tip.color||t.options.style.border.color;if(t.options.style.tip.corner===false){return}else{if(!v){v=t.options.style.tip.corner}}x=b(v,t.options.style.tip.size.width,t.options.style.tip.size.height);t.elements.tip='<div class="'+t.options.style.classes.tip+'" dir="ltr" rel="'+v+'" style="position:absolute; height:'+t.options.style.tip.size.height+"px; width:"+t.options.style.tip.size.width+'px; margin:0 auto; line-height:0.1px; font-size:1px;">';if(f("<canvas>").get(0).getContext){t.elements.tip+='<canvas height="'+t.options.style.tip.size.height+'" width="'+t.options.style.tip.size.width+'"></canvas>'}else{if(f.browser.msie){u=t.options.style.tip.size.width+","+t.options.style.tip.size.height;w="m"+x[0][0]+","+x[0][1];w+=" l"+x[1][0]+","+x[1][1];w+=" "+x[2][0]+","+x[2][1];w+=" xe";t.elements.tip+='<v:shape fillcolor="'+s+'" stroked="false" filled="true" path="'+w+'" coordsize="'+u+'" style="width:'+t.options.style.tip.size.width+"px; height:"+t.options.style.tip.size.height+"px; line-height:0.1px; display:inline-block; behavior:url(#default#VML); vertical-align:"+((v.search(/top/)!==-1)?"bottom":"top")+'"></v:shape>';t.elements.tip+='<v:image style="behavior:url(#default#VML);"></v:image>';t.elements.contentWrapper.css("position","relative")}}t.elements.tooltip.prepend(t.elements.tip+"</div>");t.elements.tip=t.elements.tooltip.find("."+t.options.style.classes.tip).eq(0);if(f("<canvas>").get(0).getContext){h.call(t,t.elements.tip.find("canvas:first"),x,s)}if(v.search(/top/)!==-1&&f.browser.msie&&parseInt(f.browser.version.charAt(0))===6){t.elements.tip.css({marginTop:-4})}n.call(t,v)}function h(t,v,s){var u=t.get(0).getContext("2d");u.fillStyle=s;u.beginPath();u.moveTo(v[0][0],v[0][1]);u.lineTo(v[1][0],v[1][1]);u.lineTo(v[2][0],v[2][1]);u.fill()}function n(u){var t,w,s,x,v;t=this;if(t.options.style.tip.corner===false||!t.elements.tip){return}if(!u){u=t.elements.tip.attr("rel")}w=positionAdjust=(f.browser.msie)?1:0;t.elements.tip.css(u.match(/left|right|top|bottom/)[0],0);if(u.search(/top|bottom/)!==-1){if(f.browser.msie){if(parseInt(f.browser.version.charAt(0))===6){positionAdjust=(u.search(/top/)!==-1)?-3:1}else{positionAdjust=(u.search(/top/)!==-1)?1:2}}if(u.search(/Middle/)!==-1){t.elements.tip.css({left:"50%",marginLeft:-(t.options.style.tip.size.width/2)})}else{if(u.search(/Left/)!==-1){t.elements.tip.css({left:t.options.style.border.radius-w})}else{if(u.search(/Right/)!==-1){t.elements.tip.css({right:t.options.style.border.radius+w})}}}if(u.search(/top/)!==-1){t.elements.tip.css({top:-positionAdjust})}else{t.elements.tip.css({bottom:positionAdjust})}}else{if(u.search(/left|right/)!==-1){if(f.browser.msie){positionAdjust=(parseInt(f.browser.version.charAt(0))===6)?1:((u.search(/left/)!==-1)?1:2)}if(u.search(/Middle/)!==-1){t.elements.tip.css({top:"50%",marginTop:-(t.options.style.tip.size.height/2)})}else{if(u.search(/Top/)!==-1){t.elements.tip.css({top:t.options.style.border.radius-w})}else{if(u.search(/Bottom/)!==-1){t.elements.tip.css({bottom:t.options.style.border.radius+w})}}}if(u.search(/left/)!==-1){t.elements.tip.css({left:-positionAdjust})}else{t.elements.tip.css({right:positionAdjust})}}}s="padding-"+u.match(/left|right|top|bottom/)[0];x=t.options.style.tip.size[(s.search(/left|right/)!==-1)?"width":"height"];t.elements.tooltip.css("padding",0);t.elements.tooltip.css(s,x);if(f.browser.msie&&parseInt(f.browser.version.charAt(0))==6){v=parseInt(t.elements.tip.css("margin-top"))||0;v+=parseInt(t.elements.content.css("margin-top"))||0;t.elements.tip.css({marginTop:v})}}function j(){var s=this;if(s.elements.title!==null){s.elements.title.remove()}s.elements.title=f('<div class="'+s.options.style.classes.title+'">').css(q(s.options.style.title,true)).css({zoom:(f.browser.msie)?1:0}).prependTo(s.elements.contentWrapper);if(s.options.content.title.text){s.updateTitle.call(s,s.options.content.title.text)}if(s.options.content.title.button!==false&&typeof s.options.content.title.button=="string"){s.elements.button=f('<a class="'+s.options.style.classes.button+'" style="float:right; position: relative"></a>').css(q(s.options.style.button,true)).html(s.options.content.title.button).prependTo(s.elements.title).click(function(t){if(!s.status.disabled){s.hide(t)}})}}function l(){var t,v,u,s;t=this;v=t.options.show.when.target;u=t.options.hide.when.target;if(t.options.hide.fixed){u=u.add(t.elements.tooltip)}if(t.options.hide.when.event=="inactive"){s=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseenter","mouseleave","mouseover"];function y(z){if(t.status.disabled===true){return}clearTimeout(t.timers.inactive);t.timers.inactive=setTimeout(function(){f(s).each(function(){u.unbind(this+".qtip-inactive");t.elements.content.unbind(this+".qtip-inactive")});t.hide(z)},t.options.hide.delay)}}else{if(t.options.hide.fixed===true){t.elements.tooltip.bind("mouseover.qtip",function(){if(t.status.disabled===true){return}clearTimeout(t.timers.hide)})}}function x(z){if(t.status.disabled===true){return}if(t.options.hide.when.event=="inactive"){f(s).each(function(){u.bind(this+".qtip-inactive",y);t.elements.content.bind(this+".qtip-inactive",y)});y()}clearTimeout(t.timers.show);clearTimeout(t.timers.hide);t.timers.show=setTimeout(function(){t.show(z)},t.options.show.delay)}function w(z){if(t.status.disabled===true){return}if(t.options.hide.fixed===true&&t.options.hide.when.event.search(/mouse(out|leave)/i)!==-1&&f(z.relatedTarget).parents("div.qtip[qtip]").length>0){z.stopPropagation();z.preventDefault();clearTimeout(t.timers.hide);return false}clearTimeout(t.timers.show);clearTimeout(t.timers.hide);t.elements.tooltip.stop(true,true);t.timers.hide=setTimeout(function(){t.hide(z)},t.options.hide.delay)}if((t.options.show.when.target.add(t.options.hide.when.target).length===1&&t.options.show.when.event==t.options.hide.when.event&&t.options.hide.when.event!=="inactive")||t.options.hide.when.event=="unfocus"){t.cache.toggle=0;v.bind(t.options.show.when.event+".qtip",function(z){if(t.cache.toggle==0){x(z)}else{w(z)}})}else{v.bind(t.options.show.when.event+".qtip",x);if(t.options.hide.when.event!=="inactive"){u.bind(t.options.hide.when.event+".qtip",w)}}if(t.options.position.type.search(/(fixed|absolute)/)!==-1){t.elements.tooltip.bind("mouseover.qtip",t.focus)}if(t.options.position.target==="mouse"&&t.options.position.type!=="static"){v.bind("mousemove.qtip",function(z){t.cache.mouse={x:z.pageX,y:z.pageY};if(t.status.disabled===false&&t.options.position.adjust.mouse===true&&t.options.position.type!=="static"&&t.elements.tooltip.css("display")!=="none"){t.updatePosition(z)}})}}function o(u,v,A){var z,s,x,y,t,w;z=this;if(A.corner=="center"){return v.position}s=f.extend({},u);y={x:false,y:false};t={left:(s.left<f.fn.qtip.cache.screen.scroll.left),right:(s.left+A.dimensions.width+2>=f.fn.qtip.cache.screen.width+f.fn.qtip.cache.screen.scroll.left),top:(s.top<f.fn.qtip.cache.screen.scroll.top),bottom:(s.top+A.dimensions.height+2>=f.fn.qtip.cache.screen.height+f.fn.qtip.cache.screen.scroll.top)};x={left:(t.left&&(A.corner.search(/right/i)!=-1||(A.corner.search(/right/i)==-1&&!t.right))),right:(t.right&&(A.corner.search(/left/i)!=-1||(A.corner.search(/left/i)==-1&&!t.left))),top:(t.top&&A.corner.search(/top/i)==-1),bottom:(t.bottom&&A.corner.search(/bottom/i)==-1)};if(x.left){if(z.options.position.target!=="mouse"){s.left=v.position.left+v.dimensions.width}else{s.left=z.cache.mouse.x}y.x="Left"}else{if(x.right){if(z.options.position.target!=="mouse"){s.left=v.position.left-A.dimensions.width}else{s.left=z.cache.mouse.x-A.dimensions.width}y.x="Right"}}if(x.top){if(z.options.position.target!=="mouse"){s.top=v.position.top+v.dimensions.height}else{s.top=z.cache.mouse.y}y.y="top"}else{if(x.bottom){if(z.options.position.target!=="mouse"){s.top=v.position.top-A.dimensions.height}else{s.top=z.cache.mouse.y-A.dimensions.height}y.y="bottom"}}if(s.left<0){s.left=u.left;y.x=false}if(s.top<0){s.top=u.top;y.y=false}if(z.options.style.tip.corner!==false){s.corner=new String(A.corner);if(y.x!==false){s.corner=s.corner.replace(/Left|Right|Middle/,y.x)}if(y.y!==false){s.corner=s.corner.replace(/top|bottom/,y.y)}if(s.corner!==z.elements.tip.attr("rel")){e.call(z,s.corner)}}return s}function q(u,t){var v,s;v=f.extend(true,{},u);for(s in v){if(t===true&&s.search(/(tip|classes)/i)!==-1){delete v[s]}else{if(!t&&s.search(/(width|border|tip|title|classes|user)/i)!==-1){delete v[s]}}}return v}function c(s){if(typeof s.tip!=="object"){s.tip={corner:s.tip}}if(typeof s.tip.size!=="object"){s.tip.size={width:s.tip.size,height:s.tip.size}}if(typeof s.border!=="object"){s.border={width:s.border}}if(typeof s.width!=="object"){s.width={value:s.width}}if(typeof s.width.max=="string"){s.width.max=parseInt(s.width.max.replace(/([0-9]+)/i,"$1"))}if(typeof s.width.min=="string"){s.width.min=parseInt(s.width.min.replace(/([0-9]+)/i,"$1"))}if(typeof s.tip.size.x=="number"){s.tip.size.width=s.tip.size.x;delete s.tip.size.x}if(typeof s.tip.size.y=="number"){s.tip.size.height=s.tip.size.y;delete s.tip.size.y}return s}function a(){var s,t,u,x,v,w;s=this;u=[true,{}];for(t=0;t<arguments.length;t++){u.push(arguments[t])}x=[f.extend.apply(f,u)];while(typeof x[0].name=="string"){x.unshift(c(f.fn.qtip.styles[x[0].name]))}x.unshift(true,{classes:{tooltip:"qtip-"+(arguments[0].name||"defaults")}},f.fn.qtip.styles.defaults);v=f.extend.apply(f,x);w=(f.browser.msie)?1:0;v.tip.size.width+=w;v.tip.size.height+=w;if(v.tip.size.width%2>0){v.tip.size.width+=1}if(v.tip.size.height%2>0){v.tip.size.height+=1}if(v.tip.corner===true){v.tip.corner=(s.options.position.corner.tooltip==="center")?false:s.options.position.corner.tooltip}return v}function b(v,u,t){var s={bottomRight:[[0,0],[u,t],[u,0]],bottomLeft:[[0,0],[u,0],[0,t]],topRight:[[0,t],[u,0],[u,t]],topLeft:[[0,0],[0,t],[u,t]],topMiddle:[[0,t],[u/2,0],[u,t]],bottomMiddle:[[0,0],[u,0],[u/2,t]],rightMiddle:[[0,0],[u,t/2],[0,t]],leftMiddle:[[u,0],[u,t],[0,t/2]]};s.leftTop=s.bottomRight;s.rightTop=s.bottomLeft;s.leftBottom=s.topRight;s.rightBottom=s.topLeft;return s[v]}function g(s){var t;if(f("<canvas>").get(0).getContext){t={topLeft:[s,s],topRight:[0,s],bottomLeft:[s,0],bottomRight:[0,0]}}else{if(f.browser.msie){t={topLeft:[-90,90,0],topRight:[-90,90,-s],bottomLeft:[90,270,0],bottomRight:[90,270,-s]}}}return t}function k(){var s,t,u;s=this;u=s.getDimensions();t='<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:false" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=\'0\'); border: 1px solid red; height:'+u.height+"px; width:"+u.width+'px" />';s.elements.bgiframe=s.elements.wrapper.prepend(t).children(".qtip-bgiframe:first")}f(document).ready(function(){f.fn.qtip.cache={screen:{scroll:{left:f(window).scrollLeft(),top:f(window).scrollTop()},width:f(window).width(),height:f(window).height()}};var s;f(window).bind("resize scroll",function(t){clearTimeout(s);s=setTimeout(function(){if(t.type==="scroll"){f.fn.qtip.cache.screen.scroll={left:f(window).scrollLeft(),top:f(window).scrollTop()}}else{f.fn.qtip.cache.screen.width=f(window).width();f.fn.qtip.cache.screen.height=f(window).height()}for(i=0;i<f.fn.qtip.interfaces.length;i++){var u=f.fn.qtip.interfaces[i];if(u.status.rendered===true&&(u.options.position.type!=="static"||u.options.position.adjust.scroll&&t.type==="scroll"||u.options.position.adjust.resize&&t.type==="resize")){u.updatePosition(t,true)}}},100)});f(document).bind("mousedown.qtip",function(t){if(f(t.target).parents("div.qtip").length===0){f(".qtip[unfocus]").each(function(){var u=f(this).qtip("api");if(f(this).is(":visible")&&!u.status.disabled&&f(t.target).add(u.elements.target).length>1){u.hide(t)}})}})});f.fn.qtip.interfaces=[];f.fn.qtip.log={error:function(){return this}};f.fn.qtip.constants={};f.fn.qtip.defaults={content:{prerender:false,text:false,url:false,data:null,title:{text:false,button:false}},position:{target:false,corner:{target:"bottomRight",tooltip:"topLeft"},adjust:{x:0,y:0,mouse:true,screen:false,scroll:true,resize:true},type:"absolute",container:false},show:{when:{target:false,event:"mouseover"},effect:{type:"fade",length:100},delay:140,solo:false,ready:false},hide:{when:{target:false,event:"mouseout"},effect:{type:"fade",length:100},delay:0,fixed:false},api:{beforeRender:function(){},onRender:function(){},beforePositionUpdate:function(){},onPositionUpdate:function(){},beforeShow:function(){},onShow:function(){},beforeHide:function(){},onHide:function(){},beforeContentUpdate:function(){},onContentUpdate:function(){},beforeContentLoad:function(){},onContentLoad:function(){},beforeTitleUpdate:function(){},onTitleUpdate:function(){},beforeDestroy:function(){},onDestroy:function(){},beforeFocus:function(){},onFocus:function(){}}};f.fn.qtip.styles={defaults:{background:"white",color:"#111",overflow:"hidden",textAlign:"left",width:{min:0,max:250},padding:"5px 9px",border:{width:1,radius:0,color:"#d3d3d3"},tip:{corner:false,color:false,size:{width:13,height:13},opacity:1},title:{background:"#e1e1e1",fontWeight:"bold",padding:"7px 12px"},button:{cursor:"pointer"},classes:{target:"",tip:"qtip-tip",title:"qtip-title",button:"qtip-button",content:"qtip-content",active:"qtip-active"}},cream:{border:{width:3,radius:0,color:"#F9E98E"},title:{background:"#F0DE7D",color:"#A27D35"},background:"#FBF7AA",color:"#A27D35",classes:{tooltip:"qtip-cream"}},light:{border:{width:3,radius:0,color:"#E2E2E2"},title:{background:"#f1f1f1",color:"#454545"},background:"white",color:"#454545",classes:{tooltip:"qtip-light"}},dark:{border:{width:3,radius:0,color:"#303030"},title:{background:"#404040",color:"#f3f3f3"},background:"#505050",color:"#f3f3f3",classes:{tooltip:"qtip-dark"}},red:{border:{width:3,radius:0,color:"#CE6F6F"},title:{background:"#f28279",color:"#9C2F2F"},background:"#F79992",color:"#9C2F2F",classes:{tooltip:"qtip-red"}},green:{border:{width:3,radius:0,color:"#A9DB66"},title:{background:"#b9db8c",color:"#58792E"},background:"#CDE6AC",color:"#58792E",classes:{tooltip:"qtip-green"}},blue:{border:{width:3,radius:0,color:"#ADD9ED"},title:{background:"#D0E9F5",color:"#5E99BD"},background:"#E5F6FE",color:"#4D9FBF",classes:{tooltip:"qtip-blue"}}}})(jQuery);
/*uploadify*/
/*
Uploadify v1.6.2
Copyright (C) 2009 by Ronnie Garcia
Co-developed by Travis Nickels

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

var flashVer=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var flashDescription=navigator.plugins["Shockwave Flash"+swVer2].description;var descArray=flashDescription.split(" ");var tempArrayMajor=descArray[2].split(".");var versionMajor=tempArrayMajor[0];var versionMinor=tempArrayMajor[1];var versionRevision=descArray[3];if(versionRevision==""){versionRevision=descArray[4]}if(versionRevision[0]=="d"){versionRevision=versionRevision.substring(1)}else{if(versionRevision[0]=="r"){ersionRevision=versionRevision.substring(1);if(versionRevision.indexOf("d")>0){versionRevision=versionRevision.substring(0,versionRevision.indexOf("d"))}}}var flashVer=versionMajor+"."+versionMinor+"."+versionRevision}}else{if($.browser.msie){var version;var axo;var e;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version=axo.GetVariable("$version")}catch(e){}flashVer=version.replace("WIN ","").replace(",",".")}}flashVer=flashVer.split(".")[0];if(jQuery){(function(a){a.extend(a.fn,{fileUpload:function(b){if(flashVer>=9){a(this).each(function(){settings=a.extend({uploader:"uploader.swf",script:"uploader.php",folder:"",height:30,width:110,cancelImg:"cancel.png",wmode:"opaque",scriptAccess:"sameDomain",fileDataName:"Filedata",displayData:"percentage",onInit:function(){},onSelect:function(){},onCheck:function(){},onCancel:function(){},onError:function(){},onProgress:function(){},onComplete:function(){}},b);var d=location.pathname;d=d.split("/");d.pop();d=d.join("/")+"/";var f="&pagepath="+d;if(settings.buttonImg){f+="&buttonImg="+escape(settings.buttonImg)}if(settings.buttonText){f+="&buttonText="+escape(settings.buttonText)}if(settings.rollover){f+="&rollover=true"}f+="&script="+settings.script;f+="&folder="+escape(settings.folder);if(settings.scriptData){var g="";for(var c in settings.scriptData){g+="&"+c+"="+settings.scriptData[c]}f+="&scriptData="+escape(g)}f+="&btnWidth="+settings.width;f+="&btnHeight="+settings.height;f+="&wmode="+settings.wmode;if(settings.hideButton){f+="&hideButton=true"}if(settings.fileDesc){f+="&fileDesc="+settings.fileDesc+"&fileExt="+settings.fileExt}if(settings.multi){f+="&multi=true"}if(settings.auto){f+="&auto=true"}if(settings.sizeLimit){f+="&sizeLimit="+settings.sizeLimit}if(settings.simUploadLimit){f+="&simUploadLimit="+settings.simUploadLimit}if(settings.checkScript){f+="&checkScript="+settings.checkScript}if(settings.fileDataName){f+="&fileDataName="+settings.fileDataName}if(a.browser.msie){flashElement='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+settings.width+'" height="'+settings.height+'" id="'+a(this).attr("id")+'Uploader" class="fileUploaderBtn"><param name="movie" value="'+settings.uploader+"?fileUploadID="+a(this).attr("id")+f+'" /><param name="quality" value="high" /><param name="wmode" value="'+settings.wmode+'" /><param name="allowScriptAccess" value="'+settings.scriptAccess+'"><param name="swfversion" value="9.0.0.0" /></object>'}else{flashElement='<embed src="'+settings.uploader+"?fileUploadID="+a(this).attr("id")+f+'" quality="high" width="'+settings.width+'" height="'+settings.height+'" id="'+a(this).attr("id")+'Uploader" class="fileUploaderBtn" name="'+a(this).attr("id")+'Uploader" allowScriptAccess="'+settings.scriptAccess+'" wmode="'+settings.wmode+'" type="application/x-shockwave-flash" />'}if(settings.onInit()!==false){a(this).css("display","none");if(a.browser.msie){a(this).after('<div id="'+a(this).attr("id")+'Uploader"></div>');document.getElementById(a(this).attr("id")+"Uploader").outerHTML=flashElement}else{a(this).after(flashElement)}a("#"+a(this).attr("id")+"Uploader").after('<div id="'+a(this).attr("id")+'Queue" class="fileUploadQueue"></div>')}a(this).bind("rfuSelect",{action:settings.onSelect},function(j,h,i){if(j.data.action(j,h,i)!==false){var k=Math.round(i.size/1024*100)*0.01;var l="KB";if(k>1000){k=Math.round(k*0.001*100)*0.01;l="MB"}var m=k.toString().split(".");if(m.length>1){k=m[0]+"."+m[1].substr(0,2)}else{k=m[0]}if(i.name.length>20){fileName=i.name.substr(0,20)+"..."}else{fileName=i.name}a("#"+a(this).attr("id")+"Queue").append('<div id="'+a(this).attr("id")+h+'" class="fileUploadQueueItem"><div class="cancel"><a href="javascript:$(\'#'+a(this).attr("id")+"').fileUploadCancel('"+h+'\')"><img src="'+settings.cancelImg+'" border="0" /></a></div><span class="fileName">'+fileName+" ("+k+l+')</span><span class="percentage">&nbsp;</span><div class="fileUploadProgress" style="width: 100%;"><div id="'+a(this).attr("id")+h+'ProgressBar" class="fileUploadProgressBar" style="width: 1px; height: 3px;"></div></div></div>')}});if(typeof(settings.onSelectOnce)=="function"){a(this).bind("rfuSelectOnce",settings.onSelectOnce)}a(this).bind("rfuCheckExist",{action:settings.onCheck},function(m,l,j,k,o){var i=new Object();i.folder=d+k;for(var h in j){i[h]=j[h];if(o){var n=h}}a.post(l,i,function(r){for(var p in r){if(m.data.action(m,l,j,k,o)!==false){var q=confirm("Do you want to replace the file '"+r[p]+"'?");if(!q){document.getElementById(a(m.target).attr("id")+"Uploader").cancelFileUpload(p)}}}if(o){document.getElementById(a(m.target).attr("id")+"Uploader").startFileUpload(n,true)}else{document.getElementById(a(m.target).attr("id")+"Uploader").startFileUpload(null,true)}},"json")});a(this).bind("rfuCancel",{action:settings.onCancel},function(j,h,i,k){if(j.data.action(j,h,i,k)!==false){a("#"+a(this).attr("id")+h).fadeOut(250,function(){a("#"+a(this).attr("id")+h).remove()})}});a(this).bind("rfuClearQueue",{action:settings.onClearQueue},function(){if(event.data.action()!==false){a("#"+a(this).attr("id")+"Queue").contents().fadeOut(250,function(){a("#"+a(this).attr("id")+"Queue").empty()})}});a(this).bind("rfuError",{action:settings.onError},function(k,h,j,i){if(k.data.action(k,h,j,i)!==false){a("#"+a(this).attr("id")+h+" .fileName").text(i.type+" Error - "+j.name);a("#"+a(this).attr("id")+h).css({border:"3px solid #FBCBBC","background-color":"#FDE5DD"})}});a(this).bind("rfuProgress",{action:settings.onProgress,toDisplay:settings.displayData},function(j,h,i,k){if(j.data.action(j,h,i,k)!==false){a("#"+a(this).attr("id")+h+"ProgressBar").css("width",k.percentage+"%");if(j.data.toDisplay=="percentage"){displayData=" - "+k.percentage+"%"}if(j.data.toDisplay=="speed"){displayData=" - "+k.speed+"KB/s"}if(j.data.toDisplay==null){displayData=" "}a("#"+a(this).attr("id")+h+" .percentage").text(displayData)}});a(this).bind("rfuComplete",{action:settings.onComplete},function(k,h,j,i,l){if(k.data.action(k,h,j,unescape(i),l)!==false){a("#"+a(this).attr("id")+h).fadeOut(250,function(){a("#"+a(this).attr("id")+h).remove()});a("#"+a(this).attr("id")+h+" .percentage").text(" - Completed")}});if(typeof(settings.onAllComplete)=="function"){a(this).bind("rfuAllComplete",settings.onAllComplete)}})}},fileUploadSettings:function(b,c){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").updateSettings(b,c)})},fileUploadStart:function(b){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").startFileUpload(b,false)})},fileUploadCancel:function(b){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").cancelFileUpload(b)})},fileUploadClearQueue:function(){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").clearFileUploadQueue()})}})})(jQuery)};
/*gritter*/
/*
 * Gritter for jQuery
 * http://www.boedesign.com/
 *
 * Copyright (c) 2009 Jordan Boesch
 * Dual licensed under the MIT and GPL licenses.
 *
 * Date: June 26, 2009
 * Version: 1.0
 */

jQuery(document).ready(function($){
 	
 	/********************************************
	 * First, we'll define our object
	 */
 	
	Gritter = {
	    
	    // PUBLIC - touch all you want
		fade_speed: 2000, // how fast the notices fade out
	    timer_stay: 6000, // how long you want the message to hang on screen for
	    
	    // PRIVATE - no touchy the private parts
		_custom_timer: 0,
	    _item_count: 0,
		_tpl_close: '<div class="gritter-close"></div>',
		_tpl_item: '<div id="gritter-item-[[number]]" class="gritter-item-wrapper" style="display:none"><div class="gritter-top"></div><div class="gritter-item">[[image]]<div class="[[class_name]]"><span class="gritter-title">[[username]]</span><p>[[text]]</p></div><div style="clear:both"></div></div><div class="gritter-bottom"></div></div>',
	    _tpl_wrap: '<div id="gritter-notice-wrapper"></div>',
	    
	    // Add a notification to the screen
	    add: function(user, text, image, sticky, time_alive){
	        
	        // This is also called from init, we just added it here because
	        // some people might just call the "add" method
	        this.verifyWrapper();
	        
	        var tmp = this._tpl_item;
	        this._item_count++;
			
			// reset
			this._custom_timer = 0;
			
			// a custom fade time set
			if(time_alive){
				this._custom_timer = time_alive;
			}
			
			var image_str = (image != '') ? '<img src="' + image + '" class="gritter-image" />' : '';
			var class_name = (image != '') ? 'gritter-with-image' : 'gritter-without-image';
			
	        tmp = this.str_replace(
	            ['[[username]]', '[[text]]', '[[image]]', '[[number]]', '[[class_name]]'],
	            [user, text, image_str, this._item_count, class_name], tmp
	        );
	        
	        $('#gritter-notice-wrapper').append(tmp);
	        var item = $('#gritter-item-' + this._item_count);
	        var number = this._item_count;
	        item.fadeIn();
	        
			if(!sticky){
				this.setFadeTimer(item, number);
			}
			
			$(item).hover(function(){
				if(!sticky){ 
					Gritter.restoreItemIfFading(this, number);
				}
				Gritter.hoveringItem(this);
			},
			function(){
				if(!sticky){
					Gritter.setFadeTimer(this, number);
				}
				Gritter.unhoveringItem(this);
			});
			
			return number;
	    
	    },
		
		// If we don't have any more gritter notifications, get rid of the wrapper
	    countRemoveWrapper: function(){
	        
	        if($('.gritter-item-wrapper').length == 0){
	            $('#gritter-notice-wrapper').remove();
	        }
	    
	    },
		
		// Fade the item and slide it up nicely... once its completely faded, remove it
	    fade: function(e){
	
	        $(e).animate({
	            opacity:0
	        }, Gritter.fade_speed, function(){
	            $(e).animate({ height: 0 }, 300, function(){
	                $(e).remove();
	                Gritter.countRemoveWrapper();
	            })
	        })
	        
	    },
		
		 // Change the border styles and add the (X) close button when you hover
	    hoveringItem: function(e){
	    	
	    	$(e).addClass('hover');
	    	
			if($(e).find('img').length){
				$(e).find('img').before(this._tpl_close);
			}
			else {
				$(e).find('span').before(this._tpl_close);
			}
			$(e).find('.gritter-close').click(function(){
				Gritter.remove(this);
			});
	        
	    },
	    
	    // Remove a notification, this is called from the inline "onclick" event
	    remove: function(e){
	        
	        $(e).parents('.gritter-item-wrapper').fadeOut('medium', function(){ $(this).remove();  });
	        this.countRemoveWrapper();
	        
	    },
		
		// Remove a specific notification based on an id (int)
		removeSpecific: function(id, params){
			
			var e = $('#gritter-item-' + id);
			
			if(typeof(params) === 'object'){
				if(params.fade){
					var speed = this.fade_speed;
					if(params.speed){
						speed = params.speed;
					}
					e.fadeOut(speed);
				}
			}
			else {
				e.remove();
			}
			
			this.countRemoveWrapper();
			
		},
		
		 // If the item is fading out and we hover over it, restore it!
	    restoreItemIfFading: function(e, number){
			
			window.clearTimeout(Gritter['_int_id_' + number]);
	        $(e).stop().css({ opacity: 1 });
	        
	    },
	    
	    // Set the notification to fade out after a certain amount of time
	    setFadeTimer: function(item, number){
			
			var timer_str = (this._custom_timer) ? this._custom_timer : this.timer_stay;
	        Gritter['_int_id_' + number] = window.setTimeout(function(){ Gritter.fade(item); }, timer_str);
	
	    },
		
		// Bring everything to a halt!    
		stop: function(){
	
			$('#gritter-notice-wrapper').fadeOut(function(){
				$(this).remove();
			});
	
		},
		
		// A handy PHP function ported to js!
	    str_replace: function(search, replace, subject, count) {
	    
	        var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
	            f = [].concat(search),
	            r = [].concat(replace),
	            s = subject,
	            ra = r instanceof Array, sa = s instanceof Array;
	        s = [].concat(s);
	        if (count) {
	            this.window[count] = 0;
	            }
	 
	        for (i=0, sl=s.length; i < sl; i++) {
	            if (s[i] === '') {
	                continue;
	            }
	            for (j=0, fl=f.length; j < fl; j++) {
	                temp = s[i]+'';
	                repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
	                s[i] = (temp).split(f[j]).join(repl);
	                if (count && s[i] !== temp) {
	                    this.window[count] += (temp.length-s[i].length)/f[j].length;}
	            }
	        }
	        return sa ? s : s[0];
	        
	    },
	    
	    // Remove the border styles and (X) close button when you mouse out
	    unhoveringItem: function(e){
	        
	        $(e).removeClass('hover');
	        $(e).find('.gritter-close').remove();
	        
	    },
		
		// Make sure we have something to wrap our notices with
		verifyWrapper: function(){
	      
			if($('#gritter-notice-wrapper').length == 0){
				$('body').append(this._tpl_wrap);
			}
	 
		}
	    
	}
	
	/********************************************
	 * Now lets turn it into some jQuery Magic!
	 */
	
	// Set it up as an object
	$.gritter = {};
	
	// Add a gritter notification
	$.gritter.add = function(params){

		try {
			if(!params.title || !params.text){
				throw "Missing_Fields"; 
			}
		} catch(e) {
			if(e == "Missing_Fields"){
				alert('Gritter Error: You need to fill out the first 2 params: "title" and "text"');
			}
		}
		
		var id = Gritter.add(
			params.title,
			params.text,
			params.image || '',
			params.sticky || false,
			params.time || ''
		);
		
		return id;

	}
	
	// Remove a specific notification
	$.gritter.remove = function(id, params){
		Gritter.removeSpecific(id, params || '');
	}
	
	// Remove all gritter notifications
	$.gritter.removeAll = function(){
		Gritter.stop();
	}
	
});

/*faviconize*/
/**
 * Faviconize (http://www.babylon-design.com/share/faviconize/)
 * A jQuery plugin for displaying a favicon on an external link.
 * 
 * Version 1.0
 * March 4th, 2008
 *
 * Author : Samuel Le Morvan (http://www.babylon-design.com/)
 * 
 * Inspired by:
 * Ask the CSS Guy (http://www.askthecssguy.com/2006/12/hyperlink_cues_with_favicons.html)
 * 
 *
 **/
(function($){
	$.fn.faviconize = function(e) {
		
		var e = $.extend({position:'before', linkable:false, exceptions: new Array()}, e);
		 
		function faviconizePlace(a, h) {
			switch(e.position) {
				case "before" : a.before(h+'&nbsp;'); break;
				case "after" : a.after('&nbsp;'+h); break;
				default :  break;
			}
		}
		
		$(this).each(function() {
			var a = $(this);
			var r = a.attr("href").match(/http:\/\/[a-z0-9.-]*(\/)?/i);
			var r = r[0] + ((r[1] == null) ? "/" : "");
			if (r) {
				if ($.grep(e.exceptions, function(x) {x = (x.match(/\/$/) == null) ? x+"/" : x; return (x == r);}).length == 0) {
					var f = r + 'favicon.ico';
					var i = new Image(); $(i).attr("src", f);
					var h = '<img src="'+f+'" alt="'+ ((e.linkable) ? a.text() : '') +'" '+ ((e.className) ? 'class="'+e.className+'"' : '') +' />';
					h = (e.linkable) ? '<a href="'+a.attr("href")+'">'+h+'</a>' : h;
					$(i).load(function() {faviconizePlace(a, h);});
					$(i).error(function() {if (e.defaultImage) {faviconizePlace(a, h.replace(/src="(.*?)"/i, 'src="'+e.defaultImage+'"')); }});
				}
			}
		});
	}
})(jQuery);
/*accessibleUISlider*/
/*
 * --------------------------------------------------------------------
 * jQuery-Plugin - accessibleUISlider - creates a UI slider component from a select element(s)
 * by Scott Jehl, scott@filamentgroup.com
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/progressive_enhancement_convert_select_box_to_accessible_jquery_ui_slider
 * demo page: http://www.filamentgroup.com/examples/slider/demo.html
 * 
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Usage Notes: please refer to our article above for documentation
 *  
 * Version: 1.0, 08.12.08
 * Changelog: 
 * 	
 * --------------------------------------------------------------------
 */



jQuery.fn.accessibleUISlider = function(settings){
	var selects = jQuery(this);

	//id attrs - selects need ids for this feature to work - links handles to original select menus
	var elIds = (function(){
		var tempArr = [];
		selects.each(function(){
			tempArr.push(jQuery(this).attr('id'));
		});
		return tempArr;
	})();
	
	//array of all option elements in select element
	var options = (function(){
		var opts = [];
		selects.eq(0).find('option').each(function(i){
			opts.push({
				value: jQuery(this).attr('value'),
				text: jQuery(this).text()
			});
		});
		return opts;
	})();
	
	//presets by selected indexes
	var presets = (function(){
		var indexes = [];
		selects.each(function(){
			var thisIndex = jQuery(this).find('option:selected').get(0).index;
			var thisPercentage = Math.round((thisIndex / (options.length-1)) *100);
			indexes.push(thisPercentage);
		});
		return indexes;
	})();
	
	//set up slider options API
	var sliderAPI = jQuery.extend({
		labels: 3,
		inject: true,
		rangeOpacity: 0.7,
		width: selects.parent().width(),
		range: selects.length > 1,//boolean for whether it's a range or not
		steps: options.length-1,
		stepping: 0,
		handles: function(){//set starting locations to selected index, if applicable
				var tempArr = [];
				selects.each(function(i){
					tempArr[i] = {
						start: presets[i],
						min: 0,
						max: 100,
						id: 'handle_'+i
					};
				});
				return tempArr;
			}(),
		change: function(e, ui) {//slide function
				var that = jQuery(this);
				var currValue = ui.value;
				var currIndex = Math.round(currValue / 100 * (options.length-1));
				var currValue = options[currIndex].value;
				var currText = options[currIndex].text;
				//handle feedback tooltip and aria attrs
				var feedback = ui.handle.find('.ui-slider-tooltip'); 
				feedback.html(currText).parent().attr('aria-valuetext', currValue).attr('aria-valuenow', currValue);
				//control original select menu
				var currSelect = jQuery('#'+ui.handle.attr('id').split('handle_')[1]);
				currSelect.find('option').eq(currIndex).attr('selected', 'selected');
			}
	}, settings);
		
	selects.change(function(){
		var thisIndex = jQuery(this).find('option:selected').get(0).index;
		var thisLeft = Math.ceil((thisIndex / (options.length-1))* 100);
		var thisIndex = jQuery('#handle_'+ jQuery(this).attr('id')).parent().prev('a').size();
		jQuery('#handle_'+ jQuery(this).attr('id')).parents('.ui-slider:eq(0)').slider("moveTo", thisLeft,thisIndex);
	});
	
	//opt groups if present
	var groups = (function(){
		if (selects.eq(0).find('optgroup').size()>0){
			var groupedData = [];
			selects.eq(0).find('optgroup').each(function(i){
				groupedData[i] = {};
				groupedData[i].label = jQuery(this).attr('label');
				groupedData[i].options = [];
				jQuery(this).find('option').each(function(){
					groupedData[i].options.push({text: jQuery(this).text(), value: jQuery(this).attr('value')});
				});
			});
			return groupedData;
		}
		else return false;
	})();	

	//create slider component div
	var sliderComponent = jQuery('<div class="sliderComponent"></div>');
	
	//CREATE HANDLES
	selects.each(function(i){
		sliderComponent.append('<div id="handle_'+elIds[i]+'" tabindex="'+ i+1 +'" class="ui-slider-handle ui-default-state" role="slider" aria-valuemin="'+ sliderAPI.minValue +'" aria-valuemax="'+  sliderAPI.maxValue +'"><span class="ui-slider-tooltip ui-component-content"></span></div>');
	});
	
	//CREATE SCALE AND TICS
	sliderComponent.width(sliderAPI.width);
	
	//write dl if there are optgroups
	if (groups) {
		var scale = sliderComponent.append('<dl class="ui-slider-scale"></dl>').find('.ui-slider-scale:eq(0)');
		jQuery(groups).each(function(){
			scale.append('<dt><span>'+this.label+'</span></dt>');//class name becomes camelCased label
			var groupOpts = this.options;
			jQuery(this.options).each(function(i){
				scale.append('<dd><span class="ui-slider-label">'+ groupOpts[i].text +'</span><span class="ui-slider-tic ui-component-content"></span></dd>');
			});
		});
	}
	//write ol
	else {
		var scale = sliderComponent.append('<ol class="ui-slider-scale"></ol>').find('.ui-slider-scale:eq(0)');
		jQuery(options).each(function(){
			scale.append('<li><span class="ui-slider-label">'+this.text+'</span><span class="ui-slider-tic ui-component-content"></span></li>');
		});
	}
	
	//style the li's or dd's
	sliderComponent.find('.ui-slider-scale li, .ui-slider-scale dd').each(function(i){
		jQuery(this).css({
			'left': ((100 /( options.length-1))*i).toFixed(2) + '%'
		});
	});
	
	//first and last classes, and right align the last li/dd
	sliderComponent.find('.ui-slider-scale li:first, .ui-slider-scale dd:first').addClass('first');
	sliderComponent.find('.ui-slider-scale li:last, .ui-slider-scale dd:last').addClass('last').each(function(){ 
		jQuery(this).css({'right': 0, 'left':'auto'});
	});
	
	//show and hide labels depending on showLabels pref
	//show the last one if there are more than 1 specified
	if (sliderAPI.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').css('text-indent', 0).addClass('ui-slider-label-show');
	//set increment
	var increm = Math.round(options.length / sliderAPI.labels);
	//show em based on inc
	for(var j=0; j<options.length; j+=increm){
		if ((options.length - j) > increm){//don't show if it's too close to the end label
			sliderComponent.find('.ui-slider-scale li:eq('+ j +') span.ui-slider-label, .ui-slider-scale dd:eq('+ j +') span.ui-slider-label').addClass('ui-slider-label-show');
		}
	}

	//style the dt's
	sliderComponent.find('.ui-slider-scale dt').each(function(i){
		var aPixel = ((3 / sliderAPI.width) * 100).toFixed(2);
		jQuery(this).css({
			'left': ((100 /( groups.length))*i).toFixed(2) + '%',
			'width': (((sliderAPI.width / groups.length) / sliderAPI.width) * 100).toFixed(2)- aPixel +'%'
		});
	});
	
	sliderAPI.markup = sliderComponent;
	
	//port slider function to pass api in.
	sliderAPI.markup.slider = function(settings){
		var sliderAPI_port = jQuery.extend(sliderAPI, settings);		
		jQuery(this).slider(sliderAPI_port).find('.ui-slider-range').css('opacity', sliderAPI_port.rangeOpacity);
		return this;
	}
	
	//if inject is true, inject slider after last select element and init, otherwise return api including markup
	if (sliderAPI.inject){
		sliderAPI.markup.insertAfter(jQuery(this).eq(this.length-1)).slider(sliderAPI).find('.ui-slider-range').css('opacity', sliderAPI.rangeOpacity);
		return this;
	}
	else{
		return sliderAPI;
	}

}



/*jmp3*/
/***
*  jMP3 v0.2.1 - 10.10.2006 (w/Eolas fix & jQuery object replacement)
* an MP3 Player jQuery Plugin (http://www.sean-o.com/jquery/jmp3)
* by Sean O
*
* An easy way make any MP3 playable directly on most any web site (to those using Flash & JS),
* using the sleek Flash Single MP3 Player & the fantabulous jQuery.
*
* SIMPLE USAGE Example:
* $(youridorclass).jMP3();
*
* ADVANCED USAGE Example:
* $("#sounddl").jmp3({
*   showfilename: "false",
*   backcolor: "000000",
*   forecolor: "00ff00",
*   width: 200,
*   showdownload: "false"
* });
*
* HTML:
* <span class="mp3">sound.mp3</span>
*
* NOTE: filename must be enclosed in tag.  Various file paths can be set using the filepath option.
*
* Copyright (c) 2006 Sean O (http://www.sean-o.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
***/
jQuery.fn.jmp3 = function(passedOptions){
	// hard-wired options
	var playerpath = "/swf/";					// SET THIS FIRST: path to singlemp3player.swf

	// passable options
	var options = {
		"filepath": "",										// path to MP3 file (default: current directory)
		"backcolor": "",									// background color
		"forecolor": "ffffff",								// foreground color (buttons)
		"width": "25",										// width of player
		"repeat": "no",										// repeat mp3?
		"volume": "50",										// mp3 volume (0-100)
		"autoplay": "false",								// play immediately on page load?
		"showdownload": "true",								// show download button in player
		"showfilename": "true"								// show .mp3 filename after player
	};
	
	// use passed options, if they exist
	if (passedOptions) {
		jQuery.extend(options, passedOptions);
	}
	
	// iterate through each object
	return this.each(function(){
		// filename needs to be enclosed in tag (e.g. <span class='mp3'>mysong.mp3</span>)
		var filename = options.filepath + jQuery(this).html();
		// do nothing if not an .mp3 file
		var validfilename = filename.indexOf(".mp3");
		if (validfilename == -1) { return false; }
		// build the player HTML
		var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		mp3html += 'width="' + options.width + '" height="20" ';
		mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
		mp3html += '<param name="movie" value="' + playerpath + 'singlemp3player.swf?';
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" />';
		mp3html += '<param name="wmode" value="transparent" />';
		mp3html += '<embed wmode="transparent" width="' + options.width + '" height="20" ';
		mp3html += 'src="' + playerpath + 'singlemp3player.swf?'
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" ';
		mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		mp3html += '</object>';
		// don't display filename if option is set
		if (options.showfilename == "false") { jQuery(this).html(""); }
		jQuery(this).prepend(mp3html+"&nbsp;");
		
		// Eolas workaround for IE (Thanks Kurt!)
		if(jQuery.browser.msie){ this.outerHTML = this.outerHTML; }
	});
};
/*/ui/selectToUISlider/js/selectToUISlider.jQuery.js*/
/*
 * --------------------------------------------------------------------
 * jQuery-Plugin - selectToUISlider - creates a UI slider component from a select element(s)
 * by Scott Jehl, scott@filamentgroup.com
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/
 * demo page: http://www.filamentgroup.com/examples/slider_v2/index.html
 * 
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Usage Notes: please refer to our article above for documentation
 *  
 * --------------------------------------------------------------------
 */


jQuery.fn.selectToUISlider = function(settings){
	var selects = jQuery(this);
	
	//accessible slider options
	var options = jQuery.extend({
		labels: 3, //number of visible labels
		tooltip: true, //show tooltips, boolean
		tooltipSrc: 'text',//accepts 'value' as well
		labelSrc: 'value',//accepts 'value' as well	,
		sliderOptions: null
	}, settings);


	//handle ID attrs - selects each need IDs for handles to find them
	var handleIds = (function(){
		var tempArr = [];
		selects.each(function(){
			tempArr.push('handle_'+jQuery(this).attr('id'));
		});
		return tempArr;
	})();
	
	//array of all option elements in select element (ignores optgroups)
	var selectOptions = (function(){
		var opts = [];
		selects.eq(0).find('option').each(function(){
			opts.push({
				value: jQuery(this).attr('value'),
				text: jQuery(this).text()
			});
		});
		return opts;
	})();
	
	//array of opt groups if present
	var groups = (function(){
		if (selects.eq(0).find('optgroup').size()>0){
			var groupedData = [];
			selects.eq(0).find('optgroup').each(function(i){
				groupedData[i] = {};
				groupedData[i].label = jQuery(this).attr('label');
				groupedData[i].options = [];
				jQuery(this).find('option').each(function(){
					groupedData[i].options.push({text: jQuery(this).text(), value: jQuery(this).attr('value')});
				});
			});
			return groupedData;
		}
		else return null;
	})();	
	
	//check if obj is array
	function isArray(obj) {
		return obj.constructor == Array;
	}
	//return tooltip text from option index
	function ttText(optIndex){
		return (options.tooltipSrc == 'text') ? selectOptions[optIndex].text : selectOptions[optIndex].value;
	}
	
	//plugin-generated slider options (can be overridden)
	var sliderOptions = {
		step: 1,
		min: 0,
		orientation: 'horizontal',
		max: selectOptions.length-1,
		range: selects.length > 1,//multiple select elements = true
		slide: function(e, ui) {//slide function
				var thisHandle = jQuery(ui.handle);
				//handle feedback 
				var textval = ttText(ui.value);
				thisHandle
					.attr('aria-valuetext', textval)
					.attr('aria-valuenow', ui.value)
					.find('.ui-slider-tooltip .ttContent')
						.text( textval );

				//control original select menu
				var currSelect = jQuery('#' + thisHandle.attr('id').split('handle_')[1]);
				currSelect.find('option').eq(ui.value).attr('selected', 'selected');
		},
		values: (function(){
			var values = [];
			selects.each(function(){
				values.push( jQuery(this).get(0).selectedIndex );
			});
			return values;
		})()
	};
	
	//slider options from settings
	options.sliderOptions = (settings) ? jQuery.extend(sliderOptions, settings.sliderOptions) : sliderOptions;
		
	//select element change event	
	selects.bind('change keyup click', function(){
		var thisIndex = jQuery(this).get(0).selectedIndex;
		var thisHandle = jQuery('#handle_'+ jQuery(this).attr('id'));
		var handleIndex = thisHandle.data('handleNum');
		thisHandle.parents('.ui-slider:eq(0)').slider("values", handleIndex, thisIndex);
	});
	

	//create slider component div
	var sliderComponent = jQuery('<div></div>');

	//CREATE HANDLES
	selects.each(function(i){
		var hidett = '';
		
		//associate label for ARIA
		var thisLabel = jQuery('label[for=' + jQuery(this).attr('id') +']');
		//labelled by aria doesn't seem to work on slider handle. Using title attr as backup
		var labelText = (thisLabel.size()>0) ? 'Slider control for '+ thisLabel.text()+'' : '';
		var thisLabelId = thisLabel.attr('id') || thisLabel.attr('id', 'label_'+handleIds[i]).attr('id');
		
		
		if ( options.tooltip == false ){hidett = ' style="display: none;"';}
		jQuery('<a '+
				'href="#" tabindex="0" '+
				'id="'+handleIds[i]+'" '+
				'class="ui-slider-handle" '+
				'role="slider" '+
				'aria-labelledby="'+thisLabelId+'" '+
				'aria-valuemin="'+options.sliderOptions.min+'" '+
				'aria-valuemax="'+options.sliderOptions.max+'" '+
				'aria-valuenow="'+options.sliderOptions.values[i]+'" '+
				'aria-valuetext="'+ttText(options.sliderOptions.values[i])+'" '+
			'><span class="screenReaderContext">'+labelText+'</span>'+
			'<span class="ui-slider-tooltip ui-widget-content ui-corner-all"'+ hidett +'><span class="ttContent"></span>'+
				'<span class="ui-tooltip-pointer-down ui-widget-content"><span class="ui-tooltip-pointer-down-inner"></span></span>'+
			'</span></a>')
			.data('handleNum',i)
			.appendTo(sliderComponent);
	});
	
	//CREATE SCALE AND TICS
	
	//write dl if there are optgroups
	if (groups) {
		var inc = 0;
		var scale = sliderComponent.append('<dl class="ui-slider-scale ui-helper-reset" role="presentation"></dl>').find('.ui-slider-scale:eq(0)');
		jQuery(groups).each(function(h){
			scale.append('<dt style="width: '+ (100/groups.length).toFixed(2) +'%' +'; left:'+ (h/(groups.length-1) * 100).toFixed(2)  +'%' +'"><span>'+this.label+'</span></dt>');//class name becomes camelCased label
			var groupOpts = this.options;
			jQuery(this.options).each(function(i){
				var style = (inc == selectOptions.length-1 || inc == 0) ? 'style="display: none;"' : '' ;
				var labelText = (options.labelSrc == 'text') ? groupOpts[i].text : groupOpts[i].value;
				scale.append('<dd style="left:'+ leftVal(inc) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></dd>');
				inc++;
			});
		});
	}
	//write ol
	else {
		var scale = sliderComponent.append('<ol class="ui-slider-scale ui-helper-reset" role="presentation"></ol>').find('.ui-slider-scale:eq(0)');
		jQuery(selectOptions).each(function(i){
			var style = (i == selectOptions.length-1 || i == 0) ? 'style="display: none;"' : '' ;
			var labelText = (options.labelSrc == 'text') ? this.text : this.value;
			scale.append('<li style="left:'+ leftVal(i) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></li>');
		});
	}
	
	function leftVal(i){
		return (i/(selectOptions.length-1) * 100).toFixed(2)  +'%';
		
	}
	

	
	
	//show and hide labels depending on labels pref
	//show the last one if there are more than 1 specified
	if (options.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').addClass('ui-slider-label-show');

	//set increment
	var increm = Math.max(1, Math.round(selectOptions.length / options.labels));
	//show em based on inc
	for(var j=0; j<selectOptions.length; j+=increm){
		if ((selectOptions.length - j) > increm){//don't show if it's too close to the end label
			sliderComponent.find('.ui-slider-scale li:eq('+ j +') span.ui-slider-label, .ui-slider-scale dd:eq('+ j +') span.ui-slider-label').addClass('ui-slider-label-show');
		}
	}

	//style the dt's
	sliderComponent.find('.ui-slider-scale dt').each(function(i){
		jQuery(this).css({
			'left': ((100 /( groups.length))*i).toFixed(2) + '%'
		});
	});
	

	//inject and return 
	sliderComponent
	.insertAfter(jQuery(this).eq(this.length-1))
	.slider(options.sliderOptions)
	.attr('role','application')
	.find('.ui-slider-label')
	.each(function(){
		jQuery(this).css('marginLeft', -jQuery(this).width()/2);
	});
	
	//update tooltip arrow inner color
	sliderComponent.find('.ui-tooltip-pointer-down-inner').each(function(){
				var bWidth = jQuery('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
				var bColor = jQuery(this).parents('.ui-slider-tooltip').css('backgroundColor')
				jQuery(this).css('border-top', bWidth+' solid '+bColor);
	});
	
	var values = sliderComponent.slider('values');
	
	if (isArray(values)){
		jQuery(values).each(function(i){
			sliderComponent.find('.ui-slider-tooltip .ttContent').eq(i).text( ttText(this) );
		});
	}
	else {
		sliderComponent.find('.ui-slider-tooltip .ttContent').eq(0).text( ttText(values) );
	}
	
	return this;
}



