/*******************************************************************************************************************
*  Global variables                                                                                                *
*******************************************************************************************************************/
var elements = new Array();    

jQuery.fx.interval = 40;

$(document).ready(function() {
        
    /*******************************************************************************************************************
    *  Change theme - set interval                                                                                     *
    *******************************************************************************************************************/
    if(isElement('.serviceWrap') == true){
        changeThemeInterval = setInterval(changeTheme, 10000);
    }   
    
    /*******************************************************************************************************************
    *  Load our services                                                                                               *
    *******************************************************************************************************************/
    if(isElement('.serviceWrap')){
        $('.service').each(function(index) {
            $('.paging').append('<a href="#" rel="' + index + '">&bull;<span></span></a>');
            $('.paging a:first').addClass('active');
            elements[index] = $(this);
        });
        $('.paging a').click(function(a) {
            a.preventDefault();
            clearInterval(changeThemeInterval);
            changeThemeByClick(parseInt($(this).attr('rel')));
        });
    }
    
    /*******************************************************************************************************************
    *  jQuery accordion                                                                                                *
    *******************************************************************************************************************/
    if(isElement('.accordion')){
        $('.accordion').accordion({
            active: false,
            collapsible: true,
            autoHeight: false,
            clearStyle: true
        });
    }
    
    /*******************************************************************************************************************
    *  FancyBox                                                                                                        *
    *******************************************************************************************************************/
        $("a[rel=lightbox]").fancybox({
		'hideOnContentClick': true,
                'padding': 0,
                'overlayOpacity': 0.8,
                'overlayColor': '#000',
                'autoScale': true
	});
        
    /*******************************************************************************************************************
    *  Table tr even                                                                                                   *
    *******************************************************************************************************************/
    if(isElement('table')){
        $('table tr:even').addClass('even');
    }
    
    /*******************************************************************************************************************
    *  Redirecting onclick                                                                                             *
    *******************************************************************************************************************/
    if(isElement('#cols')){
        $('#cols li').click(function() {
            window.location.href = $(this).find('a').attr('href');
        });
    }

    

    $('.paging a').hover(function() { actualBackground = $(this).css('background-color'); $(this).stop().animate({ backgroundColor: '#c8c8c8' }, 500); }, function() { $(this).stop().animate({ backgroundColor: actualBackground }, 500); });
    $('nav a').hover(function() { $(this).stop().animate({ opacity: 1 }, 500); }, function() { $(this).stop().animate({ opacity: 0.6 }, 500); });
    $('.button, .accordion li h3').hover(function() {  $(this).stop().animate({ backgroundColor: '#000' }, 500);  }, function() {  $(this).stop().animate({ backgroundColor: actualBackground }, 500, function() { }); });
    $('.item').hover(function() { $(this).find('strong').stop().animate({ top: '15px' }, 300); $(this).find('img').stop().animate({ top: '40px' }, 300); }, function() { $(this).find('strong').stop().animate({ top: '25px' }, 300); $(this).find('img').stop().animate({ top: '50px' }, 300); });
        
    actualBackground = $('.backgroundColor').css('background-color');

    /*******************************************************************************************************************
    *  Form elements focus                                                                                             *
    *******************************************************************************************************************/
    
    /*
    if(isElement('input[type="text"]')){
        $('input[type="text"]').focus(function() {if (this.value == this.defaultValue){ this.value = ''; }});
    }
    if(isElement('textarea')){               
        $('textarea').focus(function() {if (this.value == this.defaultValue){ this.value = ''; }});
    }
    */
   
    /*******************************************************************************************************************
    *  Set height in row (parentSelector, childSelector, itemsPerRow)                                                  *
    *******************************************************************************************************************/
    setHeight('.clearFix', '.w455 .blockWrap', 2);
    setHeight('.clearFix', '.w455 .blockWrap2', 2);
   
});
