// 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("body")[0].appendChild(fileref)
}




background = new Image(980,680)
background.src = "Background.swf"

leftArrowOff = new Image(5,11)
leftArrowOff.src = "images-generic/left-arrow-off.gif"

rightArrowOff = new Image(5,11)
rightArrowOff.src = "images-generic/right-arrow-off.gif"

tab1 = new Image(69,40)
tab1.src = "images-generic/tab1.gif"

tab2 = new Image(69,40)
tab2.src = "images-generic/tab2.gif"

tab3 = new Image(103,40)
tab3.src = "images-generic/tab3.gif"

tab4 = new Image(103,40)
tab4.src = "images-generic/tab4.gif"

tab5 = new Image(103,40)
tab5.src = "images-generic/tab5.gif"

tab1 = new Image(69,40)
tab1.src = "images-generic/tab1.gif"

linkArrowOff = new Image(5,11)
linkArrowOff.src = "images-generic/link-arrow-off.gif"

linkArrowOn = new Image(5,11)
linkArrowOn.src = "images-generic/link-arrow-on.gif"

capper = new Image(980,17)
capper.src = "images-generic/capper.gif"

tabbedPanel2BG = new Image(412,250)
tabbedPanel2BG.src = "images-generic/tabbed-panel2-bg.gif"

jobsTop = new Image(412,10)
jobsTop.src = "images-generic/jobs-top.gif"

teamTop = new Image(412,10)
teamTop.src = "images-generic/team-top.gif"

blogTop = new Image(412,10)
blogTop.src = "images-generic/blog-top.gif"

testimonialsTop = new Image(412,10)
testimonialsTop.src = "images-generic/testimonials-top.gif"

ajaxLoader = new Image(31,31)
ajaxLoader.src = "portfolio/images/ajaxloadr.gif"


function validate_contact_form(form)
{
	var return_value = false;
	if(form.realname.value == "")
	{
		alert("Please enter your name");
		form.realname.focus();
	}
	else if(form.email.value == "" && form.telephone.value == "")
	{
		alert("Please enter your email address or telephone number");
		form.email.focus();
	}
	else
	{
		return_value = true;
	}
	return return_value;
}








var currentBackground="briefcase";

function setCurrentBackground(newBackground)
{
	currentBackground = newBackground;
	SendDataToFlashMovie(newBackground);
}

function getFlashMovieObject(movieName)
{
	if (window.document[movieName])
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
		return document.embeds[movieName];
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
		return document.getElementById(movieName);
	}
}

function SendDataToFlashMovie(newBackground)
{
	var flashMovie=getFlashMovieObject("Background");
	flashMovie.changeBackground(newBackground);
}




// JQUERY -----------------------


$(document).ready(function() {
	
	
	function homePortfolio() {
		jQuery("#portfolio1").load("portfolio/portfolio1.html", function() {
			//alert("Portfolio 4 loaded.");
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 3000, 
				next:   '.mainRightArrow', 
				prev:   '.mainLeftArrow' 
			});
		});
	}
	homePortfolio();
	jQuery(".doHomePortfolio").click(function() {
		homePortfolio();
	});
	
	function graphicsPortfolio() {
		TabbedPanels3.showPanel(27);
		jQuery("#portfolio2").empty();
		jQuery("#portfolio2").load("portfolio/portfolio2.html", function() {
			//alert("Portfolio 4 loaded.");
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '#rightArrow2', 
				prev:   '#leftArrow2'
			});
		});
	}
	jQuery(".doGraphicsPortfolio").click(function() { // 
		graphicsPortfolio();				
	});
	
	function exhibPortfolio() {
		TabbedPanels3.showPanel(27);
		jQuery("#portfolio2").empty();
		jQuery("#portfolio2").load("portfolio/portfolio4.html", function() {
			//alert("Portfolio 4 loaded.");
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '#rightArrow2', 
				prev:   '#leftArrow2' 
			});
		});
	}
	jQuery(".doExhibPortfolio").click(function() { // 
		exhibPortfolio();				
	});
	
	function webPortfolio() {
		TabbedPanels3.showPanel(27);
		jQuery("#portfolio2").empty();
		jQuery("#portfolio2").load("portfolio/portfolio3.html", function() {
			//alert("Portfolio 3 loaded.");
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '#rightArrow2', 
				prev:   '#leftArrow2' 
			});
		});
	}
	jQuery(".doWebPortfolio").click(function() { // 
		webPortfolio();				
	});
	
	function logoPortfolio() {
		TabbedPanels3.showPanel(27);
		jQuery("#portfolio2").empty();
		jQuery("#portfolio2").load("portfolio/portfolio5.html", function() {
			//alert("Portfolio 5 loaded.");
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '#rightArrow2', 
				prev:   '#leftArrow2' 
			});
		});
	}
	jQuery(".doLogoPortfolio").click(function() { // 
		logoPortfolio();				
	});
	
	
	
	
	
	function about() {
		jQuery("#aboutcarousel").empty();
		jQuery("#aboutcarousel").load("about-us/about-content.html", function() {
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '.aboutRightArrow', 
				prev:   '.aboutLeftArrow' 
			});
		});
	}
	jQuery("#aboutTab").click(function() { // 
		about();				
	});
	
	function labfab() {
		jQuery("#aboutcarousel").empty();
		jQuery("#aboutcarousel").load("news-extra/labfab-content.html", function() {
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '.aboutRightArrow', 
				prev:   '.aboutLeftArrow' 
			});
		});
	}
	jQuery("#labFabLink").click(function() { // 
		labfab();				
	});
	
	function dden() {
		jQuery("#aboutcarousel").empty();
		jQuery("#aboutcarousel").load("news-extra/dragons-den-content.html", function() {
			jQuery(this).cycle({ 
				fx:     'scrollHorz', 
				speed:  '500', 
				timeout: 0, 
				next:   '.aboutRightArrow', 
				prev:   '.aboutLeftArrow' 
			});
		});
	}
	jQuery("#ddenLink").click(function() { // 
		dden();				
	});
	
	
	
	
	
	
	/* BOTTOM ROTATORS / SLIDERS */
	
	var testimonialsCycle = true;
	var newsCycle = false;
	var twitterCycle = false;
	var teamCycle = false;
	var jobsCycle = false;
	
	var isIE = jQuery.browser.msie;
	
	function slideTestimonials() {
		jQuery(".belt6").cycle({ 
			fx:     'scrollHorz', 
			speed:  '500', 
			timeout: 15000, 
			next:   '.bottomArrowRight', 
			prev:   '.bottomArrowLeft' 
		});
	}
	slideTestimonials();
	jQuery("#testimonialsTab").click(function() { // 
		if (testimonialsCycle == false) {
			if (isIE) {
				var t=setTimeout(slideTestimonials,10);
			} else {
				slideTestimonials();
			}
			testimonialsCycle = true;
		}
	});
	
	function slideNews() {
		//alert("slideNews");
		jQuery(".belt7").cycle({ 
			fx:     'scrollHorz', 
			speed:  '500', 
			timeout: 13000, 
			next:   '.bottomArrowRight', 
			prev:   '.bottomArrowLeft' 
		});
	}
	jQuery("#newsTab").click(function() { // 
		if (newsCycle == false) {
			if (isIE) {
				var t=setTimeout(slideNews,10);
			} else {
				slideNews();
			}
			newsCycle = true;
		}				
	});
	
	function slideTeam() {
		jQuery(".belt8").cycle({ 
			fx:     'scrollHorz', 
			speed:  '500', 
			timeout: 13000, 
			next:   '.bottomArrowRight', 
			prev:   '.bottomArrowLeft' 
		});
	}
	jQuery("#teamTab").click(function() { // 
		if (teamCycle == false) {
			if (isIE) {
				var t=setTimeout(slideTeam,10);
			} else {
				slideTeam();
			}
			teamCycle = true;
		}				
	});
	
	function slideJobs() {
		jQuery(".belt9").cycle({ 
			fx:     'scrollHorz', 
			speed:  '500', 
			timeout: 3000, 
			next:   '.bottomArrowRight', 
			prev:   '.bottomArrowLeft' 
		});
	}
	jQuery("#jobsTab").click(function() { // 
		if (jobsCycle == false) {
			if (isIE) {
				var t=setTimeout(slideJobs,10);
			} else {
				slideJobs();
			}
			jobsCycle = true;
		}				
	});
	
	function slideTwitter() {
		jQuery(".belt13").cycle({ 
			fx:     'scrollHorz', 
			speed:  '500', 
			timeout: 3000, 
			next:   '.bottomArrowRight', 
			prev:   '.bottomArrowLeft' 
		});
	}
	jQuery("#twitterTab").click(function() { // 
		if (twitterCycle == false) {
			if (isIE) {
				var t=setTimeout(slideTwitter,10);
			} else {
				slideTwitter();
			}
			twitterCycle = true;
		}				
	});

	
});


$(window).load(function() {
	
	
	
});


$(window).unload(function() {
	GUnload();
});





