﻿// 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 changeVideo(obj)
{
 var tbl_id = obj.id;
 var tdVideo = document.getElementById("tdVideo");
 var tdv1 = document.getElementById("tblVideo1").getElementsByTagName("td");
 var tdv2 = document.getElementById("tblVideo2").getElementsByTagName("td");
 var tdv3 = document.getElementById("tblVideo3").getElementsByTagName("td");
 if(tbl_id == "tblVideo1")
 {
    tdv1[0].style.backgroundColor = "#FFFFFF";
    tdv1[0].setAttribute("onmouseout","");
    tdv2[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv3[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv2[0].style.backgroundColor = "Transparent";
    tdv3[0].style.backgroundColor = "Transparent";
    tdVideo.innerHTML = "<object width='300' height='230'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=5440147&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=5440147&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='300' height='230'></embed></object>";
 }
 else if(tbl_id == "tblVideo2")
 {
    tdv2[0].style.backgroundColor = "#FFFFFF";
    tdv2[0].setAttribute("onmouseout","");
    tdv1[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv3[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv1[0].style.backgroundColor = "Transparent";
    tdv3[0].style.backgroundColor = "Transparent";
    tdVideo.innerHTML = "<object width='300' height='230'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=5456415&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=5456415&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='300' height='230'></embed></object>";
 }
 if(tbl_id == "tblVideo3")
 {
    tdv3[0].style.backgroundColor = "#FFFFFF";
    tdv3[0].setAttribute("onmouseout","");
    tdv1[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv2[0].setAttribute("onmouseout","this.style.backgroundColor='Transparent';this.style.cursor='pointer';");
    tdv2[0].style.backgroundColor = "Transparent";
    tdv1[0].style.backgroundColor = "Transparent";
    tdVideo.innerHTML = "<object width='300' height='230'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=5481153&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=5481153&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='300' height='230'></embed></object>";
 }
}

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 me?\n";
        lblHow.style.color = "#ff0000";
    }
    if (validation_summary == "Please complete and answer the required fields:\n")
    {
        return true;
    }
    else
    {
        alert(validation_summary);
        return false;
    }
}