// todo:Раскоминтировать
 function NoError() {    return true;}window.onerror = NoError;
$(document).ready(function() {
    $(function() {
        $('a.linked').hover(function() {
            if ($(this).find('img').length) {
                $(this).parents().next().find('a.linked').eq(0).css({color: '#333'});
                //$(this).find('img').css({'border-color': '#00a7e5'});
            }
           // else $(this).parents().find('a.linked img').eq(0).css({'border-color': '#00a7e5'});
        }, function() {
            if ($(this).find('img').length) {
                $(this).parents().next().find('a.linked').eq(0).css({color: ''});
                //$(this).find('img').css({'border-color': ''});
            }
            //else $(this).parents().find('a.linked img').eq(0).css({'border-color': ''});
        });
    });
    

});

$(document).ready(function() {
    try {
        if ($(this).val() == $(this).attr('placeholder'))
            $('INPUT[placeholder], TEXTAREA[placeholder]').blur(
                    function() {

                        if ($(this).val() == '') {
                            $(this).val($(this).attr('placeholder'));
                            $(this).addClass('m-placeholder');
                        }

                    }).focus(
                    function() {

                        $(this).removeClass('m-placeholder');
                        if (form.length)
                            $(this).val('');

                    }).each(function() {

                if (($(this).val() == '') || ($(this).val() == $(this).attr('placeholder'))) {
                    $(this).val($(this).attr('placeholder'));
                    $(this).addClass('m-placeholder');
                }

                var form = $(this).closest('FORM');
                if ($(this).val() == $(this).attr('placeholder'))
                    form.submit(function() {
                        $(this).val('');
                    });

            });
    }
    catch(e) { }


    });

//
$(document).ready(function() {
//[href="'+location.href+'"]
$('.nav a ').each(function(index) {
//    alert(+'!'+);
    if(location.href===$(this).attr('href'))
$(this).addClass("hover");
  //  alert($(this).text());

  });

        //alert('#'+ window.location.pathname);
visibleNav(window.location.pathname);

});

function contacts() {


    $.ajax({
        type: "POST",
        url: "sendform.php",
        success: function(msg) {
            $("#form").html(msg);
            hashMSG=location.hash.substr(1);
            if(hashMSG.indexOf('Мой адрес')>0) $("#send_form_div").append('<b><i>Мы гарантируем полную конфиденциальность данных и защиту переданной нам информации.</i></b>')
            hashMSG=hashMSG.replace("... ","...");
            hashMSG=hashMSG.replace("...","\r\n");
            if(hashMSG.length>0)
            hashMSG+="\r\n";
            $("textarea[name='msg']").val(hashMSG);

        }
    });
}

function visibleNav(op){

    $('ul[id="'+op+'"]').css('display','block');
    $('.nav a[href="http://bnv.com.ua'+op+'"]').addClass('hover');
    //alert('.nav a[href="http://bnv.com.ua'+op+'"]');

}

$(window).load(function() {
    $('#slider,#slider2,#slider3').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:5000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true   , //Only show on hover
        controlNav:false, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:false, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});


function runSlide() {
    $('.txt_but').each(function(index) {
        lnk = '#slide_' + $(this).attr('id');
        $(lnk).slideToggle(1000);
        $(this).click(function () {
		//todo: bugchrome Считает что изменяется высота блока
//			$('#slide_' + $(this).attr('id')).stop();
            $('#slide_' + $(this).attr('id')).slideToggle('slow');
        });

    });
    /*
     $('#text_lic').click(function () {
     $('#slide_lic').toggle('slow');
     });
     */
    $(".txt_but img").slideToggle('fast');
    $(".txt_but img").slideToggle(1400);

    //alert("#slide_"+self.document.location.hash.substring(1));
    $("#slide_" + self.document.location.hash.substring(1)).slideToggle('slow');
}



