// JavaScript Document
var ticker_on = false;
function RGB_toggle_ticker() {
	if (ticker_on) {
		// turn off ticker
		ticker_on = false;
		//MM_showHideLayers('ticker','','hide');
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_09.gif');
		scroller.location = "http://www.ecoscan.co.uk/ticker.htm";
		}
		else {
		//turn on ticker
		ticker_on = true;
		MM_showHideLayers('ticker','','show');
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_10.gif');
		scroller.location = "http://www.edie.net/dynamic_ticker/scroller2.asp?id=85";
		}	
}
function RGB_toggle_image() {
	if (ticker_on) {
		// ticker is on
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_10-over.gif');
		}
		else {
		// ticker is off
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_09-over.gif');
		}	
}

function RGB_toggle_restore() {
	if (ticker_on) {
		// ticker is on
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_10.gif');
		scroller.location = "http://www.edie.net/dynamic_ticker/scroller2.asp?id=85";
		}
		else {
		// ticker is off
		changeImages('toggle','http://www.ecoscan.co.uk/images/ecoscan_09.gif');
		scroller.location = "http://www.ecoscan.co.uk/ticker.htm";
		}	
}

function RGB_checkform() {
var score = 0;

	if (isoform.Q1[0].checked) {score++};
	if (isoform.Q2[0].checked) {score++};
	if (isoform.Q3[0].checked) {score++};
	if (isoform.Q4[0].checked) {score++};
	if (isoform.Q5[0].checked) {score++};
	if (isoform.Q6[0].checked) {score++};
	if (isoform.Q7[0].checked) {score++};
	if (isoform.Q8[0].checked) {score++};

//alert("ISO 14001 Readiness score is " + score);
scorewindow = window.open("", "_blank", "toolbar=no, status=no, width=600, height=500");
scorewindow.document.write("<head><title>EcoScan ISO 14001 Readiness Score</title><link href='http://www.ecoscan.co.uk/styles/ecoscan.css' rel='stylesheet' type='text/css'></head>");
scorewindow.document.write("<body><img src='http://www.ecoscan.co.uk/images/ecoscan-logo.jpg' width='500' height='140'>");
scorewindow.document.write("<p class='heading'>Scoring for 14001 Policy statement readiness</p>");

scoreresult = "<p class=text>Your score was " + score + "</p>";

if (score >= 8)
	{
	scoreresult = scoreresult + "<p class=text>Well done! Your Policy statement meets all the requirements of ISO14001. " ;
	scoreresult = scoreresult + "<a href='http://www.ecoscan.co.uk/contact.htm' target='_blank'>Contact us</a> for the rest of the check sheet to see if your Environmental Management System ";
	scoreresult = scoreresult + "meets all the other requirements of ISO14001, or for ongoing help and advice on running your <a href='ems.htm' target='_blank'>EMS</a>.</p>";
	} else
if (score >=5)
	{
	scoreresult = scoreresult + "<p class=text>You're almost there! Remember all the requirements are important and you won't be fully compliant until you can score 8/8. ";
	scoreresult = scoreresult + "EcoScan can help you in all areas of Environmental Management System implementation and management. <a href='http://www.ecoscan.co.uk/contact.htm' target='_blank'>Contact us</a> now!" ;
	} else
if (score >=1)
	{
	scoreresult = scoreresult + "<p class=text>You&#8217;re getting there. Do you need some help or advice? Please ";
  	scoreresult = scoreresult + "<a href='http://www.ecoscan.co.uk/contact.htm' target='_blank'>Contact us</a> and we can help take the stress out of implementing an ISO14001 Environmental Management System.";
	} else
	{//score ois zero!
	scoreresult = scoreresult + "<p class=text>Oh dear! Are you considering implementing an ISO14001 compliant Environmental Management System? If so, we can help, <a href='http://www.ecoscan.co.uk/contact.htm' target='_blank'>Contact us</a> now!";
	}

scorewindow.document.write(scoreresult);

scorewindow.document.write("<p class=text>Thank you for using this ISO14001 Readiness Check Sheet.<br>Its intention is to give some idea of how close your organisation is to achieving ISO 14001.  It is by no means a guarantee that you will achieve certification.</p>");
scorewindow.document.write("<p class=text>For further information or help with implementing an Environmental Management System please <a href='http://www.ecoscan.co.uk/contact.htm' target='_blank'>contact us.</a> Good Luck!</p>");
scorewindow.document.write("<p align=center class=footer>&copy;2004 EcoScan All Rights reserved.</p>");


return false;
}

//Form checking functions

function isAlpha(elm) {
    var pattern = /([^a-zA-Z ])$/;
    if (pattern.test(elm.value)) {
        return false;
    }
    else {
        return true;
    }
}    

function isEmail(elm) {
    var pattern = /^[a-zA-Z0-9.\_- ]+\@[a-zA-Z0-9 \_-\.]+\.([a-zA-Z]{2,3})$/;
    if (pattern.test(elm.value)) {
        return true;
    }
    else {
        return false;
    }
}    

function isPhone(elm) {
   var pattern = /([0-9 ()-])$/;
    if (pattern.test(elm.value)) {
        return true;
    }
    else {
        return false;
    }
}   
 
function FormReady(form) {
//	alert("FormReady Called");
    if (form.f_name.value == "") {
        alert("Please enter your name.");
        form.f_name.focus();
        return false;
    } else
    if (isAlpha(form.f_name) == false) {
        alert("Please enter letters only for name.");
        form.f_name.focus();
        return false;
    } else
    if (form.f_mail.value == "") {
        alert("Please enter an email address.");
        form.f_mail.focus();
        return false;
    } else
    if (isEmail(form.f_mail) == false) {
        alert("Please enter a valid email address.");
        form.f_mail.focus();
        return false;
    } else
    if (form.f_tel.value == "") {
        alert("Please enter your telephone number.");
        form.f_tel.focus();
        return false;
    } else
    if (isPhone(form.f_tel) == false) {
        alert("Please enter numbers only for telephone.");
        form.f_tel.focus();
        return false;
	}	
	return true;
}

function MemberReady(form) {
//	alert("MemberReady Called");
    if (form.f_mail.value == "") {
        alert("Please enter an email address.");
        form.f_mail.focus();
        return false;
    } else
    if (isEmail(form.f_mail) == false) {
        alert("Please enter a valid email address.");
        form.f_mail.focus();
        return false;
    } else
    if (form.f_tel.value == "") {
        alert("Please enter your telephone number.");
        form.f_tel.focus();
        return false;
    } else
    if (isPhone(form.f_tel) == false) {
        alert("Please enter numbers only for telephone.");
        form.f_tel.focus();
        return false;
	}	
	return true;
}
