$(document).ready( function(){

	// mailform
	var str = document.location.toString().split('#');
	if (str[1]) {
		str[1] = unescape(str[1]);
		var tmp = document.getElementById('department');
		if(tmp) {
			for(var i = 0; i < tmp.length; i++) {
				if (str[1] == tmp.options[i].value) {
					tmp.selectedIndex = i;
					break;
				}
			}
		}
	}

	// sitemap
	$('#arrow').click(function(){
		if($(this).is('.smap')){
			$('.smapm').slideDown('normal',function(){
				$('#arrow').attr('class','smapa');
			});
		}else if($(this).is('.smapa')){
			$('.smapm').slideUp('normal',function(){
				$('#arrow').attr('class','smap');
			});
		}
		this.blur();
		return false;
	});
	
	
	// submenu config
	var t;
	$('.s>a').hover(
		function() {
			clearTimeout(t);
			$('.subm:visible').hide();
			if(!$('.smapm').is(':visible')){
				$(this).next('.subm').show();
			}		
		},
		function(){
			var that = $(this).next('.subm');
			t = setTimeout(function(){$(that).hide();},500);
		}
	);
	
	$('.subm>a').mouseover(function() {
		clearTimeout(t);
	})
	.mouseout(function() {
		var that = $(this).parent();
		t = setTimeout(function(){$(that).hide();},500);	
	});
	
	
	//search
	$('#search_field, #username').focus(function(){
		if ($(this).val() == $(this)[0].defaultValue) {
			$(this).val("");
		}
	})
	.blur(function(){
		if ($(this).val() == "") {
			$(this).val($(this)[0].defaultValue);
		}
	});
	
	
	
	$('#domain-check-form').submit(function(){
		var name = jQuery.trim($('#host-name').val());
		var labels = getWhoisLangLabels();
		if(name.length > 0) {
			$(this).find(':submit').val(labels.domainWaitLabel).attr('disabled', true);
			$('#host-name').attr('readonly', true);
		}
		return name.length > 0;
	});

	
});
