// Close Announcement box with cookie. //Author : Aakash Chakravarthy (www.aakashweb.com) //Email : aakash.19493@gmail.com var expDate = new Date(); expDate.setDate(expDate.getDate()+365); jQuery(document).ready(function(){ if(jQuery('#announcer_box').length > 0){ // Check for cookie if(announcer_cookie() == 'hidden'){ jQuery('#announcer_box').hide(); }else{ document.cookie = "announcer-state=visible; expires=" + expDate.toGMTString()+"; path=/"; var effect = jQuery('#announcer_box').attr('data-effect'); var effdur = parseInt(jQuery('#announcer_box').attr('data-effdur')); var height = jQuery('#announcer_box').outerHeight(); var pos = jQuery('#announcer_box').attr('data-pos'); if( effect == 'slide' ){ switch( pos ){ case 'top-fixed': case 'bottom-fixed': jQuery('#announcer_box').hide().slideDown( effdur ); break; case 'top-float': jQuery('#announcer_box').css('top', -height).animate({top: 0}, effdur ); break; case 'bottom-float': jQuery('#announcer_box').css('bottom', -height).animate({bottom: 0}, effdur ); break; case 'manual': jQuery('#announcer_box').show(); break; } }else if( effect == 'fade' ){ jQuery('#announcer_box').hide().fadeIn( effdur ); } } // Close button on click jQuery('.announcer_closebt').click(function(){ document.cookie = "announcer-state=hidden; expires=" + expDate.toGMTString()+"; path=/"; jQuery(this).parent().slideUp(function(){ jQuery('body').css('margin', 0); }); }); announcer_adjheight('top'); announcer_adjheight('bottom'); } }); function announcer_cookie(){ var nameEQ = 'announcer-state='; 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); } } } function announcer_adjheight(pos){ if(jQuery('.announcer_' + pos + '-float').length > 0 && jQuery('.announcer_' + pos + '-float').is(':visible')){ jQuery('body').css('margin-' + pos, jQuery('.announcer_' + pos + '-float').outerHeight()); } }