﻿function changeBgColor(id) {
    id.style.backgroundColor = '#E5F1C2';
    id.style.cursor = 'pointer';
}
function resetBgColor(id) {
    id.style.backgroundColor = 'transparent';
}

function changeBgImage(id) {
    id.style.backgroundImage = 'url(/images/backgrounds/vnav-bg-hover.gif)';
    id.style.cursor = 'pointer';
}
function resetBgImage(id) {
    id.style.backgroundImage = 'url(/images/backgrounds/vnav-bg.gif)';
}


function onClick_Vert(page) {
if(page!="#")
    window.location.href= page + "/";
}    

function onClick_Vert_noext(page) {
if(page!="#")
    window.location.href= page;
}    
function onClick(page) {
    switch (page) {
                case 'prostate-cancer': window.location.href = "prostate-cancer/";
                    break;
                case 'kidney-cancer': window.location.href = "kidney-cancer/";
                    break;
                case 'bladder-cancer': window.location.href = "bladder-cancer/";
                    break;
                case 'testicular-cancer': window.location.href = "testicular-cancer/";
                    break;
                case 'bph': window.location.href = "bph/";
                    break;
                case 'erectile-dysfunction': window.location.href = "erectile-dysfunction/";
                    break;
                case 'kidney-stones': window.location.href = "kidney-stones/";
                    break;
                case 'urinary-incontinence': window.location.href = "urinary-incontinence/";
                    break;
                case 'contact': window.location.href = "contact/";
                    break;
    }
}

function changeCursor(id) {
    id.style.cursor = 'pointer';
}

function nav_changeBgColor(id) {
    id.style.backgroundColor = '#99B14E';
    id.style.cursor = 'pointer';
}
function nav_resetBgColor(id) {
    id.style.backgroundColor = 'transparent';
}


// JScript File
// Removes leading whitespaces
function LTrim(value) {

    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim(value) {

    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function trim(value) {

    return LTrim(RTrim(value));

}

function quick_submit() {
    var txtName = document.getElementById("ctl00_Quick_Contact1_txtFullName");
    var txtEmail = document.getElementById("ctl00_Quick_Contact1_txtEmail");
    var txtComments = document.getElementById("ctl00_Quick_Contact1_txtComments");
    var validation_summary = "Please complete and answer the required fields:\n";
    if (trim(txtName.value) == "Name" || trim(txtName.value) == "") {
        validation_summary = validation_summary + "Full Name\n";
    }
    if (trim(txtEmail.value) == "Email") {
        validation_summary = validation_summary + "E-mail\n";
    }
    else {
        retxtname = new RegExp(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
        if (!(retxtname.test(trim(txtEmail.value)))) {
            validation_summary = validation_summary + "E-mail address is not valid\n";
        }
    }
    if (trim(txtComments.value) == "Comments" || trim(txtComments.value) == "") {
        validation_summary = validation_summary + "Comments / Inquiry\n";
    }
    if (validation_summary == "Please complete and answer the required fields:\n") {
        return true;
    }
    else {
        alert(validation_summary);
        return false;
    }
}

function contactus_submit() {
    
    var txtFName = document.getElementById("ctl00_Body_Contact_Form1_txtFirstName");
    var txtLName = document.getElementById("ctl00_Body_Contact_Form1_txtLastName");
    var txtEmail = document.getElementById("ctl00_Body_Contact_Form1_txtEmail");
    var txtComments = document.getElementById("ctl00_Body_Contact_Form1_txtComments");
    var txtHow = document.getElementById("ctl00_Body_Contact_Form1_referral");

    var lblFName = document.getElementById("lblFName");
    var lblLName = document.getElementById("lblLName");
    var lblEmail = document.getElementById("lblEmail");
    var lblComments = document.getElementById("lblComments");
    var lblHow = document.getElementById("lblHow");

    var validation_summary = "Please complete and answer the required fields:\n";
    if (trim(txtFName.value) == "") {
        validation_summary = validation_summary + "First Name\n";
        lblFName.innerHTML = "*";
    }
    if (trim(txtLName.value) == "") {
        validation_summary = validation_summary + "Last Name\n";
        lblLName.innerHTML = "*";
    }
    if (trim(txtEmail.value) == "") {
        validation_summary = validation_summary + "E-mail\n";
        lblEmail.innerHTML = "*";
    }
    else {
        retxtname = new RegExp(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
        if (!(retxtname.test(trim(txtEmail.value)))) {
            validation_summary = validation_summary + "E-mail address is not valid\n";
            lblEmail.innerHTML = "*";
        }
    }
    if (trim(txtComments.value) == "") {
        validation_summary = validation_summary + "Comments / Inquiry\n";
        lblComments.innerHTML = "*";
    }
    if (trim(txtHow.value) == "") {
        validation_summary = validation_summary + "How did you hear about us?\n";
        lblHow.innerHTML = "*";
    }
    if (validation_summary == "Please complete and answer the required fields:\n") {
        return true;
    }
    else {
        alert(validation_summary);
        return false;
    }
}


function app_submit() {
    var txtFName = document.getElementById("ctl00_body_Appointment_Form1_txtFirstName");
    var txtLName = document.getElementById("ctl00_body_Appointment_Form1_txtLastName");
    var txtEmail = document.getElementById("ctl00_body_Appointment_Form1_txtEmail");
    var txtComments = document.getElementById("ctl00_body_Appointment_Form1_txtComments");
    var txtHow = document.getElementById("ctl00_body_Appointment_Form1_referral");

    var lblFName = document.getElementById("lblFName");
    var lblLName = document.getElementById("lblLName");
    var lblEmail = document.getElementById("lblEmail");
    var lblComments = document.getElementById("lblComments");
    var lblHow = document.getElementById("lblHow");

    var validation_summary = "Please complete and answer the required fields:\n";
    if (trim(txtFName.value) == "") {
        validation_summary = validation_summary + "First Name\n";
        lblFName.innerHTML = "*";
    }
    if (trim(txtLName.value) == "") {
        validation_summary = validation_summary + "Last Name\n";
        lblLName.innerHTML = "*";
    }
    if (trim(txtEmail.value) == "") {
        validation_summary = validation_summary + "E-mail\n";
        lblEmail.innerHTML = "*";
    }
    else {
        retxtname = new RegExp(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/);
        if (!(retxtname.test(trim(txtEmail.value)))) {
            validation_summary = validation_summary + "E-mail address is not valid\n";
            lblEmail.innerHTML = "*";
        }
    }
    if (trim(txtComments.value) == "") {
        validation_summary = validation_summary + "Comments / Inquiry\n";
        lblComments.innerHTML = "*";
    }
    if (trim(txtHow.value) == "") {
        validation_summary = validation_summary + "How did you hear about us?\n";
        lblHow.innerHTML = "*";
    }
    if (validation_summary == "Please complete and answer the required fields:\n") {
        return true;
    }
    else {
        alert(validation_summary);
        return false;
    }
}

function preload() {
    if (!document.images) return;
    var ar = new Array();
    var arguments = preload.arguments;
    for (var i = 0; i < arguments.length; i++) {
        ar[i] = new Image();
        ar[i].src = arguments[i];
    }
}

window.onload = function () {
    // your code here
    preload('/images/backgrounds/vnav-bg.gif', '/images/backgrounds/vnav-bg-hover.gif', '/images/backgrounds/appointment.jpg', '/images/backgrounds/appointment-hover.jpg', '/images/backgrounds/vnav-box-bg.gif', '/images/backgrounds/vnav-box-hover.gif');
}
