// Cufon
Cufon.set('fontFamily', 'HeliosExtThin').set('separate', 'none');
Cufon.replace('.cufon, #right h2', {letterSpacing: '-1px'});
//Cufon.replace('.m1 a, .m1 strong', {fontFamily: 'Helios-Cond-Light', hover: true});

var bgBotDiv, bgBotDivMinHeight, catalogFlash;

$(function(){
// bgBot
    bgBotDiv = $('#bgBot');
    if (bgBotDiv.attr('class') == 'bg-bot8') {
        bgBotDivMinHeight = 1580;
    } else {
        bgBotDivMinHeight = 1400;
    }
    bgPosition();
    $(window).resize(function(){
        bgPosition();
    });

// m1
    $('.m1:has(.m2)').each(function(){
        var m1 = $(this);
        m1.children('li:has(.m2):not(.a)').hover(
            function(){
                $(this).addClass('a');
                $('.br, .m2', m1).hide();
                $('.br, .m2', this).show();
            },
            function(){
                $(this).removeClass('a');
                $('.br, .m2', this).hide();
                $('.a .br, .a .m2', m1).show();
            }
        );
    });

// archive
    $('.archive li:has(ul)').children('a').click(function(){
        var a = $(this);
        a.next().toggle();
        a.parent().toggleClass('a');
        return false;
    });

// search holder
    var search_input = $('#search input.text');
    var search_holder = search_input.val();
    search_input.addClass('holder').focus(function(){
        if ($(this).val() == search_holder) {
            $(this).val('').removeClass('holder');
        }
    }).blur(function(){
        if ($(this).val() == '') {
            $(this).addClass('holder').val(search_holder);
        }
    });

// dealers
    $('.dealers .link').click(function(){
        $(this).parent().hide().next().show();
        bgPosition(bgBotDiv, bgBotDivMinHeight);
        return false;
    });

// catalog
    var catalogVars = {
        callback: 'catalogHeight',
        data: '/swf/menu_data/menu.xml'
    };
    var catalogParams = {
        wmode: 'opaque',
        bgcolor: '#faf8ec',
        allowscriptaccess: 'always'
    };
    var catalogCallback = function(e){
        catalogFlash = e.ref;
    };
	
	//swfobject.embedSWF('/swf/catalog.swf', 'catalogFlash', '224', '256', '9.0.115', '/swf/expressInstall.swf', catalogVars, catalogParams, false, catalogCallback);
 
// lightBox
    $('.gallery a').lightBox({
        overlayBgColor: '#000',
        overlayOpacity: 0.6,
        imageBlank: '/images/design/px.gif',
        imageLoading: '/images/design/lightbox/loading.gif',
        imageBtnClose: '/images/design/lightbox/close.gif',
        imageBtnPrev: '/images/design/lightbox/prev.gif',
        imageBtnNext: '/images/design/lightbox/next.gif',
        containerResizeSpeed: 350,
        txtImage: 'Ôîòî',
        txtOf: 'èç'
    });
})


function catalogHeight(height) {
    catalogFlash.height = height;
    bgPosition();
}


function bgPosition() {
    if (bgBotDiv.height() > bgBotDivMinHeight) {
        bgBotDiv.addClass('bg-pos-bot');
    } else {
        bgBotDiv.removeClass('bg-pos-bot');
    }
}
function getLength()
{
result = 0;
result = parseInt(document.getElementById('sa').value) + parseInt(document.getElementById('sb').value) + parseInt(document.getElementById('sc').value);
if (document.getElementById('sm').checked) result += 30.5;
result = (result - 10 * (2 + parseInt(document.getElementById('nb').selectedIndex))) / 30.5;
if (Math.floor(result) != result) result = Math.floor(result) + 1;
document.getElementById('s_result').innerHTML = result;
}
