function ValidateContactForm(){
               
                
                var result = true;
                var sb = new Sys.StringBuilder();
                sb.append("<nobr>Please enter the following: <ul>");

                if(document.getElementById('NameField').value.length<1){
                    sb.append("<li>name</li>");
                    result = false;
                }

                if(document.getElementById('contactForm_EmailField').value.length<1){
                    sb.append("<li>email address</li>");                    
                    result = false;
                }else{                

                    if(!isValidEmail(document.getElementById('contactForm_EmailField').value)){
                        sb.append("<li>valid email address</li>");                    
                        result = false;
                    }

                }

                var subject = new Sys.UI.Select($("contactForm_SubjectField"));                
                    subject.initialize();                    
                if(subject.get_selectedValue()=="x"){
                    sb.append("<li>subject</li>");                    
                    result = false;
                }

                if(document.getElementById('contactForm_CommField').value.length<1){
                    sb.append("<li>comment</li>");                    
                    result = false;
                }
                             
                if(!result){
                    sb.append("</ul></nobr>");
                    var errorlabel = new Sys.UI.Label($("errorLabel"));
                    errorlabel.initialize();
                    errorlabel.set_visible(true);
                    errorlabel.set_text(sb.toString());
                }   
                    
                return result;
                
            }
            
            function ClearContactForm(){
                    document.getElementById('NameField').value = "";
                    document.getElementById('contactForm_EmailField').value = "";
                    document.getElementById('contactForm_SubjectField').selectedIndex=0;
                    document.getElementById('contactForm_CommField').value = "";
                    document.getElementById('errorLabel').innerHTML = "";
            }
            
            function SendContactRequest(){
            
                requestContactService = RealityDigital.OpusWeb.ContactService.Contact(
                    document.getElementById('NameField').value,
                    document.getElementById('NameField').value + "<" + document.getElementById('contactForm_EmailField').value + ">",
                    document.getElementById('contactForm_SubjectField').value,
                    document.getElementById('contactForm_CommField').value,
                    document.getElementById('key').value,
                    OnComplete,     //Complete event
                    OnTimeout,       //Timeout event
                    OnError
                    );                    
            }
            
            ///contact form
            function ContactFormSubmit() 
             {              

                if(ValidateContactForm()){  
                    SendContactRequest();
                }                
                    
                return false;
            }
            
            function OnComplete(result) 
            {         
              ClearContactForm();       
              HideContactForm();
              ShowThanksPanel();
            }

            function OnError(result) 
            {
                if(result!=null){
                    document.getElementById('errorLabel').innerHTML = "<nobr>An error has occured, please retry later.</nobr><!--" + result.get_message() + "-->"; // <!--" + result.get_message() + "-->"
                }else{
                    document.getElementById('errorLabel').innerHTML = "<nobr>An error has occured, please retry later.</nobr>";
                }    
            }
            
            function OnTimeout(result) 
            {
                //alert("Timed out");
            }
            
            
            function PopContactModal(){
                //alert('yo momma');
              //  var flashplayer = new Sys.UI.Control($("MainViewerPanel"));
              //      flashplayer.initialize();
              //      flashplayer.set_visible(false);
              var p = new Sys.UI.Control($("contactForm_formPanel"))
              p.initialize();
              p.set_visible(true);
              
              var p2 = new Sys.UI.Control($("contactForm_ThankYouPanel"))
              p2.initialize();
              p2.set_visible(false);
                    ///$object('contactForm_formPanel').set_visible(true);
            $object('ModalPopupProperties')._show();
            document.getElementById('NameField').focus();
            }
            
            
            function ShowContactForm(){
                 $object('ContactFormPopupBehavior').show();
                 document.getElementById('NameField').focus();
            }
            
            function HideContactForm(){
                 $object('ContactFormPopupBehavior').hide();
            }
            
            function ShowThanksPanel(){
                 $object('ThanksPanelPopupBehavior').show();
                 document.getElementById('hidethankspanel').focus();
            }
            
            function HideThanksPanel(){            
                $object('ThanksPanelPopupBehavior').initialize();
                $object('ThanksPanelPopupBehavior').hide();
            }
            
            function CancelContactForm(){
                ClearContactForm();
                HideContactForm();
            }
            
    function contact(toggleid){
            var err = false;
            var email = getValue($('contactEmail'));
            var name = '';
            var message = '';
            
             $('contactError').style.display='none';
            
            if($('contactName'))
                name = getValue($('contactName'));
            
            if($('contactMessage'))
                message = getValue($('contactMessage'));    
                
            $('contactSubjectLabel').className="";
            
            if($('contactEmailLabel'))
                $('contactEmailLabel').className="";
            
            if($('contactNameLabel'))
                $('contactNameLabel').className="";
            
            if($('contactMessageLabel'))
                $('contactMessageLabel').className="";  
                
                if(name.length<1)
                    name = email;  
            
            if($('contactSubject').selectedIndex<1){
                err = true;
                $('contactSubjectLabel').className="alert";               
            }
            
            if(name.length<1){            
                if($('contactNameLabel')){
                    err = true;
                    $('contactNameLabel').className="alert";                    
                }    
            }
            
                        
            if($('contactEmailLabel')){
                if(email.length<1 || !multiEmail(email)){
                    err = true;
                    $('contactEmailLabel').className="alert";
                }
            }    
            
            
            if(err){            
                    if(document.all){
                         $('contactError').innerText = 'Items in red were not entered correctly. Please re-enter the information.'    
                    }else{
                        $('contactError').textContent = 'Items in red were not entered correctly. Please re-enter the information.'    
                    }
                    $('contactError').style.display='inline';                    
            }else{
                var url = 'contactservice.asmx/Contact?name=' + name + '&email=' + email + '&subject=' + getValue($('contactSubject')) + '&comments=' + message + '&key=' + key;
                new Ajax.Request(url,
                      {
                        method:'get', parameters: {},
                        onSuccess: function(transport){                   
                          if(transport.responseText.length<1){
                            //success
                            $('contactSubject').selectedIndex = 0;
                            if(toggleid.length>0){
                                toggleDropDowns(toggleid);                                
                            }else{
                                $('main-body').innerHTML = '<h2>Feedback Form</h2><p>Thank you for contacting us!</p>'
                            }                               
                          }else{             
                            if(document.all){
                                $('contactError').innerText = 'An error has occured while sending your email.';    
                            }else{
                                $('contactError').textContent = 'An error has occured while sending your email.';    
                            }
                            
                          }
                        },
                        onFailure: function(){ 
                            if(document.all){
                                $('contactError').innerText = 'An error has occured while sending your email.';    
                            }else{
                                $('contactError').textContent = 'An error has occured while sending your email.';    
                            }
                         }
                      }); 
            }          
        }