function isWhitespace(s) {
	var whitespace = " \t\n\r";    // whitespace characters
	
	if(s == null || s.length == 0 ) {
	 	return true;
	}
	else {	
		for (var i = 0; i < s.length; i++) {
			// Check that current character isn't whitespace.
			var c = s.charAt(i);
			if (whitespace.indexOf(c) == -1)
			return false;
		}
		
		return true;
	}
}

function validateVisitorLogin(username, password) {
	if (!isCookiesEnabled())
		alert("Cookies must be enabled to continue. Please check your browser settings.")
	else if((isWhitespace(username.value))) {
		alert("Please enter your Username");
		username.focus();
	}
	else if ((isWhitespace(password.value))) {
		alert("Please enter your Password");
		password.focus();
	}
	else
		return true;

	return false;
}

function validateMemberLogin(accountname, username, password) {
	if((isWhitespace(accountname.value))) {
		alert("Please enter your Account Name");
		accountname.focus();
		
	}
	else if((isWhitespace(username.value))) {
		alert("Please enter your User Name");
		username.focus();
	}
	else if ((isWhitespace(password.value))) {
		alert("Please enter your Password");
		password.focus();
	}
	else
		return true;
		
	return false;
}

function validateSearch(form, query) {
	if((isWhitespace(query.value))) {
		alert("Please enter search text");
		query.focus();
	}
	else
		form.submit()
}

function DomainRegPopup(strReferer) {
	window.open('/home/domainnamereg.asp?name=EMPTY&Visitor=' + strReferer, 'DomainReg', 'width=700,height=540,left=50,top=50,resizable=yes,menubar=no,toolbar=no,directories=no,location=no,scrollbars=yes,status=no')
}

function getCookie(name) {
	var index = document.cookie.indexOf(name + "=");
    if (index == -1)
		return null;

    var endstr = document.cookie.indexOf(";", index);
    if (endstr == -1)
		endstr = document.cookie.length; // last character
	
    return unescape(document.cookie.substring(document.cookie.indexOf("=", index)+1, endstr));
 }

function setCookie(name, value) {
	var expire = new Date();
	expire.setTime(expire.getTime() + 3600000*24*365);

    if (value != null)
      document.cookie=name + "=" + escape(value) + "; expires=" + expire.toGMTString();
}

function isCookiesEnabled() {
	if (document.cookie.indexOf("cookietest")!=-1)
		return true;

	var expire = new Date();
	expire.setTime(expire.getTime() + 3600000*24*365);
	document.cookie = "cookietest=Y" + ";expires="+expire.toGMTString();

	return (document.cookie.indexOf("cookietest") != -1);
}

