/* jSelect (using jQuery library).
*--------------------------------------------*
*  @author : ukhome ( ukhome@gmail.com | ntkhoa_friends@yahoo.com )
*--------------------------------------------*
*  @released : 24-Mar-2009 : version 1.0
*--------------------------------------------*
*  @revision history : ( latest version : 1.0 )
*--------------------------------------------*
*      + 24-Mar-2009 : version 1.0
*          - released
*--------------------------------------------*
*/

/* External Interface
*/

function callExternalFunction (o/*caller*/, droplists/*all droplists*/, val/*rel in <a>*/) {
    /*
    * o : selectUI object
    *   o.select : <select> in jQuery type
    *   o.elUL : list drop down, main list <ul>
    *----------------------------------------------*
    * droplists : all selectUI droplists in page, call by its id droplists(id), will return selectUI object
    * val : rel value in a of each selectUI option
    */
	
	var getSelectId = o.select.attr("id");
	//alert(getSelectId);
	//alert($("#" + getSelectId + "Check"));
	var getSelectIdRadio = $("#" + getSelectId + "Check");
	var getRadioName = getSelectIdRadio.attr("name");

	$('input:radio[name="'+ getRadioName +'"]').each(function(){
		var label = $(this).parent().find("label[for='"+ $(this).attr("id") +"']");
		if(label.hasClass("RadioUIActive")) {
			label.removeClass("RadioUIActive");
		}
	});
	getSelectIdRadio.next().addClass("RadioUIActive");
	getSelectIdRadio.attr("checked", true);



}

function callExternalBeforeFunction(o){
		//modification via js pour ne pas "casser" le fonctionnement du plugin

		$('ul.ThemeComboBoxExtra8  li a').bind("mouseover", function (e){
			Tooltip.populate(this);

		});
		$('ul.ThemeComboBoxExtra8  a').bind("mouseout", function (e){
			Tooltip.hide();

		});

		if(o.elUL.attr("offsetHeight") <  o.elUL.attr("scrollHeight")){

			var delta = ($.browser.msie && $.browser.version == "6.0")
				? 0:
				($.browser.msie && $.browser.version == "8.0") ? 0 :
					($.browser.msie && $.browser.version == "7.0")  ? 0 : 0;




			var w = $(o.elUL.get(0).childNodes[0]).width() - delta;

			if(w) {
				//o.elUL.css("width", w  + "px");
				o.elUL.css("height",  (o.el.height() - 10) + "px");
				o.elUL.css("overflowY",  "scroll");
				o.elUL.css("overflowX",  "hidden");
				//o.elUL.parent().css("paddingBottom",  "30px");
				o.elUL.bind("scroll", function (e){
					e.preventDefault(e);
					e.stopImmediatePropagation(e);
				});

			}
		}
   }
