$(document).ready(function(){
    $('#top-nav  a').each(function(index){
        tabid = 'top-tab-' +index.toString();
        $(this).attr('id', tabid);
        width = $(this).width();
        height = $(this).height();
        cnt = $(this).text();
        href = $(this).attr('href');
        active = $(this).parent().hasClass('current');
        $(this).wrap('<span>');
        replaceTab(tabid, width, height, cnt, href,active);
    });
    
    $('#sidenav  a').each(function(index){
        tabid = 'side-tab-' +index.toString();
        $(this).attr('id', tabid);

        width = $(this).width();
        
        height = $(this).height();
        if ($(this).text().length > 13){
             height =  56;
        } else {
             height =  32;
        }
        /*
        if (height > 20){
            height =  56;
        } else {
            height =  56;
        }*/
        cnt = $(this).text();
        href = $(this).attr('href');
        active = $(this).parent().hasClass('current');
        $(this).wrap('<span>');
        replaceMenu(tabid, width, height, cnt, href,active);
    });
    
    $('h2').each(function(index){
        titleid='title-'+index.toString();
        //$(this).attr('id', titleid);

        var flashvars = {
            cnt: $(this).text(),
            w:$(this).width(),
            h:34
            };
            $(this).wrap('<span class="h2-title">');
            $(this).attr('id', titleid);

        var params = {
            menu:"false",
            quality:"hight",
            wmode:"transparent"
        };
        var attributes = {};
        swfobject.embedSWF(path +  "flash/title.swf", titleid, flashvars.w, flashvars.h, "8.0.0", false, flashvars, params, attributes);
    });

    if ($('#main-content').height() < 450){
        $('#main-content').height(450);

    }
    setupPress();
})

function replaceTab(id, width, height, cnt, href, active){
    var flashvars = {
        cnt: cnt,
        w:width,
        h:height,
        href:href
    };
    if (active){
        flashvars.cls = 'active';
    }
    var params = {
        menu:"false",
        quality:"hight",
        wmode:"transparent"
    };
    var attributes = {};
    swfobject.embedSWF(path + "flash/tab.swf", id, width, height, "8.0.0", false, flashvars, params, attributes);
}


function replaceMenu(id, width, height, cnt, href, active){
    var flashvars = {
        cnt: cnt,
        w:width,
        h:height,
        href:href
    };
    if (active){
        flashvars.cls = 'active';
    }
    var params = {
        menu:"false",
        quality:"hight",
        wmode:"transparent"
    };
    var attributes = {};
 
    swfobject.embedSWF(path + "flash/menu.swf", id, width, height, "8.0.0", false, flashvars, params, attributes);
}

function setupPress(){
    
}
