jQuery(function(){
	//create cokie name for every banner 			
	var cokie_num = 'banner_once'+bn_id;
	var closeCokie = jQuery.cookie(cokie_num+'close');
	// check if is exists
	if(jQuery.cookie(cokie_num) == null && closeCokie == null){			
			//create cokie
			jQuery.cookie(cokie_num, "hid_banner", { expires: 1 });
			//apend to the body
			
			//animation 
			jQuery('.wp-baner-top').fadeIn('slow');
			isIe("open");
			
			setInterval(function() {
			     jQuery('.wp-baner-top').fadeOut('slow');
				 isIe("close");
			}, bn_timeout);
			jQuery('.wp-baner-top div.wp-baner-close a').click(function(){
				jQuery('.wp-baner-top').fadeOut('slow');
				isIe("close");
				jQuery.cookie(cokie_num+'close', "hid_banner_close"+bn_id, { expires: 1 });
			})	
			if(bn_link != ""){
				jQuery('.wp-baner-text').css({"cursor":"pointer"});
				jQuery('.wp-baner-text a').attr('href', '#');	
				jQuery('.wp-baner-text').click(function(){
					window.location = 	bn_link;								   
			    })
			}else{
				jQuery('.wp-baner-text').css({"cursor":"normal"});
				
			}			
		  }
		
		// delete cokie		
		if(bn_once !== 'showOnce'){
			jQuery.cookie(cokie_num, 'hid_banner', { expires: -1 });
		}
		
})


function isIe(flow){
	var bnHeight = jQuery('.wp-baner-top').height();
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)>6) {
		if(flow == "open"){
			jQuery('.headerWrap').css({'margin-top':bnHeight+'px'});
		}else if(flow == "close"){
			jQuery('.headerWrap').css({'margin-top':'0px'});
		}
	}
}
