// JavaScript Document

// <![CDATA[
var myMenu;
window.onload = function() {
	myMenu = new SDMenu("expandable");
	myMenu.init();
	myMenu.collapseAll(); 
	externalLinks();
};
// ]]>



<!--// open link in new window
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;
// -->

function featuredwork(id){
	document.getElementById("copy0").style.display="none";
	document.getElementById("copy1").style.display="none";
	document.getElementById("copy2").style.display="none";
	document.getElementById("copy3").style.display="none";
	
	document.getElementById("copy" + id).style.display="inline";
}




function LightboxDelegate(url,caption) {
	var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title',caption);
	Lightbox.prototype.start(objLink);
}

// begin sdmenu ______________________________
	/***********************************************
	* Slashdot Menu script- By DimX
	* Submitted to Dynamic Drive DHTML code library: http://www.dynamicdrive.com
	* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	***********************************************/
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};

function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = document.getElementsByClassName("group");
	this.remember = false;
	this.speed = 10;
	this.markCurrent = false;
	this.oneSmOnly = true;
}
SDMenu.prototype.init = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("span");
		for (var i = 0; i < links.length; i++)
			if (links[i].href == document.location.href) {
				links[i].className = "current";
				break;
			}
	}
	if (this.remember) {
		var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
		var match = regex.exec(document.cookie);
		if (match) {
			var states = match[1].split("");
			for (var i = 0; i < states.length; i++)
				this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("li");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "expanded";
			mainInstance.memorize();
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("li").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
			mainInstance.memorize();
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
	if (this.remember) {
		var states = new Array();
		for (var i = 0; i < this.submenus.length; i++)
			states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
		var d = new Date();
		d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
		document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
	}
};
// end sdmenu _________________________________


function getTip() {
	var arrTips=new Array();
	
	arrTips[arrTips.length] = 'Jajo is located in the historic Orpheum Theatre building in downtown Wichita.';
	arrTips[arrTips.length] = 'Jajo placed first at the Advertising Federation of Wichita\'s Ad2 Pumpkin-Carving Challenge in October 2007.';
	arrTips[arrTips.length] = 'Jajo placed first at the Advertising Federation of Wichita\'s Ad2 Bowling Challenge in May 2008.';
	arrTips[arrTips.length] = 'Wichita is known as the &ldquo;Air Capital of the World.&rdquo;';
	arrTips[arrTips.length] = 'Pro Football Hall of Fame running back Barry Sanders calls Wichita home.';
	arrTips[arrTips.length] = 'Kirstie Alley, better known as Rebecca from the TV sitcom “Cheers,” was raised in Wichita.';
	arrTips[arrTips.length] = 'Brothers Dan and Frank Carney founded Pizza Hut in Wichita in 1958 with a $600 loan from their mother.';
	arrTips[arrTips.length] = 'The first complete recording made by jazz musician Charlie “Bird” Parker took place in Wichita';
	arrTips[arrTips.length] = 'The cartoon character “Dennis the Menace” lived in the outskirts of Wichita.';
	arrTips[arrTips.length] = 'In July 2006, CNN/Money Magazine ranked Wichita one of the 10 best big cities to live in.';
	arrTips[arrTips.length] = 'In February 2008, The American Advertising Federation of Wichita awarded Jajo 22 ADDYs, including its prestigious Special Judges\' Citation. ';
	
	
	//Select random numberbetween 1 and number of tips.
	var intTip=Math.floor(Math.random()*arrTips.length);

	//Set html in Tip Div
	tipHTML = '<h4>Did You Know # ' + (intTip+1) + '</h4>';
	tipHTML = tipHTML + '<p>' + arrTips[intTip] + '</p>';
	document.getElementById('didyouknow').innerHTML = tipHTML;

}

function showcapabilities(divnum){
	showdiv = 'capabilities' + divnum;
	showlink = 'capabilitieslink' + divnum;
	
	for(x=1;x <=8;x++){
			if(document.getElementById('capabilities' + x)){
				document.getElementById('capabilities' + x).style.display="none";
			}
			if(document.getElementById('capabilitieslink' + x)){
					document.getElementById("capabilitieslink" + x).setAttribute("class", "inactive");
					document.getElementById("capabilitieslink" + x).setAttribute("className", "inactive");
			}
	}
	
	document.getElementById('capabilities1').style.display="none";
	document.getElementById('capabilities2').style.display="none";
	document.getElementById('capabilities3').style.display="none";
	document.getElementById('capabilities4').style.display="none";
	document.getElementById('capabilities5').style.display="none";
	document.getElementById('capabilities6').style.display="none";
	document.getElementById('capabilities7').style.display="none";
	document.getElementById('capabilities8').style.display="none";

	document.getElementById(showdiv).style.display="block";
	document.getElementById(showlink).setAttribute("class","selected");
	document.getElementById(showlink).setAttribute("className","selected");
	
}


function checkwidth() {
	if(document.getElementById('loadimage').width > document.getElementById('loadimage').width){
	
		return '1000';
	} else {
		return '550';
	}
}



function showhidecase(){
	if(document.getElementById('projdescription').style.display == 'inline'){
		document.getElementById('casearea').style.display = 'inline';
		document.getElementById('casearea').style.marginLeft = '0';
		
		document.getElementById('projdescription').style.display = 'none';
		if(document.getElementById('caselink')){
			document.getElementById('caselink').innerHTML='Show Description';
		}
	} else {
		document.getElementById('casearea').style.display = 'none';
		document.getElementById('projdescription').style.display = 'inline';
		if(document.getElementById('caselink')){
			document.getElementById('caselink').innerHTML='Show Case Study';
		}
		
	}
}
function hidecase(){		
		document.getElementById('casearea').style.display = 'none';
		document.getElementById('projdescription').style.display = 'inline';
		if(document.getElementById('caselink')){
			document.getElementById('caselink').innerHTML='Show Case Study';
		}
}



/******************************************************
 **************** Leadership Functions *****************
 *******************************************************/

function showbubble(id){
	getxy=getXY(document.getElementById('dawg' + id));
	getxfooter=getXY(document.getElementById('footer'));
	//alert(x);
	newx=getxy.x - getxfooter.x + 55;
	
	document.getElementById('thebubble').style.display='block';
	document.getElementById('passion').innerHTML = dawgs[id][0];
	document.getElementById('dawgname').innerHTML = dawgs[id][1];
	
	if(isIE()){
		if(document.getElementById('passion').offsetWidth > document.getElementById('dawgname').offsetWidth){
			newwidth= document.getElementById('passion').offsetWidth;
		} else {
			newwidth= document.getElementById('dawgname').offsetWidth;
		}
		document.getElementById('thebubble').style.width = newwidth + 'px';
	}
	//document.getElementById('thebubble').style.top = getxy.y + 'px';
	//document.getElementById('dawgname').style.display='inline';
	
	
	if(newx > document.getElementById('footer').offsetWidth / 2){
		document.getElementById('bubbletailright').style.display='block';
		//alert(newx);
		//alert(document.getElementById('thebubble').offsetWidth);
		newx = newx - document.getElementById('thebubble').offsetWidth;
	} else {
		document.getElementById('bubbletail').style.display='block';
	}
	document.getElementById('thebubble').style.left = newx + 'px';
	document.getElementById('thebubble').style.top='-50px';

	
}
function hidebubble(){
	document.getElementById('thebubble').style.width ='';
	document.getElementById('passion').style.width ='';
	document.getElementById('thebubble').style.display='none';
	document.getElementById('bubbletail').style.display='none';
	document.getElementById('bubbletailright').style.display='none';
	//document.getElementById('dawgname').style.display='none';
}

function swapBlog(id) {
	for(var x=0; x < getElementsByClassName('blogentry').length; x=x+1){
		elems = getElementsByClassName('blogentry');
		document.getElementById(elems[x].id).style.display="none";
	}
	document.getElementById('homecontent').style.visibility="hidden";
	document.getElementById('blog' + id).style.display="block";
}
function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

/*******************************************************
**************** General Functions *********************
********************************************************/

function getXY(obj)
{
  var curleft = 0;
  var curtop = obj.offsetHeight + 5;
  var border;
  if (obj.offsetParent)
  {
    do
    {
      // XXX: If the element is position: relative we have to add borderWidth
      if (getStyle(obj, 'position') == 'relative')
      {
        if (border = getStyle(obj, 'border-top-width')) curtop += parseInt(border);
        if (border = getStyle(obj, 'border-left-width')) curleft += parseInt(border);
      }
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    }
    while (obj = obj.offsetParent)
  }
  else if (obj.x)
  {
    curleft += obj.x;
    curtop += obj.y;
  }
  return {'x': curleft, 'y': curtop};
}
/**
 * Returns the specified computed style on an object.
 * @param {HTMLObject} obj HTML Object
 * @param {String} styleProp Property name.
 * @return {Mixed} Computed style on object.
 */
function getStyle(obj, styleProp)
{
  if (obj.currentStyle)
    return obj.currentStyle[styleProp];
  else if (window.getComputedStyle)
    return document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
}

function isIE() {
	var detect = navigator.userAgent.toLowerCase();
	if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase)) {
		return false;
	} else {
		if(detect.indexOf('msie') + 1) {
			return true;
		} else {
			return false;
		}
	}
}


