$(document).ready(function() {	
	
						   
	$('body').addClass('js');	
	
	/****
	 Insert Flash header
	****************************/
	var sl = new SWFObject("flash/header.swf?v=2", "daHeader", "960", "400", "8", "#000");
	sl.addParam("wmode","transparent");
	sl.write("header");
		
	
	/****
	 Insert Flash porfolio
	****************************/
	var so = new SWFObject("flash/work.swf?v=6", "daWork", "960", "392", "8", "#000000");
	so.addParam("wmode","transparent");
	so.addVariable("menucontent", escape(portyHTML));
	so.write("work");
	
	
	
	/****
	 Carousel - who we are
	****************************/
	
	// init carousel
	$('#who ul').jcarousel({
		scroll: 1		
	});		
	
	
	/***
	 Carousel - clients
	****************************/
	
	// add fade/rollover areas
	$('#clients .wrap_inner').prepend('<div class="fadeRight"></div>');
	$('#clients .wrap_inner').prepend('<div class="fadeLeft"></div>');	
	//$('#clients .wrap_inner').wrapInner('<div class="fadeLeft"><div class="fadeRight"></div></div>');
	
	
	// rollover function
	function clientCarousel_initCallback(carousel) {
		$('#clients ul').mouseover(function(){
			carousel.stopAuto();				  
		}).mouseout(function(){
      		carousel.startAuto();
    	});
	}
	
	// init carousel
	$('#clients ul').jcarousel({
		scroll: 1,
		/*visible: 5,*/
		wrap: 'last',
		auto: 3,
		animation: 1000,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		initCallback: clientCarousel_initCallback
	});
	
	// open client links in new window/tab (the standards way - well, sorta ;)
	$("#wrap a[rel='external']").attr("target","_blank");	
	
	/***
	 Tooltips
	****************************/	
	$('#clients a.tooltip').cluetip({
		splitTitle: '|',
		tracking: true,
		dropShadow: true,
		arrows: true,
		positionBy: 'mouse',		
		width:150,
		clickThrough: true

	});
	
	/***
	 Select Box
	****************************/	
	$('#findus').selectbox(); 
	
	
	/***
	 Form validation
	****************************/
	
	// extend the validating rules:
	// this one requires the value to be the same as the first parameter
	$.validator.methods.equal = function(value, element, param) {
		return value == param;
	}
	
	// calculate easy equation
	var answer = eval($("#contactForm .rnd1").text()) + eval($("#contactForm .rnd2").text());
	
	// validate signup form on keyup and submit
	$("#contactForm").validate({
		rules: {
			name: {
				required: true,
				minlength: 2
			},		
			email: {
				required: true,
				email: true
			},
			phone: {
				minlength: 10
			},
			enquiry: {
				required: true,
				minlength: 20
			},
			question: {
				equal: answer				
			}
		},
		messages: {
			name: {
				required: "please enter your name",
				minlength: "your name must consist of at least 2 characters"
			},			
			email: "please enter a valid email address",
			phone: {
				minlength: "your phone number should consist of at least 10 digits"
			},
			enquiry: {
				required: "please enter your enquiry",
				minlength: "your enquiry must contain at least 20 characters"
			},
			question: {
				equal: "please enter the correct result"	
			}
		}
	});
	
	// if ie6, pngfix!
	if(typeof document.body.style.maxHeight === "undefined") { $(document).pngFix(); }
	
	
});



