// JavaScript Document

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

loadjscssfile("http://www.bbdimension.co.uk/style/js/jquery.corner.js", "js") //dynamically load "javascript.php" as a JavaScript file
loadjscssfile("http://www.bbdimension.co.uk/style/js/slimbox/css/slimbox2.css", "css") ////dynamically load and add this .css file
loadjscssfile("http://www.bbdimension.co.uk/style/js/slimbox/js/slimbox2.js", "js") //dynamically load "javascript.php" as a JavaScript file
loadjscssfile("http://www.bbdimension.co.uk/style/js/jquery.tweet.js", "js") //dynamically load "javascript.php" as a JavaScript file
loadjscssfile("http://www.bbdimension.co.uk/style/js/dropCurves.js", "js") //dynamically load "javascript.php" as a JavaScript file

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

$(document).ready(function(){
	
	$('#dropmenu ul').css({
		display: "none",
		left: "auto"
	});
	$('#dropmenu').hover(function() {
		$(this)
			.find('ul')
			.stop(true, true)
			.slideDown('fast');
	}, function() {
		$(this)
			.find('ul')
			.stop(true,true)
			.fadeOut('fast');
	});
	
	$('.show-project').insertBefore('#tabs');
	$('.show-project').hide();
	$('.projectlink').click(function(){
		$('.show-project').animate({
			opacity: 'show',
			//height: '+=300px',
			marginTop: '20%'
		}, 200)
			
	});

	function fade_in(e){
		$(e).fadeIn('slow',function(){
			if($(e).next().length > 0){
				setTimeout(function(){fade_in($(e).next());},700);
			}
		});
	}
	fade_in($('.project-container:first-child'));
	
	$('.project-info').hide();
	
});
