﻿//Plugin Default actions
//$(document).ready(function () {

//    $('.pluginSettings h3').click(function () {
//        $("table", $(this).parent()).slideToggle('fast', function () {                          
//        });
//    });            
//            
//});

//Gets information stored in elements class
//Example: siteSomething should start with site
//Techique used to store information in CSS classes
function getEditableElement(element) {
    var result = null;
        //Get all classes from element
        var getElementClass = jQuery(element).attr("class");
        //Split classes in array
        getElementClass = getElementClass.split(" ");

        //Loop trough classes
        for (var x in getElementClass) {
            
            if (getElementClass[x].slice(0, 4) == 'site') {
                return getElementClass[x];
            }            
        }

    return result;
}

var langPack = {
    "pageName": "Име на страницата?",
    "pageNameDuplicate": "Вече има страница с това име!",
    "pageNameError": "Моля въведете име на страницата!",
    "pluginSelectParent": "Добавката няма родител",
    "pluginError": "Грешка в добавката!",
    "pluginInstallTip": "Сигурни ли сте, че желаете да инсталирате тази добавка?\n\nВнимание!!!\nТова ще замени предишно инсталирани добавки изтривайки въведената информация и настройки!",
    "pluginParentTip": "Грешка в добавката!",
    "pluginUninstallTip": "Сигурни ли сте, че желаете да деинсталирате тази добавка?\n\nВнимание!!!\nТова ще изтрие въведената информация и настройки!",
    "pluginError": "Тази страница няма инсталирани плъгини,\nили плъгините са наследени от родителя!"
}

//Generic function to write a cookie
function writeCookie(name, value, hours) {
    var expire = "";
    if (hours != null) {
        expire = new Date((new Date()).getTime() + hours * 3600000);
        expire = "; expires=" + expire.toGMTString();
    }
    document.cookie = name + "=" + escape(value) + expire;
}

//Generic function to read a cookie
function readCookie(name) {
    var cookieValue = "";
    var search = name + "=";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            cookieValue = unescape(document.cookie.substring(offset, end))
        }
    }
    return cookieValue;
}

function menuHelper(menuHolder) {
    var menuHolder = $(menuHolder);
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if ($('a[href^="' + sPage + '"]', menuHolder).length > 0) {
        $('a[href^="' + sPage + '"]', menuHolder).parents('li').addClass('active');
    }
}
