/**
* Copyright (c) 2006 Andriy Bidochko. All Rights Reserved.
* http://www.mapbuilder.biz
*
* This code (including but not limited to the actual source code, documentation and database schemes) 
* is not freeware and is intended for the use of the original license purchaser according to the license agreement.
* The code all or in part may not be sold, redistributed, or included as part of another application.
* 
* THIS SOFTWARE PRODUCT IS PROVIDED "AS IS" AND LICENSOR MAKE NO WARRANTY AS TO ITS USE, PERFORMANCE, 
* OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

var ProtoAJAX=null;function submitForm(documentForm,action,loadingDiv,errorDiv){str=Form.serialize(documentForm);ProtoAJAX=new Ajax.Request(action,{method:'post',parameters:str,onComplete:onCompleteContact,onLoading:FormState(1,documentForm,loadingDiv)});}
function onCompleteContact(){FormState(0,document.formContactUs,document.getElementById('divContactUsLoading'));errorDiv=document.getElementById('divContactUsError');var errorStr='';try{var items=ProtoAJAX.transport.responseXML.getElementsByTagName("Error");for(var i=0;i<items.length;i++){errorStr=(errorStr!='')?("<br />"+getElementTextNS("","Message",items[i],0)):getElementTextNS("","Message",items[i],0);}}
catch(e){}
if(errorStr!=''){SetFormError(errorDiv,"<strong>The following errors has been detected:</strong><br />"+errorStr);}
else{HideFormError(errorDiv);document.formContactUs.Message.value=''
alert("Your message has been submitted.")}}
function FormState(state,documentForm,loadingDiv){if(state==1){loadingDiv.style.display="block";Form.disable(documentForm);}
else{loadingDiv.style.display="none";Form.enable(documentForm);}}
function SetFormError(errorDiv,err){errorDiv.innerHTML=err;errorDiv.style.display="block";}
function HideFormError(errorDiv){errorDiv.style.display="none";errorDiv.innerHTML='';}
function getElementTextNS(prefix,local,parentElem,index){var result="";if(prefix&&isIE){result=parentElem.getElementsByTagName(prefix+":"+local)[index];}
else{result=parentElem.getElementsByTagName(local)[index];}
if(result){if(result.childNodes.length>1){return result.childNodes[1].nodeValue;}else{if(result.firstChild==null)return '';return result.firstChild.nodeValue;}}
else{return "n/a";}}