/*
var gallery = {};
gallery['variants'] = [];
gallery['display_image'] = function(image_object){
    var vimage = $('<h2>'+image_object.title+'</h2><img src="'+image_object.url+'"/>');
    $("#image_container").html(vimage);
    $("#contentTitle").text(image_object.title);
    return false
}

gallery['init'] = function(){
    
    variant_links = $('.variant_image_link')
    jQuery.each(variant_links, function() {
      
      vl_title = $(this).attr('title');
      vl_url = $(this).attr('href');
      vl_thumbnail = $('img',$(this)).attr('src');
      
      var vl_obj = {title:vl_title, url:vl_url, thumbnail:vl_thumbnail}
      gallery['variants'].push(vl_obj)
      $(this).click(function(){return gallery['display_image'](vl_obj)})
      
    });
    //$('#colorbox').addClass("round_corners");
    $('#modalContent').addClass("round_corners");
    
}
*/



$(document).ready(function() {
    
    
    var testimonial_height = $('#testimonials').height();
    var testimonial_quote_maxheight = testimonial_height - $('#testimonials div.name').height();
    
    if(typeof(DD_roundies) != 'undefined'){
        DD_roundies.addRule('.round_corners', '20px');
        DD_roundies.addRule('.round_corners_small', '10px');
    }
    if(typeof(DD_belatedPNG) != 'undefined'){
        DD_belatedPNG.fix('img', '#header');
    }
    
    $.fn.colorbox.settings.transitionSpeed = 30;
    $.fn.colorbox.settings.transition = "elastic";
    $.fn.colorbox.settings.slideshowSpeed = 8000;
    $.fn.colorbox.settings.opacity = "0.6";
    /*
    $.fn.colorbox.settings.initialWidth = "690px";
    $.fn.colorbox.settings.initialHeight = "540px";
    $("a[class='colorbox']").colorbox({}, gallery['init']);
    */
        
    $('.testimonial').show();
    $.each($('#testimonials .quote'), function() {
        $(this).css('font-size', '14px');
        var max_loop = parseInt($(this).css('font-size'));
        var current_loop = 0;
        while(current_loop < max_loop){
            var cheight = $(this).height();
            if (cheight < testimonial_quote_maxheight){
                var testimonial = $($(this).parent().get(0));
                //alert( (testimonial_height - testimonial.height()));
                $(this).css('margin-top',((testimonial_height - testimonial.outerHeight())/2) + 'px')
                break;   
            }
            var new_size = parseInt($(this).css('font-size')) - 1;
            $(this).css('font-size', new_size+'px');
            current_loop++;
        }
    });
    
        
    $('#testimonials ul').innerfade(
        { speed: 1000, 
          timeout: 10000, 
          type: 'random', 
          containerheight: testimonial_height+'px'
        }); 
    
    $("#contact_form").validate();
    
    // google analytics
    if (typeof(_gat) != 'undefined'){
        
        // standard tracker
        var pageTracker = _gat._getTracker("UA-9198981-1");
        pageTracker._initData();
        pageTracker._trackPageview();
        
        // outgoing links, connect to analytics.
    	var outgoing_links = $("a[href ^= 'http']");
    	$.each(outgoing_links, function(){
    		$(this).click( function() { 
    			var ahref = $(this).attr('href');
    			if (ahref.indexOf('lightec.net') == -1){				
    				var cleaned_href = ahref.replace(/https?:\/\//,'');
    				var analytics_path = '/outgoing/'+cleaned_href;
    	     		pageTracker._trackPageview(analytics_path);
    	     	}
    	    });
    	});        
        
    }    
    
    $(".slideshow").colorbox({slideshow:true});
    
    
 });

