$(document).ready(function(){
	
	/***
	*
	* Contact rotator
	*
	*/
	
	var crTimer;
	var contactShowingNum = 0;
	var contactNumOfItems = $("#studioContact li").length;
	
	contactRotate = function(){
		$('#studioContact li').eq(contactShowingNum).fadeOut("200", function(){
			contactShowingNum++;
			if (contactShowingNum == contactNumOfItems) contactShowingNum = 0;
			$('#studioContact li').eq(contactShowingNum).fadeIn("200");
		});
		
		crTimer = setTimeout("contactRotate()", 4000);	
	}
	
	crTimer = setTimeout("contactRotate()", 4000);	
	
	
	/*
	*
	* Input Label
	*
	*/
	
	$("div.inputHide").each(function(index){
		var inputBox = $(this).children("input");
		var label = $(this).children("label");
		
		if (inputBox.val() == "") {
			label.show();
		}
		inputBox.keydown(function(){
			label.hide();
		});
		inputBox.click(function(){
			label.hide();
		});
		label.click(function(){
			label.hide();
			inputBox.focus();
		});
		inputBox.blur(function(){
			if ($(this).val() == "") {
				label.show();
			}
		});
	});
	
	
	/*
	*
	* Youtube overlay fix. 
	* Checks for any query strings on the end of the video URL, stores this and appends onto the end of WMODE.
	* 
	*/
	
	$("iframe").each(function(){
		var ifr_source = $(this).attr('src');
		if(ifr_source.indexOf("youtube.com") != -1) {
			var wmode = "wmode=transparent";
			if(ifr_source.indexOf('?') != -1) {
				var getQString = ifr_source.split('?');
				var oldString = getQString[1];
				var newString = getQString[0];
				$(this).attr('src',newString+'?'+wmode+'&'+oldString);
			}
			else $(this).attr('src',ifr_source+'?'+wmode);
		}
	});
});
