/**************************************/
/*
Lloyd Engineering Ltd.
CopyrightŠUnite and Rule Ltd.
*/
/**************************************/

/**************************************/
/* Swap the active CSS */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/**************************************/
/* Popup */
function popup (obj, iW, iH) {
	var winW = iW;
	var winH = iH;
	var winName = '_blank';
	var winL = (screen.width - winW) / 2;
	var winT = ((screen.height - winH) / 2) - 50;
	window.open(obj.href, winName, 'location=no, toolbar=no, status=no, directories=no, scrollbars=yes, menubar=no, resizable=no, left=' + winL + ', top=' + winT +', width=' + winW + ', height=' + winH);
}

/**************************************/
/* Contact Validation */
function validateContactUs(oForm) {
	var bValid = true;
/*
	//check for security code
	if (oForm.code.value.length < 4) {
		alert('Please enter the security code');
		return false;
	}
*/

	//check normal form
	if (oForm.name.value == '' ||
		oForm.telephone.value == '') {
		bValid = false;
	}

	//check email
	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address');
		return false;
	}

	//return correctly
	if (bValid == false) {
		alert('Please fill out all fields');
		return false;
	}

	return true;
}

/**************************************/
/* validate the email field */
function validateEmail(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) { return false; }
		else { return true; }
	}
}

