﻿//mh
//GoBooking Replacement
//Strategy: Unobtrusive Approach which will work w/ every booking engine by using the form as the primary driver,
//instead of hard-coding urls into js, use the form to create the parameters of the url and then redirect it to Google Tracking + window.open.
//Since the form is supplied by the vendor or can easily be copied this should work w/ every booking engine.


//form tag:  class="Booking_Mask" needed and class = "popup" for popup window
//    <form id="frmRoomInventory" name="frmRoomInventory" class="Booking_Mask popup selectboxplugin" method="get"
//    action="https://indecorp.ibe.netbooker.com/web/FrontController.nb4" target="_blank" rel="resizable,scrollbars,width=800,height=600,top=500,left=500">
//resnet has very different form from others give form extra class of resnet   class="Booking_Mask iframe resnet"

//classes:  Booking_Mask, popup, noGoogleLinkerUrl, resnet, iframe, (.startmonth ->zeroBasedMonth)

//page loaded
jQuery(document).ready(function() {

    //if booking mask overrides datepickers from document.ready
    if (jQuery(".Booking_Mask").length > 0) {

        jQuery(".selectboxplugin select").selectbox();
        //all selects in booking mask prettied & styled. put styles at bottom of styles.css.

        //Booking Mask Form Submitted
        jQuery(".Booking_Mask").submit(function() {

            if (jQuery('.numbernights').length > 0) {
                pushDate(getPushdate());
            }

            //serialize all form values
            var values = jQuery(this).serialize();
            var action = jQuery(this).attr('action')
            var strLink = action + '?' + values;

            var linkerUrl = pageTracker._getLinkerUrl(strLink);  //gets url w/ GA link params

            //myfidelio throws errors if u send google vars - doesnt support.
            if (jQuery(this).hasClass("noGoogleLinkerUrl")) linkerUrl = strLink;

            //track here as after this  point all outgoing links.        
            pageTracker._trackPageview('/outgoing/check-availability/');   //calls gif asynch

            //resnet has custom url /w iframe
            if (jQuery(this).hasClass("resnet")) {
                GoBooking_Resnet(action);
               // alert('resnet');
                return false;
            }

            //need to handle iframe here -- target self - same site so no outgoing
            if (jQuery(this).hasClass("iframe")) {
                window.open(linkerUrl, jQuery(this).attr('target'), '');
                return false;
            }


            if (jQuery(this).hasClass("popup")) {
                var popup_params = 'resizable,scrollbars,width=1020,height=600,top=800,left=800';

                //pull popup parameters from forms'rel%20attribute%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(jQuery(this).attr('rel')%20!=%20undefined)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20popup_params%20=%20jQuery(this).attr('rel');
                }
                window.open(linkerUrl, '', popup_params);
                return false;  //so form doesn't submit as well as popup
            }

            //if not popup class returns  w/ target=_blank
            window.open(linkerUrl, jQuery(this).attr('target'), '');
            return false;

        }); //end .Booking_Mask submit

        dateFormat = 'm/d/yy'

        //start datepickers

        //TODO: calc numberOfNights based on startdate.getValue - enddate.getvalue
        if (jQuery("#startdate").length > 0) {


            jQuery.datepicker.setDefaults({
                minDate: 0,
                buttonText: '',
                defaultDate: +1,
                showOn: 'both',
                buttonImageOnly: false,
                dateFormat: dateFormat //leading zeros breaks selectbox plugin integration -should handle that at b4 sending to selectbox -- resnet needs leading zeros
            });

            jQuery('#startdate').datepicker({

                onClose: function() {
                    pushDate(getPushdate())
                    fillStartDateDropdowns(jQuery(this).val())  //instance data issue here if no #enddate - cascading to ?

                }
                //TODO: push dropdowns ahead
            });

            jQuery('#enddate').datepicker({
                beforeShow: minRange,
                defaultDate: +0,
                onClose: function() {
                    fillEndDateDropdowns(jQuery(this).val())
                }
            });

            //initial setup after initialize datePickers()

            pushDate(getPushdate());


        } //end datepicker

        //if submit button is img tag w/ mouseovers already attached so i can't change to <input type=image
        jQuery('.booking_submit').click(function() {
            jQuery('.Booking_Mask').submit();
        })


    } //end if booking mask form 
});         //end ready


function getPushdate() {

    pushDateVal = 1;  //put in rel attribute of #startdate or .numbernights field

    //if stardate has rel set it to that
    if (jQuery('#startdate').attr('rel') > 0) {
        pushDateVal = parseInt(jQuery('#startdate').attr('rel'));
    }

    // if there is .numbernights dropdown set it to that
    if (jQuery('.numbernights').length > 0) {
        pushDateVal = parseInt(jQuery('.numbernights').val());  //!parseInt important
    }

    return pushDateVal;

}


//goes in order from:  startdate dropdowns -> #startdate -> #enddate -> enddate dropdowns
function refreshDatepickers() {

    if (jQuery(".startmonth").length > 0) {

        //only needed on dropdowns and not for text or hidden
        if (jQuery(".selectboxplugin .startmonth").attr("type") != 'hidden' && jQuery(".selectboxplugin .startmonth").attr("type") != 'text') {


            var startmonth = jQuery(".startmonth").val();
            var startday = jQuery(".startday").val();
            var startyear = jQuery(".startyear").val();

            //todo: change format if multi lang

            //push value into startdate
            var startDateDropdowns = startmonth + "/" + startday + "/" + startyear;
            jQuery('#startdate').val(startDateDropdowns);


            //need conditional here comparing dates
            //pushes #startdate -> #enddate if needed


            //push value into enddate if pushdate didn't do it
            //pushes #enddate into enddate dropdowns !push date has this w/ comparisons

            //be careful of val() having incremented value!!!!!
            var endmonth = jQuery(".endmonth").val();
            var endday = jQuery(".endday").val(); //issue w/ #enddate here
            var endyear = jQuery(".endyear").val();
            var endDateDropdowns = endmonth + "/" + endday + "/" + endyear;
            //alert(endDateDropdowns);
            jQuery('#enddate').val(endDateDropdowns);


        }
        pushDateSeparate(getPushdate());
    }
}

//pushes into separate date fields (deprecate this??
function pushDateSeparate(numberDaysAhead) {
    if (jQuery("#enddate").length > 0) {

        var startDate = jQuery("#startdate").datepicker("getDate");
        var endDate = jQuery("#enddate").datepicker("getDate");
        var startDatePlus = jQuery("#startdate").datepicker("getDate"); //need to compare startdate plus num nights    
        startDatePlus.setDate(startDatePlus.getDate() + numberDaysAhead);

        //stardate was updated and is greater
        if (startDatePlus > endDate) {
            jQuery('#enddate').datepicker('setDate', startDatePlus);
            fillEndDateDropdowns(jQuery('#enddate').val())
        }
        //enddate updated

        //exact because if nights are changed enddate should always be exactly startdate + nights
        //if number nights set via select box plugin.
        if (jQuery('#numbernights_input').val() > 0) {
            //alert(jQuery('#numbernights_input').val() + "pushDateSeparate");
            jQuery('#enddate').datepicker('setDate', startDatePlus);
            fillEndDateDropdowns(jQuery('#enddate').val())
        }
    }
}

//pushes the endDate back to +numberDaysAhead days of startdate
function pushDate(numberDaysAhead) {
    if (jQuery("#enddate").length > 0) {

        var startDate = jQuery("#startdate").datepicker("getDate");
        var endDate = jQuery("#enddate").datepicker("getDate");
        var startDatePlus = jQuery("#startdate").datepicker("getDate"); //need to compare startdate plus num nights    
        startDatePlus.setDate(startDatePlus.getDate() + numberDaysAhead);

        //stardate was updated and is greater
        if (startDatePlus > endDate) {
            jQuery('#enddate').datepicker('setDate', startDatePlus);
            fillEndDateDropdowns(jQuery('#enddate').val())
        }
        //enddate updated

        //exact because if nights are changed enddate should always be exactly startdate + nights
        //if number nights set via select box plugin.
        if (jQuery('.numbernights').val() > 0) {
            jQuery('#enddate').datepicker('setDate', startDatePlus);
        }
    }
}


//customize mindate so that enddate cannot be b4 startdate
function minRange(input) {
    return {
        minDate: (jQuery("#startdate").datepicker("getDate") != null ? jQuery("#startdate").datepicker("getDate") : 2)
    };
}
//startdate cannot be after enddate
function maxRange(input) {
    return {
        maxDate: (jQuery("#enddate").datepicker("getDate") != null ? jQuery("#enddate").datepicker("getDate") : null)
    };
}

//TODO: dateformat on multilang site.
function fillStartDateDropdowns(date_m_d_yy) {


    //fills in selectbox plugin dropdowns or hidden fields containing the dates split
    // assumes classes of .startmonth, .startday, .startyear
    var strFilled;
    strFilled = date_m_d_yy.split("/");

    var month_id = '#' + jQuery(".startmonth").attr('id');
    //some booking engines only take zeroBased month
    if (jQuery(".startmonth").hasClass("zeroBasedMonth")) {
        strFilled[0]--;
    }
    jQuery(".startmonth").val(strFilled[0]);  //put values

    var day_id = '#' + jQuery(".startday").attr('id');
    jQuery(".startday").val(strFilled[1]);

    var year_id = '#' + jQuery(".startyear").attr('id');
    //TODO: make it so they can stack classes in any format w/ delimiters !think
    if (jQuery(".startyear").hasClass('startmonth')) {
        jQuery(".startyear").val(strFilled[0] + strFilled[2]);
    } else {
        jQuery(".startyear").val(strFilled[2]);
    }

    //if selectbox plugin
    if (jQuery(".selectboxplugin .startmonth").length > 0) {
        if (jQuery(".selectboxplugin .startmonth").attr("type") != 'hidden' && jQuery(".selectboxplugin .startmonth").attr("type") != 'text') {


            //refresh dropdowns if they exist should make fn.
            jQuery(month_id + '_input').remove();
            jQuery(month_id + '_container').remove();
            jQuery('.selectboxplugin ' + month_id).selectbox();

            jQuery(day_id + '_input').remove();
            jQuery(day_id + '_container').remove();
            jQuery('.selectboxplugin ' + day_id).selectbox();

            jQuery(year_id + '_input').remove();
            jQuery(year_id + '_container').remove();
            jQuery('.selectboxplugin ' + year_id).selectbox();

            jQuery(".selectbox-wrapper").bind("click", function(e) {
                refreshDatepickers();
            });
        }
    }
}

function fillEndDateDropdowns(date_m_d_yy) {


    //fills in selectbox plugin dropdowns or hidden fields containing the dates split
    //  assumes classes of .endmonth, .endday, .endyear
    var strFilled;
    strFilled = date_m_d_yy.split("/");
    //strFilled[1]--;  //day too low?

    var month_id = '#' + jQuery(".endmonth").attr('id');
    //some booking engines only take zeroBased month
    if (jQuery(".endmonth").hasClass("zeroBasedMonth")) {
        strFilled[0]--;
    }
    jQuery(".endmonth").val(strFilled[0]);  //if hidden field or separate text


    var day_id = '#' + jQuery(".endday").attr('id');


    jQuery(".endday").val(strFilled[1]);  //if hidden field or separate text

    //TODO: make it so they can stack classes in any format w/ delimiters !think

    if (jQuery(".endyear").hasClass('endmonth')) {
        jQuery(".endyear").val(strFilled[0] + strFilled[2]);
    } else {
        jQuery(".endyear").val(strFilled[2]);
    }


    //check if end month is select!!!
    if (jQuery(".selectboxplugin .endmonth").length > 0) {
        if (jQuery(".selectboxplugin .endmonth").attr("type") != 'hidden' && jQuery(".selectboxplugin .endmonth").attr("type") != 'text') {  //needs hidden too!


            //refresh dropdowns here fi they exist    
            jQuery(month_id + '_input').remove();
            jQuery(month_id + '_container').remove();
            jQuery('.selectboxplugin ' + month_id).selectbox();

            jQuery(day_id + '_input').remove();
            jQuery(day_id + '_container').remove();
            jQuery('.selectboxplugin ' + day_id).selectbox();


            jQuery(year_id + '_input').remove();
            jQuery(year_id + '_container').remove();
            jQuery('.selectboxplugin ' + year_id).selectbox();

            jQuery(".selectbox-wrapper").bind("click", function(e) {
                refreshDatepickers();
            });
        }
    }
}


//remove http:// & https://
function stripProtocol(inStrip) {

    inStrip = inStrip.replace(/http:\/\//gi, '');
    inStrip = inStrip.replace(/https:\/\//gi, '');
    return inStrip;
}

//add leading zeros if needed 9 -> 09
function leadZero(num) {
    if (num < 10) {
        num = '0' + num;
    }
    return num;
}

//convert long year to short year 2010 -> 10
function yyToy(year) {
    if (year.length > 2) {
        year = year.substring(2, 4);
    }
    return year;
}


//resnet does not support key-value pairs in its url... only semi-colon delimited ...  usually iFramed on same site
//also its a cgi-bin app so booking domain is same.

//cgi-bin/lansaweb in form action,  res.domain

function GoBooking_Resnet(action) {

    //build w/ SaharaV1 as model - updated janugget removed frame -added default attr

    fillStartDateDropdowns(jQuery("#startdate").val());

    //resnet url format                                       (action)      ratecode;mmddy;nights;adults;children; -- question mark terminates !important

    //https://res.saharavegas.com/cgi-bin/lansaweb?procfun+rn+resnet+sh1+funcparms+UP%28A2560%29:;Luv;050510;03;02;01;?#

    var resnet = [];



    startmonth = leadZero(jQuery('.startmonth').val());

    startday = leadZero(jQuery('.startday').val());

    startyear = yyToy(jQuery('.startyear').val());

    dateCombined = startmonth + '' + startday + '' + startyear;



    //in order by resnet !important 

    //using everything before the ":"  in the .booking_link
 
    resnet.push(action);
 
    ratecode = jQuery('.ratecode').val()
  
 
    if (ratecode.length < 2) ratecode = jQuery('.ratecode').attr('default');

    // alert(ratecode);



    resnet.push(ratecode);

    resnet.push(dateCombined);



    resnet.push(jQuery('.nights').val());

    resnet.push(jQuery('.adults').val());

    resnet.push(jQuery('.children').val());



    //other fields at end case 62673

    jQuery('.extras').each(function() {

        // alert(jQuery(this).val());

        resnet.push(jQuery(this).val());

    });


    resnet.push('?'); //must end in ?



    var url = resnet.join(';');  //adds ';' between all vars



    //mh added replaceQuote case 47446

    var linkerUrl = replaceQuote(pageTracker._getLinkerUrl(url));



    if (jQuery('.Booking_Mask').hasClass("popup")) {

        var popup_params = 'resizable,scrollbars,width=825,height=640,top=800,left=800';



        //pull popup parameters from forms' rel attribute

        if (jQuery('.Booking_Mask').attr('rel')%20!=%20undefined)%20{%20%20%20%20%20%20%20%20%20%20%20%20popup_params%20=%20jQuery(this).attr('rel');

        }

        window.open(linkerUrl, '', popup_params);

        return false;

    } else {

        //regular 

        window.open(linkerUrl, jQuery('.Booking_Mask').attr('target'), '');

    }

 
}

//debug function for creating form from booking engine url string
function alertForm(url) {
    //var url = prompt("Enter Url to create form.");
    var form_string = "";

    url_arr = url.split('?');

    if (url_arr.length > 1) {
        form_string = "<form class=\"Booking_Mask\" method=\"get\" action=\"" + url_arr[0] + "\" > \n";
    } else {
        form_string = "<form class=\"Booking_Mask\" method=\"get\" action=\"put url here\" > \n";
    }

    //split params
    hidden_arr = url_arr[1].split('&');

    var num_of_params = hidden_arr.length;

    for (i = 0; i < num_of_params; i++) {

        //split key/values
        var key_value = hidden_arr[i];

        key_value_arr = key_value.split('=');
        var this_key = key_value_arr[0];
        var this_val = key_value_arr[1];

        form_string = form_string + this_key + ": \n ";
        form_string = form_string + "   <input type=\"text\" name=\"" + this_key + "\" value=\"" + this_val + "\" />\n";

    }
    form_string = form_string + "   <input type=\"submit\" value=\"submit\" />\n";
    form_string = form_string + "</form>\n";

    alert(form_string);
    return false;
}


function Booking_Mask(startmonth, startday, startyear, endmonth, endday, endyear, adults, children, rooms, nights, ratecode, propertyIndex) {

    alert(" startmonth: " + startmonth + "\n startday: " + startday + "\n startyear: " + startyear + "\n endmonth: " + endmonth + "\n endday: " + endday + "\n endyear: " + endyear + "\n adults: " + adults + "\n children: " + children + "\n rooms: " + rooms + "\n nights: " + nights + "\n ratecode: " + ratecode + "\n propertyIndex: " + propertyIndex);

    //flash team having issues w/ flash datepicker sending null, just use current year if null
    if (startyear == 'null') {
        //alert("startyear  ==> " + startyear);
        var d = new Date();
        startyear = d.getFullYear();
    }


    //do funstuff to build url here;
    //pagetracker(url) etc
    // window.open( url etc)
    jQuery(".startmonth").val(startmonth);
    jQuery(".startday").val(startday);
    jQuery(".startyear").val(startyear);

    jQuery(".endmonth").val(endmonth);
    jQuery(".endday").val(endday);
    jQuery(".endyear").val(endyear);
    //it will push if less than but need flash team to send null of the user didn't fill enddate

    jQuery("#startdate").val(startmonth + '/' + startday + '/' + startyear);
    fillStartDateDropdowns(startmonth + '/' + startday + '/' + startyear);

    //pushdate if enddate empty or less than startdate.
    if (endmonth == 'null' || endmonth < startmonth) {
        //   alert('enddate pushed');
        refreshDatepickers();
        //fill hidden form
    }



    //submit form of html booking mask

    if (jQuery('.Booking_Mask').length > 0) {
        jQuery('.Booking_Mask').submit();
    } else {
        // alert('need to add hidden booking mask form for selected booking engine to page for flash booking to work');
    }

}

//replace "'" or %27 w/ %92 so that some booking engines / resnet dont throw error..
//happens when utmctr / search term has a quote, TODO (may have to break down vars)
function replaceQuote(a) {
    a = a.replace(/\'/,'%92');
    a = a.replace(/%27/gi, '%92');%20%20%20%20return%20a;}//end%20my%20functions%20&%20begin%20plugins%20&%20libraries/**%20jQuery%20selectbox%20plugin**%20Copyright%20(c)%202007%20Sadri%20Sahraoui%20(brainfault.com)%20//mh%20removed%20$%20to%20jQuery%20because%20of%20prototype%20conflict*/jQuery.fn.extend({%20%20%20%20selectbox:%20function(options)%20{%20%20%20%20%20%20%20%20return%20this.each(function()%20{%20%20%20%20%20%20%20%20%20%20%20%20new%20jQuery.SelectBox(this,%20options);%20%20%20%20%20%20%20%20});%20%20%20%20}});/*%20pawel%20maziarz:%20work%20around%20for%20ie%20logging%20*/if%20(!window.console)%20{%20%20%20%20var%20console%20=%20{%20%20%20%20%20%20%20%20log:%20function(msg)%20{%20%20%20%20%20%20%20%20}%20%20%20%20}}/*%20*/jQuery.SelectBox%20=%20function(selectobj,%20options)%20{%20%20%20%20var%20opt%20=%20options%20||%20{};%20%20%20%20opt.inputClass%20=%20opt.inputClass%20||%20"selectbox";%20%20%20%20opt.containerClass%20=%20opt.containerClass%20||%20"selectbox-wrapper";%20%20%20%20opt.hoverClass%20=%20opt.hoverClass%20||%20"current";%20%20%20%20opt.currentClass%20=%20opt.selectedClass%20||%20"selected"%20%20%20%20opt.debug%20=%20opt.debug%20||%20false;%20%20%20%20var%20elm_id%20=%20selectobj.id;%20%20%20%20var%20active%20=%20-1;%20%20%20%20var%20inFocus%20=%20false;%20%20%20%20var%20hasfocus%20=%200;%20%20%20%20//jquery%20object%20for%20select%20element%20%20%20%20var%20$select%20=%20jQuery(selectobj);%20%20%20%20//%20jquery%20container%20object%20%20%20%20var%20$container%20=%20setupContainer(opt);%20%20%20%20//jquery%20input%20object%20%20%20%20%20var%20$input%20=%20setupInput(opt);%20%20%20%20//%20hide%20select%20and%20append%20newly%20created%20elements%20%20%20%20$select.hide().before($input).before($container);%20%20%20%20init();%20%20%20%20$input.click(function()%20{%20%20%20%20if%20(!inFocus)%20{%20%20%20%20%20%20%20%20$container.toggle();%20%20%20%20}}).focus(function()%20{%20%20%20%20if%20($container.not(':visible')) {
	        inFocus = true;
	        $container.show();
	    }
	})
	.keydown(function(event) {
	    switch (event.keyCode) {
	        case 38: // up
	            event.preventDefault();
	            moveSelect(-1);
	            break;
	        case 40: // down
	            event.preventDefault();
	            moveSelect(1);
	            break;
	        //case 9:  // tab                                                           
	        case 13: // return
	            event.preventDefault(); // seems not working in mac !
	            jQuery('li.' + opt.hoverClass).trigger('click');%20%20%20%20%20%20%20%20%20%20%20%20break;%20%20%20%20%20%20%20%20case%2027:%20//escape%20%20%20%20%20%20%20%20%20%20%20%20hideMe();%20%20%20%20%20%20%20%20%20%20%20%20break;%20%20%20%20}}).blur(function()%20{%20%20%20%20if%20($container.is(':visible') && hasfocus > 0) {
	        if (opt.debug) console.log('container visible and has focus')%20%20%20%20}%20else%20{%20%20%20%20%20%20%20%20hideMe();%20%20%20%20}});%20%20%20%20function%20hideMe()%20{%20%20%20%20%20%20%20%20hasfocus%20=%200;%20%20%20%20%20%20%20%20$container.hide();%20%20%20%20}%20%20%20%20function%20init()%20{%20%20%20%20%20%20%20%20$container.append(getSelectOptions($input.attr('id'))).hide();%20%20%20%20%20%20%20%20var%20width%20=%20$input.css('width');%20%20%20%20%20%20%20%20$container.width(width);%20%20%20%20}%20%20%20%20function%20setupContainer(options)%20{%20%20%20%20%20%20%20%20var%20container%20=%20document.createElement("div");%20%20%20%20%20%20%20%20$container%20=%20jQuery(container);%20%20%20%20%20%20%20%20$container.attr('id', elm_id + '_container');
        $container.addClass(options.containerClass);

        return $container;
    }

    function setupInput(options) {
        var input = document.createElement("input");
        var $input = jQuery(input);
        $input.attr("id", elm_id + "_input");
        $input.attr("type", "text");
        $input.addClass(options.inputClass);
        $input.attr("autocomplete", "off");
        $input.attr("readonly", "readonly");
        $input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie

        return $input;
    }

    function moveSelect(step) {
        var lis = jQuery("li", $container);
        if (!lis) return;

        active += step;

        if (active < 0) {
            active = 0;
        } else if (active >= lis.size()) {
            active = lis.size() - 1;
        }

        lis.removeClass(opt.hoverClass);

        jQuery(lis[active]).addClass(opt.hoverClass);
    }

    function setCurrent() {
        var li = jQuery("li." + opt.currentClass, $container).get(0);
        var ar = ('' + li.id).split('_');
        var el = ar[ar.length - 1];
        $select.val(el);
        $input.val(jQuery(li).html());
        return true;
    }

    // select value
    function getCurrentSelected() {
        return $select.val();
    }

    // input value
    function getCurrentValue() {
        return $input.val();
    }

    function getSelectOptions(parentid) {
        var select_options = new Array();
        var ul = document.createElement('ul');
        $select.children('option').each(function() {
            var li = document.createElement('li');
            li.setAttribute('id', parentid + '_'+%20jQuery(this).val());%20%20%20%20%20%20%20%20%20%20%20%20li.innerHTML%20=%20jQuery(this).html();%20%20%20%20%20%20%20%20%20%20%20%20if%20(jQuery(this).is(':selected'))%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20$input.val(jQuery(this).html());%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20jQuery(li).addClass(opt.currentClass);%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20ul.appendChild(li);%20%20%20%20%20%20%20%20%20%20%20%20jQuery(li).mouseover(function(event)%20{%20%20%20%20hasfocus%20=%201;%20%20%20%20if%20(opt.debug)%20console.log('over on : '+%20this.id);%20%20%20%20jQuery(event.target,%20$container).addClass(opt.hoverClass);}).mouseout(function(event)%20{%20%20%20%20hasfocus%20=%20-1;%20%20%20%20if%20(opt.debug)%20console.log('out on : ' + this.id);
			    jQuery(event.target, $container).removeClass(opt.hoverClass);
			})
			.click(function(event) {
			    var fl = jQuery('li.'+%20opt.hoverClass,%20$container).get(0);%20%20%20%20if%20(opt.debug)%20console.log('click on :' + this.id);
			    jQuery('li.' + opt.currentClass).removeClass(opt.currentClass);
			    jQuery(this).addClass(opt.currentClass);
			    setCurrent();
			    hideMe();
			});
        });
        return ul;
    }

};
//end selectbox plugin

///v4 already has jQuery ui  //end jquery ui plugins



