﻿function validateemail(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    //var address = document.forms[form_id].elements[email].value;
    if(reg.test(email) == false) {
        //alert('Invalid Email Address');
        return false;
    }
    else
    {
        return true;
    }
}


/*************************************************************************************

function RenderForm()

Uses ExtJS to write enquiry form to the page.

Accepts the form type as a parameter, the parameter will change the form title 
and then passes the paramete to mailer.aspx which also uses it in the email sending.

usage:  <script language="javascript" type="text/javascript">
            RenderForm("enquiry");
        </script>

*************************************************************************************/
function RenderForm(type, extrainfo, width)
{

    var strTitle = "";
    var strType = "";
    
    strType = type;
    
    var strTextArea = 'Your message here...';

    switch(type)
    {
        case "partner":
            strTitle = "Become a partner";
            extrainfo = 'Your message here...';
            break;
        case "trial":
            strTitle = "Request a trial of HSSmart";
            extrainfo = 'Your message here...';
            break;
        case "event":
            strTitle = "Booking details";
            break;            
        case "newsletter":
            strTitle = "Contact us now";
            strType = "enquiry";
            extrainfo = 'Your message here...';
            break;                    
        default:
            strType = "enquiry";
            strTitle = "Submit your enquiry";
            extrainfo = 'Your message here...';
    }

    Ext.onReady(function() {

        Ext.QuickTips.init();

        // turn on validation errors beside the field globally
        Ext.form.Field.prototype.msgTarget = 'side';

        var fp = new Ext.Panel({
            labelAlign: 'side',
            //labelSeparator:'&nbsp',
            labelWidth: 200,
            frame: true,
            title: strTitle,
            bodyStyle: 'padding:4;',
            width: width,
            items: [
   		{ layout: 'form',
   		    items: [


		    {
		        layout: 'column',
		        items: [
            {
                columnWidth: .5,
                layout: 'form',
                labelWidth: 100,
                items: [
                {
                    xtype: 'textfield'
                    , id: 'txtName'
					, autoCreate: { tag: "input", type: "text", size: "50", maxlength: 50, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Name'
                    //,emptyText:'First Name'
					, name: 'fullName'
					, allowBlank: false
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtCompany'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none'
					, fieldLabel: 'Company'
                    //,emptyText:'Company'
					, name: 'company'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtPosition'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Position'
                    //,emptyText:'Position'
								    , name: 'position'
								    , anchor: '93%'

                },
                
                {
                //layout:'column',
                //items:[
                //{
                layout: 'form',
                labelWidth: 100, height: 15

			    //}]

                },                
                

                {
                xtype: 'label',
                name: 'label_name',
                id: 'label_id',
                text: 'Address',
                cls: 'x-form-item-label x-form-item-bold'
            },

                {
                    xtype: 'textfield'
                    , id: 'txtAddressA1'
					, autoCreate: { tag: "input", type: "text", size: "50", maxlength: 50, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Address Line 1'
                    //,emptyText:'First Name'
					, name: 'address1'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressA2'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none'
					, fieldLabel: 'Address Line 2'
                    //,emptyText:'Company'
					, name: 'address2'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtTownA'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Town'
                    //,emptyText:'Position'
								    , name: 'position'
								    , anchor: '93%'

                },
                {
                    xtype: 'textfield'
                    , id: 'txtPostcodeA'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Postcode'
                    //,emptyText:'Position'
								    , name: 'postcode'
								    , anchor: '93%'

                }


            //enabled for testing

                ]
        }, {
            columnWidth: .5,
            layout: 'form',
            labelWidth: 120,
            items: [
				{
				    xtype: 'textfield'
                    , id: 'txtPhone'
					, autoCreate: { tag: "input", type: "text", size: "20", maxlength: 20, autocomplete: "off" }
				    //,labelStyle: 'font-size:11px;'
				    //,style: 'font-size:11px;'
				    , fieldLabel: 'Phone'
				    , name: 'phone'
				    , allowBlank: true
				    , anchor: '93%'

				},
				{
				    xtype: 'textfield'
                    , id: 'txtEmail1'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
				    //,labelStyle: 'font-size:11px;'
				    //,style: 'font-size:11px;'
					, fieldLabel: 'Email'
					, name: 'email'
					, vtype: 'email'
					, allowBlank: false
					, anchor: '93%'
				}
				, {
				    xtype: 'textfield'
                    , id: 'txtEmail2'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
				    //,labelStyle: 'font-size:11px;'
				    //,style: 'font-size:11px;'
				    , fieldLabel: 'Email Confirmation'
                    , labelWidth: 400
				    , name: 'email2'
				    , vtype: 'email'
					, validator: function() {
					    //var email = fp.getForm().findField('email').getValue();
					    //var email2 = fp.getForm().findField('email2').getValue();
					    var email = Ext.get("txtEmail1").dom.value;
					    var email2 = Ext.get("txtEmail2").dom.value;
					    if (email != email2) {
					        return "Emails need to be the same.";
					    } else return true;
					}
				    , allowBlank: false
				    , anchor: '93%'
				},
            
            {
            //layout:'column',
            //items:[
            //{
            layout: 'form',
            labelWidth: 100, height: 15

			    //}]

			},
			


                {
                xtype: 'label',
                name: 'label_name1',
                id: 'label_id',
                text: 'Site Address (location for proposed work)', 
                cls: 'x-form-item-label x-form-item-bold'
            },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressB1'
					, autoCreate: { tag: "input", type: "text", size: "50", maxlength: 50, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Site Address Line 1'
                    //,emptyText:'First Name'
					, name: 'address1'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressB2'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none'
					, fieldLabel: 'Site Address Line 2'
                    //,emptyText:'Company'
					, name: 'address2'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtTownB'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Site Town'
                    //,emptyText:'Position'
								    , name: 'position'
								    , anchor: '93%'

                },
                {
                    xtype: 'textfield'
                    , id: 'txtPostcodeB'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Site Postcode'
                    //,emptyText:'Position'
								    , name: 'postcode'
								    , anchor: '93%'

                }

            //enabled for testing


				]
}]
		    },

			{
			    //layout:'column',
			    //items:[
			    //{
			    layout: 'form',
			    labelWidth: 100, height: 15

			    //}]

			},

			{
			    //layout:'column',
			    //items:[
			    //{
			    layout: 'form',
			    labelWidth: 100,
			    items: [


                {
                    xtype: 'textarea'
                    , id: 'txtMessage'
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Message'
                    //,emptyText: 'Your message here...'
					, emptyText: strTextArea
					, name: 'message'
					, allowBlank: false
					, anchor: '96.5%'
                }
                ]
			    //}]

			}

		  ]
   		}

		]
		,
            buttons: [
  		{
  		    text: 'Submit Details',
  		    handler: function() {

  		        if (validateemail(Ext.get("txtEmail1").dom.value) && validateemail(Ext.get("txtEmail2").dom.value) && Ext.get("txtName").dom.value != "" && Ext.get("txtEmail1").dom.value != "" && Ext.get("txtEmail2").dom.value != "" && Ext.get("txtMessage").dom.value !== "") {
  		            //window.location.href = 'Mailer.aspx?type=' + strType + '&extra=' + extrainfo + '&txtName=' + Ext.get("txtName").dom.value + "&txtCompany=" + Ext.get("txtCompany").dom.value + "&txtPosition=" + Ext.get("txtPosition").dom.value + "&txtPhone=" + Ext.get("txtPhone").dom.value + "&txtEmail1=" + Ext.get("txtEmail1").dom.value + "&txtMessage=" + Ext.get("txtMessage").dom.value;
  		            window.location.href = 'Mailer.aspx?type=' + strType + '&extra=' + extrainfo + '&txtName=' + Ext.get("txtName").dom.value + "&txtCompany=" + Ext.get("txtCompany").dom.value + "&txtPosition=" + Ext.get("txtPosition").dom.value + "&txtPhone=" + Ext.get("txtPhone").dom.value + "&txtEmail1=" + Ext.get("txtEmail1").dom.value + "&txtMessage=" + Ext.get("txtMessage").dom.value + "&txtAddressA1=" + Ext.get("txtAddressA1").dom.value + "&txtAddressA2=" + Ext.get("txtAddressA2").dom.value + "&txtTownA=" + Ext.get("txtTownA").dom.value + "&txtPostcodeA=" + Ext.get("txtPostcodeA").dom.value + "&txtAddressB1=" + Ext.get("txtAddressB1").dom.value + "&txtAddressB2=" + Ext.get("txtAddressB2").dom.value + "&txtTownB=" + Ext.get("txtTownB").dom.value + "&txtPostcodeB=" + Ext.get("txtPostcodeB").dom.value;
  		        }
  		        else {
  		            alert("Please fill in all the required fields correctly");
  		        }
  		        //enabled for testing
  		        //window.location.href = 'confirmation.php?' + fp.getForm().getValues(true )+ '&ezineId=' + ezineId;
  		    }
  		}

            //enabled for testing
				]
        });

        fp.render(Ext.get("formdetails"));

        if (type == 'event') {
            Ext.get("txtMessage").dom.value = extrainfo;
        }

        //Don't focus the form on the channel partner page as it shifts the page down
        if (type != 'newsletter') {
            Ext.get("txtName").dom.focus();
        }

    });
}

function RenderTestForm(type, extrainfo, width)
{

    var strTitle = "";
    var strType = "";
    
    strType = type;

    switch(type)
    {
        case "partner":
            strTitle = "Become a partner";
            break;
        case "trial":
            strTitle = "Request a trial of HSSmart";
            break;
        case "event":
            strTitle = "Book an event";
            break;            
        default:
            strType = "enquiry";
            strTitle = "Submit your enquiry";
    }


Ext.onReady(function(){

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';


    var fp = new Ext.Panel({
        labelAlign: 'side',
        //labelSeparator: '&nbsp',
        labelWidth: 180,
        frame:true,
        title: strTitle,
        bodyStyle:'padding:0;' ,
        width: width,		
        items: [
   		{ layout : 'form',
		  items: [
		
		
		    {
            layout:'column',
            items:[                         
            {
                columnWidth:.5,
                layout: 'form',
                items: [                
                {
                    xtype:'textfield'
                    ,id: 'txtName'
					,autoCreate : {tag: "input", type: "text", size: "50", maxlength:50, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
					//,labelStyle:'display:none;'
                    ,fieldLabel: 'Name'
					//,emptyText:'First Name'
					,name: 'fullName'
					,allowBlank:false
					,anchor:'80%'
					 ,value: 'a'                 }, 
                {
                    xtype:'textfield'
                    ,id: 'txtCompany'
					,autoCreate : {tag: "input", type: "text", size: "100", maxlength:100, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
					//,labelStyle:'display:none'
					,fieldLabel: 'Company'					
					//,emptyText:'Company'
					,name: 'company'
					,allowBlank:true
					,anchor:'80%'
					 ,value: 'c'                 },
                {
                    xtype:'textfield'
                    ,id: 'txtPosition'
					,autoCreate : {tag: "input", type: "text", size: "100", maxlength:100, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
						//				,labelStyle:'display:none'
                		,fieldLabel: 'Position'						
						//,emptyText:'Position'
								    ,name: 'position'
								    ,allowBlank:true
								    ,anchor:'80%'
								     ,value: 'b' 		
                },
                //enabled for testing
                  
                  
      {
                //layout:'column',
                //items:[
                //{
                layout: 'form',
                labelWidth: 100, height: 15

			    //}]

                },                
                

                {
                xtype: 'label',
                name: 'label_name',
                id: 'label_id',
                text: 'Address',
                cls: 'x-form-item-label x-form-item-bold'
            },

                {
                    xtype: 'textfield'
                    , id: 'txtAddressA1'
					, autoCreate: { tag: "input", type: "text", size: "50", maxlength: 50, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Address Line 1'
                    //,emptyText:'First Name'
					, name: 'address1'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressA2'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none'
					, fieldLabel: 'Address Line 2'
                    //,emptyText:'Company'
					, name: 'address2'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtTownA'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Town'
                    //,emptyText:'Position'
								    , name: 'position'
								    , anchor: '93%'

                },
                {
                    xtype: 'textfield'
                    , id: 'txtPostcodeA'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Postcode'
                    //,emptyText:'Position'
								    , name: 'postcode'
								    , anchor: '93%'

                }
                  
                  
                  
                  
                  
					, {
	                    xtype:'textfield'
	                    ,id: 'txtEmailto'
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
						//,labelStyle:'display:none'
						,fieldLabel: 'Email To (Test)'						
						//,emptyText:'Email To (Test)'
						,name: 'emailTo'
						,allowBlank:false
						,anchor:'80%'
						,value: 'dlam@arkworkplacerisk.co.uk'
					}                                 
                ]
            },{
                columnWidth:.5,
                layout: 'form',
                labelWidth: 120,
                items: [
				{
                    xtype:'textfield'
                    ,id: 'txtPhone'
					,autoCreate : {tag: "input", type: "text", size: "20", maxlength:20, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
				    ,fieldLabel: 'Phone'
				    ,name: 'phone'
				    ,allowBlank:true
				    ,anchor:'93%'
				     ,value: 'd'     								
                },
				{
                    xtype:'textfield'
                    ,id: 'txtEmail1'
					,autoCreate : {tag: "input", type: "text", size: "100", maxlength:100, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
					,fieldLabel: 'Email'
					,name: 'email'
					,vtype:'email'
					,allowBlank:false
					,anchor:'93%'
					 ,value: 'abc@abc.com'                 }
				,{
                    xtype:'textfield'
                    ,id: 'txtEmail2'
					,autoCreate : {tag: "input", type: "text", size: "100", maxlength:100, autocomplete: "off"} 
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
				    ,fieldLabel: 'Email Confirmation'
				    ,name: 'email2'
				    ,vtype:'email'
					,validator: function() {
			 		  var email = Ext.get("txtEmail1").dom.value;
			 		  var email2 = Ext.get("txtEmail2").dom.value;
					  if(email!=email2){
						  return "Emails need to be the same.";
					  }	else return true;
					}
				    ,allowBlank:false
				    ,anchor:'93%'
				     ,value: 'abc@abc.com'                 }
				
				   //enabled for testing
				    /*	, {
	                    xtype:'textfield'
						,readOnly: true
					    ,labelStyle: 'font-size:11px;'
					    ,style: 'font-size:11px;'
						//,labelStyle:'display:none'
						,fieldLabel: 'EzineId'						
						//,emptyText:'Email To (Test)'
						,name: 'ezineId'
						,allowBlank:false
						,anchor:'80%'
						,value: ezineId
					}      
					*/
					

,
            {
            //layout:'column',
            //items:[
            //{
            layout: 'form',
            labelWidth: 100, height: 15

			    //}]

			},
			

					

                {
                xtype: 'label',
                name: 'label_name1',
                id: 'label_id',
                text: 'Site Address (location for proposed work)', 
                cls: 'x-form-item-label x-form-item-bold'
            },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressB1'
					, autoCreate: { tag: "input", type: "text", size: "50", maxlength: 50, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none;'
                    , fieldLabel: 'Site Address Line 1'
                    //,emptyText:'First Name'
					, name: 'address1'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtAddressB2'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //,labelStyle:'display:none'
					, fieldLabel: 'Site Address Line 2'
                    //,emptyText:'Company'
					, name: 'address2'
					, allowBlank: true
					, anchor: '93%'
                },
                {
                    xtype: 'textfield'
                    , id: 'txtTownB'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Site Town'
                    //,emptyText:'Position'
								    , name: 'position'
								    , anchor: '93%'

                },
                {
                    xtype: 'textfield'
                    , id: 'txtPostcodeB'
					, autoCreate: { tag: "input", type: "text", size: "100", maxlength: 100, autocomplete: "off" }
                    //,labelStyle: 'font-size:11px;'
                    //,style: 'font-size:11px;'
                    //				,labelStyle:'display:none'
                		, fieldLabel: 'Site Postcode'
                    //,emptyText:'Position'
								    , name: 'postcode'
								    , anchor: '93%'

                }					
				
				]
            }]
        	},
			{
            //layout:'column',
            //items:[                         
            //{                
                layout: 'form',
                items: [                
                {
                    xtype:'textarea'
                    ,id: 'txtMessage'
					//,labelStyle: 'font-size:11px;'
					//,style: 'font-size:11px;'
					//,labelStyle:'display:none;'
                    ,fieldLabel: 'Message'
					,emptyText: 'Your message here...'
					,name: 'message'
					,allowBlank:false
					,anchor:'96.5%'
					,value: 'Test message'                 }                     
                ]
            //}]
			
        	}
		  
		  ]}
		  
		]		
		,
		buttons: [
  		{
		  text: 'Submit Details',
		  handler: function(){		  	  	  
            if(validateemail(Ext.get("txtEmailto").dom.value) && validateemail(Ext.get("txtEmail1").dom.value) && validateemail(Ext.get("txtEmail2").dom.value) && Ext.get("txtName").dom.value != "" && Ext.get("txtEmail1").dom.value != "" && Ext.get("txtEmail2").dom.value != "" && Ext.get("txtMessage").dom.value !== "")
            {
                //window.location.href = 'Mailer.aspx?test=1&TestEmail=' + Ext.get("txtEmailto").dom.value + '&type=' + strType + '&extra=' + extrainfo + '&txtName=' + Ext.get("txtName").dom.value + "&txtCompany=" + Ext.get("txtCompany").dom.value + "&txtPosition=" + Ext.get("txtPosition").dom.value + "&txtPhone=" + Ext.get("txtPhone").dom.value + "&txtEmail1=" + Ext.get("txtEmail1").dom.value + "&txtMessage=" + Ext.get("txtMessage").dom.value;
                window.location.href = 'Mailer.aspx?test=1&TestEmail=' + Ext.get("txtEmailto").dom.value + '&type=' + strType + '&extra=' + extrainfo + '&txtName=' + Ext.get("txtName").dom.value + "&txtCompany=" + Ext.get("txtCompany").dom.value + "&txtPosition=" + Ext.get("txtPosition").dom.value + "&txtPhone=" + Ext.get("txtPhone").dom.value + "&txtEmail1=" + Ext.get("txtEmail1").dom.value + "&txtMessage=" + Ext.get("txtMessage").dom.value + "&txtAddressA1=" + Ext.get("txtAddressA1").dom.value + "&txtAddressA2=" + Ext.get("txtAddressA2").dom.value + "&txtTownA=" + Ext.get("txtTownA").dom.value + "&txtPostcodeA=" + Ext.get("txtPostcodeA").dom.value + "&txtAddressB1=" + Ext.get("txtAddressB1").dom.value + "&txtAddressB2=" + Ext.get("txtAddressB2").dom.value + "&txtTownB=" + Ext.get("txtTownB").dom.value + "&txtPostcodeB=" + Ext.get("txtPostcodeB").dom.value;
            }
            else
            {
                alert("Please fill in all the required fields correctly");                
            }
          }
        }

	  	//enabled for testing
		/*
			, {
				text: 'Reset (Test)',
				handler: function(){				
					fp.getForm().findField('fullName').setValue('');
					fp.getForm().findField('position').setValue('');
					fp.getForm().findField('company').setValue('');
					fp.getForm().findField('phone').setValue('');
					fp.getForm().findField('email').setValue('');
					fp.getForm().findField('email2').setValue('');
					fp.getForm().findField('message').setValue('');
				}
	
			}, {
				text: 'Default (Test)',
				handler: function(){
					fp.getForm().findField('emailTo').setValue('gerard.sans@gmail.com');				
					fp.getForm().findField('fullName').setValue('a');
					fp.getForm().findField('position').setValue('b');
					fp.getForm().findField('company').setValue('c');
					fp.getForm().findField('phone').setValue('d');
					fp.getForm().findField('email').setValue('abc@abc.com');
					fp.getForm().findField('email2').setValue('abc@abc.com');
					fp.getForm().findField('message').setValue('test text');
				}
				
			} */		]
    });
		
    fp.render(Ext.get("formdetails"));    

	
});


}

                
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function checkVersion()
{
  var ver = 10;
  var ver = getInternetExplorerVersion();
  
  return ver;

}

function maplink() {
    if ((checkVersion() > 6) || (checkVersion() == -1)) {
        document.write("<a href='map.aspx' rel='#overlay' title='Directions to our office'>[ View map ]</a>");
    }
    else {
        document.write("<a href='map.aspx?l=1' title='Directions to our office'>[ View map ]</a>");
    }
}


/*

//Fade navigation menu items -- Not working for IE6
$(function() {
    $("#navigation a").hover(
		function() {
		
		var aClass = $(this).attr('className');

    if (aClass != "current") {
		        $(this).fadeTo(0, 0.5, function() {
		            $(this).addClass("fade");
		        });
		        $(this).fadeTo(300, 1);
		    }
		},
		function() {

		var aClass = $(this).attr('className');
		
		if (aClass != "current") {
		        $(this).fadeTo(100, 0.5, function() {
		            $(this).removeClass("fade");
		        });
		        $(this).fadeTo(100, 1);
		    }
		}
	);
});

*/