//FLASH SETUP
	//Background SWF
	var flashvars = {};
	var attributes = { styleClass: "flash-object"};
	var params = {wmode: "transparent", movie: "/assets/flash/background.swf"};
	swfobject.embedSWF("/assets/flash/background.swf", "flash-bg", "100%", "100%", "9.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);

	function initFlashMovies(){
		//Portal Gun SWF
		params = {wmode: "transparent", movie: "/assets/flash/portal.swf", allowfullscreen: "true"};
		swfobject.embedSWF("/assets/flash/portal.swf", "portalGun-flash", "600", "375", "9.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);
		//Headkickers SWF
		params = {wmode: "transparent", movie: "/assets/flash/headkickers.swf", allowfullscreen: "true"};
		swfobject.embedSWF("/assets/flash/headkickers.swf", "headkickers-flash", "600", "375", "9.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);
		//Betaman SWF
		params = {wmode: "transparent", movie: "/assets/flash/itguy.swf", allowfullscreen: "true"};
		swfobject.embedSWF("/assets/flash/itguy.swf", "betaman-flash", "600", "375", "9.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);
	}

//JQUERY SETUP
	$(function() {	
		$('#message').slideUp();
		$.localScroll( {
			target: this, 
			duration: 2000,
			easing: 'easeInOutExpo',
			axis: 'y',
			queue: true
		});
		$('.work-item-content, acronym').tooltip({
			track: true,
			delay: 500,
			showURL: false,
			fade: 250
		});
		$('#item1').cycle({ 
			fx:     'fade', 
			speed:   300, 
			next:   '#item1',
			timeout: 3000,
			pause: 1
		});		
		$('#item2').cycle({ 
			fx:     'fade', 
			speed:   300, 
			next:   '#item2',
			timeout: 3000,
			pause: 1
		});		
		$('#item3').cycle({ 
			fx:     'fade', 
			speed:   300, 
			next:   '#item3',
			timeout: 3000,
			pause: 1
		});		
		$('#item4').cycle({ 
			fx:     'fade', 
			speed:   300, 
			next:   '#item4',
			timeout: 3000,
			pause: 1
		});		
		$('#item5').cycle({ 
			fx:     'fade', 
			speed:   300, 
			next:   '#item5',
			timeout: 3000,
			pause: 1
		});		
		$('#contact_form').ajaxForm({ 
			 target: '#message',
			 clearForm: true,
			 resetForm: true,
			 beforeSubmit: validate
		});	
		initFlashMovies();

	//AJAX and Icons

	/*	$('#work-col span.icon').hide();

		$('#work-col div').bind("mouseenter",

			function() {

					var name = $(this).attr("id");

					$('#'+name+' span.icon').fadeIn();

			}

		);

		$('#work-col div').bind("mouseleave",

			function() {

					name = $(this).attr("id");

					if (!$('#'+name+' span.icon').hasClass('hovered'))

						$('#'+name+' span.icon').fadeOut();

			}

		);*/

	});	



//VALIDATION	



	function validate(formData, jqForm, options) { 
		var nameValue = $('input[@name=Name]').fieldValue(); 
		var emailValue = $('input[@name=Email]').fieldValue();

		var checkValue = $('input[@name=Check]').fieldValue();

		var commentsValue = document.getElementById('Comments').value;

	 	var errorItems = [];



		document.getElementById('Name').className = "form-input";

		document.getElementById('Email').className = "form-input";

		document.getElementById('Check').className = "form-input";

		document.getElementById('Comments').className = "form-textarea";



		if (!nameValue[0])

			errorItems.push("Name");

		if (!emailValue[0] || emailValue[0].indexOf('@') == 0 || emailValue[0].indexOf('@') == 1 || emailValue[0].indexOf('@') == emailValue[0].length || !emailValue[0].indexOf('.') || emailValue[0].lastIndexOf('.') == emailValue[0].length || emailValue[0].lastIndexOf('.') == emailValue[0].indexOf('@'))

			errorItems.push("Email");

		if (!commentsValue[0])

			errorItems.push("Comments");

		if (!checkValue[0] || checkValue[0]!="t")

			errorItems.push("Check");



		for (var i=0; i<errorItems.length; i++) {

			var errorItem = errorItems[i];

			switch (errorItem){

				case "Name":

					document.getElementById('Name').className = "form-input form-error";

					break;

				case "Email":

					document.getElementById('Email').className = "form-input form-error";

					break;

				case "Comments":

					document.getElementById('Comments').className = "form-textarea form-error";	

					break;

				case "Check":

					document.getElementById('Check').className = "form-input form-error";

					break;

			}

		}



		if (errorItems.length > 0){

			setFormMessage("Please complete the highlighted fields.");

			return false;

		}else

			return true;

	}		



	function setFormMessage(str) {

		$('#message').html('<div class="errormessage">'+str+'</div>'); 

		$('#message').slideDown();

	}







//LINKS	



	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.getAttribute("rel") == "pdf" || anchor.getAttribute("rel") == "word"))

				anchor.target = "_blank";

		}

	}



	window.onload = externalLinks;

	

	

	

//sIFR

//<![CDATA[



if(typeof sIFR == "function"){



// This is the preferred "named argument" syntax

	sIFR.replaceElement(named({sSelector:"h2", sFlashSrc:"/assets/flash/chaparralPro.swf", sColor:"#ffffff", sLinkColor:"#ffffff", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode: "transparent", sFlashVars:""}));

	sIFR.replaceElement(named({sSelector:".work-item h3, #contact h3, #about h3, #home h3", sFlashSrc:"/assets/flash/chaparralPro.swf", sColor:"#000000", sLinkColor:"#F4AF41", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode: "transparent", sFlashVars:""}));

	sIFR.replaceElement(named({sSelector:".work-item h4, #home h4", sFlashSrc:"/assets/flash/chaparralPro.swf", sColor:"#3259ca", sLinkColor:"#3259ca", sBgColor:"#000000", sHoverColor:"#000000", nPaddingTop:0, nPaddingBottom:0, sWmode: "transparent", sFlashVars:""}));

	sIFR.replaceElement(named({sSelector:"#subtitle", sFlashSrc:"/assets/flash/chaparralPro.swf", sColor:"#F4AF41", sLinkColor:"#F4AF41", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode: "transparent", sFlashVars:""}));



};



//]]>



