/**
  * version: 1.0
  * author: Frenk T. Sedmak Nahtigal
  * email: frenk.ten@3fs.si <frenk.ten@3fs.si>
  * website:
 */

function neki()
{
    $('#boxwide').each(function() {
        img = $('#boxwide img').attr("src").replace("/preview/", "/thumb/");
        title = $('#boxwide').children('h3').text();
        subtitle = $('#boxwide span.subtitle').text();
        content = $("#boxwide p").text();
        content_more = $("#boxwide span.more").children().attr('href');
        project = $("#boxwide a.img").attr('href');

        //Temporary storage data variables
        tmp_img = img;
        tmp_title = title;
        tmp_content = content;
        tmp_subtitle = subtitle;
        tmp_content_more = content_more;
        tmp_project = project;
    });
    // Replace the var values...
    img = dd_img;
    title = dd_title;
    subtitle = dd_subtitle;
    content = dd_content;
    content_more = dd_content_more;
    project = dd_project;

    // And replace the content...
    $('#boxwide h3').html(title);
    $('#boxwide span.subtitle').html(subtitle);
    $('#boxwide p').html(content);
    $('#boxwide img').attr("src", img);
    $('#boxwide span.more').children().attr("href", content_more);
    $('#boxwide a.img').attr("href", project);
}

$(document).ready(function(){
    $('#boxbottom a').each(function() {
        $(this).click(function(){
            // zapišemo vrednosti elementov v spremenljivke iz Objekta...
            dd_img = $(this).children().attr('src').replace("/thumb/", "/preview/");  // img
            dd_title = $(this).parent().parent().children('dt').children('span.h4').text();  // title
            dd_subtitle = $(this).parent().parent().children('dt').children('span.sub').text();  // subtitle
            dd_content = $(this).parent().parent().children('dd').children('p').text();   // content
            dd_content_more = $(this).parent().parent().children('dd').children('a').attr('href'); // content: "more" link
            dd_project = $(this).parent().parent().children('dd.h').children('a').attr('href'); // link to the last project in the group
            //alert(dd_project);
            neki();  // funkcija zamenjave

            $(this).parent().parent().children('dt').children('span').text(tmp_title); // zapiše zgornji tmp_title v <dt> title.
            $(this).parent().parent().children('dt').children('span.sub').text(tmp_subtitle);  // zapiše zgornji tmp_subtitle v <dt> <p> title.
            $(this).parent().parent().children('dd').children('p').text(tmp_content); // zapiše zgornji tmp_content v <p> content.
            $(this).children().attr('src', tmp_img); // zapiše zgornji tmp_img(src) v <img src="">. key -> val.
            $(this).parent().parent().children('dd').children('a').attr('href', tmp_content_more); // zapiše zgornji tmp_content_more v <dd> <span class="more">
            $(this).parent().parent().children('dd.h').children('a').attr('href', tmp_project); // zapiše zgornji ProjectID v <dl> content, last_project class="h"
            return false;
        });

    // BoxBottom <dt> hover -> remove class:"h"
    //$(this).mouseover( function() { $('#boxbottom dl dt.js').addClass("h") } );
    $('#boxbottom dl dt.js').addClass("h");
    $(this).mouseover( function() { $(this).parent().parent().children('dt').removeClass("h") } );
    $(this).mouseout( function() { $(this).parent().parent().children('dt').addClass("h") } );
    //alert(this);
    });
});
