
// Pop up opener
function centrePop(mypage, myname, w, h, scroll)
{
	window.opener = self;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0 && navigator.userAgent.indexOf('MSIE')>0;
	if (Macintosh) {
	w = w - 16;
	h = h - 16;
	}
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,status=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}



// SHOW/HIDE ID
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers) {
       document.layers[szDivID].display = iState ? "block" : "none";
    } else if(document.getElementById) {
        var obj = document.getElementById(szDivID);
        obj.style.display = iState ? "block" : "none";
    } else if(document.all) {
        document.all[szDivID].style.display = iState ? "block" : "none";
    }
}


function errorField(labelID)
{
	document.getElementById(labelID).style.color="#D6191D";
}

function correctField(labelID)
{
	document.getElementById(labelID).style.color="#666";
}


function checkSignup()
{
	var submitForm = true;
	
	if (document.getElementById("termsCheck").checked == false) {
		submitForm = false;
		errorField('lblTerms');
	} else {
		correctField('lblTerms');
	}
	if (document.getElementById("firstname").value == "") {
		submitForm = false;
		errorField('lblFirstName');
	} else {
		correctField('lblFirstName');
	}
	if (document.getElementById("secondname").value == "") {
		submitForm = false;
		errorField('lblSecondName');
	} else {
		correctField('lblSecondName');
	}
	if (document.getElementById("address").value == "") {
		submitForm = false;
		errorField('lblAddress');
	} else {
		correctField('lblAddress');
	}
	if (document.getElementById("postcode").value == "") {
		submitForm = false;
		errorField('lblPostcode');
	} else {
		correctField('lblPostcode');
	}
	if ((document.getElementById("personEmail").value == "") || (document.getElementById("personEmail").value.indexOf('@') == -1) || (document.getElementById("personEmail").value.indexOf('.') == -1)) {
		submitForm = false;
		errorField('lblEmail');
	} else {
		correctField('lblEmail');
	}
	if (document.getElementById("phone").value == "") {
		submitForm = false;
		errorField('lblPhone');
	} else {
		correctField('lblPhone');
	}
	
	
	if (submitForm) {
		document.signup.submit();
	} else {
		toggleBox('errorMSG',1);
		return false;
	}
}


function checkFAQ()
{
	var submitForm = true;
	
	if (document.getElementById("personName").value == "") {
		submitForm = false;
		errorField('lblName');
	} else {
		correctField('lblName');
	}
	if ((document.getElementById("personEmail").value == "") || (document.getElementById("personEmail").value.indexOf('@') == -1) || (document.getElementById("personEmail").value.indexOf('.') == -1)) {
		submitForm = false;
		errorField('lblEmail');
	} else {
		correctField('lblEmail');
	}
	if (document.getElementById("question").value == "") {
		submitForm = false;
		errorField('lblQuestion');
	} else {
		correctField('lblQuestion');
	}
	
	
	if (submitForm) {
		document.faq.submit();
	} else {
		toggleBox('errorMSG',1);
		return false;
	}
}
