/*
|------------------------------------------|
| MelonHTML5 - Royal Preloader |
|------------------------------------------|
| @author: Lee Le (lee@melonhtml5.com) |
| @version: 2.06 (11 April 2015) |
| @website: www.melonhtml5.com |
|------------------------------------------|
*/
/**
(https://developer.mozilla.org/en-US/docs/DOM/document.cookie)
docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
docCookies.getItem(name)
docCookies.removeItem(name[, path])
docCookies.hasItem(name)
*/
var docCookies={getItem:function(a){return!a||!this.hasItem(a)?null:unescape(document.cookie.replace(RegExp("(?:^|.*;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1"))},setItem:function(a,c,b,e,f,g){if(a&&!/^(?:expires|max\-age|path|domain|secure)$/i.test(a)){var d="";if(b)switch(b.constructor){case Number:d=Infinity===b?"; expires=Tue, 19 Jan 2038 03:14:07 GMT":"; max-age="+b;break;case String:d="; expires="+b;break;case Date:d="; expires="+b.toGMTString()}document.cookie=
escape(a)+"="+escape(c)+d+(f?"; domain="+f:"")+(e?"; path="+e:"")+(g?"; secure":"")}},removeItem:function(a,c){a&&this.hasItem(a)&&(document.cookie=escape(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(c?"; path="+c:""))},hasItem:function(a){return RegExp("(?:^|;\\s*)"+escape(a).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)}};
var JQ=jQuery;window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();
window.transitionEnd=function(a,c){var b=!1,d=document.createElement("div");JQ(["transition","WebkitTransition","MozTransition","msTransition"]).each(function(a,c){if(void 0!==d.style[c])return b=!0,!1});b?a.bind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend",function(b){a.unbind("webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionend");c(b,a)}):setTimeout(function(){c(null,a)},0);return a};
var Royal_Preloader={_overlay:null,_loader:null,_name:null,_percentage:null,_on_complete:null,_text_loader:null,_text_loader_overlay:null,_logo_loader:null,_logo_loader_meter:null,_total:0,_loaded:0,_image_queue:[],_percentage_loaded:0,_mode:"number",_text:"loading...",_text_colour:"#FFFFFF",_images:[],_show_progress:!0,_show_percentage:!0,_background:"#000000",_logo:"",_logo_size:[80,80],_cookie:!1,_timeout:10,_init:function(){JQ("img").each(function(a){JQ(this).attr("src")&&Royal_Preloader._images.push(JQ(this).attr("src"))});
if(Royal_Preloader._cookie){if(docCookies.getItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie)){JQ("#royal_preloader").remove();JQ(document.body).removeClass("royal_preloader");return}docCookies.setItem("melonhtml5_royal_preloader_"+Royal_Preloader._cookie,(new Date).getTime(),Infinity)}Royal_Preloader._total=Royal_Preloader._images.length;Royal_Preloader._build();Royal_Preloader._load()},_build:function(){this._overlay=JQ("#royal_preloader");this._overlay.length||(this._overlay=JQ("
").attr("id",
"royal_preloader").prependTo(JQ(document.body)));this._overlay.addClass("royal_preloader_"+this._mode);"line"!==this._mode&&this._overlay.css("background-color",this._background);switch(this._mode){case "number":var a=this._hexToRgb(this._text_colour);this._percentage=JQ("
").html("
").css({color:this._text_colour,"border-color":a?"rgba("+a.r+", "+a.g+", "+a.b+", 0.7)":this._text_colour}).addClass("royal_preloader_percentage").appendTo(this._overlay);this._percentage.children("div").css("border-left-color",
this._text_colour);break;case "text":this._text_loader=JQ("
").addClass("royal_preloader_loader").text(this._text).css("color",this._text_colour).appendTo(this._overlay);this._text_loader_overlay=JQ("
").css("background-color",this._background).appendTo(this._text_loader);break;case "scale_text":for(var a="",c=0;c
"+this._htmlentities(this._text.charAt(c))+"";this._text_loader=JQ("").addClass("royal_preloader_loader").html(a).css("color",this._text_colour).appendTo(this._overlay);
break;case "logo":this._logo_loader=JQ("
").css({width:this._logo_size[0],height:this._logo_size[1],"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2*-1,"background-image":'url("'+this._logo+'")'}).addClass("royal_preloader_loader").appendTo(this._overlay);this._logo_loader_meter=JQ("
").css("background-color",this._background).appendTo(this._logo_loader);this._show_progress&&(this._percentage=JQ("
").css({color:this._text_colour,width:this._logo_size[0],height:this._logo_size[1],
"margin-left":this._logo_size[0]/2*-1,"margin-top":this._logo_size[1]/2,"background-color":this._background}).addClass("royal_preloader_percentage").appendTo(this._overlay));break;case "line":this._line_loader=JQ("
").addClass("royal_preloader_loader").css("background-color",this._background).appendTo(this._overlay);JQ("
").addClass("royal_preloader_peg").css("box-shadow","0 0 10px "+this._background).appendTo(this._line_loader);JQ(document.body).css("visibility","visible");break;case "progress":this._progress_loader=
JQ("
").addClass("royal_preloader_loader").appendTo(this._overlay),this._progress_loader_meter=JQ("
").addClass("royal_preloader_meter").appendTo(this._progress_loader),this._show_progress&&(this._percentage=JQ("
").addClass("royal_preloader_percentage").text(0).appendTo(this._overlay))}this._overlay.appendTo(JQ(document.body));"text"!==this._mode&&"scale_text"!==this._mode||this._text_loader.css("margin-left",this._text_loader.width()/2*-1)},_load:function(){if(("number"===this._mode||
"logo"===this._mode||"progress"===this._mode)&&this._show_progress){this._percentage.data("num",0);var a="0"+(Royal_Preloader._show_percentage?"%":"");"number"===this._mode?this._percentage.children("span").text(a):this._percentage.text(a)}JQ.each(this._images,function(a,b){var d=function(){Royal_Preloader._imageOnLoad(b)},e=new Image;e.src=b;e.complete?d():(e.onload=d,e.onerror=d)});setTimeout(function(){Royal_Preloader._overlay&&Royal_Preloader._animatePercentage(Royal_Preloader._percentage_loaded,
100)},this._images.length?1E3*this._timeout:0)},_hexToRgb:function(a){return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null},_htmlentities:function(a){return a.toString().replace(/&/g,"&").replace(/\"/g,""").replace(//g,">").replace(/ /g," ")},_animatePercentage:function(a,c){Royal_Preloader._percentage_loaded=a;a