﻿var notify=function(){
	var d=false;
	var e=0;
	var c=-1;
	var g="m";
	var a=function(i){
		if(!d){
			$("#notify-container").append('<table id="notify-table"></table>');
			d=true
		}
		var h="<tr"+(i.messageTypeId?' id="notify-'+i.messageTypeId+'"':"");
		h+=' class="notify" style="display:none"><td class="notify">'+i.text;
		h+='</td><td class="notify-close"><a title="abaikan peringatan ini" onclick="notify.close(';
		h+=(i.messageTypeId?i.messageTypeId:"")+')">&times;</a></td></tr>';
		$("#notify-table").append(h)
	};
	var b=function(h){
		$.cookie(g,(h?h:"0"),{expires:90,path:"/"})
	};
	var f=function(){
		var h=parseInt($.cookie(g));
		if(isNaN(h)){h=0}
		if(h<5){
			$(".module.newuser").show();
			b(++h)
		}
	};
	return{
		showFirstTime:function(){
			if($.cookie(g)){
				f()
			}else{
				$(".module.newuser").show();
				$("body").css("margin-top","2.5em");
				a({messageTypeId:c,text:'Baru tahu kumpulanskripsi.com silahkan <a onclick="notify.closeRegister()">Daftar</a> / Login? Baca dulu <a onclick="notify.closeFirstTime()">FAQ</a>!'});
				$(".notify").fadeIn("slow")
			}
		},
		showMessages:function(h){
			for(var j=0;j<h.length;j++){
				a(h[j])
			}
			$(".notify").fadeIn("slow");
			e=h.length
		},
		show:function(h){$("body").css("margin-top","2.5em");a({text:h});$(".notify").fadeIn("slow")},
		close:function(h){
			var j;
			var i=0;
			if(h&&h!=c){
				j=$("#notify-"+h);
				if(e>1){
					i=parseInt($("body").css("margin-top").match(/\d+/));
					i=i-(i/e)
				}
			}else{
				if(h&&h==c){b()}
				j=$(".notify")
			}
			j.children("td").css("border-bottom","none").end().fadeOut("fast",function(){
																					   $("body").css("margin-top",i+"px");
																						j.remove()
			})
		},
		closeFirstTime:function(){b();document.location="/faq.php"},
		closeRegister:function(){b();document.location="/index.php?do=register"}
	}
}();jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};

