var port_selector = 'portfolio';
var serv_selector = 'port_services';

function clearActive(){
	$("li h5").removeClass("active");
	$("#body_video_description").empty();
}

$(document).ready(function(){
	
	
	$(".video_button").click(function(event){
		var button_caller = $(this).attr("id");
		//document.getElementById('flashContent').innerHTML = $("#" + button_caller + "_embed").html();
		//alert( $("#" + button_caller + "_embed").html());
		$("#flashContent").html($("#" + button_caller + "_embed").html());
		//$("#flashContent").empty();
		//$("#flashContent").append($("#" + button_caller + "_embed"));
	});
	$(".video_button").hover(function(){
		var button_caller = $(this).attr("id");
		$("#body_video_description").empty();
		document.getElementById('body_video_description').innerHTML = $("#" + button_caller + "_description").html()
		//$("#body_video_description").html($("#" + button_caller + "_description").html());
		//$("#body_video_description").empty();
		//$("#body_video_description").append($("#" + button_caller + "_description"));
	});
	
	
	//Portfolio jQuery
	$("#portfolio").click(function(event){
		clearActive();
		$("#" + port_selector + "_buttons").hide();
		port_selector = $(this).attr("id");
		$("#" + port_selector + "_buttons").show();
		//$("#body_top_bar").empty();
		//$("#body_top_bar").append("<h1>Portfolio</h1>");
		//document.getElementById('body_top_bar').innerHTML = "<h1>Portfolio</h1>";
		$("#body_top_bar").html("<h1>Portfolio</h1>");
		$("#" + port_selector + " h5").addClass("active");
	});

	$("#broadcast").click(function(event){
		clearActive();
		$("#" + port_selector + "_buttons").hide();
		port_selector = $(this).attr("id");
		$("#" + port_selector + "_buttons").show();
		
		//$("#body_top_bar").empty();
		//$("#body_top_bar").append("<h1>Broadcast</h1>");
		$("#body_top_bar").html("<h1>Broadcast</h1>");
		$("#" + port_selector + " h5").addClass("active");
	});
	$("#corporate").click(function(event){
		clearActive();
		$("#" + port_selector + "_buttons").hide();
		port_selector = $(this).attr("id");
		$("#" + port_selector + "_buttons").show();
		
		//$("#body_top_bar").empty();
		//$("#body_top_bar").append("<h1>Corporate</h1>");
		$("#body_top_bar").html("<h1>Corporate</h1>");
		$("#" + port_selector + " h5").addClass("active");
	});
	$("#commercial").click(function(event){
		clearActive();
		$("#" + port_selector + "_buttons").hide();
		port_selector = $(this).attr("id");
		$("#" + port_selector + "_buttons").show();
		
		//$("#body_top_bar").empty();
		//$("#body_top_bar").append("<h1>Commercial</h1>");
		$("#body_top_bar").html("<h1>Commercial</h1>");
		$("#" + port_selector + " h5").addClass("active");
	});

	
	//Services
	$("#port_services").click(function(event){
		clearActive();
		$("#" + serv_selector + "_buttons").hide();
		serv_selector = $(this).attr("id");
		$("#" + serv_selector + "_buttons").show();
		
		$("#body_top_bar").html("<h1>What do we do?</h1>");
		$("#" + port_selector + " h5").addClass("active");
	});
	$("#port_corporate").click(function(event){
		clearActive();
		$("#" + serv_selector + "_buttons").hide();
		serv_selector = $(this).attr("id");
		$("#" + serv_selector + "_buttons").show();
		
		$("#body_top_bar").html("<h1>Corporate Video</h1>");
		$("#" + serv_selector + " h5").addClass("active");
	});
	$("#port_television").click(function(event){
		clearActive();
		$("#" + serv_selector + "_buttons").hide();
		serv_selector = $(this).attr("id");
		$("#" + serv_selector + "_buttons").show();
		
		$("#body_top_bar").html("<h1>Television Production</h1>");
		$("#" + serv_selector + " h5").addClass("active");
	});
	$("#port_commercials").click(function(event){
		clearActive();
		$("#" + serv_selector + "_buttons").hide();
		serv_selector = $(this).attr("id");
		$("#" + serv_selector + "_buttons").show();
		
		$("#body_top_bar").html("<h1>Commercials</h1>");
		$("#" + serv_selector + " h5").addClass("active");
	});
	$("#port_facilities").click(function(event){
		clearActive();
		$("#" + serv_selector + "_buttons").hide();
		serv_selector = $(this).attr("id");
		$("#" + serv_selector + "_buttons").show();
		
		$("#body_top_bar").html("<h1>Facilities</h1>");
		$("#" + serv_selector + " h5").addClass("active");
	});




	//$("#video_body").corner();
	//$("#body_content").corner();
   $("#why_video").click(function(event){
   	 clearActive();
     $("#description").html($("#why_video_description").html());
	 $("#why_video h5").addClass("active");
   });
   $("#how_much").click(function(event){
   	 clearActive();
     $("#description").html($("#how_much_description").html());
	 $("#how_much h5").addClass("active");
   });
   $("#meaning").click(function(event){
   	 clearActive();
     $("#description").html($("#meaning_description").html());
	 $("#meaning h5").addClass("active");
   });
   $("#how_happen").click(function(event){
   	 clearActive();
     $("#description").html($("#how_happen_description").html());
	 $("#how_happen h5").addClass("active");
   });
   $("#first_meeting").click(function(event){
   	 clearActive();
     $("#description").html($("#first_meeting_description").html());
	 $("#first_meeting h5").addClass("active");
   });
   $("#creative").click(function(event){
   	 clearActive();
     $("#description").html($("#creative_description").html());
	 $("#creative h5").addClass("active");
   });
   $("#budgeting").click(function(event){
   	 clearActive();
     $("#description").html($("#budgeting_description").html());
	 $("#budgeting h5").addClass("active");
   });
   $("#project_production").click(function(event){
   	 clearActive();
     $("#description").html($("#project_production_description").html());
	 $("#project_production h5").addClass("active");
   });
   $("#pre_production").click(function(event){
   	 clearActive();
     $("#description").html($("#pre_production_description").html());
	 $("#pre_production h5").addClass("active");
   });
   $("#production").click(function(event){
   	 clearActive();
     $("#description").html($("#production_description").html());
	 $("#production h5").addClass("active");
   });
   $("#post_production").click(function(event){
   	 clearActive();
     $("#description").html($("#post_production_description").html());
	 $("#post_production h5").addClass("active");
   });
   
 });

jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};


