﻿function toggle(e)
{
if (e.which==119)
    {
    fade(0,1,'crf');
    }
return true;
}

function fade(now, amount, el)
{
obj = document.getElementById(el);
obj.style.opacity = (now+amount)/10;
obj.style.filter = 'alpha(opacity=' + (now+amount)*10 + ')';
if (now==0) {obj.style.display='block';}
if ((now+amount) > 0 && (now+amount) < 10)
    {
    setTimeout("fade(" + (now+amount) + "," + amount + ",'" + el + "')", 10);
    return;
    }
if ((now+amount)==0) {obj.style.display='none';}
if ((now+amount)==10) {obj.style.display='block';}
}

function check(el, bol, oth)
{
if (document.getElementById(el+'-'+bol).checked==1)
    {
    document.getElementById(el).value = bol;
    document.getElementById(el+'-'+oth).checked = 0;
    }
else
    {
    document.getElementById(el).value = oth;
    document.getElementById(el+'-'+oth).checked = 1;
    }

}

function validateForm()
{
var reqEls = new Array(0,2,7,9)
var errText = "";

for (x=0;x<reqEls.length;x++)
    {
    if (document.getElementById('f-'+reqEls[x]).value=="")
        {errText += "Please can you enter a"
        if (/[aeiouAEIOU]/.test(document.getElementById('f-'+reqEls[x]).name[0])) errText += "n"
        errText += " " + document.getElementById('f-'+reqEls[x]).name + "\n";}
    }
if (errText!="") alert(errText);
else sendRequest();
}

function sendRequest()
{
var postVars = "";
var url = "send_request.asp";
for (x=0;x<15;x++)
    {
    postVars += document.getElementById('f-'+x).name + "=" + escape(document.getElementById('f-'+x).value.replace("\n","[lb]")) + "&";
    }
postVars = postVars.substring(0,postVars.length-1);

xmlHttp = GetXmlHttpObject();
xmlHttp.onreadystatechange=requestBack;
xmlHttp.open("POST",url,false);
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
xmlHttp.send(postVars);
//document.getElementById('crf').innerHTML = postVars;
}

var xmlHttp;

function GetXmlHttpObject()
{var xmlHttp=null;
try  {xmlHttp=new XMLHttpRequest();}
catch (e) {
try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}

function requestBack()
{
if (xmlHttp.responseText=="1")
    {
    alert("Thank you for your enquiry,\nthe literature you requested will be with you shortly.");
    fade(10,-1,'crf');
    }
else
    {
    alert("Your request have failed.\nPlease try again.");
    }
}

try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}