// Company JavaScript Document

$(function() {
	
	$.lts.navigation();
	$.lts.rotate();
	$.lts.tips();
	$.lts.share();

	if ($('.user-actions').length > 0) {
		$('.user-actions').localScroll({
		   hash:true
		});
	}

	$('.navigation ul li a').addClass('toplevel');
	$('.navigation ul li ul li a').removeClass('toplevel');
	
	$('.link-button').append('<span class="pointer"></span>');
	
	
	/*
	$('.content .eight p').eq(0).addClass("highlight");
	$('.content .ten p').eq(0).addClass("highlight");
	$('.content .twelve p').eq(0).addClass("highlight");

	
	Cufon.replace($('.navigation ul li a.toplevel'), {hover: true});
	Cufon.replace('h1', { fontFamily: 'Interstate-Light', fontWeight: '400' });
	Cufon.replace('.two h2', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.tabs > div h2', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.tabs .tabs-nav li a', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.header a.link-button', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.straplines', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.form-expand h3 a', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	
	
	Cufon.replace('.content p.succes', { fontFamily: 'Interstate-Regular', fontWeight: '400' });

	Cufon.replace('.secondary-navigation h3', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	Cufon.replace('.job-list h2', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	
	Cufon.replace('.telephone', { fontFamily: 'Interstate-Regular', fontWeight: '400' });
	
	

	var sectorul = $('.home-panel-sectors ul').eq(0).addClass('small');
	var sectorlis = sectorul.find('li');
	var sectorli = Math.round(sectorlis.length/2)-1;

	sectorul.after('<ul class="small last"></ul>');
	
	for (i = sectorli+1; i < sectorlis.length; i++) {
		$('.home-panel-sectors ul').eq(1).append(sectorlis.eq(i));
	}
	*/
	
	if ($('.sales-jobs').length > 0) {
		
		searchForm = $('.form-expand').find('form');
		
		searchForm.submit(function(){
			
			if ($('#search_terms').hasClass('focus-clear')) {
				$('#search_terms').val('');
			}
				
		});
		
	}
	
	
	
	/* ###### Expandable Form Area ###### */
			$('.form-expand fieldset').each(function() {
				
				errorCount = $(this).find('.error').length;
				
				$(this).wrap('<div class="fieldset clear" />');
				$(this).parent().append('<span class="crnr bl" />');
				$(this).parent().append('<span class="crnr br" />');
				
				lgd = $(this).find('legend');
		
				if (lgd.length > 0) {
					
					lbl = lgd.eq(0);
					lbl.css("display", "none");
					
					fsHeaderText = lbl.html();
					
					if (errorCount > 0) {
						$(this).removeClass('hide')
						fsHeaderText = fsHeaderText	 + '<span class="error-count">' + errorCount + '</span>';
					}
					
					$(this).before($('<h3 />')
						.addClass('fieldset-header')
						.html(
							$('<a />')
								.html('<span></span>' + fsHeaderText)
								.click(function() { 
										
										$fs = $(this).parent().next();
										$(this).toggleClass('collapsed');	
										$fs.toggle(100);
										
								})
						));
						
					if ($(this).hasClass('hide') ) {
						$(this).hide();
						$(this).prev().find('a').addClass('collapsed');
					}
				}
				
			}); // end Expandable Form Areas
	
	
	
	
	var tabContainers = $('div.tabs > div');
    
	tabContainers.hide().eq(0).show();
                        
    $('div.tabs ul.tabs-nav a').click(function () {
        tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('div.tabs ul.tabs-nav a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).eq(0).click();

		   	
});
