pos = 1;
tweet_no=0;
tweet_total_count = 0;  
left = 0;
$(document).ready(function(){
     start_slide(1);
        
        $('#servicesLinkContainer').mouseout(function(){
        $('.servicesLinkContainerActive').addClass('servicesTopLink');
        $('.servicesLinkContainerActive').removeClass('servicesLinkContainerActive');
        $(this).removeClass('servicesLinkContainerActive');
        $(this).children('#servicesTopLink').removeClass('servicesLinkContainerActive');
        $(this).children('#servicesLinks').css('display','none')
    }
    );
    
        $('#servicesLinkContainer').mouseover(function(){
        $(this).addClass('servicesLinkContainerActive');
        $('.servicesTopLink').addClass('servicesLinkContainerActive');
        $('.servicesLinkContainerActive').removeClass('servicesTopLink');
        //$(this).children('.servicesLinkContainerActive').removeId('servicesTopLink');
        $(this).children('#servicesLinks').css('display','block')
    }
    );
    
    
    $('#tweet_list li').each(function() {
        tweet_total_count++;
    });
    
        $('.thumb').click(function(){
            pos = $(this).attr('id');
            pos = pos.replace("thumb", "");
            pos = parseInt(pos);
            banner_interval = window.clearInterval(banner_interval);
            slide_left(pos);
            start_slide(pos);
        });
    
    
    
    interval = window.setInterval(function(){ 
        tweet_no = tweet_no + 1;
        if(tweet_no >= tweet_total_count){
            tweet_no = 0;
        }                      
        tweet_slide_up(tweet_no);
   }, 5000);
   
   
   $('#tweet_list li').each(function(){
        height = $(this).height();
        margin = 55 - height;
        margin_top = margin/2;
        margin_top = Math.ceil(margin_top);
        margin_bottom = margin-margin_top;
        $(this).css('margin',margin_top+'px 0px '+margin_bottom+'px 0px');
    })
    
    
});


    function service_list_start(){

    ////////////////////////////////////////
    ///////// service slider ///////////////
    ////////////////////////////////////////
    services_count = document.getElementById('services_count').value;
    left = 0;
    max_right = services_count * 300;
    max_right = max_right - 900;
    max_left = max_right * -1; 
        
        
    $('#right').click(function(){
              
        left = left - 300;

        if(left >= max_left){
            $("#service_list").animate({"left": "-=300px"}, "slow");
        }
        else{
            $("#service_list").animate({"left": "+="+max_right+"px"}, 500);
            left = 0;
        }
        service_interval = window.clearInterval(service_interval);
        service_interval = window.setInterval(function(){
        left = left - 300;
        if(left >= max_left){
        }
        else{
            left = 0;
        }
        service_slide_left(left);
    }, 10000);

    })
    
    $('#left').click(function(){

        if(left == 0){
             left = max_left;
            $("#service_list").animate({"left": "+="+max_left}, 500);
        }
        else{
            left = left + 300;
            $("#service_list").animate({"left": "+=300px"}, "slow");
        }
        service_interval = window.clearInterval(service_interval);
        service_interval = window.setInterval(function(){
        left = left - 300;
        if(left >= max_left){
        }
        else{
            left = 0;
        }
        service_slide_left(left);
    }, 10000);
    })
    
    
    service_interval = window.setInterval(function(){
        left = left - 300;
        if(left >= max_left){
        }
        else{
            left = 0;
        }
        service_slide_left(left);
    }, 10000);
    
    
    function service_slide_left(left){
        
        if(left >= max_left){
            $("#service_list").animate({"left": left+"px"}, "slow");
        }
        else{
            $("#service_list").animate({"left": "+="+max_right+"px"}, 500);
        }
    }
   
    
    
    ////////////////////////////////////////
    ///////// service slider end ///////////
    ////////////////////////////////////////
    }  


function start_slide(pos){
    var image_count = 3;
    var image_max_right = image_count * 940;  //extra 3px for top left image margin
    image_max_right = image_max_right - 940;  //extra 3px for top left image margin
    image_max_left = image_max_right * -1;
    
    banner_interval = window.setInterval(function(){                               
        pos = pos + 1 ;
        if(pos > image_count){
            pos = 1;
        }
        
        slide_left(pos);
   }, 5000);
}

function slide_left(pos){
        image_left = (pos-1)*940;  //extra 3px for top left image margin
        image_left = image_left * -1;
        thumb_left = (pos-1)*15;
        thumb_top = (pos-1)*-15;
        
        if(image_left < 0){
            $("#image_list").animate({"left": +image_left+"px"}, "slow");
            $("#active_thumb").animate({"left": 14+thumb_left+"px", "top": 50+thumb_top+"px"}, "slow");
        }
        else{
            $("#image_list").animate({"left": "0px"}, 500);
            $("#active_thumb").animate({"left": "14px", "top": "50px"}, 500);
        }    
    }

function top_of_page(){
    jQuery('html, body').animate( { scrollTop: 0 }, 'slow' );
}


function tweet_slide_up(tweet_no){
    
        tweet_top = (tweet_no) * 55;  //extra 3px for top left image margin
        tweet_top = tweet_top * -1;
        if(tweet_no == 0){
            $("#tweet_list").animate({"top": "0px"}, 500);
        }
        else{
            $("#tweet_list").animate({"top": + tweet_top +"px"}, "slow");
        }    
}

function checkbox(name){ 
    value = $("#"+name+":checked").val();

    if(value == null){
        $('#label_'+name).removeClass('quote_label');
        $('#label_'+name).addClass('quote_label_true');
        $('#'+name).attr('checked','checked')
    }
    else{
        $('#label_'+name).removeClass('quote_label_true');
        $('#label_'+name).addClass('quote_label');
        $('#'+name).removeAttr('checked')
    }
}

function checkbox_load(name){
    value = $("#"+name+":checked").val();
    if(value == null){
        $('#label_'+name).removeClass('quote_label_true');
        $('#label_'+name).addClass('quote_label');
        $('#'+name).removeAttr('checked')    
    }
    else{
        $('#label_'+name).removeClass('quote_label');
        $('#label_'+name).addClass('quote_label_true');
        $('#'+name).attr('checked','checked')
        
    }
}

function checkbox_reload(){
    checkbox_load('website_design_box');
    checkbox_load('website_development_box');
    checkbox_load('seo_box');
    checkbox_load('ppc_box');
    checkbox_load('graphic_design_box');
    checkbox_load('branding_box');
    checkbox_load('printing_box');
    checkbox_load('brochure_website');
    checkbox_load('website_cms');
    checkbox_load('ecommerce_website');
}
  
