﻿function preload(filename){preload_image= new Image();preload_image.src = filename;}
function roll(name, filename){document.images[name].src = filename;}
function doCountLimit(ele){
    //alert(ele);
    ta = 3;
    tc = 0;
    for(i = 0; i < document.forms[0].elements.length; i ++){
        curEle = document.forms[0].elements[i];
        //alert(curEle.type);
        if(curEle.type == "checkbox" && curEle.checked){
            tc ++;
        }
    }
    //alert(tc);
    if(tc > ta){
        ele.checked = false;
        alert("You can submit your contact information to up to three (3) offices at a time.");
    }
}
function checkEmailMatch(source, clientside_arguments){
    email = clientside_arguments.Value;
    for(i = 0; i < document.forms[0].elements.length; i ++){
        currEle = document.forms[0].elements[i];
        if(currEle.name.indexOf("tbEmailConfirm") > -1){
            emailConfirm = currEle.value;
            break;
        }
    }
    if(email.length > 0 && emailConfirm.length > 0){
        clientside_arguments.IsValid = (email == emailConfirm );
    }else{
        clientside_arguments.IsValid = true;
    }
}
function validEmail(source, clientside_arguments){
    /*if(clientside_arguments.IsValid){
        email = clientside_arguments.Value;
        for(i = 0; i < document.forms[0].elements.length; i ++){
            currEle = document.forms[0].elements[i];
            if(currEle.name.indexOf("tbEmailConfirm") > -1){
                emailConfirm = currEle.value;
                break;
            }
        }
        if(email.length > 0 && emailConfirm.length > 0){
            clientside_arguments.IsValid = (email == emailConfirm && (email.indexOf("@") > -1) );
        }else{
            clientside_arguments.IsValid = true;
        }
    }*/
    clientside_arguments.IsValid = (clientside_arguments.Value.indexOf("@") > -1);
}
function validatePhone(source, clientside_arguments){
    phone = clientside_arguments.Value;
    if(phone.length == 10){
        phoneIsValid = true;
        for( i = 0; i < phone.length; i ++ ){
            if( isNaN(phone.charAt(i)) ){
                phoneIsValid = false;    
            }
        }
        clientside_arguments.IsValid = phoneIsValid;
    }else{
        clientside_arguments.IsValid = false;
    }
}
function alt_disp(imageId , rowId)
        {
			var image = document.getElementById(imageId);
			var imageSrc = document.getElementById(imageId).src;
			var imageName = new String(imageSrc).substr(new String(imageSrc).lastIndexOf('/') + 1);
			if (new String(imageName) == 'more.gif')
            {
				document.getElementById(rowId).style.display ="block";
                document.getElementById(imageId).src="../images/structure/close.gif";
			}
            else
            {
				document.getElementById(rowId).style.display ="none";
                document.getElementById(imageId).src="../images/structure/more.gif";
			}
         }
