$(document).ready(function(){

/* --- Styles --- */

/* -- Section -- */

/* - About - */

if ($.browser.msie && $.browser.version <= 7 ) { 
	$('div.aboutSlide').css({'position': 'static'});
	$('div.aboutSlide div.buttons').hide();
}

/* - Projects - */

if ($.browser.msie && $.browser.version <= 7 ) { 
 $('div.projects div.column:first-child').addClass('firstChild');
	$('div.projects div#title, div.work div#title').css({'position': 'static'});
	$('div.projects div#title div.right, div.work div#title div.right').css({'position': 'static', 'padding': '0 0 0 112px'});
}

/* - Share - */

if ($.browser.msie && $.browser.version <= 7 ) { 
	$('div#share, div.section').css({'position': 'static'});
}

/* --- Functions --- */

/* --- Header --- */

/* -- Home -- */

var homeButton = $('a.home');

homeButton.hover(
 function(){
		$(this).fadeTo('fast', 0.6);
	},
 function(){
		$(this).fadeTo('fast', 1);
	}
);

/* -- Nav -- */

var aboutButton = $('span.about');
var contactButton = $('span.contact');
var aboutSection = $('div.about');
var contactSection = $('div.contact');

aboutButton.toggle(
	function(){
  if(contactSection.is(':visible')){ contactButton.trigger('click'); aboutSection.delay(600).slideDown('slow'); $('body').addClass('about'); }
		else { aboutSection.slideDown('slow'); $('body').addClass('about'); }
	},
	function(){
  aboutSection.slideUp('slow');
		$('body').removeClass('about');
	}
);

contactButton.toggle(
	function(){
  if(aboutSection.is(':visible')){ aboutButton.trigger('click'); contactSection.delay(800).slideDown('normal'); $('body').addClass('contact'); }
		else { contactSection.slideDown('normal'); $('body').addClass('contact'); }
	},
	function(){
  contactSection.slideUp('normal');
		$('body').removeClass('contact');
	}
);

/* -- Menu -- */

var menu = $('div#menu span');
var subMenu = $('div#menu ul');
var subMenuItems = $('div#menu ul li');

menu.toggle(
	function(){
		$('body').addClass('projects');
		subMenu.slideDown('fast', function(){
			subMenuItems.css({'visibility': 'visible'});
			subMenuItems.hide();
			subMenuItems.fadeIn('fast');
		});
	},
	function(){
		$('body').removeClass('projects');
		subMenuItems.fadeOut('fast', function(){
			subMenu.slideUp('fast');
			subMenuItems.css({'visibility': 'hidden'});
			subMenuItems.show();
		});
});

/* --- Section --- */

/* -- About -- */

/* - Slide - */

var aboutSlideItem = $('div.aboutSlide div.item');
var aboutSlideSize = aboutSlideItem.length - 1;
var aboutSlideSelected = 0;
var aboutSlideWrapper = $('div.aboutSlide div.slideWrapper');
var aboutSlideWrapperWidth = (aboutSlideSize + 1) * 346;
var aboutPrev = $('div.aboutSlide span.prev');
var aboutNext = $('div.aboutSlide span.next');

aboutSlideWrapper.width(aboutSlideWrapperWidth);
aboutPrev.css({'cursor': 'default'});

aboutNext.click(function(event){
	if(aboutSlideSelected < aboutSlideSize){
	 aboutSlideItem.eq(aboutSlideSelected).animate({'margin-left': '-146px'}, 'slow');
  aboutSlideSelected++;
	}
	if(aboutSlideSelected == aboutSlideSize){
		$(this).css({'cursor': 'default'});
	}
	aboutPrev.css({'cursor': 'pointer'});
});

aboutPrev.click(function(event){
	if(aboutSlideSelected != 0){
	 aboutSlideSelected--;
		aboutSlideItem.eq(aboutSlideSelected).animate({'margin-left': '0px'}, 'slow');
	}
	if(aboutSlideSelected == 0){
		$(this).css({'cursor': 'default'});
	}
	aboutNext.css({'cursor': 'pointer'});
});

/* -- Contact -- */

/* - Hide email - */

$('a.mailTo').each(function(){
	$('a.mailTo').attr('href', function(index, value){ return (value).replace('(at)','@').replace('(dot)','.').replace('(dot)','.'); });
	$('a.mailTo').text(function(index, text) { return (text).replace('(at)','@').replace('(dot)','.').replace('(dot)','.'); });
});

/* -- Home -- */

/* - Random image - */

var rand = Math.ceil(Math.random()*2)
var title = $('div#title');

switch(rand){
 case 1:
 title.css({'background-position': 'right 0px'});
	break;
	case 2:
 title.css({'background-position': 'right -38px'});
	break;
}

/* - Hover - */

// Works in projects too.

var thumbnailWork = $('div.box a img');

thumbnailWork.hover(
 function(){
		$(this).fadeTo('fast', 0.8);
	},
 function(){
		$(this).fadeTo('fast', 1);
	}
);

/* -- Projects -- */

/* - Categories - */

var categoryButton = $('div#title h2 span');
var tagButton = $('div.projects p span');
var tagButtonTitle = $('div.projects div#title p span');
var projectsItem = $('div.projects div.items div.categoryAndTags');
var wrapperClass = $('div#wrapper');

wrapperClass.ready(function(){
	if(wrapperClass.hasClass('')) {
	 wrapperClass.addClass('all');
	}
	var categoryClass = wrapperClass.attr('class');
	if(wrapperClass.hasClass('all')){
		projectsItem.fadeTo('fast', 1);
	} else {
		projectsItem.each(function() {
			if($(this).hasClass(categoryClass)){
				$(this).fadeTo('fast', 1);
			} else {
				$(this).fadeTo('fast', 0.2);
			}
		});
		tagButtonTitle.each(function() {
			if($(this).hasClass(categoryClass)){
				$(this).css({'color': '#ff0047'});
			}
		});
	}
});

categoryButton.click(function(){
	var categoryClass = $(this).attr('class');
	if($(this).hasClass('all')){
		projectsItem.fadeTo('fast', 1);
	} else {
		projectsItem.each(function() {
			if($(this).hasClass(categoryClass)){
				$(this).fadeTo('fast', 1);
			} else {
				$(this).fadeTo('fast', 0.2);
			}
		});
	}
	tagButtonTitle.css({'color': '#bcbcbc'});
	wrapperClass.removeClass().addClass(function() { return categoryClass; });
});

tagButton.click(function(){
	var categoryClass = $(this).attr('class');
	projectsItem.each(function() {
		if($(this).hasClass(categoryClass)){
			$(this).fadeTo('fast', 1);
		} else {
			$(this).fadeTo('fast', 0.2);
		}
	});
	tagButtonTitle.css({'color': '#bcbcbc'});
	$(this).css({'color': '#ff0047'});
	wrapperClass.removeClass().addClass(function() { return categoryClass; });
});

/* - Show more items when scroll - */

// Variables.
var column1 = $('div.projects div.one div.box');
var column2 = $('div.projects div.two div.box');
var column3 = $('div.projects div.three div.box');
var column4 = $('div.projects div.four div.box');
var column5 = $('div.projects div.five div.box');
var projectsListed = $('div#projectsListed span');
var visibleBoxes = 0;
var showMoreButton = $('strong#showMore');
var hideButton = true;


// Show more function.
function showMore(){
	visibleBoxes += 6;	 // Edited 2010.18.12  Cambia la cantidad de 20 trabajos a 30//
	hideButton = true;
	column1.each(function(index){
		if(index < visibleBoxes) { $(this).fadeIn('normal'); } else {	hideButton = false; }
	});
	column2.each(function(index){
		if(index < visibleBoxes) { $(this).fadeIn('normal');	} else {	hideButton = false;	}
	});
	column3.each(function(index){
		if(index < visibleBoxes) { $(this).fadeIn('normal');	} else {	hideButton = false;	}
	});
	column4.each(function(index){
		if(index < visibleBoxes) { $(this).fadeIn('normal');	} else {	hideButton = false;	}
	});
	column5.each(function(index){
		if(index < visibleBoxes) { $(this).fadeIn('normal'); } else {	hideButton = false;	}
	});
	$('div.projects div.box:visible').each(function(index){ projectsListed.text(index+1); });
	if(hideButton) {	showMoreButton.hide(); }
}

// Initiate.
showMore();

// Button function.
showMoreButton.click(function(){
 showMore();
});

/* -- Work -- */

/* - Share - */

var shareButton = $('div#share dt span');
var shareContent = $('div#share dd');
var shareItems = $('div#share dd ul li');

shareButton.toggle(
	function(){
		shareContent.slideDown('fast', function(){
			shareItems.css({'visibility': 'visible'});
			shareItems.hide();
			shareItems.fadeIn('fast');
		});
	},
	function(){
		shareItems.fadeOut('fast', function(){
			shareContent.slideUp('fast');
			shareItems.css({'visibility': 'hidden'});
			shareItems.show();
		});
});

/* - Slides - */

/* - Slide type 1 - */

var slideType1Item = $('div.slideType1 div.slideItems img');
var slideType1Size = slideType1Item.length - 1;
var slideType1Selected = 0;
var slideType1Wrapper = $('div.slideType1 div.slideItems');
var slideType1WrapperWidth = (slideType1Size + 1) * 460;
var slideType1Prev = $('div.slideType1 span.prev');
var slideType1Next = $('div.slideType1 span.next');
var slideType1Buttons = $('div.slideType1 div.buttons');

if (slideType1Size == 0){ slideType1Buttons.hide(); }
slideType1Wrapper.width(slideType1WrapperWidth);
slideType1Prev.css({'cursor': 'default'});

slideType1Next.click(function(event){
	if(slideType1Selected < slideType1Size){
	 slideType1Item.eq(slideType1Selected).animate({'margin-left': '-460px'}, 'slow');
  slideType1Selected++;
	}
	if(slideType1Selected == slideType1Size){
		$(this).css({'cursor': 'default'});
	}
	slideType1Prev.css({'cursor': 'pointer'});
});

slideType1Prev.click(function(event){
	if(slideType1Selected != 0){
	 slideType1Selected--;
		slideType1Item.eq(slideType1Selected).animate({'margin-left': '0px'}, 'slow');
	}
	if(slideType1Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType1Next.css({'cursor': 'pointer'});
});

/* - Slide type 2 - */

var slideType2Item = $('div.slideType2 div.slideItems img');
var slideType2Size = slideType2Item.length - 1;
var slideType2Selected = 0;
var slideType2Height = slideType2Item.height();
var slideType2Wrapper = $('div.slideType2 div.slideItems');
var slideType2WrapperHeight = (slideType2Size + 1) * slideType2Item.height();
var slideType2Prev = $('div.slideType2 span.prev');
var slideType2Next = $('div.slideType2 span.next');
var slideType2Buttons = $('div.slideType2 div.buttons');

if (slideType2Size == 0){ slideType2Buttons.hide(); }
$('div.slideType2 div.slideWrapper').height(slideType2Height);
slideType2Wrapper.width(slideType2WrapperHeight);
slideType2Prev.css({'cursor': 'default'});

slideType2Next.click(function(event){
	if(slideType2Selected < slideType2Size){
	 slideType2Item.eq(slideType2Selected).animate({'margin-top': -slideType2Height}, 'slow');
  slideType2Selected++;
	}
	if(slideType2Selected == slideType2Size){
		$(this).css({'cursor': 'default'});
	}
	slideType2Prev.css({'cursor': 'pointer'});
});

slideType2Prev.click(function(event){
	if(slideType2Selected != 0){
	 slideType2Selected--;
		slideType2Item.eq(slideType2Selected).animate({'margin-top': '0px'}, 'slow');
	}
	if(slideType2Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType2Next.css({'cursor': 'pointer'});
});

/* - Slide type 3 - */

var slideType3Item = $('div.slideType3 div.slideItems img');
var slideType3Size = slideType3Item.length - 1;
var slideType3Selected = 0;
var slideType3Wrapper = $('div.slideType3 div.slideItems');
var slideType3WrapperWidth = (slideType3Size + 1) * 590;
var slideType3Prev = $('div.slideType3 span.prev');
var slideType3Next = $('div.slideType3 span.next');
var slideType3Buttons = $('div.slideType3 div.buttons');

if (slideType3Size == 0){ slideType3Buttons.hide(); }
slideType3Wrapper.width(slideType3WrapperWidth);
slideType3Prev.css({'cursor': 'default'});

slideType3Next.click(function(event){
	if(slideType3Selected < slideType3Size){
	 slideType3Item.eq(slideType3Selected).animate({'margin-left': '-590px'}, 'slow');
  slideType3Selected++;
	}
	if(slideType3Selected == slideType3Size){
		$(this).css({'cursor': 'default'});
	}
	slideType3Prev.css({'cursor': 'pointer'});
});

slideType3Prev.click(function(event){
	if(slideType3Selected != 0){
	 slideType3Selected--;
		slideType3Item.eq(slideType3Selected).animate({'margin-left': '0px'}, 'slow');
	}
	if(slideType3Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType3Next.css({'cursor': 'pointer'});
});

/* - Slide type 4 - */

var slideType4Item = $('div.slideType4 div.slideItems img');
var slideType4TextItem = $('div.slideType4 div.textWrapper div.item');
var slideType4Size = slideType4Item.length - 1;
var slideType4Selected = 0;
var slideType4Wrapper = $('div.slideType4 div.slideItems');
var slideType4TextWrapper = $('div.slideType4 div.textItems');
var slideType4WrapperWidth = (slideType4Size + 1) * 480;
var slideType4TextWrapperWidth = (slideType4Size + 1) * 190;
var slideType4TextWrapperHeight = slideType4Item.height() - 23;
var slideType4Prev = $('div.slideType4 span.prev');
var slideType4Next = $('div.slideType4 span.next');
var slideType4Buttons = $('div.slideType4 div.buttons');

if (slideType4Size == 0){ slideType4Buttons.hide(); }
$('div.slideType4 div.textWrapper').height(slideType4TextWrapperHeight);
slideType4Wrapper.width(slideType4WrapperWidth);
slideType4TextWrapper.width(slideType4TextWrapperWidth);
slideType4Prev.css({'cursor': 'default'});

slideType4Next.click(function(event){
	if(slideType4Selected < slideType4Size){
	 slideType4Item.eq(slideType4Selected).animate({'margin-left': '-480px'}, 'slow');
		slideType4TextItem.eq(slideType4Selected).animate({'margin-left': '-390px'}, 'slow');
  slideType4Selected++;
	}
	if(slideType4Selected == slideType4Size){
		$(this).css({'cursor': 'default'});
	}
	slideType4Prev.css({'cursor': 'pointer'});
});

slideType4Prev.click(function(event){
	if(slideType4Selected != 0){
	 slideType4Selected--;
		slideType4Item.eq(slideType4Selected).animate({'margin-left': '0px'}, 'slow');
		slideType4TextItem.eq(slideType4Selected).animate({'margin-left': '0px'}, 'slow');
	}
	if(slideType4Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType4Next.css({'cursor': 'pointer'});
});

/* - Slide type 5 - */

var slideType5Item = $('div.slideType5 div.slideItems img');
var slideType5TextItem = $('div.slideType5 div.textWrapper div.item');
var slideType5Size = slideType5Item.length - 1;
var slideType5Selected = 0;
var slideType5Wrapper = $('div.slideType5 div.slideItems');
var slideType5TextWrapper = $('div.slideType5 div.textItems');
var slideType5WrapperWidth = (slideType5Size + 1) * 950;
var slideType5TextWrapperWidth = (slideType5Size + 1) * 190;
var slideType5Prev = $('div.slideType5 span.prev');
var slideType5Next = $('div.slideType5 span.next');
var slideType5Buttons = $('div.slideType5 div.buttons');

if (slideType5Size == 0){ slideType5Buttons.hide(); }
slideType5Wrapper.width(slideType5WrapperWidth);
slideType5TextWrapper.width(slideType5TextWrapperWidth);
slideType5Prev.css({'cursor': 'default'});

slideType5Next.click(function(event){
	if(slideType5Selected < slideType5Size){
	 slideType5Item.eq(slideType5Selected).animate({'margin-left': '-950px'}, 'slow');
		slideType5TextItem.eq(slideType5Selected).animate({'margin-left': '-390px'}, 'slow');
  slideType5Selected++;
	}
	if(slideType5Selected == slideType5Size){
		$(this).css({'cursor': 'default'});
	}
	slideType5Prev.css({'cursor': 'pointer'});
});

slideType5Prev.click(function(event){
	if(slideType5Selected != 0){
	 slideType5Selected--;
		slideType5Item.eq(slideType5Selected).animate({'margin-left': '0px'}, 'slow');
		slideType5TextItem.eq(slideType5Selected).animate({'margin-left': '0px'}, 'slow');
	}
	if(slideType5Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType5Next.css({'cursor': 'pointer'});
});

/* - Slide type 6 - */

var slideType6Item = $('div.slideType6 div.slideItems div.item');
var slideType6TextItem = $('div.slideType6 div.textWrapper div.item');
var slideType6Size = slideType6Item.length - 1;
var slideType6Selected = 0;
var slideType6Wrapper = $('div.slideType6 div.slideItems');
var slideType6TextWrapper = $('div.slideType6 div.textItems');
var slideType6WrapperHeight = (slideType6Size + 1) * 480;
var slideType6TextWrapperWidth = (slideType6Size + 1) * 190;
var slideType6Prev = $('div.slideType6 span.prev');
var slideType6Next = $('div.slideType6 span.next');
var slideType6Buttons = $('div.slideType6 div.buttons');

if (slideType6Size == 0){ slideType6Buttons.hide(); }
slideType6Wrapper.height(slideType6WrapperHeight);
slideType6TextWrapper.width(slideType6TextWrapperWidth);
slideType6Prev.css({'cursor': 'default'});

slideType6Next.click(function(event){
	if(slideType6Selected < slideType6Size){
	 slideType6Item.eq(slideType6Selected).animate({'margin-top': '-480px'}, 'slow');
		slideType6TextItem.eq(slideType6Selected).animate({'margin-left': '-190px'}, 'slow');
  slideType6Selected++;
	}
	if(slideType6Selected == slideType6Size){
		$(this).css({'cursor': 'default'});
	}
	slideType6Prev.css({'cursor': 'pointer'});
});

slideType6Prev.click(function(event){
	if(slideType6Selected != 0){
	 slideType6Selected--;
		slideType6Item.eq(slideType6Selected).animate({'margin-top': '0px'}, 'slow');
		slideType6TextItem.eq(slideType6Selected).animate({'margin-left': '0px'}, 'slow');
	}
	if(slideType6Selected == 0){
		$(this).css({'cursor': 'default'});
	}
	slideType6Next.css({'cursor': 'pointer'});
});

/* - Projects nav - */

/* - Slide - */

var projectsSlideItem = $('div.projectsSlide div.item');
var projectsSlideSize = projectsSlideItem.length - 7;
var projectsSlideSelected = 0;
var projectsSlideWrapper = $('div.projectsSlide div.slideItems');
var projectsSlideWrapperWidth = (projectsSlideSize + 7) * 128;
var projectsSlidePrev = $('div.projectsSlide span.prev');
var projectsSlideNext = $('div.projectsSlide span.next');
var projectsSlideButtons = $('div#projectsNav span.prev, div#projectsNav span.next');

if (projectsSlideSize <= 0){ projectsSlideButtons.hide(); }
projectsSlideWrapper.width(projectsSlideWrapperWidth);
projectsSlidePrev.css({'cursor': 'default'});

projectsSlideNext.click(function(event){
	if(projectsSlideSelected < projectsSlideSize){
	 projectsSlideItem.eq(projectsSlideSelected).animate({'margin-left': '-128px'}, 'fast');
  projectsSlideSelected++;
	}
	if(projectsSlideSelected == projectsSlideSize){
		$(this).css({'cursor': 'default'});
	}
	projectsSlidePrev.css({'cursor': 'pointer'});
});

projectsSlidePrev.click(function(event){
	if(projectsSlideSelected != 0){
	 projectsSlideSelected--;
		projectsSlideItem.eq(projectsSlideSelected).animate({'margin-left': '0px'}, 'fast');
	}
	if(projectsSlideSelected == 0){
		$(this).css({'cursor': 'default'});
	}
	projectsSlideNext.css({'cursor': 'pointer'});
});

/* - Hover - */

var projectsNavLink = $('div.projectsSlide a');
var projectsNavTitle = $('div.projectsSlide a span');
var projectsNavItem = $('div.projectsSlide div.item');

projectsNavItem.fadeTo(0, 0.3);

projectsNavLink.hover(
 function(){
	 $(this).children('span').show();
		$(this).children('span').css({'display': 'block'});
		$(this).parent().fadeTo('fast', 1);
	},
 function(){
	 $(this).children('span').hide();
		$(this).parent().fadeTo('fast', 0.3);
	}
);

/* --- Footer --- */

// Function.
function footerPosition() {
	$('div#wrapper').css({'min-height': $(window).height() - $('div#footer').height() - 80});
}

// Resize.
$(window).resize(function() { footerPosition(); });

// Activate.
footerPosition();

/* --- General functions --- */

/* -- Back to top -- */

$('a.backTop').click(function (event) {
	if ($.browser.opera) {
  $('html').animate({ scrollTop: 0 }, 500);
 } else {
	 $('body, html').animate({ scrollTop: 0 }, 500);  
	}
 event.preventDefault();
});

/* -- Swf object -- */

(function ($, flash) {
var createAttrs = function (obj) {
var aEach,
aArray = [];
for (aEach in obj) {
if (/string|number/.test(typeof obj[aEach]) && obj[aEach] !== '') {
aArray.push(aEach + '="' + obj[aEach] + '"');
}
}
return aArray[j]('');
},
createParams = function (obj) {
var aEach,
bEach,
aArray = [],
bArray;
if (typeof obj == 'object') {
for (aEach in obj) {
if (typeof obj[aEach] == 'object') {
bArray = [];
for (bEach in obj[aEach]) {
bArray.push([bEach, '=', encodeURIComponent(obj[aEach][bEach])][j](''));
}
obj[aEach] = bArray[j]('&amp;');
}
if (obj[aEach]) {
aArray.push(['<param name="', aEach, '" value="', obj[aEach], '" />'][j](''));
}
}
obj = aArray[j]('');
}
return obj;
},
expressInstallIsActive = false,
j = 'join';
$[flash] = (function () {
try {
var flashVersion = '0,0,0',
Plugin = navigator.plugins['Shockwave Flash'] || ActiveXObject;
flashVersion = Plugin.description || (function () {
try {
return (new Plugin('ShockwaveFlash.ShockwaveFlash')).GetVariable('$version');
}
catch (eIE) {}
}());
}
catch(e) {}
flashVersion = flashVersion.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+[d|r]|,)(\d+)/);
return {
available: flashVersion[1] > 0,
activeX: Plugin && !Plugin.name,
version: {
major: flashVersion[1] * 1,
minor: flashVersion[2] * 1, 
release: flashVersion[3] * 1
},
hasVersion: function (version) {
var versionCompare = this.version,
major = 'major',
minor = 'minor',
release = 'release';
version = (/string|number/.test(typeof version)) ? version.toString().split('.') : version || [0, 0, 0];
version = [
version[major] || version[0] || versionCompare[major],
version[minor] || version[1] || versionCompare[minor],
version[release] || version[2] || versionCompare[release]
];
return (version[0] < versionCompare[major]) || (version[0] == versionCompare[major] && version[1] < versionCompare[minor]) || (version[0] == versionCompare[major] && version[1] == versionCompare[minor] && version[2] <= versionCompare[release]);
},
expressInstall: 'expressInstall.swf',
create: function (obj) {
if (!$[flash].available || expressInstallIsActive || !typeof obj == 'object' || !obj.swf) {
return false;
}
if (obj.hasVersion && !$[flash].hasVersion(obj.hasVersion)) {
obj = {
swf: obj.expressInstall || $[flash].expressInstall,
attrs: {
id: obj.id || 'SWFObjectExprInst',
name: obj.name,
height: Math.max(obj.height || 137),
width: Math.max(obj.width || 214)
},
params: {
flashvars: {
MMredirectURL: location.href,
MMplayerType: ($[flash].activeX) ? 'ActiveX': 'PlugIn',
MMdoctitle: document.title.slice(0, 47) + ' - Flash Player Installation'
}
}
};
expressInstallIsActive = true;
}
else {
obj = $.extend(
true,
{
attrs: {
id: obj.id,
name: obj.name,
height: obj.height || 180,
width: obj.width || 320
},
params: {
wmode: obj.wmode || 'opaque',
flashvars: obj.flashvars
}
},
obj
);
}
if ($[flash].activeX) {
obj.attrs.classid = obj.attrs.classid || 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
obj.params.movie = obj.params.movie || obj.swf;
}
else {
obj.attrs.type = obj.attrs.classid || 'application/x-shockwave-flash';
obj.attrs.data = obj.attrs.data || obj.swf;
}
return ['<object ', createAttrs(obj.attrs), '>', createParams(obj.params), '</object>'][j]('');
}
};
}());
$.fn[flash] = function (args) {
if (typeof args == 'object') { 
this.each(
function () {
var test = document.createElement(flash);
var newFlash = $[flash].create(args);
if (newFlash) {
test.innerHTML = newFlash;
if (test.childNodes[0]) {
this.appendChild(test.childNodes[0]);
}
};
}
);
}
else if (typeof args == 'function') {
this.find('object').andSelf().filter('object').each(
function () {
var elem = this,
jsInteractionTimeoutMs = 'jsInteractionTimeoutMs';
elem[jsInteractionTimeoutMs] = elem[jsInteractionTimeoutMs] || 0;
if (elem[jsInteractionTimeoutMs] < 660) {
if (elem.clientWidth || elem.clientHeight) {
args.call(this);
}
else {
setTimeout(
function () {
$(elem)[flash](args);
},
elem[jsInteractionTimeoutMs] + 66
);
}
}
}
);
}
return this;
};
}(jQuery, 'flash'));

/* -- Background -- */

(function(jQuery){

jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
jQuery.fx.step[attr] = function(fx){
if ( fx.state == 0 ) {
fx.start = getColor( fx.elem, attr );
fx.end = getRGB( fx.end );
}
fx.elem.style[attr] = "rgb(" + [
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
].join(",") + ")";
}
});
function getRGB(color) {
var result;
if ( color && color.constructor == Array && color.length == 3 )
return color;
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
return colors[jQuery.trim(color).toLowerCase()];
}
function getColor(elem, attr) {
var color;
do {
color = jQuery.curCSS(elem, attr);
if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
break; 
attr = "backgroundColor";
} while ( elem = elem.parentNode );
return getRGB(color);
};
})(jQuery);


// Animate.
$('body#video').animate({'background-color': "#292929"}, 750);
});

/* --- Vertical Align --- */


$(window).load(function(){
	(function($){
	$.fn.extend({ 
		verticalAlign: function() {
			return this.each(function() {
				var obj = $(this);
				var childHeight = obj.height();
				var parentHeight = obj.parent().height();
				var diff = Math.round( ( (parentHeight - childHeight) / 2) );
				obj.css( { "display": "block", "margin-top": diff } );
			});
		}
	}); 
	})(jQuery);

	$('div.projectsSlide div.item img').verticalAlign();
});
