﻿function roll(img_name, img_src) {
    document[img_name].src = img_src;
}

function show_menu(cellid) {
    var thiscell = document.getElementById(cellid);
    thiscell.className = 'navOption visible';
}

function hide_menu(cellid) {
    var thiscell = document.getElementById(cellid);
    thiscell.className = 'navOption';
}

function verifyContact() {
    var themessage = "Please complete the following fields: \n\n";
    if (document.contact.name.value == "") {
        themessage = themessage + " - Name\n";
    }
    if (document.contact.email.value == "" && document.contact.telephone.value == "") {
        themessage = themessage + " - either Email or Telephone\n";
    }
    //alert if fields are empty and cancel form submit
    if (themessage == "Please complete the following fields: \n\n") {
        document.contact.submit();
    }
    else {
        alert(themessage);
    }
}

function MM_preloadimages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadimages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}


function homeOut() {
    document['home'].src = 'http://www.potential2achieve.co.uk/images/navigation/home.png';
}

function homeOver() {
    document['home'].src = 'http://www.potential2achieve.co.uk/images/navigation/home-over.png';
}

function whatOut() {
    document['whatwedo'].src = 'http://www.potential2achieve.co.uk/images/navigation/what-we-do.png';
}

function whatOver() {
    document['whatwedo'].src = 'http://www.potential2achieve.co.uk/images/navigation/what-we-do-over.png';
}

function aboutOut() {
    document['about'].src = 'http://www.potential2achieve.co.uk/images/navigation/about-us.png';
}

function aboutOver() {
    document['about'].src = 'http://www.potential2achieve.co.uk/images/navigation/about-us-over.png';
}

function clientsOut() {
    document['clients'].src = 'http://www.potential2achieve.co.uk/images/navigation/clients.png';
}

function clientsOver() {
    document['clients'].src = 'http://www.potential2achieve.co.uk/images/navigation/clients-over.png';
}

function sharingOut() {
    document['sharing'].src = 'http://www.potential2achieve.co.uk/images/navigation/sharing-selected.png';
}

function sharingOver() {
    document['sharing'].src = 'http://www.potential2achieve.co.uk/images/navigation/sharing-selected-over.png';
}

function contactOut() {
    document['contactus'].src = 'http://www.potential2achieve.co.uk/images/navigation/contact-us.png';
}

function contactOver() {
    document['contactus'].src = 'http://www.potential2achieve.co.uk/images/navigation/contact-us-over.png';
}

function showWhat() {
    show_menu('topnav1');
    return true;
}

function hideWhat() {
    hide_menu('topnav1');
    return true;
}

function showAbout() {
    show_menu('topnav2');
    return true;
}

function hideAbout() {
    hide_menu('topnav2');
    return true;
}

function showClients() {
    show_menu('topnav3');
    return true;
}

function hideClients() {
    hide_menu('topnav3');
    return true;
}

function showSharing() {
    show_menu('topnav4');
    return true;
}

function hideSharing() {
    hide_menu('topnav4');
    return true;
}



/* NAVIGATION */
$(document).ready(function() {
    var config = {
        sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        over: makeTall, // function = onMouseOver callback (REQUIRED)
        timeout: 400, // number = milliseconds delay before onMouseOut
        out: makeShort // function = onMouseOut callback (REQUIRED)
    };

    $('ul#navigation li').hoverIntent(config).hover(function() {
        $(this).addClass("subhover"); //On hover over, add class “subhover”
    }, function() { //On Hover Out
        $(this).removeClass("subhover"); //On hover out, remove class “subhover”
    });
});

function makeTall() {
    $(this).find("ul.subnav").slideDown('normal').show();
}

function makeShort() {
    $(this).find("ul.subnav").slideUp('normal');
}