(function($){
	$(document).ready(function() {
		$('input[type=text]').focus(function(){
			var currentVal = $(this).val();										// Read initial field value
			$(this).val('');														// Clear initial value

			$(this).blur(function(){
				var getNewVal = $(this).val();										// Read new input value
				if ( getNewVal == '' || getNewVal == ' ' ) {
					$(this).val(currentVal);										// Switch to initial value
				}
			});
		});
		
		// fix PNG for IE6
		if ( $.browser.msie && $.browser.version == '6.0' )
			DD_belatedPNG.fix('div, a, img, li, em, label');
		
		// remove any borders on last LI element
		$("ul").each(function(){
			 $(this).children("li:last").css({borderRight:"0",borderBottom:"0",background:"none",paddingRight:"0",marginRight:"0"});
		});

		$('#navigator ul li#search a').click(function(){
			$(this).toggleClass('selected').siblings('form').toggle('fast',function(){
				if ($.browser.msie && $.browser.version == '6.0') {
					DD_belatedPNG.fix('#navigator ul li#search form');
				}
			});

			return false;
		});

		if ( $('div.updates').length ){
			var currentHeight = parseFloat($('div.updates').height());
			var newDim = parseFloat(currentHeight+40);

			$('#grayBar').css({
				height:newDim,
				top:'-'+newDim+'px'
			});
		}
		
		if ( $('#right-side').length && $('#left-side').length && $('#grayBar').length ){
			$('#left-side').css({
				minHeight: $('#right-side').height(),
				height:'auto !important',
				height: $('#right-side').height()}
			);
		}

		if ( $('#nav li a.on').length ){
			var elWidth = $('#nav li a.on').parent().innerWidth();
			var elHeight = parseFloat(0-$('#nav li a.on').parent().innerHeight());
			var elPos = $('#nav li a.on').parent().position();
			
			if ( $('ul.submenu').length ) {
				$('em.dsp').show();
				if ( ($.browser.msie && $.browser.version == '9.0') ) {
					$('em.dsp').css({
						width: elWidth+5,
						left: elPos.left-3
					});
				} else {
					$('em.dsp').css({
						width: elWidth+6,
						left: elPos.left-3
					});
				}
			} else {
				$('em.dsp').hide();
			}
		}
		
		$('div.mainContent table').each(function(){
			$(this).attr('width','');			
			$(this).children('col').remove();
			$(this).children().find('td').attr('width','');			
			
			$(this).children().find('td').children('p').each(function(){
				if ( $(this).html() == '<br>' || $(this).html() == '<br/>' || $(this).html() == '<BR><BR>' || $(this).html() == '<br><br>' || $(this).html() == '<br></br>' ){
					$(this).remove(); 
				}
			});		
		});
		
		$('div.mainContent table td p:last-child').each(function(){		
			$(this).css('margin-bottom','0');
		});
		
		$('div.mainContent p').each(function(){
			$(this).attr('style','');			
		});

		// ie6 specific
		if ( ($.browser.msie && ($.browser.version == '6.0' || $.browser.version == '7.0' || $.browser.version == '8.0') ) ){
			// css3 fixes
			$('ul.options li:nth-child(2)').css({
				margin: '0 20px'
			});
			
			$('#right-side a:first-child').css({
				paddingTop:'7px'
			});
			
			$('p#crumb a:last-child').css({
				fontWeight:'bold',
				color:'#5c686e'
			});

		}		
	});
})(jQuery);

window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};

function iPrint(iFrameTarget){
	iFrameTarget.focus();
	iFrameTarget.print();
} 
