﻿var i = 100;
var speed = 50;
var myint


function runStartUpScripts() {
    myint = self.setInterval("imgFadeOut()", 3000);
}
function imgFadeOut() {
    if (navigator.appName == "Netscape") {
        document.getElementById("fader").style.MozOpacity = i / 100;
        document.getElementById("fader").style.KhtmlOpacity = i / 100;
        i--;
        if (i <= 0) { return; }
        setTimeout("imgFadeOut()", speed);
    }
    else {
        document.getElementById("fader").style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + i + ')';
        i--;
        if (i <= 0) { return; }
        setTimeout("imgFadeOut()", speed);
    }
    window.clearInterval(myint);
}


function formSendBegin() {
    document.getElementById('SubmitButton').disabled = true;
    $("#Processing").html("Sending...");
}
function formSendFailure() {
    $("#Processing").html("An error has occured...");
}

function formSendSuccess() {
    $("#Processing").html("Sent...");
}

function userLogin() {
    $("#ctl00_MasterOne_Main_Login_Processing").html("Validating Login Fields...");
    if (Page_ClientValidate()) {
        $("#ctl00_MasterOne_Main_Login_Processing").html("Fields Validated - Processing Login...");
    }
    else {
        $("#ctl00_MasterOne_Main_Login_Processing").html("Login Field Validation Failed! - * Indicates Required Field...");
    }
}

function checkFileValid(file) {
    var extension = file.substr((file.lastIndexOf('.') + 1));
    switch (extension) {

        case 'pdf':
        case 'doc':
        case 'docx':
            //valid
            break;
        default:
            alert('Word documents or PDF files only please (.doc,.docx or .pdf)');
            document.getElementById('CustomerBrief').value = '';
            break;
    }
};

function toggleItem(item, idToUse, buttonToShow) {
    var ele = document.getElementById(idToUse);
    var text = document.getElementById(buttonToShow);

    var imageSwitchDown = "";
    var imageSwitchUp = "";
    switch (item) {
        case "login":
            imageSwitchUp = "<img src='http://localhost/pcw2/resources/website_images/login_dropDown.png' width='109' height='43' alt='drop down login button' />";
            imageSwitchDown = "<img src='http://localhost/pcw2/resources/website_images/login_close.png' width='109' height='35' alt='drop down login button' />";
            break;
        case "promotion":
            imageSwitchUp = "<img src='http://localhost/pcw2/resources/website_images/advert_dropDown.png' width='267' height='45' alt='drop down advert button' />";
            imageSwitchDown = "<img src='http://localhost/pcw2/resources/website_images/login_close.png' width='109' height='35' alt='drop down advert button' />";
            break;
            break;
    }
    switch (item) {
        default:
            if (ele.style.display == "block") {
                $(ele).slideUp('slow');
                text.innerHTML = imageSwitchUp;
            }
            else {
                $(ele).slideDown('slow');
                text.innerHTML = imageSwitchDown;
            }
            break;
    }
}

function toggleFaq(faqItem) {
    var imageSwitchUp = "<img src='http://localhost/pcw2/resources/website_images/faqOpen.png' width='187' height='14' alt='drop down advert button' />";
    var imageSwitchDown = "<img src='http://localhost/pcw2/resources/website_images/faqClose.png' width='41' height='26' alt='drop down login button' />";
    var faqNumber = faqItem.replace("Question", "");

    if (document.getElementById('Answer' + faqNumber).style.display == "block") {
        $('#Question' + faqNumber).html(imageSwitchUp);
        $('#Answer' + faqNumber).slideUp('slow', function() {
            $('#Contact' + faqNumber).slideUp('slow')
        });
    }
    else {
        $('#Question' + faqNumber).html(imageSwitchDown);
        $('#Answer' + faqNumber).slideDown('slow', function() {
            $('#Contact' + faqNumber).slideDown('slow')
        });
    }

}

