// JavaScript Document

var j$ = jQuery;

	j$(document).ready(init);
//	j$(window).load(loaded);


	
var windowWidth = 400;
var windowHeight = 400;
var contentHeight = 0;
var lcHeight = 0;
var rcHeight = 0;
var lcTop = 0;
var rcTop = 0;
var lBgOffset = 'foo';

var ii = 0;
var sections = 0;

function init()
{
	//ASSIGN VALUES TO GLOBALS
	windowWidth = j$(window).width();
	windowHeight = j$(window).height();
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//TABLE RESET
	j$('table').attr({'cellspacing':0, 'width':'100%'});
	j$('td').attr({'valign':'top'});
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//PHOTO BANNER in header using panelGallery pluging
	
	if(j$.browser.msie && j$.browser.version<7)
	{
	}
	else
	{
		j$('#photoBanner').panelGallery({sections:5,direction:"lr",sectionTransitionDelay:1000,imageTransitionDelay:10000});
	}
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//STYLE FORMS using jqTransform plugin
	j$('form.jqTransform').jqTransform();
	//hide antibot input field
	j$('form #LastName').parents('.jqTransformInputWrapper').hide();
	//remove error paragraph from top of forms if it is empty
	j$('#section1 p.error').each(function(i){
		var $contents  = j$(this).text();
		if($contents == "")
		{
			j$(this).remove();
		}
	});
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//SET UP DROP DOWN MENUS
	//strip away title tags so drop-downs work smoothly
	j$('#mainNav a').attr({'title':''});
	//set position for menus while at rest
	j$('#mainNav li div').css({'top':'1.3em'});
	//add class to submenus
	j$('#mainNav li div').parents('li').addClass('hasSubmenu');
	//apply nmcDropDown plugin
	j$('#mainNav').nmcDropDown({submenu_selector: 'div',
							   show:{opacity:'show',top:'1.05em'},
							   show_speed:300,
							   hide:{opacity:'hide',top:'1.3em'},
							   hide_speed:100});
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//CLEAN UP SECTION NAVIGATION
	//remove parent page title if no menu below
	var $subMenuIndex = j$('*').index(j$('#sectionNav'));
	if($subMenuIndex == -1)
	{
		j$('.leftCol h2.active').remove();
	}
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//clean up ditto output on pages with STATE-BY-STATE JOB INDEX
	j$('.dittoOutput').each(function(i)
		{
			var $thisText = j$(this).text();
			if($thisText.indexOf('No documents found') > -1)
			{
				j$(this).remove();
			}
			else
			{
				var $thisTitle = j$(this).attr('title');
				j$(this).before("<h4>"+$thisTitle+"</h4>");
				j$(this).children('dt:first').addClass('first');
			}
			
		});
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//COLUMNIZE plugin used throughout site
	//footer
	j$('.foot_outer .siteMap ul').columnize({columns:2, dontsplit:'li'});
	j$('.foot_outer .siteMap ul .column:first').css({'padding-right':20});
	//colleges page
	j$('#collegesAndUniversities #section1').columnize({columns:2, dontsplit:'dl'});
	j$('#collegesAndUniversities #section1 .column:first').css({'padding-right':20});
	//clients page
	j$('#clients #soloAccounts').columnize({columns:3});
	j$('#clients #soloAccounts .column:last').css({'padding-right':0});
	j$('#clients #partnershipAccounts').columnize({columns:3, dontsplit:'dl'});
	j$('#clients #partnershipAccounts .column:last').css({'padding-right':0});
	if(!j$.browser.msie)
	{
		j$('#index #frontPage').columnize({columns:2,balance:false,height:230,minHeight:230});
		j$('#index #frontPage .column:first').css({'padding-right':30});
	}
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//apply target="blank" to OUTGOING LINKS
	j$('a').each(function(i){
			var h=j$(this).attr('href');
			if(h.indexOf('http://')>-1)
			{
				var cI = h.indexOf('thompsonhospitality.com');
				if(cI<0 || cI>12)
				{
					j$(this).attr({'target':'_blank'});
				}
			}
		})
	
////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
	//add video to AGX Page
	j$('#austinGrillExpress #agxVid').flash(
		{
			swf: '/assets/flash/agxVid.swf',
			width: 700,
			height: 393,
			wmode:'transparent',
			style: 'z-index:0' 
		}
	);

}

function loaded()
{
}

		  