// JScript File

function sendComments_onclick(commentsObj,btnId)
{
    
     document.getElementById(btnId).href="javascript:alert('Your request has been submitted.');";

    if(commentsObj.value=='')
    {
        alert('Please enter your comments and then submit.')
        commentsObj.focus();
         document.getElementById(btnId).href="javascript:sendComments_onclick(document.getElementById('tSiteComments'),'sendCommBtnId');";
        //return false;
    }
    else
    {
        var sPage=window.location;
        
        /*This will replace any & to &amp sign and any ' quote to '' quote to store into databse*/
        var strFeedback = commentsObj.value;
	    strFeedback = strFeedback.replace(/&/g,"&amp;");
	    strFeedback = strFeedback.replace(/'/g,"''");
        strFeedback = strFeedback.replace(/</g,"''");
        
                
        
        // create XML for HTTP POST
	    var oDomDoc = Sarissa.getDomDocument();
	    var xmlString = "<request><feedback>"+strFeedback+"</feedback><page>"+sPage+"</page></request>";
	    oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");

    	// debug-target: popup XML request for debugging

    	// create XMLHTTPRequest object and POST xml
    	var xmlhttp = new XMLHttpRequest();
    	xmlhttp.open("POST", "http://www.parkdeanholidayhomes.co.uk/resource/scripts/ajax/insertFeedBackIntoDb.aspx", false);
    	xmlhttp.send(oDomDoc);
    
	    // enable following line
	    var oDomResultDoc = xmlhttp.responseXML;

    	// debug-target display xml response result
    	//alert("XML HTTP Response: "+Sarissa.serialize(oDomResultDoc));


        document.getElementById('sendMyComments').innerHTML = "<span style='font-size:14px; font-weight:bold;'>Thank you for your comments.</span>";


    }
}