// JavaScript Document
// created by Michael Gunn
// working for the Zucconi Idea Agency, Inc
// December 2009
// email: mijogu@gmail.com

/**************************************************************************/
/**************************************************************************/
//                              GLOBAL FUNCTIONS
/**************************************************************************/
/**************************************************************************/

addLoadListener(function()
					{
						if (Core.getElementsByClass("nonSelectable"))
						{
							var nonSelectable = Core.getElementsByClass("nonSelectable");
							/*alert(nonSelectable.length);*/
							for (var i=0; i<nonSelectable.length; i++)
							{
								nonSelectable[i].onmousedown = nonSelectable[i].onselectstart = function()
								{
									return false;
								};
							}
							/*alert("non selectable!");*/
						}
					}
					);
/****************************************/
//  REMOVING CURRENT CLASS FROM LIST
/****************************************/
function removeCurrentClass(listOfLinks)
{
	//alert(listOfLinks[0].parentNode.id);
	for (var i = 0; i < listOfLinks.length; i++)
	{
		removeClass(listOfLinks[i], "current");
	}
}

/****************************************/
//     HOME PAGE NAVIGATION BACKGROUND
/****************************************/
addLoadListener(function ()
						 {
							if ( !(document.getElementById("homeTable")) )
							{
								document.getElementById("navigation").style.backgroundImage = 'url(../IMG/navBkgd_orange.png)';
							}
						}
						 );

/****************************************/
/*    SETTING THE DATE AND GREETING */
/****************************************/
function settingDate()
{
	var today = new Date();
	var timeNow = today.getTimeString(12);

	var sentence1 = today.getDateString('%day the %date%ordinal day');
	var sentence2 = today.getDateString('of %month: ' + timeNow);
	
	var todaysDate1 = document.getElementById('date1');
	if (todaysDate1.firstChild == null)
	{
		var text = document.createTextNode(sentence1);
		todaysDate1.appendChild(text);
	}
	else 
	{
		todaysDate1.firstChild.nodeValue = sentence1;
	}
	
	
	var todaysDate2 = document.getElementById('date2');
	if (todaysDate2.firstChild == null)
	{
		var text = document.createTextNode(sentence2);
		todaysDate2.appendChild(text);
	}
	else 
	{
		todaysDate2.firstChild.nodeValue = sentence2;
	}
	
	var hours = today.getHours();
	
	var newGreeting1; 
	//var newGreeting2;
	
	if (hours >= '0' && hours < '7')
	{	
		newGreeting1 = "Good morning!";
		//newGreeting2 = "Go back to bed!";
	}
	else if (hours >= '7' && hours < '12')
	{
		newGreeting1 = "Good morning!";
		//newGreeting2 = "Make it a great day!";
	}
	else if (hours >= '12' && hours < '16')
	{
		newGreeting1 = "Good afternoon!";
		//newGreeting2 = "How's the day going?";
	}
	else if (hours >= "16" && hours < "19")
	{
		newGreeting1 = "Good evening!";
		//newGreeting2 = "What's for dinner?";
	}
	else
	{
		newGreeting1 = "It's getting late.";
		//newGreeting2 = "Perhaps it's bed time?";
	}
	var greet1 = document.getElementById("greet1");
	if (greet1.firstChild == null)
	{
		var text = document.createTextNode(newGreeting1);
		greet1.appendChild(text);
	}
	else
	{
		greet1.firstChild.nodeValue = newGreeting1;
	}
}

addLoadListener(function()
						 {
							settingDate();
							setTimeout(settingDate, 60000);   //updates time every 60 seconds
						});

/****************************************/
// CURRENT MAIN NAV 
/****************************************/
function currentMainNav()
{
	 if (!(document.getElementById("homeTable")))
	 {
		 var mainNav = document.getElementById("mainNav");
		 var mainNavLinks = mainNav.getElementsByTagName("a");
		 var currentPage; 
			 
		 if (document.getElementById("portNav") != undefined)
		 {
			 currentPage = mainNavLinks[0];
		 }
		 else if (document.getElementById("aboutNav") != undefined)
		 {
			 currentPage = mainNavLinks[1];
		 }
		 else if (document.getElementById("contactNav") != undefined)
		 {
			 currentPage = mainNavLinks[2];
		 }
		 else if (document.getElementById("newsNav") != undefined)
		 {
			 currentPage = mainNavLinks[3];
		 }
		 
		 currentPage.style.color = "#FF9933";
	 }
}

addLoadListener(currentMainNav);

/****************************************/
// SIDE NAVIGATION 
/****************************************/
function hideContent(element)
{
	element.style.display = "none";
	/*element.style.visibility = "visible";
	element.style.position = "absolute";
	element.style.left = "-10000px";*/
}

function showContent(element)
{
	element.style.display = "block";
	/*element.style.visibility = "visible";
	element.style.position = "relative";
	element.style.left = "0px";*/
}

/**************************************************************************/
/**************************************************************************/
//                              HOME 
/**************************************************************************/
/**************************************************************************/

function showHomeImg()
{
	var linkHref = $(this).attr('href');
	//alert(linkHref);

	//get home image and change SRC
	var homeImgDiv = document.getElementById("enlarge");
	var homeImg = homeImgDiv.getElementsByTagName("img")[0];
	
	//homeImg.src = linkSrc.replace("_HOME", "_HOME");
	homeImg.src = linkHref;
	homeImgDiv.style.visibility = "visible";
}
function hideHomeImg()
{
	var homeImgDiv = document.getElementById("enlarge");
	homeImgDiv.style.visibility = "hidden";
	var homeImg = homeImgDiv.getElementsByTagName("img")[0];
	homeImg.src = "";
}
function homeImgHover()
{
	//alert("hovering");
	var img = this.childNodes[0];
	while (img.nodeName != "IMG")
	{
		img = img.nextSibling;
	}
	var oldSrc = img.src;
	
	var newSrc = oldSrc.replace(".jpg", "_HOVER.jpg");
	newSrc = newSrc.replace("homeDEFAULT", "homeHOVER");
	img.src = newSrc;
	//alert(newSrc);
}
function homeImgRevert()
{
	//alert("reverting");
	var img = this.childNodes[0];
	while (img.nodeName != "IMG")
	{
		img = img.nextSibling;
	}
	var oldSrc = img.src;
	var newSrc = oldSrc.replace("_HOVER.jpg", ".jpg");
	newSrc = newSrc.replace("homeHOVER", "homeDEFAULT");
	img.src = newSrc;
	//alert("done reverting");
}

addLoadListener(function()
						 {
							 if (document.getElementById("homeTable"))
							 {
								 var homeImgDiv = document.getElementById("enlarge");
								 //alert(homeImgDiv.nodeName);
								 attachEventListener(homeImgDiv, "click", hideHomeImg, false);
								 attachEventListener(homeImgDiv, "click", Core.preventDefault, false);
								 
								 var homeLinks = Core.getElementsByClass("homeLink");
								 //alert(homeLinks.length);
								 for (var i=0; i<homeLinks.length; i++)
								 {
									attachEventListener(homeLinks[i], "click", showHomeImg, false);
									attachEventListener(homeLinks[i], "click", Core.preventDefault, false);
									attachEventListener(homeLinks[i], "mouseover", homeImgHover, false);
									attachEventListener(homeLinks[i], "mouseout", homeImgRevert, false);
								 }
								 
								 /*var table = document.getElementById("homeTable");
								 var tableH = retrieveComputedStyle(table, "height");
								 var tableW = retrieveComputedStyle(table, "width");
								 alert(tableH + " x " + tableW);*/
								 }
						 }
						 );

function preloadHomeImgs()
{
	//get all default images
	var homeTable = document.getElementById("homeTable");
	var homeImgs = homeTable.getElementsByTagName("img");
	//alert(homeImgs.length);
	var newImages = [];
	var newEnlarge = [];
	for (var i=0; i<homeImgs.length; i++)
	{
		//preload hover images
		newImages[i] = new Image();
		var oldSrc = homeImgs[i].src;
		var newSrc = oldSrc.replace(".jpg", "_HOVER.jpg");
		newSrc = newSrc.replace("homeDEFAULT", "homeHOVER");
		newImages[i].src = newSrc;
		
		//preload main images
		var imgLink = homeImgs[i].parentNode;
		while (imgLink.nodeName != "A")
		{
			imgLink = imgLink.parentNode;
		}
		newEnlarge[i] = new Image();
		newEnlarge[i].src = imgLink.href;
		//if (i == 0) { alert(imgLink.href)};
		}
}

addLoadListener(function()
						 {
							if (document.getElementById("homeTable"))
							{
								//alert("preloading");
								preloadHomeImgs();
								//alert("preloaded");
							}
						 }
						 );


/**************************************************************************/
/**************************************************************************/
//                              CONTACT
/**************************************************************************/
/**************************************************************************/

/****************************************/
/* CHANGING CONTACT CONTENT */
/****************************************/
function changeContactContent()
{
	if (!Core.hasClass(this, "current"))
	{	
		var list = this.parentNode;
		while (list.nodeName != "UL")
		{	
			list = list.parentNode;
		}
		list = list.getElementsByTagName("a");
		//alert(list.nodeName);
		removeCurrentClass(list);
		addClass(this, "current");
		
		var allContactContent = Core.getElementsByClass("contactContent");
		for (var i = 0; i < allContactContent.length; i++)
		{	
			hideContent(allContactContent[i]);
		}
		if (this.id == "directionsLink")
		{	
			showContent(document.getElementById("directionsContent"));
		}
		else if (this.id == "employmentLink")
		{	
			showContent(document.getElementById("employmentContent"));
		}
		else if (this.id == "eMailLink")
		{	
			showContent(document.getElementById("eMailContent"));
		}
	}
}
addLoadListener(function()
				    {
					    if (document.getElementById("contactNav"))
					    {
						    var contactSideNav = document.getElementById('contactNav');
							var contactLinks = contactSideNav.getElementsByTagName('a');
							for (var i = 0; i < contactLinks.length; i++)
							{
								attachEventListener(contactLinks[i], "click", changeContactContent, false);
								attachEventListener(contactLinks[i], "click", Core.preventDefault, false);
							} 
					    }
				    }
				    );


/**************************************************************************/
/**************************************************************************/
//                              ABOUT US
/**************************************************************************/
/**************************************************************************/
function changePageInfo()//changes page content for AWARDS and STAFF pages when bottom nav is clicked
{
	//alert("changing page info");
	var list = this.parentNode;
	while (list.nodeName != "TABLE")
	{
		list = list.parentNode;
	}
	//alert(list.nodeName);
	var listOfLinks = list.getElementsByTagName("a");
	removeCurrentClass(listOfLinks);
	//alert("current removed");
	addClass(this, "current");
	//alert(list.id);
	
	if (list.id == "staffTable")
	{	
		//var newProfile = this.id;
		//alert("changing staff info");
		changeStaffInfo(this.id);
		
		//alert(this.id);
	}
	else if (list.id == "awardsTable")
	{	
		//alert("change awards info to " + this.id);
		//alert("changing awards info");
		changeAwardsInfo(this.id);
	}
}

/****************************************/
/* CHANGING ABOUT US CONTENT */
/****************************************/
function changeAboutContent()
{
	if (!Core.hasClass(this, "current"))
	{
		var list = this.parentNode;
		while (list.nodeName != "UL")
		{	
			list = list.parentNode;
		}
		list = list.getElementsByTagName("a");
		removeCurrentClass(list);
		addClass(this, "current");
		
		var allAboutContent = Core.getElementsByClass("aboutContent");
		for (var i = 0; i < allAboutContent.length; i++)
		{	
			hideContent(allAboutContent[i]);
		}
		var allAboutNav = Core.getElementsByClass("bottomNav");	
		for (var j = 0; j < allAboutNav.length; j++)
		{
			hideContent(allAboutNav[j]);
		}
		if (this.id == "thinkingLink")
		{
			showContent(document.getElementById("thinkingContent"));
		}
		else if (this.id == "staffLink")
		{	
			showContent(document.getElementById("staffContent"));
			showContent(document.getElementById("staffFoot"));
		}
		else if (this.id == "awardsLink")
		{	
			showContent(document.getElementById("awardsContent"));
			showContent(document.getElementById("awardsFoot"));
			showContent(document.getElementById("awardsImg"));
			/*var w = retrieveComputedStyle(document.getElementById("awardsImg"), 'width');
			alert(w);*/
			//var img = document.getElementById("awardsImg");
			//alert(document.getElementById("awardsImg").src);
			//hide disclaimer b/c 2009 is default
			//hideDisclaimer();
		}
	}
}
addLoadListener(function()
					{
						if (document.getElementById("aboutNav"))
						{
							var thinkingLink = document.getElementById("thinkingLink");
							var staffLink = document.getElementById("staffLink");
							var awardsLink = document.getElementById("awardsLink");
							
							attachEventListener(thinkingLink, "click", changeAboutContent, false);
							attachEventListener(thinkingLink, "click", Core.preventDefault, false);
							attachEventListener(staffLink, "click", changeAboutContent, false);
							attachEventListener(staffLink, "click", Core.preventDefault, false);
							attachEventListener(awardsLink, "click", changeAboutContent, false);
							attachEventListener(awardsLink, "click", Core.preventDefault, false);
						}
					}
					);

/*********************************/
//      CHANGING AWARDS PAGES
/*********************************/
function changeAwardsInfo(newAwards)
//function changeAwardsInfo()
{
	//alert("change awards info");
	//var newAwards = this.id;
	
	var awardsTitle = document.getElementById("awardsTitle");
	var parent = document.getElementById("awardsContent").childNodes[0];
	while (parent.nodeName != "DIV")
	{	
		parent = parent.nextSibling;
	}
	var awardsText = parent.childNodes;
	//alert("parent nodes " + parent.childNodes.length);
	while (awardsText[0])
	{
		awardsText[0].parentNode.removeChild(awardsText[0]);
	}
	//alert("parent node " + parent.childNodes.length);
	var newTitle;	
	var newText = [];
	switch(newAwards)
	{
		case "yr2009":
			newTitle = "2009 Awards";
			newText = yr2009Text;
			break;
		case "yr2007":
			newTitle = "2007 Awards";
			newText = yr2007Text;
			break;
		case "yr2006":
			newTitle = "2006 Awards";
			newText = yr2006Text;
			break;
		case "yr2003":
			newTitle = "2003 Awards";
			newText = yr2003Text;
			break;
		case "yr2001":
			newTitle = "2001 Awards";
			newText = yr2001Text;
			break;
		case "yr1998":
			newTitle = "1998 Awards";
			newText = yr1998Text;
			break;
		case "yr1997":
			newTitle = "1997 Awards";
			newText = yr1997Text;
			break;
		case "yr1996":
			newTitle = "1996 Awards";
			newText = yr1996Text;
			break;
		case "yr1995":
			newTitle = "1995 Awards";
			newText = yr1995Text;
			break;	
		default:
			newTitle = "2009 Awards";
			newText = yr2009Text;
	}
	awardsTitle.childNodes[0].nodeValue = newTitle;
	
	for (var i=0;i<newText.length; i++)
	{
			if (newText[i] == "img")
			{
				//alert("adding image");
				i++;
				var newImg = new Image();
				newImg.src = newText[i];
				addClass(newImg, "awardImg");
				parent.appendChild(newImg);
			}
			else 
			{
				var newUl = document.createElement("ul");
				i++;
				while (newText[i] != "endMain")
				{
					var li = document.createElement("li");
					//alert("created " + li.nodeName + i);
					var liText = document.createTextNode(newText[i]);// TRYING TO USE INNERHTML INSTEAD OF TEXT NODE
					li.appendChild(liText);
					i++;
					
					if (newText[i] == "nest")
					{
						//alert("creating nest");
						var nestUl = document.createElement("ul");
						//alert("created nested " + nestUl.nodeName);
						//var nestToAdd = [];
						i++;
						while (newText[i] != "endNest")
						{
							
							var nestli = document.createElement("li");
							//alert("created nested " + nestli.nodeName);
							var nestliText = document.createTextNode(newText[i]);
							nestli.appendChild(nestliText);
							nestUl.appendChild(nestli);
							i++;
						}
						li.appendChild(nestUl);
						i++;
						//alert("appending nested");
					}
					newUl.appendChild(li);
					//alert("appending main");
				}
				parent.appendChild(newUl);
				//alert("end of loop");
			}
	}
}

addLoadListener(function() 
					{
						if (document.getElementById("awardsFoot"))
						{
							var awardsBottom = document.getElementById("awardsFoot");
							var awardsBottomLinks = awardsBottom.getElementsByTagName("a");
							for (var i = 0; i < awardsBottomLinks.length; i++)
							{
								attachEventListener(awardsBottomLinks[i], "click", changePageInfo, false);
								//attachEventListener(awardsBottomLinks[i], "click", changeAwardsInfo, false);
								attachEventListener(awardsBottomLinks[i], "click", Core.preventDefault, false);
							}
						}
					}
					);

addLoadListener(function()
						 {
							if (document.getElementById("awardsFoot"))
							{
								var awardsImgs = [
												  'IMG/aboutImgs/awards.jpg',
												  'IMG/aboutImgs/2009_Twilight.jpg',
												  'IMG/aboutImgs/2009_TOD.jpg',
												  'IMG/aboutImgs/2009_ringlingTruck.jpg',
												  'IMG/aboutImgs/2007_Pirates.jpg',
												  'IMG/aboutImgs/2006_StarWars.jpg',
												  'IMG/aboutImgs/2003_Shrek2.jpg',
												  'IMG/aboutImgs/2001_GlobalVote.jpg',
												  'IMG/aboutImgs/1998_ImposterBin.jpg',
												  'IMG/aboutImgs/1998_ChewClue.jpg',
												  'IMG/aboutImgs/1997_CrispyBin.jpg',
												  'IMG/aboutImgs/1996_Nabisco.jpg',
												  'IMG/aboutImgs/1996_FruitTwist.jpg',
												  'IMG/aboutImgs/1995_ringlingDisplay.jpg'
												  ];
								var preload = [];
								for (var i=0; i<awardsImgs.length; i++)
								{
									preload[i] = new Image();
									preload[i].src = awardsImgs[i];
								}
								//alert("awards preloaded");
							}
						 }
						 );

/****************************************/
// CHANGING STAFF PROFILES
/****************************************/
function changeStaffInfo(newProfile)
//function changeStaffInfo()
{
	//alert("changing profile");
	//var newProfile = this.id;
	var staffName = document.getElementById("staffName");
	/*if (staffName.childNodes[0])
	{
		staffName.removeChild(staffName.childNodes[0]);
	}*/
	var staffTitle = document.getElementById("staffTitle");
	/*if (staffTitle.childNodes[0])
	{
		staffTitle.removeChild(staffTitle.childNodes[0]);
	}*/
	var parent = document.getElementById("staffContent").childNodes[0];
	while (parent.nodeName != "DIV")
	{	
		parent = parent.nextSibling;
	}
	var staffText = parent.childNodes;
	while (staffText[0])
	{
		staffText[0].parentNode.removeChild(staffText[0]);
		//alert(staffText.length);
	}
	var newName;
	var newTitle;
	var newText = [];
	switch(newProfile)
	{
		case "sue":
			newName = "Sue Zucconi";
			newTitle = "President, Owner";
			newText = sueText;
			break;
		case "joeA":
			newName = "Joseph Andl";
			newTitle = "Chief Financial Officer";
			newText = joeAText;
			break;
		case "lance":
			newName = "Lance Eichert";
			newTitle = "SVP, Creative Director";
			newText = lanceText;
			break;
		case "gabe":
			newName = "Gabe Vuotto";
			newTitle = "VP of Production";
			newText = gabeText;
			break;
		case "jon":
			newName = "Jon Hechtman";
			newTitle = "SVP, Copy and Concept Development";
			newText = jonText;
			break;
		default:
			newName = "Joe Zucconi";
			newTitle = "CEO, Account Director";
			newText = joeZText;
			break;
	}
	//alert("changing name and title");
	/*if (staffName.childNodes[0].nodeValue)
	{
		staffName.childNodes[0].nodeValue = newName;
	}
	else
	{
		var name = document.createTextNode(newName);
		staffName.appendChild(name);
	}*/
	staffName.childNodes[0].nodeValue = newName;
	
	/*if (staffTitle.childNodes[0].nodeValue)
	{
		staffTitle.childNodes[0].nodeValue = newTitle;
	}
	else
	{
		var title = document.createTextNode(newTitle);
		staffTitle.appendChild(title);
	}*/
	//alert(staffTitle.childNodes[0].nodeName);
	staffTitle.childNodes[0].nodeValue = newTitle;
	
	
	//alert(newText.length);
	for (var i = 0; i < newText.length; i++)
	{
		var toAdd = document.createElement("p");
		var textNode = document.createTextNode(newText[i]);
		toAdd.appendChild(textNode);
		parent.appendChild(toAdd);
	}
}
addLoadListener(function() 
					{
						if (document.getElementById("staffFoot"))
						{
							var staffBottom = document.getElementById("staffFoot");
							var staffBottomLinks = staffBottom.getElementsByTagName("a");
							//alert(staffBottomLinks.length);
							for (var i=0; i < staffBottomLinks.length; i++)
							{
								//attachEventListener(staffBottomLinks[i], "click", changeStaffInfo, false);
								attachEventListener(staffBottomLinks[i], "click", changePageInfo, false);
								attachEventListener(staffBottomLinks[i], "click", Core.preventDefault, false);
							}
							//alert('attaching ');
						}
					}
					);

/**************************************************************************/
/**************************************************************************/
//                              PORTFOLIO
/**************************************************************************/
/**************************************************************************/


 /**************************************/
 //       PORTFOLIO loaded
 /**************************************/
 $(document).ready(function() {
		if ($('#portInner').length) {
			//console.log($('#portInner').length);

	var flowp;
	
	//FLOW Player
	$.getScript('../MOV/flowplayer/example/flowplayer.js', function() { 
		flowp = flowplayer("a.player", "../MOV/flowplayer/flowplayer.swf", { 
			clip: {
				autoPlay: true,
				autoBuffering: true
			},
			plugins: { 
				audio: { 
					url: "../MOV/flowplayer/flowplayer.audio.swf" 
					} 
				}	
			});
	});
			//define Portfolio namespace
			var PORT = {				
				 //change the MAIN portolio image
				 swapImage: function(thisLink) {
					 //alert('swap');
					 if (!$(thisLink).hasClass('current')) {
						 $mainImage = $('#portImage');
						 $mainImage.attr('src', '');
						 
						 PORT.currentImage(thisLink);
						 if ($(thisLink).hasClass('movie')) PORT.loadMovie(thisLink);
						 
						 $newhref = $(thisLink).attr('href');
						 $mainImage.attr('src', $newhref);
						 PORT.switchCaseStudyText(thisLink);
					 }
				 },
				 //determine whether or not to display NEXT button
				 showNextBtn: function() {
					 //alert('show next');
						if ($('#portInner').width() <= $('#portBottomLinks').width()) {
							$('#nextBtn').hide();
						} else if ( Math.abs($('#portInner').position().left) + $('#portBottomLinks').width() >= $('#portInner').width() ) {
							$('#nextBtn').hide();
						}
						else {
							//console.log('showing next btn');
							//console.log('left is ' + $('#portInner').position().left);
							$('#nextBtn').show();
							//console.log($('#portInner').width());
						}
				},	
				 //determine whether or not to display PREVIOUS button
				showPreviousBtn: function() {
					//alert('show previous');
					//console.log($('#portInner').position().left);
					if ($('#portInner').position().left < 0) {
						//console.log('showing prev btn');
						$('#prevBtn').show();
					}
					else {
						//console.log('not showing prev btn');
						$('#prevBtn').hide();
					}
				},
				 //scroll portfolio
				 nextScroll: function() {
					 //alert('next scroll');
					 //console.log('starting left ' + $('#portInner').css('left'));
					 var scrollAmount = $('#portInner').width() - $('#portBottomLinks').width();
					 var currentPos = Math.abs(parseInt($('#portInner').position().left));
					 var remainingScroll = scrollAmount - currentPos;
					 var nextScroll = Math.floor($('#portBottomLinks').width());
					 //console.log('scroll amt ' + scrollAmount + ', currentPos ' + currentPos + ', remainingScroll ' + remainingScroll + ', nextScroll ' + nextScroll);
					 if (remainingScroll < nextScroll) { //if there isn't a full scroll left only scroll remaining amount
						nextScroll = remainingScroll; 
					 }
					 //console.log('calculated nextScroll is ' + nextScroll);
					 $('#portInner').animate({'left' : '-=' + nextScroll}, 1000 , 'swing', function() {
										   PORT.showNextBtn();
										   PORT.showPreviousBtn();
										   //console.log('ending left ' + $('#portInner').css('left'));
										   }); 
				 },
				 prevScroll: function() {
					 //alert('prev scroll');
					 //console.log('starting left ' + $('#portInner').css('left'));
					 var currentPos = Math.abs(parseInt($('#portInner').position().left));
					 var nextScroll = Math.ceil($('#portBottomLinks').width());
					 
					 if (currentPos < nextScroll) { //if there isn't a full scroll left only scroll remaining amount
						nextScroll = currentPos; 
					 }
					 
					 $('#portInner').animate({'left' : '+=' + nextScroll}, 1000 , 'swing' , function() {
										   PORT.showNextBtn();
										   PORT.showPreviousBtn();
										   //console.log('ending left ' + $('#portInner').css('left'));
										   });
				 },
				 filter: function() {
					 //alert('filter');
					//alert('sort img array');
					var matchedArray = [];
					var classesArray = [];
					var thisClass;
					
					if ($('#portInner').hasClass("campbells")) thisClass = 'campbells';
					else if ($('#portInner').hasClass("corporate")) thisClass = 'corporate'; 
					else if ($('#portInner').hasClass("entertainment")) thisClass = 'entertainment'; 
					else if ($('#portInner').hasClass("exhibit")) thisClass = 'exhibit'; 
					else if ($('#portInner').hasClass("flavia")) thisClass = 'flavia'; 
					else if ($('#portInner').hasClass("hershey")) thisClass = 'hershey'; 
					else if ($('#portInner').hasClass("integrated")) thisClass = 'integrated'; 
					else if ($('#portInner').hasClass("justborn")) thisClass = 'justborn'; 
					else if ($('#portInner').hasClass("necco")) thisClass = 'necco'; 
					else if ($('#portInner').hasClass("online")) thisClass = 'online'; 
					else if ($('#portInner').hasClass("outdoor")) thisClass = 'outdoor'; 
					else if ($('#portInner').hasClass("packaging")) thisClass = 'packaging'; 
					else if ($('#portInner').hasClass("pinnacle")) thisClass = 'pinnacle'; 
					else if ($('#portInner').hasClass("pop")) thisClass = 'pop'; 
					else if ($('#portInner').hasClass("print")) thisClass = 'print'; 
					else if ($('#portInner').hasClass("promotions")) thisClass = 'promotions'; 
					else if ($('#portInner').hasClass("ringling")) thisClass = 'ringling'; 
					else if ($('#portInner').hasClass("sales")) thisClass = 'sales'; 
					else if ($('#portInner').hasClass("sanofi")) thisClass = 'sanofi'; 
					else if ($('#portInner').hasClass("scotts")) thisClass = 'scotts'; 
					else if ($('#portInner').hasClass("sleep")) thisClass = 'sleep'; 
					else if ($('#portInner').hasClass("valio")) thisClass = 'valio'; 
					else if ($('#portInner').hasClass("videos")) thisClass = 'videos'; 
					else if ($('#portInner').hasClass("archive")) thisClass = 'archive';
					else return;
					
					//MAKE SIDE NAV LINK 'CURRENT'
					$('#portNav ul li a#' + thisClass + 'Link').addClass('current');
					//alert(PORT.imgNames.length);
					
					var _imgNames = PORT.imgNames;
					//CHECK IF THE ARRAY CONTAINS THE CLASS AND ADD TO NEW ARRAY
					for (var i=0; i < _imgNames.length; i++) {
						var next = _imgNames[i].split('|');
						
						if (next[1].indexOf(thisClass) > -1) {
							//alert(next[0]);
							matchedArray.push(next[0]);  //ADD THE IMG NAME TO NEW ARRAY
							classesArray.push(next[1]);  //ADD THE CLASSES TO THIS ARRAY
							//alert(matchedArray.length);
						}
					}
					
					if (matchedArray.length == 0) {
						//console.log('none');
						return false;
					}
					else if (matchedArray.length < 5) {
						$('#nextBtn').hide();
					}
					
					var linkstoadd = "";
					//var videoTable = $('#videoTable');
					var videoAdded = false;
					//alert(matchedArray.length + "  " + classesArray.length);
					for (var j=0; j<matchedArray.length; j++) {
						
						
						if (classesArray[j].indexOf('movie') > -1) {  //if there is a movie class, href is empty
							linkstoadd += '<li><a href="" class="' + classesArray[j] + '"><img src="../IMG/portfolioImgs/DEFAULT/' + matchedArray[j] + '.jpg" /></a></li>';
							
							var toadd ;
							//alert('adding vid');
							//alert(classesArray[j]);
							if (classesArray[j].indexOf('campbells') > -1) {
								 //lert('this');
								 //$('a.player.campbells').show();
								 toadd = '<a class="player campbells" href="../MOV/Despereaux.flv" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"><img src="../IMG/play_large.png" alt="play button" class="flowplay" /><!-- <img src="../MOV/Despereaux.jpg" alt="Despereaux video" /> --> </a>';
							} else if (classesArray[j].indexOf('flavia1') > -1) {
								 //$('a.player.flavia1').show();
								 //alert('that');
								 toadd = '<a class="player flavia1" href="../MOV/Flavia1.flv" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"> <img src="../IMG/play_large.png" alt="play button" class="flowplay" /> <!-- <img src="../MOV/flavia1.jpg" alt="Flavia video" /> --> </a>';
							} else if (classesArray[j].indexOf('flavia2') > -1) {
								 //$('a.player.flavia2').show();
								 toadd = '<a class="player flavia2" href="../MOV/Flavia2.flv" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"><img src="../IMG/play_large.png" alt="play button" class="flowplay" /> <!-- <img src="../MOV/flavia2.jpg" alt="Flavia video" /> --> </a>';
							} else if (classesArray[j].indexOf('ringlingmov') > -1) {
								//$('a.player.ringlingmov').show();
								toadd = '<a class="player ringlingmov" href="../MOV/Trailers.flv" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"><img src="../IMG/play_large.png" alt="play button" class="flowplay" /> <!-- <img src="../MOV/trailers.jpg" alt="Ringling Brothers trailers video" /> --> </a>';
							} else if (classesArray[j].indexOf('ringlingads') > -1) {
								//$('#bannerAds').show();
								toadd = '<div id="bannerAds"><img src="../IMG/portfolioImgs/gifs/rbbbc_234X60A.gif" alt="ringling bros. banner ad" id="rb1" /><img src="../IMG/portfolioImgs/gifs/rbbc_300X250A.gif" alt="ringling bros. banner ad" id="rb2" /><p>Banner Ads</p></div>';
							} else if (classesArray[j].indexOf('wife') > -1) {
								//$('a.player.wife').show();
								 toadd = '<a class="player wife" href="../MOV/wife.mp3" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"><img src="../IMG/play_large.png" alt="play button" class="flowplay" /></a>';
							} else if (classesArray[j].indexOf('newexpert') > -1) {
								 //$('a.player.newexpert').show();
								 toadd = '<a class="player newexpert" href="../MOV/newexpert.mp3" style="background: gray; display: block; height: 350px; width: 500px; margin-top: 10px; margin-left: 20px;"><img src="../IMG/play_large.png" alt="play button" class="flowplay" /></a>';
							} else if (classesArray[j].indexOf('sleepMovie') > -1) {
								 toadd = '<a class="player sleepMovie" href="../MOV/sleep.flv" style="background: gray; display: block; margin-top: 10px; margin-left: 20px;"> <img src="../IMG/play_large.png" alt="play button" class="flowplay" /></a>';
							}
							
							
							
							$('#videoTable').append(toadd);
							//alert('added video');
									//$('<li><a href="" class="' + classesArray[j] + '"><img src="../IMG/portfolioImgs/DEFAULT/' + matchedArray[j] + '.jpg" /></a></li>').appendTo($('#portBottomLinks ul'));
						} else {//not a video link
							linkstoadd += '<li><a href="../IMG/portfolioImgs/MAIN/' + matchedArray[j] + '_MAIN.jpg" class="' + classesArray[j] + '"><img src="../IMG/portfolioImgs/DEFAULT/' + matchedArray[j] + '.jpg" /></a></li>';
						}
					}
					
					$('#portBottomLinks ul').html(linkstoadd);
										
						//alert('not added');					
					/*var addscript = '<script type="text/javascript">var api = flowplayer("a.player", "../MOV/flowplayer/flowplayer.swf", { plugins: { audio: { url: "../MOV/flowplayer/flowplayer.audio.swf" } }	});</script>';	*/
					
					//$(document).append(addscript);
					
					//if(api) alert('api');
					//else alert('no api');
					
					$('a.player').hide(); //hide links for flowplayer

					PORT.swapImage($('#portInner li:first-child a'));
					
					
					//alert('end filter');
				},
				hideCaseStudy: function() {
					//alert('hide cs');
					$('#caseStudyLink').show();
					$('#caseStudyExpanded').animate({
								opacity: 'hide',
								height: 'hide'
							}, 500, 'swing');
				},
				showCaseStudy: function() {
					//alert('show cs');
					$('#caseStudyLink').hide();
					$('#caseStudyExpanded')
							.animate({
								  opacity: 'show',
								  height: 'show'
							}, 800, 'swing')
							.hover(function() {
								  $(this).css('cursor','pointer');
							});
				},
				hideCaseStudyBtn: function() {
					//alert('hide cs btn');
					$('#caseStudyLink').hide();
				},
				showCaseStudyBtn: function() {
					//alert('show cs btn');
					$('#caseStudyLink').show();
				},
				switchCaseStudyText: function(portLink) { //attach this function to the portBottom links
				//alert('switch cs text');
					PORT.hideCaseStudy();
					var caseStudyText;
					if ($(portLink).hasClass("noCaseStudy")) PORT.hideCaseStudyBtn();
					else
					{
						PORT.showCaseStudyBtn();
						switch (true)
						{
							case $(portLink).hasClass('despereaux'):
								caseStudyText = despereaux;
								break;			
							case $(portLink).hasClass("despereaux"):
								caseStudyText = despereaux;
								break;
							case $(portLink).hasClass("rulePark"):
								caseStudyText = rulePark;
								break;
							case $(portLink).hasClass("v8"):
								caseStudyText = v8;
								break;
							case $(portLink).hasClass("freshLook"):
								caseStudyText = freshLook;
								break;
							case $(portLink).hasClass("hungryMan"):
								caseStudyText = hungryMan;
								break;
							case $(portLink).hasClass("pieSky"):
								caseStudyText = pieSky;
								break;
							case $(portLink).hasClass("footsteps"):
								caseStudyText = footsteps;
								break;
							case $(portLink).hasClass("clownCollege"):
								caseStudyText = clownCollege;
								break;
							case $(portLink).hasClass("fastTrack"):
								caseStudyText = fastTrack;
								break;
							case $(portLink).hasClass("overTheTop"):
								caseStudyText = overTheTop;
								break;
							case $(portLink).hasClass("unforgettable"):
								caseStudyText = unforgettable;
								break;
							case $(portLink).hasClass("allAges"):
								caseStudyText = allAges;
								break;
							case $(portLink).hasClass("eat5"):
								caseStudyText = eat5;
								break;
							case $(portLink).hasClass("dough"):
								caseStudyText = dough;
								break;
							case $(portLink).hasClass("bread"):
								caseStudyText = bread;
								break;
							case $(portLink).hasClass("zoom"):
								caseStudyText = zoom;
								break;
							case $(portLink).hasClass("glow"):
								caseStudyText = glow;
								break;
							case $(portLink).hasClass("regMedTeam"):
								caseStudyText = regMedTeam;
								break;
							case $(portLink).hasClass("metBrochure"):
								caseStudyText = metBrochure;
								break;
							case $(portLink).hasClass("waterSmart"):
								caseStudyText = waterSmart;
								break;
							case $(portLink).hasClass("turf"):
								caseStudyText = turf;
								break;
							case $(portLink).hasClass("wafers"):
								caseStudyText = wafers;
								break;
							case $(portLink).hasClass("twilight"):
								caseStudyText = twilight;
								break;
							case $(portLink).hasClass("trueLove"):
								caseStudyText = trueLove;
								break;
							case $(portLink).hasClass("goodness"):
								caseStudyText = goodness;
								break;
							case $(portLink).hasClass("bigman"):
								caseStudyText = bigman;
								break;
							case $(portLink).hasClass("holiday"):
								caseStudyText = holiday;
								break;
							case $(portLink).hasClass("eggies"):
								caseStudyText = eggies;
								break;
							case $(portLink).hasClass("growing"):
								caseStudyText = growing;
								break;
							case $(portLink).hasClass("peep"):
								caseStudyText = peep;
								break;
							case $(portLink).hasClass("reinvent"):
								caseStudyText = reinvent;
								break;
							case $(portLink).hasClass("memories"):
								caseStudyText = memories;
								break;
							case $(portLink).hasClass("bigDog"):
								caseStudyText = bigDog;
								break;	
							case $(portLink).hasClass("riseEmpire"):
								caseStudyText = riseEmpire;
								break;
							case $(portLink).hasClass("ogreSuccess"):
								caseStudyText = ogreSuccess;
								break;	
							case $(portLink).hasClass("ogreExpect"):
								caseStudyText = ogreExpect;
								break;
							case $(portLink).hasClass("indyHat"):
								caseStudyText = indyHat;
								break;
							case $(portLink).hasClass("indyPack"):
								caseStudyText = indyPack;
								break;
							case $(portLink).hasClass("piratesKit"):
								caseStudyText = piratesKit;
								break;	
							case $(portLink).hasClass("shrekKit"):
								caseStudyText = shrekKit;
								break;
							case $(portLink).hasClass("tisSeason"):
								caseStudyText = tisSeason;
								break;	
							case $(portLink).hasClass("novelties"):
								caseStudyText = novelties;
								break;
							case $(portLink).hasClass("greenLove"):
								caseStudyText = greenLove;
								break;
							case $(portLink).hasClass("dimension"):
								caseStudyText = dimension;
								break;
							case $(portLink).hasClass("panda"):
								caseStudyText = panda;
								break;	
							case $(portLink).hasClass("santa"):
								caseStudyText = santa;
								break;
							case $(portLink).hasClass("berries"):
								caseStudyText = berries;
								break;	
							case $(portLink).hasClass("ghouls"):
								caseStudyText = ghouls;
								break;
							case $(portLink).hasClass("newTarget"):
								caseStudyText = newTarget;
								break;	
							case $(portLink).hasClass("timeAfter"):
								caseStudyText = timeAfter;
								break;
							case $(portLink).hasClass("shades21"):
								caseStudyText = shades21;
								break;
							case $(portLink).hasClass("sponsorships"):
								caseStudyText = sponsorships;
								break;
							case $(portLink).hasClass("indulge"):
								caseStudyText = indulge;
								break;	
							case $(portLink).hasClass("oneSource"):
								caseStudyText = oneSource;
								break;
							case $(portLink).hasClass("innovation"):
								caseStudyText = innovation;
								break;	
							case $(portLink).hasClass("evolve"):
								caseStudyText = evolve;
								break;
							case $(portLink).hasClass("highWater"):
								caseStudyText = highWater;
								break;
							case $(portLink).hasClass("globalColor"):
								caseStudyText = globalColor;
								break;	
							case $(portLink).hasClass("chewClue"):
								caseStudyText = chewClue;
								break;
							case $(portLink).hasClass("minis"):
								caseStudyText = minis;
								break;	
							case $(portLink).hasClass("twist"):
								caseStudyText = twist;
								break;	
							case $(portLink).hasClass("imposter"):
								caseStudyText = imposter;
								break;
							case $(portLink).hasClass("radioad"):
								caseStudyText = radioad;
								break;
							case $(portLink).hasClass("easter"):
								caseStudyText = easter;
								break;
							case $(portLink).hasClass("thinmints"):
								caseStudyText = thinmints;
								break;
							case $(portLink).hasClass("skybar"):
								caseStudyText = skybar;
								break;
							case $(portLink).hasClass("clarkbar"):
								caseStudyText = clarkbar;
								break;
							case $(portLink).hasClass("leadingedge"):
								caseStudyText = leadingedge;
								break;
							case $(portLink).hasClass("holiday2"):
								caseStudyText = holiday2;
								break;	
							case $(portLink).hasClass("reality"):
								caseStudyText = reality;
								break;	
							case $(portLink).hasClass("york"):
								caseStudyText = york;
								break;	
							case $(portLink).hasClass("take5"):
								caseStudyText = take5;
								break;	
							case $(portLink).hasClass("served"):
								caseStudyText = served;
								break;	
							case $(portLink).hasClass("sleeping"):
								caseStudyText = sleeping;
								break;	
							case $(portLink).hasClass("momentum"):
								caseStudyText = momentum;
								break;	
							
						}
						$('#caseStudyExpanded').html(caseStudyText);
					}
				},
				
				showHoverImage: function(thisLink) {
					//console.log('hover');
					var img = $(thisLink).find('img');
					//console.log('img ' + $(img).attr('src'));
					var $src = $(img).attr("src");
					//console.log('src '+ $src);
					$src = $src.replace(".jpg", "_HOVER.jpg");
					$src = $src.replace("portfolioImgs/DEFAULT/", "portfolioImgs/HOVER/");
					//console.log($src);
					$(img).attr("src", $src);	 
				 },
				 showDefaultImage: function(thisLink) {
					//console.log('default');
					var img = $(thisLink).find('img');
					var $src = $(img).attr("src");
					//console.log($src);
					$src = $src.replace("_HOVER.jpg" , ".jpg");
					$src = $src.replace("portfolioImgs/HOVER/" , "portfolioImgs/DEFAULT/");
					$(img).attr("src", $src);
				 },
				currentImage: function(thisLink) {
					//alert('current image');
					//console.log('current image');
					var $current = $('#portInner li a.current');
					//console.log($current.length);
					if ($current.length) {
						$current.removeClass('current');
						PORT.showDefaultImage($current);
						if ($current.hasClass('movie')) PORT.removeMovie();
					}
					$(thisLink).addClass('current');
					PORT.showHoverImage(thisLink);
				},
				removeMovie: function() {
					//alert('remove movie');
					//$('#videoTable').html('');
					$('a.player, #bannerAds, a object').hide();
					flowplayer().stop(); 
					//alert('stopping');
					$('#portImage').show();
				},
				/*movieLoaded: var = false,*/
				loadMovie: function(thisLink) {
					//alert($('#videoTable').html() );
					//alert('load movie');
					$('a.player, #bannerAds').hide();
					$('#portImage').hide();
					
					//$('a.player, #bannerAds').hide();
					//var newhtml;
					
					if ($(thisLink).hasClass('campbells')) {
						 $('a.player.campbells, a.player.campbells object').show();
					} else if ($(thisLink).hasClass('flavia1')) {
						 $('a.player.flavia1, a.player.flavia1 object').show();
					} else if ($(thisLink).hasClass('flavia2')) {
						$('a.player.flavia2, a.player.flavia2 object').show();
					} else if ($(thisLink).hasClass('ringlingmov')) {
						$('a.player.ringlingmov, a.player.ringlingmov object ').show();
					} else if ($(thisLink).hasClass('ringlingads')) {
						$('#bannerAds').show();
					} else if ($(thisLink).hasClass('wife')) {
						$('a.player.wife, a.player.wife object').show();
					} else if ($(thisLink).hasClass('newexpert')) {
						$('a.player.newexpert, a.player.newexpert object').show();
					} else if ($(thisLink).hasClass('sleepMovie')) {
						$('a.player.sleepMovie, a.player.sleepMovie object').show();
					}
					
					//$('#videoTable').html(newhtml);
				},
				
				init: function() {
					//alert('init');

					 $('#portInner li a').live('click',function(ev) { //attaches to dynamically created links
									   ev.preventDefault(); 
									   if (!$(this).hasClass('current'))  {
										   PORT.swapImage($(this));
										   //PORT.currentImage($(this));
										   //$('#portInner li a.current').removeClass('current');
										   //$(this).addClass('current');
									   }
									   });
					 $('#nextBtn').click(function(ev) {
											PORT.nextScroll();
											ev.preventDefault();
											//console.log('next');
											});
					 $('#prevBtn').click(function(ev) {
											PORT.prevScroll();
											ev.preventDefault();
											//console.log('prev');
											});
					 $('#caseStudy').click(function(ev) {
											PORT.showCaseStudy();
											ev.preventDefault();
											});
					 $('#caseStudyExpanded').click(function(ev) {
											PORT.hideCaseStudy();
											ev.preventDefault();
											});
					 
					 //PORT.showNextBtn();
					 //PORT.showPreviousBtn();
					 //console.log('imgNames length ' + $(PORT.imgNames).length);
					 
				 },
				 imgNames: ["campbells_01|campbells entertainment integrated despereaux",  
						"campbells_03|campbells online integrated despereaux",
						"campbells_04|campbells despereaux pop",
						"campbells_05|campbells despereaux integrated print",
						"campbells_02|campbells sales despereaux",
						"campbells_06|campbells rulePark integrated",
						"campbells_07|campbells rulePark print",
						"v8_01|campbells print v8",
						"hershey_splash| hershey noCaseStudy print outdoor pop packaging",
						/*"hershey_27|hershey momentum",*/
						/*
						"hershey_19|hershey holiday2 print",
						"hershey_20|hershey holiday2 print",
						"hershey_30|hershey holiday2 outdoor",
						"hershey_29|hershey holiday2 outdoor",
						"hershey_21|hershey holiday2 pop",
						"hershey_22|hershey holiday2 pop",
						"hershey_23|hershey holiday2 pop",
						"hershey_24|hershey holiday2 packaging",
						"hershey_31|hershey holiday2 packaging",
						"hershey_25|hershey york packaging",
						"hershey_26|hershey take5 packaging",
						"hershey_28|hershey reality packaging",
						"hershey_07|hershey packaging holiday",
						"hershey_10|hershey packaging holiday",
						"hershey_11|hershey packaging holiday",
						"hershey_08|hershey print holiday",
						"hershey_06|hershey print holiday",
						"hershey_04|hershey print holiday",
						"hershey_05|hershey print holiday",
						"hershey_12|hershey packaging holiday",
						"hershey_09|hershey packaging eggies",
						*/
						"flavia_10|flavia served integrated",
						"flavia_03|flavia sales growing",
						"flavia_04|flavia print freshLook",
						"flavia_05|flavia sales freshLook",
						"flavia_06|flavia exhibit freshLook",
						"flavia_08|flavia exhibit freshLook",
						"flavia_07|flavia exhibit freshLook",
						"flavia_09|flavia exhibit freshLook",
						"flavia_02|flavia exhibit freshLook",
						"necco_04|necco packaging thinmints",
						"necco_05|necco packaging clarkbar",
						"necco_06|necco packaging skybar",
						"sweetheart_03|necco packaging trueLove",
						"sweetheart_07|necco pop trueLove",
						"sweetheart_08|necco pop trueLove",
						"sweetheart_02|necco packaging noCaseStudy",
						"sweetheart_01|necco packaging entertainment twilight",
						"sweetheart_10|necco packaging entertainment twilight",
						"sweetheart_11|necco packaging entertainment twilight",
						"sweetheart_04|necco sales entertainment twilight",
						"sweetheart_13|necco packaging entertainment twilight",
						"sweetheart_14|necco packaging entertainment twilight",
						"sweetheart_05|necco packaging trueLove",
						"sweetheart_06|necco sales trueLove",
						"necco_03|necco packaging wafers",
						"necco_02|necco corporate reinvent",
						"pinnacle_01|pinnacle pop hungryMan",
						"rbbc_04|ringling print overTheTop",
						"rbbc_19|ringling outdoor overTheTop",
						"rbbc_20|ringling outdoor overTheTop",
						"rbbc_21|ringling movie ringlingads online noCaseStudy",
						"rbbc_10|ringling print zoom",
						"rbbc_18|ringling outdoor zoom",
						"rbbc_17|ringling outdoor zoom",
						"rbbc_13|ringling videos memories",
						"rbbc_05|ringling print unforgettable",
						"rbbc_11|ringling outdoor glow",
						"glowMovie|ringling videos movie ringlingmov noCaseStudy",
						"rbbc_12|ringling pop footsteps",
						"rbbc_02|ringling corporate clownCollege",
						"rbbc_15|ringling pop noCaseStudy",
						"rbbc_14|ringling print noCaseStudy",
						"rbbc_16|ringling sales noCaseStudy",
						"rbbc_01|ringling online videos pieSky",
						"sanofi_01|sanofi corporate regMedTeam",
						"sanofi_02|sanofi sales metBrochure",
						"sanofi_04|sanofi sales leadingedge",
						"sanofi_05|sanofi sales leadingedge",
						"sanofi_03|sanofi sales leadingedge",
						"scotts_02|scotts outdoor waterSmart",
						"scotts_01|scotts integrated pop turf",
						"scotts_03|scotts print integrated turf",
						"sleep_01|sleep sleeping packaging",
						"sleep_02|sleep sleeping packaging",
						"sleep_03|sleep sleeping outdoor",
						"sleep_04|sleep sleeping print",
						"sleep_05|sleep sleeping pop",
						"valio_04|valio sales goodness",
						"valio_02|valio print goodness",
						"valio_07|valio print goodness",
						"valio_01|valio integrated goodness",
						"valio_05|valio print goodness",
						"valio_03|valio promotions bigman",
						"valio_06|valio print bigman",
						"valio_09|valio outdoor radioad",
						//videos
						"valio_10|valio videos movie wife noCaseStudy",
						"valio_11|valio videos movie newexpert noCaseStudy",
						"despMovie|campbells videos movie noCaseStudy",
						"flaviaMovie_01|flavia flavia1 videos movie noCaseStudy",
						"flaviaMovie_02|flavia flavia2 videos movie noCaseStudy",
						"sleepMovie|sleep sleepMovie videos movie noCaseStudy",
						//archives
						"peeps_01|archive noCaseStudy corporate peep",
						"indyHat| archive noCaseStudy indyHat",
						"indyPack| archive noCaseStudy indyPack",
						"highWater| archive noCaseStudy highWater",
						"piratesKit| archive noCaseStudy noCaseStudy",	
						"riseEmpire| archive noCaseStudy riseEmpire",
						"shrekKit| archive noCaseStudy noCaseStudy",
						"ogreExpect| archive noCaseStudy ogreExpect",
						"ogreSuccess| archive noCaseStudy ogreSuccess",			
						"globalColor| archive noCaseStudy globalColor",	
						"tisSeason| archive noCaseStudy tisSeason",
						"imposter| archive noCaseStudy imposter",
						"minis| archive noCaseStudy minis",
						"greenLove| archive noCaseStudy greenLove",	
						"dimension| archive noCaseStudy dimension",
						"berries| archive noCaseStudy berries",	
						"ghouls| archive noCaseStudy ghouls",
						"newTarget| archive noCaseStudy newTarget",
						"shades21| archive noCaseStudy shades21",	
						"sponsorships| archive noCaseStudy sponsorships",
						"novelties| archive noCaseStudy noCaseStudy",
						"indulge| archive noCaseStudy indulge",	
						"timeAfter| archive noCaseStudy timeAfter",
						"chewClue| archive noCaseStudy chewClue",
						"twist| archive noCaseStudy twist",
						"panda| archive noCaseStudy panda",
						"santa| archive noCaseStudy santa",
						"leno_01| archive noCaseStudy corporate bigDog",
						"leno_02| archive noCaseStudy corporate bigDog",
						"evolve| archive noCaseStudy evolve",
						"innovation| archive noCaseStudy innovation",
						"oneSource| archive noCaseStudy oneSource"]

			 
			}; 		
		PORT.init(); //initiate portfolio namespace 
		//flowplayer("a.player", "../MOV/flowplayer/flowplayer.swf", { plugins: { audio: { url: "../MOV/flowplayer/flowplayer.audio.swf" } }	});
		var movieLoaded = false;
		PORT.filter();
		

		//var api = flowplayer("a.player", "../MOV/flowplayer/flowplayer.swf", { plugins: { audio: { url: "../MOV/flowplayer/flowplayer.audio.swf" } }	});
		//alert('loaded port');
		
		//SET PORTBOTTOMLINKS WIDTH DEPENDING ON HOW MANY LINKS THERE WILL BE
		//WIDTH OF EACH LINK = 50px
		//PADDING ON R AND L = 15px
		
		
		
		var ARRAY_LENGTH = $('#portInner li a img').length;
		var LINK_WIDTH = 80; 
		var newWidth = ARRAY_LENGTH * LINK_WIDTH;
		//alert(newWidth);
		$('#portBottomLinks ul').css('width', newWidth + 'px');
	
	
	
	}
	//console.log('no port');
	
});
