
function checkcode(code) {

	// Trim code
	code.replace(/^\s+|\s+$/g, '') ;

	if (!code.match(/^[0-9]{8}$/))
	{
		alert("Please Enter Code");
		document.expressform.code.focus();
	}
	else
	{
		ajaxgetdomain(code);
	}
	return false;

}

function ajaxgetdomain(code) {

    var statcallback =
    {
        success:parsedomainlist
    };
    var sUrl = "/cms/setsession_getdomain.php?" + code;
    YAHOO.util.Connect.asyncRequest('GET', sUrl , statcallback);

}

function parsedomainlist(o) {
	if (o.responseText.match(/^error$/))
	{
		alert("Invalid Code");
		document.expressform.code.focus();
	}
	else
	{
		var domain = o.responseText.split(":");

		document.expressform.domain.value = domain[0];
		document.expressform.ext.value = domain[1];

		document.expressform.submit();
	}
}
