/* 	Interface Functions
*/

// Portfolio Simple Switch Image Toggle Text
//Version 1: March 1 2009. Author: Barbara Lynn - Lynn Creative, Inc. (www.lynncreative.com)


	$(document).ready(function(){
    
	$('.item_desc:not(:first)').hide();
	
	//fixes ie6 refusal to accept not:first
	$('.firstitem').show();

	$("#section_select a").click(function() {
	
	var element = $(this);
	
	$('.item_desc').slideUp("slow");
    $($(element).attr("href")).slideDown("slow");
	return false;
	});
	
	$("img.fader").click(function() {
    var largePath = $(this).attr('src').replace('_t.', '.');
	var largeAlt = $(this).attr("title");
	
	$("#largeImg").attr({ src: largePath, alt: largeAlt });
	
	}); 
	
	$("img.caseFader").click(function() {
		
    var largePath = $(this).attr('src').replace('_t.', '.');
	var largeAlt = $(this).attr("title");
	
	$("#largeImg").attr({ src: largePath, alt: largeAlt });
	return false;
	}); 
	
	


// Porfolio Fader	
$('img.fader')
		
		.mouseover(function(){
			$(this).stop().animate({"opacity" : ".25" }, {duration:1000})
		})
		
		.mouseout(function(){
			$(this).stop().animate({"opacity" : "1"}, {duration:1000, complete:function(){
			}})
	});	


// Left Squares Fader
	
$('img.leftFader')
		
		.mouseover(function(){
			$(this).stop().animate({"opacity" : ".25" }, {duration:1000})
		})
		

		.mouseout(function(){
			$(this).stop().animate({"opacity" : "1"}, {duration:1000, complete:function(){
			}})
	
	});
		
		
// Case Study Fader
	
$('img.caseFader')
		
		.mouseover(function(){
			$(this).stop().animate({"opacity" : ".25" }, {duration:1000})
		})
		
	
		.mouseout(function(){
			$(this).stop().animate({"opacity" : "1"}, {duration:1000, complete:function(){
			}})
	
	});
		
		
	// Call To Action Fader
	
$('img.talkFader')
		
		.mouseover(function(){
			$(this).stop().animate({"opacity" : ".25" }, {duration:1000})
		})
		
	
		.mouseout(function(){
			$(this).stop().animate({"opacity" : "1"}, {duration:1000, complete:function(){
			}})
	
	});
		
	
// Menu Slide

$('.menu a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 -126px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300, complete:function(){
				$(this).css({backgroundPosition: "0px 0px"})
			}})
		})
	
	});
	
	
	
	
	
function initMenu() {
  $('#subnav ul').hide();
  $('#subnav li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
  }
$(document).ready(function() {initMenu();});
	


// External 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.target = "_blank";  
   }  
}  
window.onload = externalLinks;




// Submenu


<!--
var temp, temp2, cookieArray, cookieArray2, cookieCount;
function initiate(){
  cookieCount=0;
  if(document.cookie){
    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();
    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }
  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();
  temp=document.getElementById("submenu");
  for(var o=0;o<temp.getElementsByTagName("li").length;o++){
    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(images/plusminus/minus.png)":"url(images/plusminus/plus.png)"):"url(images/plusminus/plus.png)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else{
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(images/plusminus/page.png)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}

function showhide(el){
  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(images/plusminus/minus.png)":"url(images/plusminus/plus.png)";
}

function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
  cookieArray=new Array()
  for(var q=0;q<temp.getElementsByTagName("li").length;q++){
    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
}


JQuery.find.selectors.filters.hidden = function(elem){
        return "hidden" === elem.type ||
                jQuery.css(elem, "display") === "none" ||
                jQuery.css(elem, "visibility") === "hidden";

};

//-->
