var TCP = TCP || {};
TCP.CMS = TCP.CMS || {};
TCP.CMS.exact_target = function(options) {

  options = options || {};
  if (!options.email)  
		return; 

   var sendRequest
      ,handleResponse
	    ,headers = {"SOAPAction" : "none", "content-type" : "application/soap+xml"}
			,endPoint=options.endPoint || 'http://localhost:8088/mockExactTargetServiceSoapBinding'
			,soapBody=options.soapBody || '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:http.exacttarget.service.cms.tp5.com"><soapenv:Header/><soapenv:Body><urn:addEmailAddress soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><emailAddress xsi:type="xsd:string">{email}</emailAddress></urn:addEmailAddress></soapenv:Body></soapenv:Envelope>'
      ,newSoapBody=soapBody
			,replaceKeyValue=options.replaceKeyValue || {"email":options.email}
			,successCallBack=options.successCallBack || function(response){
                                                    alert("Please give me a call back");
                                                  };

   sendRequest = function() {
	  	//alert(endPoint);
		  for(key in replaceKeyValue)
  		{
		  	newSoapBody = newSoapBody.replace('{' +key + '}', replaceKeyValue[key]);
  		}
	
		  $.ajax( endPoint, {
        'type' : 'POST',
			  'processData' : false,
  			'data' : newSoapBody,
	  		'headers' : headers,
			  'success' : successCallBack
		  });
  	};


    sendRequest();
};

