    var $ = jQuery;

    function hosting_ie67_fix() {
        var $above = $('tr:first td:last', '#hosting .htable');
        var aboveheight = $('tr', '#hosting .htable').eq(1).height() + $('tr', '#hosting .htable').eq(0).height();
        $('#vip_long').css({
        height:
            $('#hosting .htable').innerHeight()
            -
            aboveheight
            -
            $('tr:last', '#hosting .htable').innerHeight()
            + 'px',
        width: $above.width() - 2 + 'px',
        left:  $above.position().left + 'px',
        top:   ($above.position().top + aboveheight) + 'px'
        });
    }

    $(document).ready(function(){
	if ( document.getElementById('hosting') != null ) {
	    if ($.browser.msie && $.browser.version < 8) {
		hosting_ie67_fix();
		$(window).resize(function(){
		    hosting_ie67_fix();
		});
	    }

	    $('th.expand', '#hosting').click(function(){
		var section = $(this).parents('tr').eq(0).hide().attr('id') + '_ex';
		$('tr.'+section, '#hosting').show();
		if ($.browser.msie && $.browser.version < 8) {
		    hosting_ie67_fix();
		}
	    });
	    $('th.collapse', '#hosting').click(function(){
		var section = $(this).parents('tr').attr('class');
		$('tr.'+section, '#hosting').hide();
		$('tr#'+section.replace('_ex', '')).show();
		if ($.browser.msie && $.browser.version < 8) {
		    hosting_ie67_fix();
		}
	    });
	}
	else if ( document.getElementById('existing_domain') != null ){
	    $('#existing_domain').click();
	}
	else if ( document.getElementById('hosting_pp') != null ) {
	   document.getElementById( document.getElementById( 'precontype' ).value ).click();
	}
    });

    function show_uplink_domain_way(sender, form) {
	if (sender == 'existing_domain') {
	    document.getElementById('existing_domain_tbl').style.display = '';
	    document.getElementById('new_domain_tbl').style.display = 'none';
	}
	else if (sender == 'new_domain') {
	    document.getElementById('existing_domain_tbl').style.display = 'none';
	    document.getElementById('new_domain_tbl').style.display = '';
	}
    }
    
    function show_person_type(sender, form) {
	if (sender == 'hosting_pp') {
	    document.getElementById('hosting_pp_fields').style.display = '';
	    document.getElementById('hosting_org_fields').style.display = 'none';
	}
	else if (sender == 'hosting_org') {
	    document.getElementById('hosting_pp_fields').style.display = 'none';
	    document.getElementById('hosting_org_fields').style.display = '';
	}
    }
