var home = new Image();
var services = new Image();
var payments = new Image();
var contact = new Image();
var links = new Image();

var imgHomeOn = new Image();
var imgServicesOn = new Image();
var imgPaymentsOn = new Image();
var imgContactOn = new Image();
var imgLinksOn = new Image();

home.src = "images/home.jpg";
services.src = "images/services.jpg";
payments.src = "images/payments.jpg";
contact.src = "images/contact.jpg";
links.src = "images/links.jpg";

imgHomeOn.src = "images/homeOn.jpg";
imgServicesOn.src = "images/servicesOn.jpg";
imgPaymentsOn.src = "images/paymentsOn.jpg";
imgContactOn.src = "images/contactOn.jpg";
imgLinksOn.src = "images/linksOn.jpg";


//DOWNLOAD MOUSE OVERS//

function mOverDownload(obj)
{
    obj.style.cursor = 'pointer';
}

function mOutDownload(obj)
{
    obj.style.cursor = 'default';
}


//SIDE BUTTON MOUSE OVERS//

function homeOn(obj)
{
    obj.src = imgHomeOn.src;
    obj.style.cursor='pointer';
}
function homeOff(obj)
{   
    obj.src = home.src;
    obj.style.cursor='default';
}

function servicesOn(obj)
{
    obj.src = imgServicesOn.src;
    obj.style.cursor='pointer';
}
function servicesOff(obj)
{   
    obj.src = services.src;
    obj.style.cursor='default';
}

function paymentsOn(obj)
{
    obj.src = imgPaymentsOn.src;
    obj.style.cursor='pointer';
}

function paymentsOff(obj)
{   
    obj.src = payments.src;
    obj.style.cursor='default';
}

function contactOn(obj)
{
    obj.src = imgContactOn.src;
    obj.style.cursor='pointer';
}

function contactOff(obj)
{   
    obj.src = contact.src;
    obj.style.cursor='default';
}

function linksOn(obj)
{
    obj.src = imgLinksOn.src;
    obj.style.cursor='pointer';
}

function linksOff(obj)
{   
    obj.src = links.src;
    obj.style.cursor='default';
}

function winPop(pageToLoad, winName, width, height, center, scroll)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=1,"
    + "resizable=1,"
    + "scrollbars="+scroll+", "
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}

function NumberOfChar(str,char)
{
    var ii, charCount;
    charCount = 0;
    for (ii=0; ii < str.length;ii++)
    {
        var cc = str.charAt(ii);
        if (cc == char)
        {
            charCount = charCount + 1;
        }
    }
    return charCount;
}

function validEmail(str)
{
    var bool;
    bool = true;
    if (str.length < 6)
    {
        bool = false;
        alert("Email address has too few characters.");
    }
    if ((bool) && ((NumberOfChar(str,'@')==0)||(NumberOfChar(str,'@')>1)))
    {
        bool = false;
        alert("Email address contains the wrong number of @'s.");
    }
    if ((bool) && (NumberOfChar(str,'.')==0))
    {
        bool = false;
        alert("Email address must contain at least one '.'.");
    }
    if ((bool) && (NumberOfChar(str,' ')!=0))
    {
        bool = false;
        alert("Email address must not contain any spaces.");
    }
    return bool;
}

function validateContactForm(pForm)
{
    var bValid;
    bValid = true;

    if (pForm.Name.value=='')
    {
        alert('You must enter a name.');
        bValid = false;
    }

    if ((bValid) && (pForm.EmailxxxAddress.value=='') && (pForm.Address.value=='') && (pForm.PhonexxxNumber.value=='') && (pForm.Mobile.value==''))
    {
        alert('You must enter either your address, phone number or an email address.');
        bValid = false;
    }
    else if ((bValid) && (pForm.EmailxxxAddress.value!=''))
    {
        if (validEmail(pForm.EmailxxxAddress.value))
        {
            bValid = true;
        }
        else
        {
            bValid = false;
        }
    }
    
    if ((bValid) && (pForm.Comments.value==''))
    {
        alert('You must enter some comments.');
        bValid = false;
    }
    
    return bValid;
};



