$(document).ready(function() { $.divload(0); })
$(window).load(function () {
	$.divload(1);		 
	$('div#head').append('<div class="head-01"></div><div class="head-11"></div>');
	$('div#head ul.menu li:last').css({'float': 'right'});
	$.tdna();     });



jQuery.tdna = function () { $('td').each(function() { if ($(this).text() == '&nbsp;' || $(this).text() == 'N/A') { $(this).classswitch('na'); } }); }

jQuery.filestyle = function () {	
	_this = $('input[type=file]');
	_this.wrap('<div class="file"></div>');
	_this.css({'opacity': 0});
	_this.parent().append('<input class="text-mid" type="text" value="Browse . . ." />');
	_this.parent().append('<input type="button" class="button-file" value="find" />');
	_this.bind('change', function() { $(this).siblings('input[type=text]').val($(this).val()); });
	_this.bind('mouseout', function() { 
		if ($(this).val()) { $(this).siblings('input[type=text]').val($(this).val()); }
		else { $(this).siblings('input[type=text]').val('Browse . . .'); }     });     }
	
jQuery.selectstyle = function () { 
	$('select').each(function() { 
		if ($(this).val()) { _selected = $(this).children('option:selected'); } else { _selected = $(this).children('option:first'); } 
		_selected.css({'font-weight':'bold'});     });     }	
	
jQuery.selectjump = function () {
	$('select.jump').each(function() {
		if ($(this).val()) { _selected = $(this).children('option:selected'); } else { _selected = $(this).children('option:first'); }
		$(this).wrap('<div class="jump" style="margin: ' + $(this).cssmargin() + '; width: ' + ($(this).width() - 5) + 'px;"></div>');
		$(this).after('<span class="jump">' + _selected.text() + '</span>');
		$(this).css({'left':'0', 'margin':'0', 'opacity':0, 'position':'absolute', 'top':'0', 'z-index':'2'});   });
	$('input.button-jump').hide();
	$('select.jump').change(function() { $(this).parents('form').submit(); }); }

jQuery.helpprint = function () {
	$('span.help').show();
	$('div.help').hide();
	$('span.help').bind('click', function() {
		_width = $(this).width();
		_div = $(this).next('div.help');
		_pos = $(this).offset();
		_div.css({'left':_pos.left + _width, 'top':_pos.top});
		if (_div.is(':hidden')) { $('div.help').hide(); _div.show('fast'); } else { _div.hide('fast'); }     })
	$('span.help').bind('mouseleave', function() { $('div.help').hide('fast'); })     }
	
jQuery.fieldsetshow = function () { 
	$('fieldset.hide').hide();
	$('fieldset.show').prepend('<span class="show">show</span>');
	$('fieldset.show span.show, fieldset.show span.hide').click(function() { 
		var _show = $(this).parent('fieldset.show');
		var _hide = _show.next('fieldset.hide');		
		if ($(this).attr('class') == 'show') {
			//$('div#win').wincenter(_show.heightplus('padding') - _hide.heightplus('padding'));
			_hide.slideDown('fast');
			$(this).classswitch('hide'); }
		else if ($(this).attr('class') == 'hide') {
			//$('div#win').wincenter(_hide.heightplus('padding') - _show.heightplus('padding'));
			_hide.slideUp('fast');
			$(this).classswitch('show'); }     });    }
	
jQuery.fn.wincenter = function (_change) { 
	var _buffer = 80;
	var _max = document.documentElement.clientHeight - (_buffer * 2);
	
	var _top = $(this).cssint('marginTop') + (_change / 2);
	if (_top > _buffer) { _top = _buffer; }
	
	var _height = $(this).height();
	if (_height > _max) { _height = _max; }
	
	$(this).animate({'height': _height + 'px', 'marginTop': _margin + 'px'}, 'fast'); }
	
jQuery.divlayout = function () { 
	$('div.layout fieldset.min').wrap('<div class="js"></div>');
	$('div.layout div.js').each(function() { 
		_height = $(this).parent('form').parent('div').heightplus('footprint');
		_width = $(this).parent('form').parent('div').widthplus('footprint');
		$(this).css({'height': (_height - 10) + 'px', 'width': (_width - 10) + 'px'}); }); }	
	
jQuery.divtable = function () { 
	$('div.table').each(function() {
		var _row = $(this).find('div.row');
		var _length = _row.eq(0).find('div.cell').length();
		var _item = 0; 
		while (_item < _length) { _row.find('div.cell').eq(_item).matchwidth(); _item ++; } }); }	

