﻿/////// Design boxů //////////
/////// ver. 1.1    //////////

$(document).ready(function () {
    $(".box").each(function (i) {
        //$(this).bind ( "click",  function() { alert("Index: " + intIndex ); return false; });
        var nadpis = $(this).attr("title");
        if (nadpis) {
            if (nadpis.length > 14) {
                nadpis = nadpis.substr(0, 12) + "...";
            } 
        }
        $(this).children("img").before("<h4>" + nadpis + "</h4>");
        $(this).children("img").css("width", "90px");
        $(this).children("img").css("height", "90px");
    });

    $(".leftbox a").each(function (i) {
        //$(this).css("color","red");
        if (($(this).attr("rel") != undefined) && ($(this).attr("rel") != '')) {
            $(this).html($(this).html() + "<span class='adminlabel admininline'>[" + $(this).attr("rel") + "]</span>")
        }
    });

    /* img.menubox ??? */

    $("img.x").each(function (i) {
        //$(this).bind ( "click",  function() { alert("Index: " + intIndex ); return false; });
        var IDlink = $(this).attr("title");
        var selektor = "a[rel='" + IDlink + "']";
        //// odkaz
        var odkaz = $(selektor).attr("href");
        $(this).wrap(document.createElement("a"));
        $(this).parent().attr("class", "x");
        $(this).bind("click", function () { window.location = odkaz });
        $(this).parent().bind("mouseenter", function (e) { $(this).css("cursor", "hand"); });
        $(this).parent().bind("mouseleave", function (e) { $(this).css("cursor", "pointer"); });
        //// nadpis
        var nadpis = $(selektor).html();
        if (nadpis) {
            nadpis = nadpis.substring(0, nadpis.indexOf("<"));            
            if (nadpis.length > 14) {
                nadpis = nadpis.substr(0, 12) + "...";
            } 
        }
        $(this).before("<h4>" + nadpis + "</h4>");
        $(this).css("width", "90px");
        $(this).css("height", "90px");
    });
});