function sh(elId,act) {
	var tmp = document.getElementById(elId);
	if (tmp) tmp.style.display = (act==0?'none':'');
}
function chClass(elId,classname) {
	document.getElementById(elId).className = classname;
}
function trim(strg) {
	var str = '';
	if ((typeof strg).toLowerCase() == 'string') str = strg;
	return str.replace(/^\s*(.*)\s*$/i,'$1');
}

function checkEmail(email) {
    var re = new RegExp("^[\\w\\.-]+@[\\w\\.-]+\\.[A-Za-z]{2,}");
    return (re.test(email));
}
function addDomain() {
	var cntDomains = parseInt(document.buyDomain.cntDom.value);
	if (trim(document.getElementById('BDUrl'+cntDomains).value)!='') {
		if (cntDomains==9) alert('You can submit no more than 10 domains at once.');
		else {
			document.buyDomain.action.value='add';
			document.buyDomain.submit();
		}
	} else {
		document.getElementById('BDUrl'+cntDomains+'TXT').style.color='red';
	}
}
function delDomain(numb) {
	if (confirm('Are you sure?')) {
		document.buyDomain.action.value='del';
		document.buyDomain.delDom.value=numb;
		document.buyDomain.submit();
	}
}
function sendBuyForm() {
	is_ok=1;
	tmp1 = document.buyDomain.BDPhone;
	tmp2 = document.buyDomain.BDEmail;
	if ( trim(tmp1.value)!='' || checkEmail(trim(tmp2.value)) ) {
		document.getElementById('noteEmail').style.color='';
		document.getElementById('BDPhoneTXT').style.color='';
		tmp1.style.border = '';
		document.getElementById('BDEmailTXT').style.color='';
		tmp2.style.border = '';
	} else {
		is_ok=0;
		document.getElementById('BDPhoneTXT').style.color='red';
		tmp1.style.border = '1px solid red';
		document.getElementById('BDEmailTXT').style.color='red';
		tmp2.style.border = '1px solid red';
		document.getElementById('noteEmail').style.color='red';
		tmp2.focus();
	}
	cntCheck = (document.buyDomain.cntDom.value==0?1:document.buyDomain.cntDom.value);
	for (i=0; i<cntCheck; i++) {
		tmp1 = eval('document.buyDomain.BDUrl'+i);
		if (tmp1) {
			if ( trim(tmp1.value)!='' ) {
				sh('noteURL',0);
				document.getElementById('BDUrl'+i+'TXT').style.color='';
				tmp1.style.border = '';
			} else {
				is_ok=0;
				sh('noteURL',1);
				document.getElementById('BDUrl'+i+'TXT').style.color='red';
				tmp1.style.border = '1px solid red';
				tmp1.focus();
			}
		}
	}
	if (is_ok==1) {
		if (confirm('Send now?')) { document.buyDomain.action.value='buy'; document.buyDomain.submit(); }
		else return false;
	}
}
function sendContactForm() {
	is_ok=1;
	tmp1 = document.contact.comments;
	if ( trim(tmp1.value)!='' ) {
		sh('noteContComm',0);
	    document.getElementById('commentsTXT').style.color='';
	    tmp1.style.border = '';
	} else {
	    is_ok=0;
	    sh('noteContComm',1);
	    document.getElementById('commentsTXT').style.color='red';
	    tmp1.style.border = '1px solid red';
	    tmp1.focus();
	}
	tmp1 = document.contact.email;
	if ( checkEmail(trim(tmp1.value)) ) {
		sh('noteContEmail',0);
		document.getElementById('emailTXT').style.color='';
		tmp1.style.border = '';
	} else {
		is_ok=0;
		sh('noteContEmail',1);
		document.getElementById('emailTXT').style.color='red';
		tmp1.style.border = '1px solid red';
		tmp1.focus();
	}
	if (is_ok==1) {
	    if (confirm('Send now?')) { document.contact.action.value='send'; document.contact.submit(); }
	    else return false;
	}
}
