
/* START FILE /data/www/world/facilities/files/javascript/jquery.newsticker.js*/

/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 2.0
 * Demo: http://www.texotela.co.uk/code/jquery/newsticker/
 *
 * $LastChangedDate$
 * $Rev$
 *
 */
 
(function($) {
/*
 * A basic news ticker.
 *
 * @name     newsticker (or newsTicker)
 * @param    delay      Delay (in milliseconds) between iterations. Default 4 seconds (6000ms)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $("#news").newsticker(); // or $("#news").newsTicker(5000);
 *
 */
$.fn.newsTicker = $.fn.newsticker = function(delay)
{
	delay = delay || 6000;
	initTicker = function(el)
	{
		stopTicker(el);
		el.items = $("li", el);
		// hide all items (except first one)
		el.items.not(":eq(0)").hide().end();
		// current item
		el.currentitem = 0;
        if (el.items.length > 1) {
		    startTicker(el);
        }
	};
	startTicker = function(el)
	{
		el.tickfn = setInterval(function() { doTick(el) }, delay)
	};
	stopTicker = function(el)
	{
		clearInterval(el.tickfn);
	};
	pauseTicker = function(el)
	{
		el.pause = true;
	};
	resumeTicker = function(el)
	{
		el.pause = false;
	};
	doTick = function(el)
	{
		// don't run if paused
		if(el.pause) return;
		// pause until animation has finished
		el.pause = true;
		// hide current item
		$(el.items[el.currentitem]).fadeOut("slow",
			function()
			{
				$(this).hide();
				// move to next item and show
				el.currentitem = ++el.currentitem % (el.items.size());
				$(el.items[el.currentitem]).fadeIn("slow",
					function()
					{
						el.pause = false;
					}
				);
			}
		);
	};
	this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			initTicker(this);
		}
	)
	.addClass("newsticker")
	.hover(
		function()
		{
			// pause if hovered over
			pauseTicker(this);
		},
		function()
		{
			// resume when not hovered over
			resumeTicker(this);
		}
	);
	return this;
};

})(jQuery);



/* END FILE /data/www/world/facilities/files/javascript/jquery.newsticker.js*/

/* START FILE /data/www/world/facilities/files/javascript/drupal-formsapi.js*/

/**
 * For a given form element label, make it look
 * required (as if #required=>TRUE was defined in the form
 *
 * Developed for unfolding forms using the Drupal FormsAPI
 */
jQuery.fn.drupal_form_require = function(params){
    return this.each(function(){
        if(jQuery('span.form-required', jQuery(this)).length == 0){
            jQuery('<span></span>').
                attr('title', 'This field is required.').
                addClass('form-required').
                text('*').
                appendTo(jQuery(this));
        }
    });
};

/**
 * For a given form element label, should it 'look' required
 * make it look like it isn't required.
 * 
 * Developed for unfolding forms using the Drupal FormsAPI
 */
jQuery.fn.drupal_form_unrequire = function(params){
    return this.each(function(){
        jQuery('span.form-required', jQuery(this)).remove();        
    });
}

/**
 * For a given element, show or hide it based o2s and o2h
 * 
 * @param selector o2s On click, show the selector element
 * @param selector|array o2h On click, hide the selector element(s). If null, o2s toggles the selector element
 * @param array options Options for the function itself
 * 
 * Developed for unfolding forms using the Drupal FormsAPI
 */
jQuery.fn.drupal_form_showhide = function(o2s, o2h, opts){
    return this.each(function(){
        var element = this;

        /* Sensible defaults */
        var defaults = {
            hideAnimation: true,
            hideAnimationSpeed: 'slow',
            showAnimation: true,
            showAnimationSpeed: 'slow',
            clearHidden: true
        }

        /* Complete options */
        var options = jQuery.extend(defaults, opts);

        /* The show function: Animate?, require */
        var show_func = function(e){
            if (options['showAnimation']) {
                jQuery(element).slideDown(options['showAnimationSpeed']);
            } else {
                jQuery(element).show();
            }

            jQuery('label[class!="option"]', element).drupal_form_require();
        }

        /* The hide function: Animate?, unrequire, clear? */
        var hide_func = function(e){
            if (options['hideAnimation']) {
                jQuery(element).slideUp(options['hideAnimationSpeed']);
            } else {
                jQuery(element).hide();
            }
            jQuery('label', element).drupal_form_unrequire();
            
            if (options['clearHidden']) {
                jQuery('input[type="text"], textarea', element).val('');
                jQuery('input[type="radio"][type="checkbox"]', element).
                    attr('checked', false);
            }
        }

        /* Support both a single selector or an array of selectors */
        var o2s_array = null;
        var o2s_checked = null;
        if (o2s != null && o2s.constructor == String){
            o2s_array = o2s.split(/,\s*/);
        } else if(o2s != null && o2s.constructor == Array){
            o2s_array = o2s;
            o2s = o2s.join(', ');
        }

        /* Just in case IE ever supports `onclick` for `options` */
        var eType = jQuery(o2s).get(0).tagName;
        var joinStr = ':checked';
        if (eType.match(/option/i)) { joinStr = ':selected';  }

        if(o2s_array != null){
            o2s_checked = o2s_array.join(joinStr + ', ') + joinStr; 
        }

        /* Support both a single selector or an array of selectors */
        var o2h_array = null;
        var o2h_checked = null;
        if (o2h != null && o2h.constructor == String){
            o2h_array = o2h.split(/,\s*/);
        } else if(o2h != null && o2h.constructor == Array){
            o2h_array = o2h;
            o2h = o2h.join(', ');
        }

        if(o2h_array != null){
            o2h_checked = o2h_array.join(joinStr + ', ') + joinStr; 
        }
        
        // Pre-hide the elements
        if ((o2h == null && jQuery(o2s_checked).length == 0) ||
           (o2h != null && (jQuery(o2h_checked).length > 0) || jQuery(o2s_checked).length == 0)) { 
            
            jQuery(element).css('display', 'none'); 
        }

        // Pre-require the elements
        if (jQuery(o2s_checked).length > 0) {
            jQuery('label[class!="option"]', element).drupal_form_require();
        }


        // Show/Toggle when the 'Show' element is clicked
        jQuery(o2s).click(function(e){
            if(o2h != null || (o2h == null && jQuery(o2s).is(joinStr))){
                show_func(e);
            } else { hide_func(e); }
        });

        // Hide when the 'Hide' element is clicked
        if(o2h != null){ jQuery(o2h).click(hide_func); }
    });
}


/* END FILE /data/www/world/facilities/files/javascript/drupal-formsapi.js*/

/* START FILE /data/www/world/facilities/.drupal-6.x/sites/all/themes/facilities/transsvcs/javascript/custom.js*/

$(document).ready(function() {
    $('#unified_alerts').newsTicker();

    $('#familymembers').drupal_form_showhide('#edit-neededfor-Family-member-health-condition', ['#edit-neededfor-Parental-Leave', '#edit-neededfor-Personal-Health-Condition']);
    $('#edit-otherfamilymember-wrapper').drupal_form_showhide('#edit-familymember-Other', ['#edit-familymember-Child', '#edit-familymember-Parent', '#edit-familymember-Spouse']);

    $('div#familymembers label[class != "option"]').drupal_form_require();
    $('label[for = "edit-otherfamilymember"]').drupal_form_require();

});




/* END FILE /data/www/world/facilities/.drupal-6.x/sites/all/themes/facilities/transsvcs/javascript/custom.js*/
