jQuery.noConflict();
  
jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
    
    jQuery('#indexPage').click(function() {
        location="http://www.fporen.ru"; 
    }); 
    
    jQuery('.left-menu .parent').hover(
        function(){
            sub = jQuery(this).children('ul');
            if (jQuery(this).hasClass('active')) {
                jQuery('.temp').hide();     
            }
            else {
                if (jQuery(this).hasClass('temp')){   
                }
                else {
                    jQuery('.temp').hide();
                    sub.show();    
                    sub.addClass("temp");    
                }
                
            }   
        },
        
        
        function(){
            if (jQuery(this).hasClass('active')) {
                   
            }
            else {
                jQuery('.temp').hide();    
            }
        }
    );  
    
    chasiki();
    window.setTimeout("chasiki()", 1000);
    
    
    
    jQuery('#personRight').nivoSlider({
        effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 1000, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: true, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: true, // 1,2,3... navigation
        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: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        randomStart: false, // Start on a random slide
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    }); 
    
    /*jQuery("#mycarousel").jcarousel({
        auto: 1,
        scroll: 1,
        start: 1,
        wrap: 'last',
        animation: 1000
    }); */
    
    cornersAvatar();
    
    jQuery('#social .s1').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s1').click(function() {
        location="http://www.odnoklassniki.ru"; 
    });
    
    jQuery('#social .s2').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s2').click(function() {
        location="http://my.mail.ru/mail/studio-r5/"; 
    });
    
    jQuery('#social .s3').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s3').click(function() {
        location="http://www.facebook.com/groups/132969843426933/"; 
    });
    
    jQuery('#social .s4').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s4').click(function() {
        location="http://www.twitter.com"; 
    });
    
    jQuery('#social .s5').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s5').click(function() {
        location="http://fporen.livejournal.com/3299.html"; 
    });
    
    jQuery('#social .s6').hover(
        function() {
            jQuery(this).addClass("active");   
        },
        function() {
            jQuery(this).removeClass("active"); 
        }
    );
    jQuery('#social .s6').click(function() {
        location="http://vkontakte.ru/club19341992"; 
    }); 

});

/**
* Выводит часы и дату
*/
function chasiki() {
    var time, minutes, hours;  
    
    time = new Date();
    
    minutes = time.getMinutes(); 
    hours = time.getHours();   
    
    if (minutes <= 9) minutes = "0"+minutes;
    if (hours <= 9) hours = "0"+hours;

    jQuery('#time .time').html(hours+":"+minutes); 
} 

function showPerson(title, img, desc, post) {
    //alert(title+'-'+img+'-'+desc+'-'+post);
    
    content = '';
    content += ' <div id="basic-modal-content">';
    content += '     <div class="float-l foto"><img src="'+img+'"><div class="button"><a href=\'#\' title=\'Close\' onclick="closeModal(); return false;">Закрыть окно</a> (Esc)</div></div>';
    content += '     <div class="float-l info">';
    content += '         <div class="name"><h3>'+title+'</h3></div>';
    content += '         <div class="post">'+post+'</div>';
    content += '         <div class="desc">'+desc+'</div>';
    content += '     </div>';
    content += '     <br class="clear none"/>';
    content += '</div>';
    
    jQuery('#infoPerson').html(content);
    jQuery('#basic-modal-content').modal({
        minHeight: 270,
        containerCss: {
            height: 270,
            width: 640
        },
    });
    
}  

function closeModal() {
    jQuery.modal.close();
}

function cornersAvatar() {
    jQuery('.hotnews .avatar img').corner();
    jQuery('.news .avatar img').corner();
    jQuery('.news_org .avatar img').corner();    
    
    jQuery('.temp').corner();    
}


function addComment() {
    cit = jQuery('#cBuf').attr('cit');
    cii = jQuery('#cBuf').attr('cii');
    
    content = '';
    content += '<div id="basic-modal-content">';
    content += '    <div id="cForm">';
    content += '        <input type="hidden" id="cIT" value="'+cit+'">'; 
    content += '        <input type="hidden" id="cII" value="'+cii+'">'; 
    content += '        <div class="cField">';
    content += '            <div class="cTextName">Ваше имя</div>';
    content += '            <div class="cHtml"><input type="text" id="cName" value=""></div>';
    content += '        </div>';
    content += '        <div class="cField">';
    content += '            <div class="cTextName"></div>';
    content += '            <div class="cHtml"><textarea id="cComment"></textarea></div>';
    content += '        </div>'; 
    content += '        <div class="cField">';
    content += '            <input type="button" id="cSend" onclick="cSend();" value="Оставить комментарий">';
    content += '        </div>';   
    content += '    </div>';
    content += '</div>';
    
    jQuery('#cBuf').html(content);
    jQuery('#basic-modal-content').modal({
        minHeight: 270,
        containerCss: {
            height: 222,
            width: 622
        },
    });
    
    jQuery('#cBuf').html('');  
    
} 

function cSend() {
    cIT      = jQuery('#cIT').val(); 
    cII      = jQuery('#cII').val(); 
    cName    = jQuery('#cName').val();          
    cComment = jQuery('#cComment').val();
    cAction  = "cAdd";  
    
    //alert (cIT+'-'+cII+'-'+cName+'-'+cComment);
    
    var post = { cIT:cIT, cII:cII, cName:cName, cComment:cComment, cAction:cAction };   
    jQuery.ajax ({
        type: "POST",
        url: "/assets/snippets/ajax/comment.php",                
        data: post,
        success: function(response) {
            dataResponse = jQuery.parseJSON(response);
            if (dataResponse.success) {
                //alert (dataResponse.cAction+'-'+dataResponse.cIndexTable+'-'+dataResponse.cIndexItem+'-'+dataResponse.cName+'-'+dataResponse.cComment+'-'+dataResponse.success+'-'+dataResponse.errorCode); 
                jQuery.modal.close();
                jQuery(".cItem:last").after(dataResponse.cHtml);
            }
        }
    });
    
    //alert (cIT+cName+cComment);              
}

function cDelete(cIT, cII) {
    if (confirm("Вы действительно хотите удалить этот комментарий")) {
        cAction  = "cDelete"; 
        var post = { cIT:cIT, cII:cII, cAction:cAction }; 
        jQuery.ajax ({
            type: "POST",
            url: "/assets/snippets/ajax/comment.php",                
            data: post,
            success: function(response) {
                dataResponse = jQuery.parseJSON(response);
                if (dataResponse.success) {
                    //alert (dataResponse.cAction+'-'+dataResponse.cIndexTable+'-'+dataResponse.cIndexItem+'-'+dataResponse.success+'-'+dataResponse.errorCode); 
                    jQuery('#cItem'+dataResponse.cIndexItem).hide();  
                }
            }
        });  
    } 
    else {}
        
}    

  

  
