
$(document).ready(function() { // prepare the contact us form when the DOM is ready
    var options = {
        target:        '#responseDisplay',   // target element(s) to be updated with server response
        beforeSubmit:	validate,      // pre-submit callback
        success:     	showResponse,  // post-submit callback
		url:       		'email_by_ajax/ajaxemail2.php',
		type:      		'post'
        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    };

    // bind form using 'ajaxForm'
    $('#emailForm').ajaxForm(options);

	// bind form to open contactus
	$('#contactus').bind('click', function(){
		  $('#container').css('display','block');
		 $('body').css("opacity", "0.5");
	});
	// bind form to hide on close
	$('#btnHide').bind('click', function(){
		  //$('#container').css('display','none');
		  $('#container').fadeOut(500);
		  $('body').css("opacity", "1.10");

	});

});
function validate(formData, jqForm, options) {  // pre-submit callback
    return true;  // false;
}
function showResponse(responseText, statusText)  {  // post-submit callback
	$('#btnSubmit').css('display','none');
}
function contactus(){
	document.write("<table border='0' cellspacing='0' cellpadding='0'  id='container'><tr><td style='padding:18px'>");
	document.write("<form id='emailForm' action='email_by_ajax/ajaxemail2.php' method='post'><table><tr><td><div id='contact_us'>Contact Us</div>");
	document.write("<table><tr><td style='text-align:right;padding-top:8px'>Name&nbsp;</td><td><input name='Name' type='text' maxlength='50'  size='30' id='First_Name' /></td></tr><tr><td style='text-align:right;padding-top:8px'>E-mail&nbsp;</td><td><input name='Email' type='text' maxlength='254' size='40' id='Email' /></td></tr><tr><td style='text-align:right;padding-top:8px'>Comments&nbsp;</td><td><textarea name='Comments'  cols='30' rows='6' ></textarea></td></tr></table>");
	document.write("<div style='text-align:center;padding:9px 0px 6px 0px'><input type='submit' value='Submit' id='btnSubmit' style='font-size:14px' />&nbsp;&nbsp;<input type='button' id='btnHide' value='Close' style='font-size:14px' /></div><div style='padding:9px' class='center'  id='responseDisplay'>					Please include your name and e-mail address.</div></td></tr></table>");
	document.write("<input type='hidden' value='hugh@webpoynor.com' name='mail_sent_to_you_at' /><input type='hidden' value='hugh@webpoynor.com' name='mail_from_your_email' /><input type='hidden' value='WebPoynor.com Contact' name='mail_was_sent_from_this_page' /></form></td></tr></table>");
	}