// JavaScript Document
(function($) {
	$(document).ready(function() {
		Cufon.replace('h1');
		
		var path = location.pathname.substring(1);
		if ( path )
			$('.sub-nav a[href$="' + path + '"]').attr('class', 'active');

		var aNewsletter = $('#contact');	//Show/Hide link
        var divSubscribe = $('.contact-wrap'); //Subscription container
        if(divSubscribe.length != 0) {  //DOM Exists
            //Did the user show the div.
            var stateCookie = $.cookie('expanded_contact');
            if(stateCookie == null) {   //No he didn't
                divSubscribe.hide();
                //aNewsletter.parent().toggleClass('show');
            } else {
                divSubscribe.show();
                aNewsletter.parent().toggleClass('show');			
			}
            aNewsletter.click(function(e) {
                divSubscribe.slideToggle('slow', function() {
                    //divNewsletter = aNewsletter.parent(); //Div with the background image                    					
					aNewsletter.toggleClass('show');
                    //Set the cooke as desired
                    var divSubscribeClass = divSubscribe.css('display');
                    if(divSubscribeClass == 'none') {   //User does not bother about our newsletters :-)
                        //Set the cookie to show the div
                        $.cookie('expanded_contact', null, {path: '/'});
                    } else {    //Hide on all pages
                        $.cookie('expanded_contact', true, {path: '/'});
                    }
                });
                return false;
            });
        }
	});
})(jQuery);
