
/*
Custom funtion to general accordion menus
*/

Drupal.behaviors.buildAccordionMenus = function (context) 
{
    $("div.accordion").accordion({ header: 'div.accordion-title', clearStyle: true, autoHeight: false, active: (window.accordion_active_index ? accordion_active_index : 0) });
	
	$("div.accordion .accordion-item:not(.hilite)").mouseenter(function(event){ $(this).addClass('hilite'); })
				.mouseleave(function(event){ $(this).removeClass('hilite'); });
};


 Drupal.behaviors.setBanner = function (context) {
	
	//var img = {'/content/services': 'Banner2.jpg'}[location.pathname] || 'Banner1.jpg';

	//$("td#header").css("background","url(/sites/all/themes/mytheme/images/" + img + ") no-repeat");
	//alert($.param(Drupal.settings));	
	//$("div.banner").removeClass().addClass("banner").addClass();
	//alert($.param(Drupal.settings));
	if(Drupal.settings.taxonomy && Drupal.settings.taxonomy[0].length > 0) {
		//alert('banner_' + Drupal.settings.taxonomy[0]);
		$(".banner").removeClass().addClass("banner taxonomy" +  Drupal.settings.taxonomy[0]);
	} else {
		//alert('No taxonomy');
	}
	
	$('.accordion-title a').click( function(ev){
       document.location = $(this).attr('href');
	});

 };


/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 */
function setCookie(name, value)
{
    document.cookie = name + "=" + escape(value) + "; expires=Thu, 4 Aug 2011 20:47:11 UTC;";
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}