$(function() {
	$('#switcher').tabs();
});

$(function() {
		
		var username = $("#username"),
		password = $("#passwort"),
		allFields = $([]).add(username).add(password),
		tips = $("#validateTips");

		function updateTips(t) {
			tips.text(t).effect("highlight",{},1000);
		}

		function checkLength(o,n) {

			if ( o.val().length == "" ) {
				o.addClass('ui-state-error');
				updateTips("Venligst udfyld: " + n);
				return false;
			} else {
				return true;
			}

		}

	$("#Control_Box").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 250,
			modal: true,
			resizable: false,
			buttons: {
				'Login': function() {
				
				var bValid = true;
				allFields.removeClass('ui-state-error');

				bValid = bValid && checkLength(username,"Brugernavn");
				bValid = bValid && checkLength(password,"Kode");
				
				if (bValid) {

					$('#loginForm').submit();
				
				}
				
				},
				Cancel: function() {
					$(this).dialog('close');
					allFields.val('').removeClass('ui-state-error');
				}
			}
		});
		
		
		
		$('#ControlLogin').click(function() {
			$('#Control_Box').dialog('open');
		
		});

	});

	$(function() {
		
		var name = $("#username").val();
		var password = $("#passwort").val();

		
		$("#Webmail_Box").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 250,
			modal: true,
			resizable: false,
			buttons: {
				'Login': function() {
				
					$('#WebmailForm').submit();
				
				}
				,
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});	
		
		
		$('#WebmailLogin').click(function() {
			$('#Webmail_Box').dialog('open');
		
		});
/*
	$('#domain_name1').mousedown(function() {
  		$(this).animate({
    	width: '200px'
  		}, 1000, function() {
 		});
	});
	
	$('#domain_name1').mouseleave(function() {
  			$(this).animate({
    		width: '150px'
  			}, 1000, function() {
    		// Animation complete.
  			});
		});
*/	
	});

function show_mydomain(){
document.getElementById('orderspace').style.visibility = "visible";
}
function hide_domaincheck(){
document.getElementById('domaincheck').innerHTML = "";
document.getElementById('orderspace').style.visibility = "hidden";
}
