/*
	JavaScript: bundle
	Version: 	1.0
	Date		2009-10-05 
	Author:		elementalblend.com (brandon burkett)
	
	Desc:		This class combines the minified versions of teh following: blend_png, blend_link, blend_table.
				It is ideal to put code in here that is small to begin with and will be used throughout the site.
				Original files should still be included on the server and if edits are made to them, update this
				file with new minified versions.
				
	Note:		Class may be custom per site, added to or removed from.
*/
/* blend_png */
var png={spacerGif:'media/contentImages/blank.gif',ieAlpha:function(img)
{img.style.width=img.offsetWidth+'px';img.style.height=img.offsetHeight+'px';img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"', sizingMethod='scale')";img.oldSrc=img.src;img.src=png.spacerGif;},init:function()
{if(document.all&&!window.opera&&!window.XMLHttpRequest)
{$('img').each(function(i,img)
{if(img.src.match('.png'))
{img.origWidth=img.offsetWidth;img.origHeight=img.offsetHeight;png.ieAlpha(img);}});}}}
$(document).ready(function(){png.init();});

/* blend_link */
var link={init:function()
{$('a.newWindow').attr('target','_blank');$('.deleteAlert').bind('click',function(){return confirm('Are you sure you want to delete this item?');});}}
$(document).ready(function(){link.init();});

/* blend_table */
var table={sortableClass:['sortableTable'],fixRowClass:function(jqObject)
{jqObject.children('tbody').children('tr:even').attr('class','tableRow');jqObject.children('tbody').children('tr:odd').attr('class','tableRowAlt');},init:function()
{$.each(table.sortableClass,function(i,val)
{$('.'+val).tablesorter({textExtraction:function(node)
{var nodeValue='';if(node.childNodes[0]!=undefined)
{if(node.childNodes[0].innerHTML!=undefined)
{nodeValue=node.childNodes[0].innerHTML;}
else
{nodeValue=node.innerHTML;}}
return nodeValue;}}).bind("sortEnd",function()
{table.fixRowClass($(this));});});}}
$(document).ready(function(){table.init()});

/* blend_resource */
var resource={show:function(jqObject)
{if(forms)
{forms.clearData();}
if(jqObject.val()!='')
{resource.hide();$('#'+jqObject.val()+'Resource').show();$('#'+jqObject.val()+'Resource label').each(function()
{var html=$(this).html().replace(/<[eE][mM]\sclass\=(inputOptional|"inputOptional")>optional<\/[eE][mM]>/,'');$(this).html(html);});}
else
{resource.hide();}
if(forms)
{forms.rebuildFormData();}},hide:function()
{$('#docResource').hide();$('#linkResource').hide();$('#emailResource').hide();$('#docResource label, #linkResource label, #emailResource label').each(function()
{var html=$(this).html().replace(/<[eE][mM]\sclass\=(inputOptional|"inputOptional")>optional<\/[eE][mM]>/,'');$(this).html(html+' <em class="inputOptional">optional</em>');});},init:function()
{$('#resourceType').bind('change',function(){resource.show($(this));});}}
$(document).ready(function(){resource.init();});

/* FF html5 block link fix */
if(typeof RTS!='object')
var RTS={};RTS.ffRebuild={init:function(){var me=this;var links=[];var stack=null;if(typeof $!='function'){if(typeof console!='undefined'&&typeof console.info=='function')
console.info('[ffRebuild] jQuery\'s undefined, can\'t run.');return;}
$('a').each(function(){var you=$(this);if(me.equals(you,stack)){var found=false;for(var i in links)
if(me.equals(links[i],stack))
found=true;if(!found){var cpt=0;var mozFound=false;var parent=you.parent();var realStack=null;parent.find('a').each(function(){var it=$(this);if(me.equals(it,stack)){if(it.attr('_moz-rs-heading')!=undefined){mozFound=true;}
if(it.html()!=stack.html())
cpt++;}});if(!realStack)
realStack=stack;if(cpt>1&&mozFound){links.push(realStack);}
else if(cpt>1&&!mozFound){cpt=0;parent.children('a').each(function(){var it=$(this);if(me.equals(it,stack))
cpt++;});if(cpt>1){links.push(realStack);}}}}else
stack=you;});for(var i in links){var parent=links[i].parent();var currentLink=links[i];var html='';var cpt=0;var firstLinkDetected=false;var stack=[];var idClass='ffRebuild-'+me.randomString();parent.children().each(function(){var you=$(this);if(!firstLinkDetected&&me.isLink(you)){if(me.equals(you,currentLink)){currentLink=you;firstLinkDetected=true;}}
if(firstLinkDetected&&cpt>0){if(me.isLink(you)){if(me.equals(you,currentLink)){if(stack.length>0)
for(var j=0;j<stack.length;j++)
stack[j].addClass(idClass);stack=[];you.before('<div class="'+idClass+' ffRebuild-toRemove">'+you.html()+'</div>');you.remove();}}else{var found=false;you.find('a').each(function(){var it=$(this);if(me.equals(it,currentLink)){if(stack.length>0)
for(var j=0;j<stack.length;j++)
stack[j].addClass(idClass);stack=[];you.addClass(idClass);it.before(it.html());it.remove();}
found=true;});if(!found)
stack.push(you);}}
if(firstLinkDetected)
cpt++;});parent.find('.'+idClass).each(function(){var you=$(this);if(you.hasClass('ffRebuild-toRemove')){currentLink.append(you.html());you.remove();}else{you.removeClass(idClass);currentLink.append(you);}});if(typeof console!='undefined'&&typeof console.info=='function'){console.info('[ffRebuild] fixed link :');console.info(currentLink);}}},isLink:function(n){var me=this;if(typeof n!='object'||!n)
return false;return(n.attr('nodeName').toLowerCase()=='a')?true:false;},equals:function(n1,n2){var me=this;if(typeof n1!='object'||!n1)
return false;if(typeof n2!='object'||!n2)
return false;var onclick1=(n1.attr('onclick'))?n1.attr('onclick').toString():'';var onclick2=(n2.attr('onclick'))?n2.attr('onclick').toString():'';var toReturn=(n1.attr('nodeName')==n2.attr('nodeName')&&n1.attr('class')==n2.attr('class')&&n1.attr('title')==n2.attr('title')&&n1.attr('href')==n2.attr('href')&&onclick1==onclick2)?true:false;return toReturn;},randomString:function(){var chars=new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');var str='';for(var i=0;i<32;i++)
str+=chars[Math.floor(Math.random()*chars.length)];return str;}};RTS.ffRebuild.init();

/* blend_tracking */
var blendTracking={init:function()
{$('.gaTrackLink').bind('click',function()
{if(typeof _gaq!="undefined")
{var title=($(this).attr('title')!='')?$(this).attr('title'):$(this).text();title=$.trim(title);_gaq.push(['_trackEvent','Resource Clicks',title,$(this).attr('href')]);setTimeout('document.location = "'+$(this).attr('href')+'"',100);}
return false;});$('.gaTrackDocument').bind('click',function()
{if(typeof _gaq!="undefined")
{var title=($(this).attr('title')!='')?$(this).attr('title'):$(this).text();title=$.trim(title);_gaq.push(['_trackEvent','Resource Clicks',title,$(this).attr('href')]);}})}}
$(document).ready(function(){blendTracking.init();});

/* blend_navigation */
var navigation={parentListId:'navList',childListClass:'navSubList',parentClass:'navListItemLink',parentHoverClass:'parentKeyboardFocus',childClass:'navSubListItemLink',childHoverClass:'childKeyboardFocus',timeoutTime:1000,timeout:{},opacity:0.9,parentIndex:0,childIndex:0,json:[],childAll:null,parentAll:null,reset:function()
{if(navigation.childAll==null)
{navigation.childAll=$('.'+navigation.childListClass);}
if(navigation.parentAll==null)
{navigation.parentAll=$('#'+navigation.parentListId+' > li');}
navigation.childAll.hide();navigation.parentAll.find('a').attr('class',navigation.parentClass);navigation.childAll.find('a').attr('class',navigation.childClass);},showChildNav:function(jqObject)
{var childNav=jqObject.find('.'+navigation.childListClass);if(childNav.length>0)
{childNav.show();}},hideChildNav:function(jqObject)
{jqObject.find('.'+navigation.childListClass).hide();},toggleParentClass:function(jqObject,action)
{if(action=='focus')
{jqObject.attr('class',navigation.parentHoverClass);}
else if(action=='blur')
{jqObject.attr('class',navigation.parentClass);}},toggleChildClass:function(jqObject,action)
{if(action=='focus')
{jqObject.attr('class',navigation.childHoverClass);}
else if(action=='blur')
{jqObject.attr('class',navigation.childClass);}},jsonCache:function()
{var parentIndex=0;var childIndex=0;var childArray=[];$.each($('#'+navigation.parentListId+' > li'),function(i,parentLI)
{var parentAnchor=$(parentLI).children('a');if(parentAnchor.length>0)
{parentAnchor.attr('id','p'+parentIndex);var subNav=$(parentLI).find('ul');if(subNav.length>0)
{$.each(subNav.find('li'),function(i,subNavLI)
{var subNavAnchor=$(subNavLI).find('a');if(subNavAnchor.length>0)
{subNavAnchor.attr('id','p'+parentIndex+'c'+childIndex);childArray.push(subNavAnchor.attr('id'));childIndex++;}});}
navigation.json.push({'parent':parentAnchor.attr('id'),'child':childArray});childIndex=0;childArray=[];parentIndex++;}});},loadMouseEvents:function()
{$('#'+navigation.parentListId+' > li').bind('mouseenter',function()
{clearTimeout(navigation.timeout);navigation.reset();navigation.showChildNav($(this));}).bind('mouseleave',function()
{navigation.hideChildNav($(this));});},loadKeyboardEvents:function()
{$('#'+navigation.parentListId+' > li > a').bind('focus',function()
{navigation.reset();navigation.parentIndex=parseInt($(this).attr('id').replace('p',''));navigation.childIndex=0;clearTimeout(navigation.timeout);navigation.showChildNav($(this).parent());navigation.toggleParentClass($(this),'focus');}).bind('blur',function()
{navigation.timeout=setTimeout("navigation.reset()",navigation.timeoutTime);}).bind('keydown',function(e)
{navigation.childIndex=0;if(e.keyCode==37)
{if(navigation.parentIndex==0)
{navigation.parentIndex=navigation.json.length-1;}
else
{navigation.parentIndex--;}
$('#'+navigation.json[navigation.parentIndex].parent).trigger('focus');return false;}
else if(e.keyCode==38)
{if(navigation.json[navigation.parentIndex].child.length!=0)
{navigation.childIndex=navigation.json[navigation.parentIndex].child.length-1;$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('focus');}
return false;}
else if(e.keyCode==39)
{if(navigation.parentIndex<(navigation.json.length-1))
{navigation.parentIndex++;}
else
{navigation.parentIndex=0;}
$('#'+navigation.json[navigation.parentIndex].parent).trigger('focus');return false;}
else if(e.keyCode==40)
{if(navigation.json[navigation.parentIndex].child.length!=0)
{$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('focus');}
return false;}
else if(e.keyCode==9)
{}});$('.'+navigation.childListClass+' > li > a').bind('focus',function()
{navigation.childIndex=parseInt($(this).attr('id').replace('p'+navigation.parentIndex+'c',''));clearTimeout(navigation.timeout);navigation.toggleChildClass($(this),'focus');}).bind('blur',function()
{navigation.timeout=setTimeout("navigation.reset()",navigation.timeoutTime);navigation.toggleChildClass($(this),'blur');}).bind('keydown',function(e)
{if(e.keyCode==37)
{if(navigation.parentIndex==0)
{navigation.parentIndex=navigation.json.length-1;}
else
{navigation.parentIndex--;}
navigation.childIndex=0;$('#'+navigation.json[navigation.parentIndex].parent).trigger('focus');return false;}
else if(e.keyCode==38)
{$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('blur');if(navigation.childIndex==0)
{navigation.childIndex=navigation.json[navigation.parentIndex].child.length-1;}
else
{navigation.childIndex--;}
$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('focus');return false;}
else if(e.keyCode==39)
{if(navigation.parentIndex<(navigation.json.length-1))
{navigation.parentIndex++;}
else
{navigation.parentIndex=0;}
navigation.childIndex=0;$('#'+navigation.json[navigation.parentIndex].parent).trigger('focus');return false;}
else if(e.keyCode==40)
{$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('blur');if(navigation.childIndex<(navigation.json[navigation.parentIndex].child.length-1))
{navigation.childIndex++;}
else
{navigation.childIndex=0;}
$('#'+navigation.json[navigation.parentIndex].child[navigation.childIndex]).trigger('focus');return false;}
else if(e.keyCode==9)
{}});},init:function()
{navigation.jsonCache();navigation.loadMouseEvents();navigation.loadKeyboardEvents();}}
$(document).ready(function(){navigation.init();});
