jQuery(document).ready(function($){
	
	//get some colors from the label settings
	var color1 = $('.q').css('background-color'); //links #25787B
	var color2 = $('.error A').css('color'); //highlight #455138
	var color3 = $('table.main').css('background-color'); // background #9EBE7D
	var color4 = $('body').css('color'); // text #EEFFDF
	var color5 = $('.error').css('color'); //errors-alerts #F00000
	var color6 = $('h1').css('color'); //header #213D21
	var color7 = $('body').css('background-color'); //outer background #090903
	
	//add a custom class to the body tag so that we only target custom css when javascript has edited the dom, otherwise its a stock label pg
	$('body').addClass('custom');
	
	//****** FGT TOP BAR  ***********//
	if($('table.topnav').length){

			
		//get the fgt top nav html so we can move it somewhere else
		var topNavTable = $('table.topnav td.topnav table tr').html();
		
					
		
		//add the fgt top nav to beginning of page
		$('body').prepend('<div class="fgtTop"><div class="fgtNav"><ul>'+topNavTable+'</ul><div class="clear"></div></div></div>');
		
		//set css of various 
		$('.fgtTop').css({
			'position':'fixed',
			'top':'0',
			'width':'100%',
			'height':'40px',
			'margin':'0',
			'padding':'0',
			'background':'transparent url(//fgt-static.s3.amazonaws.com/label_455/images/fgtTop-bg.png) repeat-x top left',
			'z-index':'99'
		});
		$('.fgtNav').css({
			'width':'960px',
			'margin':'0 auto',
			'position':'relative',
			'left':'0px'
		});
		$('.fgtNav ul').css({
			'margin':'0',
			'display':'block',
			'position':'absolute',
			'right':'0'
		});
		
	
		$('.fgtNav a').wrap('<li />');
		$('.fgtNav li').css({
			'float':'left',
			'background':'transparent',
			'list-style-type':'none',
			'border-right':'1px solid #333',
			'padding':'0',
			'margin':'0',
			'width':'auto'
		});
		$('.fgtNav li a').css({
			'display':'block',
			'line-height':'30px',
			'font-size':'12px',
			'padding':'0 15px',
			'color':'#fff',
			'font-size':'10px'
		});
		$('.fgtNav li a').hover(function(){
			$(this).css({
				'background-image':'url(//fgt-static.s3.amazonaws.com/label_455/images/transBlack20.png)',
				'text-decoration':'none'
			});
		},
		function(){
			$(this).css({
				'background-image':'none',
				'text-decoration':'none'
			});
		});
		$('.fgtNav li:first').addClass('first').css('border-left','1px solid #333');
		
		
		
		//get rid of hard coded <br>'s in the nav
		$('.fgtNav li a br').remove();
		
		//hide original top nav
		//$('table.topnav').hide();
		$('table.topnav td.topnav').hide();
		
		//add fgt logo to fgt top bar
		$('.fgtTop .fgtNav').prepend('<div class="fgtLogo" style="float:left;padding-top:2px;"><a href="http://www.frontgatetickets.com" title="Powered By Front Gate Tickets"><img height="26" border="0" src="http://static.independenttickets.com/label_960/images/logoFGT.png"></a></div>');
		
		
		//set the width of the nav based on the total link width
		var wholeNavWidth = $('.fgtTop .fgtNav').width();
		var logoWidth = $('.fgtTop .fgtNav .fgtLogo').width();
		$('.fgtNav ul').width(wholeNavWidth - logoWidth);
		var navUlWidth = 0;
		$('.fgtNav li').each(function(){
			navUlWidth = $(this).outerWidth() + navUlWidth;
		});
		$('.fgtNav ul').width(navUlWidth);
	
	}//end if statement to check for nav to replace (this avoids putting nav bar on pupups)
	//******* end fgt top bar *****/
	

	//add a 'align left' class to the fgt top nav
	$('.fgtTop').addClass('leftAligned');
	
	
	//wrap the main table in a div
	$('table.main').wrap('<div class="wrapper" id="wrapper"/>');
	$('table.main').wrap('<div id="body" />');
	$('table.main').wrap('<div id="content" />');
		
	//wrap the top header in a new div
	$('table.topnav').wrap('<div class="headerWrapper fgtOrigHeader" />');
		
	
	//set the appropriate width of the main content td
	$('td.sidenav').next().width(720);
	
	if ($('form[action*="checkout.php"]').length)
	{
		// the checkout form is getting mangled -- this line to the rescue
		$('#content').wrap('<form name="order" action="/secure/checkout.php" method="POST" />');
	}
	
			
});


