﻿//on document ready
$(document).ready(function() {
    $("#btnSelectLabel").click( function() {
        $("#labelsMenu").slideToggle(400);
    });
    // select one or more elements to be scrollable-enabled 
    //$("div.scrollable").scrollable();
	//bottomBar();
});

function bottomBar(){
var cookieName = "bottomBarClosed";
//check for cookie
var userClosed = readCookie(cookieName);
//if cookie exists
if (userClosed == "true") {
	return null;
}
else
{
	var aboveBar = $("<div></div>").css({
			height: 60,
			position: 'fixed',
			bottom: 4,
			left: 0,
			right: 0,
			'z-index': 100000,
			opacity: 1
		//padding: '5px 75px 0px 0px'
		});
	var content = $('<div><div style="display:block;width:150px;color:white;float:left;">The Island Def Jam Music Group supports Haitian Earthquake Relief.</div><a href="http://www.redcross.org/go/donatenow/?s_src=RSG00100E002&s_subsrc=Island Def Jam Music Group"  target="_blank"><img border="0" style="float:right" src="http://www.redcross.org/www-files/psabanners/Haiti/468x60_2.jpg" alt="International Response Fund"></a></div>')
		.css({'display':'block', 'margin-left':'auto', 'margin-right':'auto', width: 628});
	aboveBar.append(content);

	var bar = $("<div></div>").css({
		height: 70,
		position: 'fixed',
		bottom: -1,
		left: 0,
		right: 0,
		'z-index': 99999,
		'background-color': '#222',
		opacity: .8
	//padding: '5px 75px 0px 0px'
	});
	var closeButton = $("<div>close</div>").css({
		padding: 10,
		position: 'fixed',
		cursor: 'pointer',
		bottom: 40,
		left: 0,
		'z-index':1000010
		}).click(function(){
				aboveBar.animate({bottom: -75},1000);
				closeButton.hide();
				bar.animate({
					bottom: -80
				}, 1000, function(){
						bar.remove();
						createCookie(cookieName, "true", 1);
					});
				});
	
	//set cookie
	//
	$("body").append(bar);
	$("body").append(aboveBar);
	$("body").append(closeButton);
}

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
