;(function($){
	$.fn.hasAttr = function(attr) {
		if (typeof attr !== typeof undefined && attr !== false) {
		    return true;
		}
		return false;
	};
	$.fn.live=function(evt,func){
		$(document).on(evt, $(this).selector,func);
	};
})(jQuery);
Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
};
;(function(){
	var madness=function(){};
	var state=0;
	madness.__proto__ = madness.prototype = {
		
	};
	var is_obj=function(obj){
		if((typeof obj)=='object'){return true;}
		if((typeof obj)=='Object'){return true;}
		return false;
	};
	window.is_obj=is_obj;
	var is_array=function(obj){
		if((typeof obj)=='array'){return true;}
		if((typeof obj)=='Array'){return true;}
		return false;
	};
	window.is_array=is_array;
	var is_str=function(obj){
		if((typeof obj)=='string'){return true;}
		if((typeof obj)=='String'){return true;}
		return false;
	};
	window.is_str=is_str;
	var is_und=function(obj){
		if((typeof obj)=='undefined'){return true;}
		if((typeof obj)=='Undefined'){return true;}
		return false;
	};
	window.is_und=is_und;
	var is_func = function(functionToCheck) {
	 var getType = {};
	 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
	};
	window.is_func=is_func;
	madness.prototype.extend=function(name,obj,toobj){
		if(is_und(toobj)){
			if(is_str(name)){
				if(is_func(obj) && is_obj(toobj)){
					madness.__proto__[name] = madness.prototype[name] = obj;
					madness[name].__proto__ = madness[name].prototype = toobj;
				}else{
					madness.__proto__[name] = madness.prototype[name] = obj;
				}
			}else{
				if(is_obj(name)){
					for(var n in name){
						if(!madness.__proto__.hasOwnProperty(n)){
							var obj_n=name[n];
							madness.__proto__[name] = madness.prototype[name] = obj_n;
						}
					}
				}
			}
		}else{
			if(is_str(name)){
				toobj.__proto__[name] = toobj.prototype[name] = obj;
			}else{
				if(is_obj(name)){
					for(var n in name){
						if(!toobj.__proto__.hasOwnProperty(n)){
							var obj_n=name[n];
							toobj.__proto__[name] = toobj.prototype[name] = obj_n;
						}
					}
				}
			}
		}
	};
	window.madness=madness;
})(window);
madness.extend('load_background',function (url){
	url=jQuery('div.main_background').attr('bgimg');
	jQuery('<img/>').attr('src', url).on('load', function() {
		jQuery(this).remove();
		jQuery('div.main_background').css('background-image', 'url('+url+')');
		madness.load_params.load_3.background_loaded=true;
	});
});
/*
 * https://development.adomasalcore3.tk/wp-content/themes/portfolio_madness2.0/assets/css/bootstrap.min.css?ver=1.2.7.8
 * https://development.adomasalcore3.tk/wp-content/themes/portfolio_madness2.0/assets/js/bootstrap.min.js?ver=1.2.7.8
 * */
madness.extend('load_styles',function (){
	if(is_obj(madness.prototype.styles) || is_array(madness.prototype.styles)){
		for(var id in madness.styles){
			jQuery.ajax({
				url:madness.styles[id].url,
				nameof:id,
				success:function(e){
					jQuery("head").after('<style nameof="'+this.nameof+'">'+e+'</style>');
					madness.load_params.load_3.styles_loaded[this.nameof]=true;
					if(is_func(window[madness.styles[this.nameof].callback])){window[madness.styles[this.nameof].callback]();}
				}
			});
		}
	}
});
madness.extend('checkFont',function(name,obj,ati){
	if(is_obj(ati) || is_str(ati)){
		if(is_obj(ati) && (ati!=$(ati))){
			ati=$(ati);
		}
		else{
			if(is_str(ati)){
				ati=$(ati);
			}
		}
		if(ati[0].localName==="div"){
			var prewidth=ati.find('i').width();
			var max_count=60;
			var count=0;
			madness.__proto__.checkFont.__proto__={
				'prewidth':0,
				'max_count':60,
				'count':0,
				'obj':obj,
				'intv':0,
				'ati':ati
			};
			madness.checkFont.prewidth=madness.checkFont.ati.find('i').width();
			madness.checkFont.intv=setInterval(function(){
				if((madness.checkFont.count<madness.checkFont.max_count)){
					if((madness.checkFont.prevwidth<madness.checkFont.ati.find('i').width()) || (0<madness.checkFont.ati.find('i').width())){
						if(!is_und(madness.checkFont.obj) && !is_und(madness.checkFont.obj.success)){
							madness.checkFont.obj.success();
						}
						clearInterval(madness.checkFont.intv);
					}else{
						madness.checkFont.count++;
					}
				}else{
					clearInterval(madness.checkFont.intv);
					if(!is_und(madness.checkFont.obj) && !is_und(madness.checkFont.obj.failure)){
						madness.checkFont.obj.failure();
					}
				}
			},250);
		}
	}
	else{
		throw new Error('Function Usage: madness.checkFont(name,object,element to check)');
	}
});
madness.extend('load_fonts',function(){
	if(is_obj(madness.prototype.fonts) || is_array(madness.prototype.fonts)){
		for(var id in madness.fonts){
					var nameof=id;
			madness.checkFont(nameof, {
				success: function() {
					madness.load_params.load_3.fonts_loaded[nameof]=true;
					if(is_func(window[madness.fonts[nameof].callback])){window[madness.fonts[nameof].callback]();}
				},
				failure: function() {
					//alert("My Icons failed to load");
					console.log('font: ['+nameof+'] Failed to load!');
				}
			},'.site_loader .loading_font');
			jQuery.ajax({
				url:madness.fonts[id].url,
				nameof:id,
				success:function(e){
					var nameof=this.nameof;
					jQuery("head").after('<style nameof="'+nameof+'">'+e+'</style>');
				}
			});
		}
	}
});
madness.extend('load_scripts',function (){
	if(is_obj(madness.prototype.scripts) || is_array(madness.prototype.scripts)){
		for(var id in madness.scripts){
			jQuery.ajax({
				url:madness.scripts[id].url,
				nameof:id,
				success:function(e){
					jQuery("head").after('<script nameof="'+this.nameof+'">'+e+'</script>');
					madness.load_params.load_3.scripts_loaded[this.nameof]=true;
					if(is_func(window[madness.scripts[this.nameof].callback])){window[madness.scripts[this.nameof].callback]();}
				}
			});
		}
	}
	
});
madness.extend('menu_scripts',function(){jQuery(document).ready(function($){
		$(document).on('click','.side_menu .icon',function(){
			var t=$(this);
			if(!t.parent().hasClass('active')){
				t.parent().parent().children().each(function(){
					var temp=$(this);
					if(temp.hasClass('active')){
						temp.removeClass('active');
					}
				});
				t.parent().parent().addClass('iactive');
				t.parent().addClass('active');
			}
			else{
				t.parent().removeClass('active');
				t.parent().parent().removeClass('iactive');
			}
		});
		$(document).on('click','.side_menu ul li a',function(){
			var t=$(this);
			$('.side_menu .mini_overlay').trigger('click');
		});
		$(document).on('click','.side_menu .mini_overlay',function(){
			var t=$(this);
			t.parent().removeClass('iactive').children().each(function(){
				var temp=$(this);
				if(temp.hasClass('active')){
					temp.removeClass('active');
				}
			});
		});
	});
});
madness.extend('add_script',function(name,url,callback){
	if(!is_obj(madness.prototype.scripts) && !is_array(madness.prototype.scripts)){
		madness.__proto__.scripts = madness.prototype.scripts = {};
	}
	if(is_str(name) && is_str(url)){
		madness.scripts[name]={'url':url,'callback':callback};
	}
	else{
		madness.scripts[name]={'url':name,'callback':url};
	}
});
madness.extend('add_style',function(name,url,callback){
	if(!is_obj(madness.prototype.styles) && !is_array(madness.prototype.styles)){
		madness.__proto__.styles = madness.prototype.styles = {};
	}
	if(is_str(name) && is_str(url)){
		madness.styles[name]={'url':url,'callback':callback};
	}
	else{
		madness.style[name]={'url':name,'callback':url};
	}
});
madness.extend('add_font',function(name,url,callback){
	if(!is_obj(madness.prototype.fonts) && !is_array(madness.prototype.fonts)){
		madness.__proto__.fonts = madness.prototype.fonts = {};
	}
	if(is_str(name) && is_str(url)){
		madness.fonts[name]={'url':url,'callback':callback};
	}
	else{
		madness.fonts[name]={'url':name,'callback':url};
	}
});
window["style_0-main_styles_1"] =
window["style_1-main_styles_2"] =
window["style_2-main_styles_3"] =
window["style_3-main_styles_4"] =
window["style_5-bootstrap"] =
window["style_6-slick_slider"] = function(){
	var width=Math.floor((Object.size(madness.load_params.load_3.styles_loaded)/Object.size(madness.styles))*100);
	if(width.toString().length<2){
		width='00'+width.toString();
	}
	if(width.toString().length<3){
		width='0'+width.toString();
	}
	$('.css_loader').addClass('p'+width);
};
window["script_bootstrap"] =
window["script_slick_slider"] =function(){
	
	var width=Math.floor((Object.size(madness.load_params.load_3.scripts_loaded)/Object.size(madness.scripts))*100);
	if(width.toString().length<2){
		width='00'+width.toString();
	}
	if(width.toString().length<3){
		width='0'+width.toString();
	}
	$('.js_loader').addClass('p'+width);
};
function style_ac3(){
	$('.font_loader').addClass('p100');
}
madness.extend('pre_language',function(){
	$(document).on('click','.site_loader_languages_menu a',function(e){
		e.preventDefault();
		var dload_1=$('.site_loader .load_1');
		dload_1.find('.content').slideUp();
		dload_1.find('.standby').slideDown();
		var t=$(this);
		var tall=$(this).parent().parent();
		var turl=tall.attr('ajax_call');
		var data={
			'nonce':tall.attr('ajax_nonce'),
			'type':'pre',
			'value':{'language':t.attr('href'),'type':'lang'},
			'curl':window.location.href,
			'action':'load_madness'
		};
		$.ajax({
			url:turl,
			data:data,
			success:function(re){
				var r=JSON.parse(re);
				$('#the_litle_one').html(r.m);
				$('.site_loader').html(r.pre);
				$('.site_loader').html(r.pre);
				window.history.pushState({"html":e.h,"pageTitle":r.t},"", r.curl);
				window.location.reload();
				return false;
				$('title').html(r.t);
				madness.load_params.load_1.complete=true;
				if($('.site_loader .load_2').attr('ok')=="0"){
					$('.site_loader .load_1').attr('ok','1');
					$('.site_loader .load_1').slideUp();
					$('.site_loader .load_2').slideDown();
				}else{
					$('.site_loader .load_1').attr('ok','1');
					$('.site_loader .load_1').slideUp();
					$('.site_loader .load_3').slideDown();
				}
			}
		});
	});
});
madness.extend('load_step2',function(){
	$(document).on('click','.site_loader a[data-continue="step_3"]',function(e){
		e.preventDefault();
		var dload_2=$('.site_loader .load_2');
		dload_2.find('.content').slideUp();
		dload_2.find('.standby').slideDown();
		var t=$(this);
		var tall=$(this).parent();
		var turl=tall.attr('ajax_call');
		var data={
			'nonce':tall.attr('ajax_nonce'),
			'type':'pre',
			'value':{'cookie':true,'type':'cookie'},
			'curl':window.location.href,
			'action':'load_madness'
		};
		$.ajax({
			url:turl,
			data:data,
			success:function(re){
				var r=JSON.parse(re);
				$('#the_litle_one').html(r.m);
				$('.site_loader').html(r.pre);
				$('.site_loader').html(r.pre);
				madness.load_params.load_2.complete=true;
				$('.site_loader .load_2').attr('ok','1');
				$('.site_loader .load_2').slideUp();
				$('.site_loader .load_3').slideDown();
			}
		});
	});
});
madness.extend('preload_menu',function(){
	if(is_und(madness.load_params.load_1.menu_scripts)){
		madness.load_params.load_1.menu_scripts=false;
		
	}else{
		if(is_und(madness.load_params.load_1.language)){
			madness.pre_language();
			madness.load_params.load_1.language=true;
		}
		if(madness.load_params.load_1.menu_scripts==false){
			madness.menu_scripts();
			madness.load_params.load_1.menu_scripts=true;
		}
	}
});
madness.extend('load',function(){
	jQuery(document).ready(function($){
		madness.__proto__.load_interval = madness.prototype.load_interval = setInterval(function(){
			if(!is_obj(madness.prototype.load_params) && !is_array(madness.prototype.load_params)){
				madness.__proto__.load_params = madness.prototype.load_params = {};
				$('.site_loader>div').each(function(){
					var t=$(this);
					madness.load_params[t.attr('class')]={
						'complete':(t.attr('ok')==='1'),
					};
				});
			}
			if(madness.load_params.load_1.complete==false){ 
				madness.preload_menu();
			}else{ if(madness.load_params.load_2.complete==false){
				if(is_und(madness.load_params.load_2.cookie)){
						madness.load_step2(); 
						madness.preload_menu();
						madness.load_params.load_2.cookie=true;
					}
			}else{ if(madness.load_params.load_3.complete==false){
					 	madness.preload_menu();
						if(is_und(madness.load_params.load_3.styles)){
							madness.load_params.load_3.styles=false;
							madness.load_params.load_3.styles_loaded={};
						}
						if(madness.load_params.load_3.styles==false){
							madness.load_styles();
							madness.load_params.load_3.styles=true;
						}
						if(is_und(madness.load_params.load_3.scripts)){
							madness.load_params.load_3.scripts=false;
							madness.load_params.load_3.scripts_loaded={};
						}
						if(madness.load_params.load_3.scripts==false){
							madness.load_scripts();
							madness.load_params.load_3.scripts=true;
						}
						if(is_und(madness.load_params.load_3.background)){
							madness.load_params.load_3.background=false;
						}
						if(madness.load_params.load_3.background==false){
							madness.load_background();
							madness.load_params.load_3.background=true;
						}
						if(is_und(madness.load_params.load_3.fonts)){
							madness.load_fonts();
							madness.load_params.load_3.fonts=true;
							madness.load_params.load_3.fonts_loaded={};
						}
						
						if(!is_und(madness.load_params.load_3.background_loaded) 
						&& (Object.size(madness.load_params.load_3.fonts_loaded)==Object.size(madness.fonts)) 
						&& (Object.size(madness.load_params.load_3.styles_loaded)==Object.size(madness.styles)) 
						&& (Object.size(madness.load_params.load_3.scripts_loaded)==Object.size(madness.scripts))
						&& (is_und(madness.load_params.donotcomplete) || (madness.load_params.donotcomplete==false))){
							madness.complete_load();
						}
					}
				}
			}
		},500);
	});
});
madness.extend('dont_complete',function(){
	madness.load_params.donotcomplete=true;
});
madness.extend('complete_proceed',function(){
	madness.load_params.donotcomplete=false;
});
madness.extend('complete_load',function(){
	madness.load_params.load_3.complete=true;
	clearInterval(madness.load_interval);
	$('body').addClass('loaded');
	madness.complete_load.__proto__ = madness.complete_load.prototype = {
		'max_count':15,
		'instance':0,
		'count':0,
		'interval':50
	};
	madness.complete_load.instance=setInterval(function(){
		if(madness.complete_load.max_count<=madness.complete_load.count){
			clearInterval(madness.complete_load.instance);
			$('.site_loader').slideUp();
			
		}else{
			madness.complete_load.count++;
		}
	},madness.complete_load.interval);
});
madness.load();
