
//autocomplete
$(function() {
    
    $('#comp_name').attr('autocomplete', 'off');
    $("#comp_name").autocomplete('search_company.php');
	
});


$(document).ready(function() {
    
    //top nav
    $('#nav li').hover(function() {
	
	$(this).addClass('over');
	//var negMarg = ($('ul', this).innerWidth() / 2) - 35;
	//$('ul', this).css('margin-left', -negMarg).fadeIn('fast');
	$('ul', this).fadeIn('fast');
	    
    },function() {
	
	$(this).removeClass('over');
	$('ul', this).fadeOut('fast');
	    
    });
    
    //add selected to parent link
    /*if ($('li.selected').parent().parent() == 'li') {
	alert('found');
    }*/
    
    $('li.selected').parent().parent().addClass('selected');
    
    //alert();
    
    //home slider
    $('#service_holder a').hover(function() {
        
        var servId = $(this).attr('id');
        var newTitle = $(this).attr('title');
        
        $('#services h4').hide();
        $('#services h2').hide();
        $('<h4>' + newTitle + '</h4>').insertBefore('#service_holder').hide().fadeIn('fast', function() {
            if ($.browser.msie) {
                this.style.removeAttribute('filter');
            }
        });
        
        
        if (servId == 'my_eco') {
            
            $('#business').stop(true, true).animate({left : 518}, 500);
            $('#learn').stop(true, true).animate({left : 703}, 500);
            
        }else if (servId == 'business') {
            
            $('#business').stop(true, true).animate({left : 185}, 500);
            $('#learn').stop(true, true).animate({left : 703}, 500);
            
        }else if (servId == 'learn') {
            
            $('#business').stop(true, true).animate({left : 185}, 500);
            $('#learn').stop(true, true).animate({left : 370}, 500);
            
        }
        
    });
    
    $('#services').mouseleave(function() {
        
        $('#services h4').hide();
        $('#services h2').fadeIn('fast', function() {
            if ($.browser.msie) {
                this.style.removeAttribute('filter');
            }
        });
        
    });
    
    //search box
    $('input.search_text').click(function() {
	if ($(this).val() == 'Search') {
	    $(this).val('');
	}
    });
    
    //case study arrow
    $('.case_arrow').css('opacity', 0.4);
    
    $('.case_arrow').hover(function() {
	$(this).fadeTo(500, 0.7, function() {
	    if ($.browser.msie) {
                this.style.removeAttribute('filter');
            }
	});
    },function() {
	$(this).fadeTo(500, 0.4, function() {
	    if ($.browser.msie) {
                this.style.removeAttribute('filter');
            }
	});
    });
    
    //news fade
    $('#news').cycle({ 
        fx: 'fade',
	pause: 1,
        speed: 2000,
   	timeout: 6000
    });
    
    $('#ad_slide').cycle({ 
        fx: 'fade',
	pause: 1,
        speed: 2000,
   	timeout: 6000
    });
    
    $('.case_box').cycle({ 
        fx: 'fade',
	pause: 1,
        speed: 2000,
   	timeout: 6000,
	next: '.case_next', 
	prev: '.case_prev' 
    });
    
    $('.press_box').cycle({ 
        fx: 'fade',
	pause: 1,
        speed: 2000,
   	timeout: 6000,
	next: '.press_next', 
	prev: '.press_prev' 
    });
    
    $('.res_box').cycle({ 
        fx: 'fade',
	pause: 1,
        speed: 2000,
   	timeout: 6000,
	next: '.res_next', 
	prev: '.res_prev' 
    });
    
    
    
});
