﻿function over_block(object)
{
    if(object != null)
        object.style.cursor = 'hand';
}

function out_block(object)
{
    if(object != null)
        object.style.cursor = 'pointer';
}

function over_button_nav_vertical(divid) 
{
    if(divid != null)
    {
        divid.style.cursor='hand'; 
        divid.style.backgroundImage='url(images/backgrounds/nvertical-hover.png)';
    }
}

function up_button_nav_vertical(divid) 
{
    if(divid != null)
    {divid.style.backgroundImage='url()';}
}

function over_button_nav_hori(divid) 
{
    if(divid != null)
    {
        divid.style.cursor='hand'; 
        divid.style.backgroundImage='url(images/backgrounds/nhover.jpg)';
    }
}

function up_button_nav_hori(divid) 
{
    if(divid != null)
    {divid.style.backgroundImage='url()';}
}

function click_nav_vertical(path) 
{
    window.location.href = path + '.aspx';
}

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 ddlVisit = document.getElementById("ctl00_Body_Appointment_Form1_ddlVisit");
    var ddlHow = 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 lblVisit = document.getElementById("lblVisit");
    
    lblFName.style.color = "#000000";
    lblLName.style.color = "#000000";
    lblEmail.style.color = "#000000";
    lblComments.style.color = "#000000";
    lblHow.style.color = "#000000";
    lblVisit.style.color = "#000000";
    
    
    var validation_summary = "Please complete and answer the required fields:\n";
    if(trim(txtFName.value)=="")
    {
        validation_summary = validation_summary + "First Name\n";
        lblFName.style.color = "#ff0000";
    }
    if(trim(txtLName.value)=="")
    {
        validation_summary = validation_summary + "Last Name\n";
        lblLName.style.color = "#ff0000";
    }
    if(trim(txtEmail.value)=="")
    {
        validation_summary = validation_summary + "E-mail\n";
        lblEmail.style.color = "#ff0000";
    }
    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.style.color = "#ff0000";
       	}
    }
    if(trim(ddlVisit.value)=="")
    {
        validation_summary = validation_summary + "Reason for your visit?\n";
        lblVisit.style.color = "#ff0000";
    }
    if(trim(txtComments.value)=="")
    {
        validation_summary = validation_summary + "Comments / Inquiry\n";
        lblComments.style.color = "#ff0000";
    }
    if(trim(ddlHow.value)=="")
    {
        validation_summary = validation_summary + "How did you hear about us?\n";
        lblHow.style.color = "#ff0000";
    }
    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");
    
    lblFName.style.color = "#000000";
    lblLName.style.color = "#000000";
    lblEmail.style.color = "#000000";
    lblComments.style.color = "#000000";
    lblHow.style.color = "#000000";
    
    
    var validation_summary = "Please complete and answer the required fields:\n";
    if(trim(txtFName.value)=="")
    {
        validation_summary = validation_summary + "First Name\n";
        lblFName.style.color = "#ff0000";
    }
    if(trim(txtLName.value)=="")
    {
        validation_summary = validation_summary + "Last Name\n";
        lblLName.style.color = "#ff0000";
    }
    if(trim(txtEmail.value)=="")
    {
        validation_summary = validation_summary + "E-mail\n";
        lblEmail.style.color = "#ff0000";
    }
    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.style.color = "#ff0000";
       	}
    }
    if(trim(txtComments.value)=="")
    {
        validation_summary = validation_summary + "Comments / Inquiry\n";
        lblComments.style.color = "#ff0000";
    }
    if(trim(txtHow.value)=="")
    {
        validation_summary = validation_summary + "How did you hear about us?\n";
        lblHow.style.color = "#ff0000";
    }
    if (validation_summary == "Please complete and answer the required fields:\n")
    {
        return true;
    }
    else
    {
        alert(validation_summary);
        return false;
    }
}
 // 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 preload() {
    var form = document.getElementById("aspnetForm");
    if (form != null) {
        form.action = "";
    }
    
  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];
  }
}