$(function(){
	
	//stripe table 
	$(".stripe tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
    $(".stripe tr:even").addClass("even");
	
	//about us quote boxes
	$(".q-link1").hover(function(){
        $("#q1").fadeIn("fast");
 	}, function() {
        $("#q1").fadeOut("fast");
 	}); 
	$(".q-link2").hover(function(){
        $("#q2").fadeIn("fast");
 	}, function() {
        $("#q2").fadeOut("fast");
 	}); 
	$(".q-link3").hover(function(){
        $("#q3").fadeIn("fast");
 	}, function() {
        $("#q3").fadeOut("fast");
 	}); 
	$(".q-link4").hover(function(){
        $("#q4").fadeIn("fast");
 	}, function() {
        $("#q4").fadeOut("fast");
 	}); 
	$(".q-link5").hover(function(){
        $("#q5").fadeIn("fast");
 	}, function() {
        $("#q5").fadeOut("fast");
 	}); 
	$(".q-link6").hover(function(){
        $("#q6").fadeIn("fast");
 	}, function() {
        $("#q6").fadeOut("fast");
 	}); 
	
	//client portfolio logos
	$(".c-link1").hover(function(){
        $("#c1").fadeIn("fast");
 	}, function() {
        $("#c1").fadeOut("fast");		
 	}); 
	$(".c-link2").hover(function(){
        $("#c2").fadeIn("fast");
 	}, function() {
        $("#c2").fadeOut("fast");		
 	}); 
	$(".c-link3").hover(function(){
        $("#c3").fadeIn("fast");
 	}, function() {
        $("#c3").fadeOut("fast");		
 	}); 
	$(".c-link4").hover(function(){
        $("#c4").fadeIn("fast");
 	}, function() {
        $("#c4").fadeOut("fast");		
 	}); 
	$(".c-link5").hover(function(){
        $("#c5").fadeIn("fast");
 	}, function() {
        $("#c5").fadeOut("fast");		
 	}); 
	$(".c-link6").hover(function(){
        $("#c6").fadeIn("fast");
 	}, function() {
        $("#c6").fadeOut("fast");		
 	}); 
	$(".c-link7").hover(function(){
        $("#c7").fadeIn("fast");
 	}, function() {
        $("#c7").fadeOut("fast");		
 	}); 
	$(".c-link8").hover(function(){
        $("#c8").fadeIn("fast");
 	}, function() {
        $("#c8").fadeOut("fast");		
 	}); 
	$(".c-link9").hover(function(){
        $("#c9").fadeIn("fast");
 	}, function() {
        $("#c9").fadeOut("fast");		
 	}); 
	$(".c-link10").hover(function(){
        $("#c10").fadeIn("fast");
 	}, function() {
        $("#c10").fadeOut("fast");		
 	}); 
	$(".c-link11").hover(function(){
        $("#c11").fadeIn("fast");
 	}, function() {
        $("#c11").fadeOut("fast");		
 	}); 
	$(".c-link12").hover(function(){
        $("#c12").fadeIn("fast");
 	}, function() {
        $("#c12").fadeOut("fast");		
 	});
	$(".c-link13").hover(function(){
        $("#c13").fadeIn("fast");
 	}, function() {
        $("#c13").fadeOut("fast");		
 	}); 
	$(".c-link14").hover(function(){
        $("#c14").fadeIn("fast");
 	}, function() {
        $("#c14").fadeOut("fast");		
 	}); 
	$(".c-link15").hover(function(){
        $("#c15").fadeIn("fast");
 	}, function() {
        $("#c15").fadeOut("fast");		
 	}); 
	$(".c-link16").hover(function(){
        $("#c16").fadeIn("fast");
 	}, function() {
        $("#c16").fadeOut("fast");		
 	}); 
	$(".c-link17").hover(function(){
        $("#c17").fadeIn("fast");
 	}, function() {
        $("#c17").fadeOut("fast");		
 	}); 
	$(".c-link18").hover(function(){
        $("#c18").fadeIn("fast");
 	}, function() {
        $("#c18").fadeOut("fast");		
 	});
	$(".c-link19").hover(function(){
        $("#c19").fadeIn("fast");
 	}, function() {
        $("#c19").fadeOut("fast");		
 	}); 
	$(".c-link20").hover(function(){
        $("#c20").fadeIn("fast");
 	}, function() {
        $("#c20").fadeOut("fast");		
 	}); 
	$(".c-link21").hover(function(){
        $("#c21").fadeIn("fast");
 	}, function() {
        $("#c21").fadeOut("fast");		
 	}); 
	$(".c-link22").hover(function(){
        $("#c22").fadeIn("fast");
 	}, function() {
        $("#c22").fadeOut("fast");		
 	}); 
	$(".c-link23").hover(function(){
        $("#c23").fadeIn("fast");
 	}, function() {
        $("#c23").fadeOut("fast");		
 	}); 
	$(".c-link24").hover(function(){
        $("#c24").fadeIn("fast");
 	}, function() {
        $("#c24").fadeOut("fast");		
 	});
	$(".c-link25").hover(function(){
        $("#c25").fadeIn("fast");
 	}, function() {
        $("#c25").fadeOut("fast");		
 	}); 
	$(".c-link26").hover(function(){
        $("#c26").fadeIn("fast");
 	}, function() {
        $("#c26").fadeOut("fast");		
 	}); 
	$(".c-link27").hover(function(){
        $("#c27").fadeIn("fast");
 	}, function() {
        $("#c27").fadeOut("fast");		
 	}); 		
});

//ext link
$(document).ready(function() {
        $('a').filter(function() {
         return this.hostname && this.hostname !== location.hostname;
        }).addClass('externalLink');	
});

jQuery(function($){
	
	// addSizes was written by Natalie Downe 
	// http://natbat.net/2008/Aug/27/addSizes/
	
	// Copyright (c) 2008, Natalie Downe under the BSD license
	// http://www.opensource.org/licenses/bsd-license.php
	
	$('a[href$=".pdf"], a[href$=".doc"], a[href$=".mp3"], a[href$=".jpg"], a[href$=".png"], a[href$=".swf"], a[href$=".zip"], a[href$=".ogg"], a[href$=".m4u"]').each(function(){
		// looking at the href of the link, if it contains pdf, doc, zip, mp3, ogg, m4u, jpg, png, swf
		var link = $(this);
		var bits = this.href.split('.');
		var type = bits[bits.length -1];
		
		var url= "http://json-head.appspot.com/?url="+encodeURIComponent (this.href)+"&callback=?";
		//console.log(url);
	
		// then call the json thing and insert the size back into the link text
		 $.getJSON(url, function(json){
			if(json.ok && json.headers['Content-Length']) {
				var length = parseInt(json.headers['Content-Length'], 10);
				
				// divide the length into its largest unit
				var units = [
					[1024 * 1024 * 1024, 'GB'],
					[1024 * 1024, 'MB'],
					[1024, 'KB'],
					[1, 'bytes']
				];
				
				for(var i = 0; i < units.length; i++){
					
					var unitSize = units[i][0];
					var unitText = units[i][1];
					
					if (length >= unitSize) {
						length = length / unitSize;
						// 1 decimal place
						length = Math.ceil(length * 10) / 10;
						var lengthUnits = unitText;
						break;
					}
				}
				
				// insert the text directly after the link and add a class to the link
				// note: if you want to insert the size into the link rather than after it change the following 'after' to 'append'
				link.after(' <span class="quiet small">(' + type + ' ' + length + ' ' + lengthUnits + ')</span>');
				link.addClass(type);
			}
		});
	});
});
