"use strict";
var lepopuptab_vars={};
var lepopuptab_vertical_indent=50;
var lepopuptab_horizontal_indent=50;
var lepopuptab_open_before;
var lepopuptab_close_after;
if(typeof lepopuptab==typeof undefined) var lepopuptab=new Array();
if(window.jQuery){
jQuery(document).ready(function(){
if(typeof lepopup_ajax_url!=typeof undefined){
lepopuptab_vars["mode"]="local";
lepopuptab_vars["ajax-url"]=lepopup_ajax_url;
if(typeof lepopuptab_preview!=typeof undefined&&lepopuptab_preview=="on") lepopuptab_vars["preview"]="on";
else lepopuptab_vars["preview"]="off";
}else{
lepopuptab_vars["mode"]="remote";
if(jQuery("#lepopuptab-remote").length==0||!jQuery("#lepopuptab-remote").attr("data-handler")){
alert('Make sure that you properly included lepopuptab.js. Currently you did not.');
}
if(jQuery("#lepopuptab-remote").attr("data-preview")=="on") lepopuptab_vars["preview"]="on";
else lepopuptab_vars["preview"]="off";
lepopuptab_vars["ajax-url"]=jQuery("#lepopuptab-remote").attr("data-handler");
jQuery('head').append("<style>#lepopuptab-ready{display:none;width:0px;height:0px;}</style>");
jQuery('body').append("<div id='lepopuptab-ready'></div>");
}
var slug=window.location.hash;
var idx=slug.indexOf("#lepopuptab-");
if(idx >=0){
slug=slug.substr(idx+12);
if(slug.length > 0){
lepopuptab=new Array(slug);
}}
var tabs=new Array();
var tabs_mobile=new Array();
var temp;
for (var i=0; i<lepopuptab.length; i++){
temp=lepopuptab[i].split("*");
if(temp.length==1){
if(temp[0]!=""){
tabs.push(temp[0]);
tabs_mobile.push(temp[0]);
}}else{
if(temp[0]!="") tabs.push(temp[0]);
if(temp[1]!="") tabs_mobile.push(temp[1]);
}}
jQuery.ajax({
url:lepopuptab_vars['ajax-url'],
data:{"action":"lepopuptab-init", "tabs":(lepopup_mobile ? tabs_mobile.join(','):tabs.join(',')), "preview":lepopuptab_vars["preview"], "hostname":window.location.hostname},
method:(lepopuptab_vars["mode"]=="remote" ? "get":"post"),
dataType:	(lepopuptab_vars["mode"]=="remote" ? "jsonp":"json"),
async:true,
success:function(return_data){
try {
var data, temp;
if(typeof return_data=='object') data=return_data;
else data=jQuery.parseJSON(return_data);
if(data.status=="OK"){
if(lepopuptab_vars["mode"]=="local"){
jQuery('body').append(data.html);
lepopuptab_show_tabs();
jQuery(window).resize(function(){
lepopuptab_tab_position();
});
}else{
if(typeof data["resources"]["css"]!=typeof undefined){
for (var i=0; i<(data["resources"]["css"]).length; i++){
jQuery('head').append("<link href='"+(data["resources"]["css"])[i]+"' rel='stylesheet' type='text/css' media='all' />");
}}
var counter=50;
var ready=function(){
counter--;
if(counter==0){
console.log("Can't load style.css.");
return;
}
var width=jQuery("#lepopuptab-ready").width();
if(width==1){
jQuery('body').append(data.html);
lepopuptab_show_tabs();
jQuery(window).resize(function(){
lepopuptab_tab_position();
});
}else{
setTimeout(ready, 200);
}}
ready();
}}
} catch(error){
console.log(error);
}},
error:function(XMLHttpRequest, textStatus, errorThrown){
console.log(errorThrown);
}});
});
}else{
alert('lepopuptab.js requires jQuery to be loaded. Please include jQuery library above lepopup.js. Do not use "defer" or "async" option to load jQuery.');
}
function lepopuptab_show_tabs(){
lepopuptab_tab_position();
jQuery(".lepopuptab").each(function(){
var tab=this;
var tab_width=parseInt(jQuery(tab).width(), 10);
var tab_height=parseInt(jQuery(tab).height(), 10);
jQuery(tab).show();
if(jQuery(tab).hasClass("lepopuptab-bottom-left")||jQuery(tab).hasClass("lepopuptab-bottom-center")||jQuery(tab).hasClass("lepopuptab-bottom-right")){
jQuery(tab).css({"bottom":"-"+tab_height+"px"});
jQuery(tab).animate({"bottom":"0px"}, 500);
}else if(jQuery(tab).hasClass("lepopuptab-top-left")||jQuery(tab).hasClass("lepopuptab-top-center")||jQuery(tab).hasClass("lepopuptab-top-right")){
jQuery(tab).css({"top":"-"+tab_height+"px"});
jQuery(tab).animate({"top":"0px"}, 500);
}else if(jQuery(tab).hasClass("lepopuptab-left-top")||jQuery(tab).hasClass("lepopuptab-left-middle")||jQuery(tab).hasClass("lepopuptab-left-bottom")){
jQuery(tab).css({"left":"-"+tab_height+"px"});
jQuery(tab).animate({"left":"0px"}, 500);
}else if(jQuery(tab).hasClass("lepopuptab-right-top")||jQuery(tab).hasClass("lepopuptab-right-middle")||jQuery(tab).hasClass("lepopuptab-right-bottom")){
jQuery(tab).css({"right":"-"+tab_height+"px"});
jQuery(tab).animate({"right":"0px"}, 500);
}});
}
function lepopuptab_tab_position(){
var sizes={
width:{
right_top:lepopuptab_vertical_indent,
right_middle:-10,
right_bottom:lepopuptab_vertical_indent,
left_top:lepopuptab_vertical_indent,
left_middle:-10,
left_bottom:lepopuptab_vertical_indent,
bottom_left:lepopuptab_horizontal_indent,
bottom_center:-10,
bottom_right:lepopuptab_horizontal_indent,
top_left:lepopuptab_horizontal_indent,
top_center:-10,
top_right:lepopuptab_horizontal_indent
},
height:{
right_top:lepopuptab_vertical_indent,
right_middle:-10,
right_bottom:lepopuptab_vertical_indent,
left_top:lepopuptab_vertical_indent,
left_middle:-10,
left_bottom:lepopuptab_vertical_indent
},
};
var viewport={
width: Math.max(240, jQuery(window).width()),
height: Math.max(240, jQuery(window).height())
};
jQuery(".lepopuptab").removeClass("lepopuptab-icon-only");
jQuery(".lepopuptab").each(function(){
if(jQuery(this).hasClass("lepopuptab-right-top")){
sizes.width.right_top +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.right_top +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-right-middle")){
sizes.width.right_middle +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.right_middle +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-right-bottom")){
sizes.width.right_bottom +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.right_bottom +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-left-top")){
sizes.width.left_top +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.left_top +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-left-middle")){
sizes.width.left_middle +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.left_middle +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-left-bottom")){
sizes.width.left_bottom +=parseInt(jQuery(this).outerWidth(), 10) + 10;
sizes.height.left_bottom +=44 + 10;
}else if(jQuery(this).hasClass("lepopuptab-bottom-left")) sizes.width.bottom_left +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-bottom-center")) sizes.width.bottom_center +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-bottom-right")) sizes.width.bottom_right +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-top-left")) sizes.width.top_left +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-top-center")) sizes.width.top_center +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-top-right")) sizes.width.top_right +=parseInt(jQuery(this).outerWidth(), 10) + 10;
});
var top_position;
var left_position;
var icons_only=false;
if(sizes.width.right_top > lepopuptab_vertical_indent&&sizes.width.right_middle > -10){
if(sizes.width.right_top + sizes.width.right_middle/2 > viewport.height/2) icons_only=true;
}
if(sizes.width.right_bottom > lepopuptab_vertical_indent&&sizes.width.right_middle > -10){
if(sizes.width.right_bottom + sizes.width.right_middle/2 > viewport.height/2) icons_only=true;
}
if(sizes.width.right_bottom > lepopuptab_vertical_indent&&sizes.width.right_top > lepopuptab_vertical_indent){
if(sizes.width.right_top + sizes.width.right_bottom > viewport.height) icons_only=true;
}
if(sizes.width.right_top > viewport.height||sizes.width.right_middle > viewport.height||sizes.width.right_bottom > viewport.height) icons_only=true;
var set_top=function(object){
var tab_size={
width:parseInt(jQuery(object).outerWidth(), 10),
height:parseInt(jQuery(object).outerHeight(), 10)
};
if(icons_only||jQuery(object).hasClass("lepopuptab-no-turn")){
jQuery(object).addClass("lepopuptab-icon-only");
tab_size={
width:parseInt(jQuery(object).outerWidth(), 10),
height:parseInt(jQuery(object).outerHeight(), 10)
};
jQuery(object).css({"top":(top_position - tab_size.height)+"px", "margin-top":"0"});
top_position -=tab_size.height + 10;
}else{
jQuery(object).outerWidth(tab_size.width);
jQuery(object).css({"top":(top_position - tab_size.width)+"px", "margin-top":"-"+tab_size.height+"px"});
top_position -=tab_size.width + 10;
}};
if(icons_only) top_position=parseInt((viewport.height + sizes.height.right_middle)/2, 10);
else top_position=parseInt((viewport.height + sizes.width.right_middle)/2, 10);
jQuery(".lepopuptab-right-middle").each(function(){set_top(this);});
top_position=viewport.height - lepopuptab_vertical_indent;
jQuery(".lepopuptab-right-bottom").each(function(){set_top(this);});
if(icons_only) top_position=sizes.height.right_top;
else top_position=sizes.width.right_top;
jQuery(".lepopuptab-right-top").each(function(){set_top(this);});
icons_only=false;
if(sizes.width.left_top > lepopuptab_vertical_indent&&sizes.width.left_middle > -10){
if(sizes.width.left_top + sizes.width.left_middle/2 > viewport.height/2) icons_only=true;
}
if(sizes.width.left_bottom > lepopuptab_vertical_indent&&sizes.width.left_middle > -10){
if(sizes.width.left_bottom + sizes.width.left_middle/2 > viewport.height/2) icons_only=true;
}
if(sizes.width.left_bottom > lepopuptab_vertical_indent&&sizes.width.left_top > lepopuptab_vertical_indent){
if(sizes.width.left_top + sizes.width.left_bottom > viewport.height) icons_only=true;
}
if(sizes.width.left_top > viewport.height||sizes.width.left_middle > viewport.height||sizes.width.left_bottom > viewport.height) icons_only=true;
set_top=function(object){
var tab_size={
width:parseInt(jQuery(object).outerWidth(), 10),
height:parseInt(jQuery(object).outerHeight(), 10)
};
if(icons_only||jQuery(object).hasClass("lepopuptab-no-turn")){
jQuery(object).addClass("lepopuptab-icon-only");
tab_size={
width:parseInt(jQuery(object).outerWidth(), 10),
height:parseInt(jQuery(object).outerHeight(), 10)
};
jQuery(object).css({"top":(top_position - tab_size.height)+"px"});
top_position -=tab_size.height + 10;
}else{
jQuery(object).css({"top":(top_position)+"px"});
top_position -=tab_size.width + 10;
}};
if(icons_only) top_position=parseInt((viewport.height + sizes.height.left_middle)/2, 10);
else top_position=parseInt((viewport.height + sizes.width.left_middle)/2, 10);
jQuery(".lepopuptab-left-middle").each(function(){set_top(this);});
top_position=viewport.height - lepopuptab_vertical_indent;
jQuery(".lepopuptab-left-bottom").each(function(){set_top(this);});
if(icons_only) top_position=sizes.height.left_top;
else top_position=sizes.width.left_top;
jQuery(".lepopuptab-left-top").each(function(){set_top(this);});
icons_only=false;
if(sizes.width.bottom_left > lepopuptab_horizontal_indent&&sizes.width.bottom_center > -10){
if(sizes.width.bottom_left + sizes.width.bottom_center/2 > viewport.width/2) icons_only=true;
}
if(sizes.width.bottom_right > lepopuptab_horizontal_indent&&sizes.width.bottom_center > -10){
if(sizes.width.bottom_right + sizes.width.bottom_center/2 > viewport.width/2) icons_only=true;
}
if(sizes.width.bottom_left > lepopuptab_horizontal_indent&&sizes.width.bottom_right > lepopuptab_horizontal_indent){
if(sizes.width.bottom_left + sizes.width.bottom_right > viewport.width) icons_only=true;
}
if(sizes.width.bottom_left > viewport.width||sizes.width.bottom_right > viewport.width||sizes.width.bottom_center > viewport.width) icons_only=true;
if(icons_only){
jQuery(".lepopuptab-bottom-left, .lepopuptab-bottom-center, .lepopuptab-bottom-right").addClass("lepopuptab-icon-only");
sizes.width.bottom_left=lepopuptab_horizontal_indent;
sizes.width.bottom_center=-10;
sizes.width.bottom_right=lepopuptab_horizontal_indent;
jQuery(".lepopuptab-bottom-left, .lepopuptab-bottom-center, .lepopuptab-bottom-right").each(function(){
if(jQuery(this).hasClass("lepopuptab-bottom-left")) sizes.width.bottom_left +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-bottom-center")) sizes.width.bottom_center +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-bottom-right")) sizes.width.bottom_right +=parseInt(jQuery(this).outerWidth(), 10) + 10;
});
}
var set_left=function(object){
var tab_size={
width:parseInt(jQuery(object).outerWidth(), 10),
height:parseInt(jQuery(object).outerHeight(), 10)
};
jQuery(object).css({"left":left_position+"px"});
left_position +=tab_size.width + 10;
};
left_position=parseInt((viewport.width - sizes.width.bottom_center)/2, 10);
jQuery(".lepopuptab-bottom-center").each(function(){set_left(this);});
left_position=viewport.width - sizes.width.bottom_right;
jQuery(".lepopuptab-bottom-right").each(function(){set_left(this);});
left_position=lepopuptab_horizontal_indent;
jQuery(".lepopuptab-bottom-left").each(function(){set_left(this);});
icons_only=false;
if(sizes.width.top_left > lepopuptab_horizontal_indent&&sizes.width.top_center > -10){
if(sizes.width.top_left + sizes.width.top_center/2 > viewport.width/2) icons_only=true;
}
if(sizes.width.top_right > lepopuptab_horizontal_indent&&sizes.width.top_center > -10){
if(sizes.width.top_right + sizes.width.top_center/2 > viewport.width/2) icons_only=true;
}
if(sizes.width.top_left > lepopuptab_horizontal_indent&&sizes.width.top_right > lepopuptab_horizontal_indent){
if(sizes.width.top_left + sizes.width.top_right > viewport.width) icons_only=true;
}
if(sizes.width.top_left > viewport.width||sizes.width.top_right > viewport.width||sizes.width.top_center > viewport.width) icons_only=true;
if(icons_only){
jQuery(".lepopuptab-top-left, .lepopuptab-top-center, .lepopuptab-top-right").addClass("lepopuptab-icon-only");
sizes.width.top_left=lepopuptab_horizontal_indent;
sizes.width.top_center=-10;
sizes.width.top_right=lepopuptab_horizontal_indent;
jQuery(".lepopuptab-top-left, .lepopuptab-top-center, .lepopuptab-top-right").each(function(){
if(jQuery(this).hasClass("lepopuptab-top-left")) sizes.width.top_left +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-top-center")) sizes.width.top_center +=parseInt(jQuery(this).outerWidth(), 10) + 10;
else if(jQuery(this).hasClass("lepopuptab-top-right")) sizes.width.top_right +=parseInt(jQuery(this).outerWidth(), 10) + 10;
});
}
left_position=parseInt((viewport.width - sizes.width.top_center)/2, 10);
jQuery(".lepopuptab-top-center").each(function(){set_left(this);});
left_position=viewport.width - sizes.width.top_right;
jQuery(".lepopuptab-top-right").each(function(){set_left(this);});
left_position=lepopuptab_horizontal_indent;
jQuery(".lepopuptab-top-left").each(function(){set_left(this);});
}
if(typeof lepopupext_open_before=='function'){
lepopuptab_open_before=lepopupext_open_before;
}
lepopupext_open_before=function(id){
if(typeof lepopuptab_open_before=='function'){
lepopuptab_open_before(id);
}
jQuery(".lepopuptab-"+id).each(function(){
jQuery(this).fadeOut(500);
});
}
if(typeof lepopupext_close_after=='function'){
lepopuptab_close_after=lepopupext_close_after;
}
lepopupext_close_after=function(id){
if(typeof lepopuptab_close_after=='function'){
lepopuptab_close_after(id);
}
jQuery(".lepopuptab-"+id).each(function(){
jQuery(this).fadeIn(500);
});
};