jQuery(document).ready(function() {
	
	// AUTO HIGHLIGHT ACTIVE NAVIGATION
	jQuery(function(){
		var path = location.pathname.substring(1);
		if(path)
			jQuery('ul#nav li a[href$="' + path + '"]').parent().addClass('active');
	});
	
	
	// FIX PNG TRANSPARENCY
	jQuery.ifixpng('images/pixel.gif');
	jQuery('img').ifixpng();
	
	
	// TOGGLE RESOURCECENTER
	jQuery('a#resourceCenter').click(function(){
		jQuery('#search').slideToggle(600);
	});
	
	
	// TOGGLE SIDEBOXES
	jQuery('div.sidebox h3').click(function(){
		
		if (jQuery(this).siblings('div.content').css('display') == 'none') {		
			jQuery('div.sidebox div.content').slideUp('fast');
			
			jQuery(this).siblings('div.content').slideDown('fast');
			
			jQuery(this).children('span').html('-');
		}
		
		else {
			jQuery(this).siblings('div.content').slideUp('fast');
			
			jQuery(this).children('span').html('+');
		}
		
	});
		
	$('div.sidebox div.content').hide();
	
	$('#thermophyiscalinstrumentation div.content').show();
	
	
	// STYLES
	jQuery('div.sidebox div.content ul li:first-child').addClass('first');
	jQuery('div.sidebox div.content ul li:last-child').addClass('last');
	
	jQuery('#news div.content ul li:first-child').addClass('first');
	jQuery('#news div.content ul li:last-child').addClass('last');
	
	// CONVERSION SELECTORS
	$("select#propertySelect").change(function(){
		$.getJSON("/get_conversion_json.php",{property: $(this).val(), ajax: 'true'}, function(j){
      		var options = '';
      		for (var i = 0; i < j.length; i++) {
        		options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      		}
    		$("select#multiplyerSelect").html(options);
    	})
  	})
  	
  	// CONVERSION TOOL
  	$("input#value").change(function(){
  		var result = $(this).val() * $("select#multiplyerSelect").val();
  		$("input#result").val(result);
  	})
  	
  	$("select#multiplyerSelect").change(function(){
  		if ($("input#value").val() != '')
  		{
  			var result = $(this).val() * $("input#value").val();
  			$("input#result").val(result);
  		}
  	})


});