Dacor.Validation.HasValidExtension = function(filename, extensions) {
			   var loweredFilename = filename.toLowerCase();
			var extension = '';
			var index = loweredFilename.lastIndexOf('.');
			if(index > -1) { extension = loweredFilename.substring(index);	}
			for(var i=0; i<extensions.length; i++)
			{
				if(extension == ('.' + extensions[i])) { return true; }
			}
			return false;
			};
			
			fnCallBackTest = function(e, obj) {
			   var extensions = ['doc', 'pdf', 'jpg', 'jpeg'];
			   var filename = document.getElementById('PostedFile').value;
			   if (filename.length > 0) { 
			       if (!Dacor.Validation.HasValidExtension(filename, extensions)){
			       	alert('The file you selected is not a supported file type.');
			           YAHOO.util.Event.stopEvent(e);
			       }
			   }
			};
			
            function changeVisibility(e, obj)
            {
                if (obj.selectedIndex != 2) {toggleFields2(false);}
                else {toggleFields2(true);}
            }
            
            function toggleFields2(visibleValue2)
            {
                if (visibleValue2) {
                    YAHOO.util.Dom.setStyle(telephoneRequired,'display','');
		    telephoneElement.setAttribute('onblur',oldOnBlurValue);
                    telephoneElement.setAttribute('ektdesignns_validation',oldValidationValue);
                    design_validate_re(/^(((\+?1[\. \-]?)?\(?[2-9][0-9]{2}\)?[\. \-\/]*)?[2-9][0-9]{2}[\. \-]?[0-9]{4})$/,telephoneElement,'');
                }
                else {
                    YAHOO.util.Dom.setStyle(telephoneRequired,'display','none');
		    design_validate_complete(telephoneElement,true,"");
                    telephoneElement.setAttribute('onblur','design_validate_complete(telephoneElement,true,"");');
                    telephoneElement.setAttribute('ektdesignns_validation','');
                }
            }

		
                	   
	            function changeCountry(e, obj)
	            {
	                for(i=0;obj[i];i++)
                    {
                        if (obj[i].tagName == "INPUT" && obj[i].checked)
                        {
                            switch(obj[i].value)
                            {
                                case "Canada":
                                    YAHOO.util.Dom.setStyle(txtPostalCode,'display','');
                                    YAHOO.util.Dom.setStyle(txtZip,'display','none');
                                    break;
                                case "United States":
                                default:
                                     YAHOO.util.Dom.setStyle(txtPostalCode,'display','none');
                                     YAHOO.util.Dom.setStyle(txtZip,'display','');
                            }
                        }
                    }
	            }	

            var rblCountry = null;
            var txtZip = null;
            var txtPostalCode = null;
            
            var cta;
            var telephoneElement;
            var oldOnBlurValue;
            var oldValidationValue;
            var telephoneRequired;

            function initContactUsForm()
            { 
		rblCountry = document.forms[0].Country;
		
                txtZip = document.getElementById('Zip');
                txtPostalCode = document.getElementById('PostalCode');
	                

                changeCountry(null,rblCountry);
                YAHOO.util.Event.addListener(rblCountry,'click',changeCountry,rblCountry);		


		cta = document.getElementById('BestWayToContactMe');
            	telephoneElement = document.getElementById('Telephone');
		telephoneRequired = document.getElementById('telephoneRequired');
           	oldOnBlurValue = telephoneElement.getAttribute('onblur');
            	oldValidationValue = telephoneElement.getAttribute('ektdesignns_validation');                

		YAHOO.util.Event.addListener(document.getElementById('SubmitEktronForm'), 'click', fnCallBackTest);
                changeVisibility(null, cta);
                YAHOO.util.Event.addListener(cta,'change',changeVisibility,cta);
            } 
            YAHOO.util.Event.onDOMReady(initContactUsForm);