function ValidateDomainForm(frm) {
	if (emptyField(frm.DomainName)) {
		alert("Enter Domain");
		frm.DomainName.focus();
		return false;
	}	
	if (invalidDomain(frm.DomainName)) {					
		frm.DomainName.focus();
		return false;
	}
	if (frm.DomainName.value.length < 3) {					
		alert("Domain Name must contain at least 3 characters");
		frm.DomainName.focus();
		return false;
	}	
	return true;	
}
function invalidDomain(textObj) {
	for (var i=0; i<textObj.value.length; ++i)  {
		var ch = textObj.value.charAt(i);
		if ( (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') && (ch != '-') ) {					
			alert("Domain Name contains invalid characters!");
			return true;
		}
		if ( (i == 0 && ch == '-') || (i == textObj.value.length - 1 && ch == '-') ) {
			alert ("Domain Name must begin and end with a letter or a number")
			return true;
		}
	}
	return false;
}
function emptyField(textObj) {
	if (textObj.value.length == 0) return true;
	for (var i=0; i<textObj.value.length; ++i)  {
		var ch = textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;
		}
	return true;
}

function openPopup(url, window_name, width, height)
{
	features = '';
	features = features + 'toolbar=yes,';
	features = features + 'scrollbars=yes,';
	features = features + 'location=no,';
	features = features + 'statusbar=yes,';
	features = features + 'menubar=no,';
	features = features + 'resizable=yes,';
	features = features + 'width=' + width + ',';
	features = features + 'height=' + height;
		
	window.open(url, window_name, features);
}

function setStylesheet(title) {
	var i, cacheobj
	for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
		if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title"))
		{
			cacheobj.disabled = true
			if(cacheobj.getAttribute("title") == title)	cacheobj.disabled = false //enable chosen style sheet
		}
	}
	}