// Cufon
Cufon.replace('h1', { fontFamily: 'DIN-Regular' });
Cufon.replace('h3', { fontFamily: 'DIN-Regular' });
Cufon.replace('h4', { fontFamily: 'DIN-Bold' });

Cufon.DOM.ready(function() {

	// TOP 10 SUB NAV
	if(document.getElementById('sector-nav') != null){
  		Cufon.replace(document.getElementById('sector-nav').getElementsByTagName('span'), { fontFamily: 'DIN-Bold' });
  		Cufon.replace(document.getElementById('sector-nav').getElementsByTagName('a'), { fontFamily: 'DIN-Bold' });
	}

	// SECTOR NAME
	if(document.getElementById('title1') != null){
		Cufon.replace(document.getElementById('title1'), { fontFamily: 'DIN-Bold' });
	}
			
	// KEY
	if(document.getElementById('sector-key') != null){
		Cufon.replace(document.getElementById('sector-key').getElementsByTagName('li'), { fontFamily: 'DIN-Bold' });
	}

});

// eo:CUFON	

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function() {

  if ($('#survey_offices_outside_region_false').attr("checked")) {
    $('#other-offices').hide();
  }
  $('#survey_offices_outside_region_input input').click(
    function() {
      $('#other-offices').toggle( );
    }
  );
  
  if ($('#survey_parent_company_false').attr("checked")) {
    $('#parent-fields').hide();
  }
  $('#survey_parent_company_input input').click(
    function() {
      $('#parent-fields').toggle( );
    }
  );
  
	/* COMMENTED OUT FOR TESTING - REQUIRE EXPLAINATION*/
  //$('input#survey_respected_company_name').autocomplete({ajax: "/respected_companies.json"}).attr('autocomplete','off');
  //$('input#survey_respected_individual_name').autocomplete({ajax: "/respected_individuals.json"}).attr('autocomplete','off');

	//  Click table row and go somewhere quite magical
	//  Added logic so that top5/top10 watch pages don't click
	//  Will need to update when body has correct ID
	var link;
	var bodyid;
	var tableid;

	$("tr").click(function(){
		
		//top_5_company
		//top_5_individual
	
		bodyid = $("body").attr("id");
		tableid = $("table").attr("class");

		if (bodyid != "show" || tableid == "tbl top_5_company"){
			link = $(this).find('td a').attr("href");
			window.location.href = link;
		}
	
	});

});

