/**
 * Campaign tracking code. Requires prototype.js
 *
 * @author Eduardo Ramirez (http://lizt.mty.itesm.mx/~eramirez/)
 */

//From urhin.js
function _uGC(l,n,s) {
	// originally from urchin.js 
	if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
   	var i,i2,i3,c="-";
    i=l.indexOf(n);
    i3=n.indexOf("=")+1;
    if (i > -1) {
		i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }
		c=l.substring((i+i3),i2);
	}
	return c;
}

function _trackLead(name, company, email, phone, subject, message, domain) {
	var z = _uGC(document.cookie, "__utmz=", ";");
	ga_source = _uGC(z,"utmcsr=", "|");         
	ga_medium = _uGC(z,"utmcmd=", "|");          
	ga_term = _uGC(z,"utmctr=", "|");            
	ga_content = _uGC(z,"utmcct=", "|");         
	ga_campaign = _uGC(z,"utmccn=", "|");        
	
	var request = new Ajax.Request('/idem.php?module=Contacts&action=TrackLead',{		
			method:'post', 
			parameters: { 	name: name, company: company, email: email, phone: phone, subject: subject, message: message, domain: domain,
							source: ga_source, medium: ga_medium, term: ga_term, content: ga_content, campaign: ga_campaign }, 
			asynchronous:false,
			encoding: 'iso-8859-1' }
	);
}
