window.onload=load;

function load(){
var path = location.pathname.toLowerCase();
if(path=="/default.aspx" || path=="/"){
changetext();
}
if(path=="/categories/67/default.aspx" || path=="/categories/66/default.aspx" || path=="/categories/70/default.aspx" || path=="/categories/71/default.aspx"){
randomTest();
}
}

var text=new Array(8);

text[0]="<blockquote>I was extremely impressed with the quality of work I received. It was better than I had ever imagined. The service was great and the delivery time was unbelievable. You made my fiance very happy with your product. I truly intend to use this service again and again.<div>-Edward A., Sunland, CA </div></blockquote>";

text[1]="<blockquote>What beautiful art! I love the changes from the original photograph and it looks great as a big canvas. Thanks for all the advice, your service is excellent!,<div>Ruth P., Birmingham, AL</div></blockquote>";

text[2]="<blockquote>This is a great way to save and display those special photos.,<div>Mike R., Franklin, TN</div></blockquote>";

text[3]="<blockquote>Thank you for helping make my parents anniversary unforgettable! They loved reliving the memories with such a lovely painting.,<div>Sarah G., East Windsor, NJ</div></blockquote>";

text[4]="<blockquote>My husband loved his painting of his childhood home. The only thing different I would have done was to have gotten a larger painting than the 16 x 24. I think it would have been even more impressive in a larger canvas.,<div>Michal G., Tucson, AZ</div></blockquote>";

text[5]="<blockquote>Our dogs have never looked so cute and angelic. Thanks for being so responsive.,<div>Melissa N., San Francisco, CA</div></blockquote>";

text[6]="<blockquote>I don't know how you did it but its exactly what I wanted! Thanks so much!,<div>Joannie W., Austin, TX</div></blockquote>";

text[7]="<blockquote>I just wanted to let you know that the paintings arrived yesterday, and they really blew me away. Each looks much better than I had even hoped they would. Thank you so much for a great product and your fast, friendly service. Expect more business from me in the future.,<div>Rob M., Hinsdale, IL</div></blockquote>";


hexinput=255;  // Initial color value.
var inc=0; //increment variable

function fadingtext(){	         	
  if(hexinput>0) {	
  hexinput-=11; // increase color value
  document.getElementById("testimonials").style.color="rgb("+hexinput+","+hexinput+","+hexinput+")";
  setTimeout("fadingtext()",20);	
  }
  else
    hexinput=255;  //reset hex value
}

function changetext(){
document.getElementById("testimonials").innerHTML=text[inc];
if(inc==7){
inc=0;
}
else{
inc+=1;
}

fadingtext();
setTimeout("changetext()",4000);
}

function randomTest(){
var randNum=Math.floor(Math.random()*8);
document.getElementById("testimonial-content").innerHTML=text[randNum];
}

function openWindow(){
window.open("/data/audio-tour.html", "mywindow","status=0,toolbar=0,scrollbars=0,width=440,height=200");
}
requiredfields = new Array('first_name','First Name','last_name','Last Name','email','Email Address','phone','Phone','country','Country','00N30000000wQso','Fleet Size','company','Company Name');
var country;
var state;
var first_name;
var last_name;
var phone_number;
function formrules(frm)
{


    var thisform = frm;
    var elements = document.forms['aspnetForm'].elements;
    var ret = listAllRequiredFields(elements);
    if (ret == false) {return false;}
    
        for (var x = 0;x<elements.length;x++)
        {
            if (elements[x].FieldName != undefined)
            {
                
                if (elements[x].FieldName == 'country')
                {
                    country = elements[x].value;
                }
                else if (elements[x].FieldName == 'state')
                {
                    state = elements[x].value;
                }
                else if (elements[x].FieldName == 'first_name')
                {
                    ret = badFormValue(elements[x].value);
                    if (ret == true) {alert('Invalid first name');return false;}
			first_name = elements[x].value;
                }
		else if (elements[x].FieldName == 'last_name')
		{
			last_name = elements[x].value;
		}
		else if (elements[x].FieldName == 'phone')
		{
			if (phonenumber(elements[x].value).length <= 7)
			{alert('Invalid Phone Number');return false;}

		}
		else if (elements[x].FieldName == '00N30000001DYuT')
		{
			ret = badFormValue(elements[x].value);
                    if (ret == true) {alert('Invalid content in comments box');return false;}
		}

            }
        }
        if (country == 'US' && state == '')
        {
            alert('You must select a state.')
            return false;
        }
        else if (country != 'US' && state != '')
        {
            alert('Please delete your state selection.')
            return false;
        }
if (first_name == last_name)
{
alert('invalid name');
return false;
}

if (CheckBoxSelection() == false)
{
alert('Please select an interest');
return false;
}
            
    return true;
}

function badFormValue(frmvalue)
{
    var badwords = new Array('http://*');
    for (var b = 0;b<badwords.length;b++)
    {
    var re = new RegExp(badwords[b]);
          if (frmvalue.match(re)) 
          {
            return true;
          } 
    }
return false;
}

function phonenumber(phonevalue)
{
	var p = new RegExp(/\d/g);
    var s = '';
    var match = phonevalue.match(p);
    //alert(match.length);
    for (var m=0;m<match.length;m++)
    {
    s += match[m];
    }
    //alert(s);
	return s;
}

function listAllRequiredFields(elements)
{
                for (var x = 0;x<elements.length;x++)
                {
                    for (r=0;r<requiredfields.length;r++)
                    {
                        if (requiredfields[r] == elements[x].FieldName && elements[x].value == '')
                        {
                            alert(requiredfields[r+1] + ' is required');
                            r++
                            elements[x].focus()
                            return false;
                        }
                    }
                }
return true;
}

function validateEmail(elementValue)
{ 
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailPattern.test(elementValue);
 }

function CheckBoxSelection()
{
	var c = document.getElementById('00N60000001YFpD');
	if (c == null) {return true;}
	if (document.getElementById('00N60000001YFpD').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpI').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpN').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpS').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpX').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpc').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFph').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFpr').checked == true) {return true;}
	else if (document.getElementById('00N60000001YFqE').checked == true) {return true;}
	return false;
}
