// JavaScript Document
function sendInfo(client, campaign, state, metro,ip, phone, fax)
{
	var info='';
	info = '?client='+client;
	info = info + '&website='+document.referrer;
	if(campaign)
	{
		info = info + '&campaign='+campaign;
	}
	if(state)
	{	
		info = info + '&state='+state;
	}
	if(metro)
	{
		info = info + '&metro='+metro;
	}
	info = info + '&datetime='+(new Date()).getTime()+'&ip='+ip;
	document.getElementById('phone').innerHTML='<p>'+phone+fax+'</p>';
	document.collect.src="http://www.cmtmdotasp.com/"+(new Date()).getTime()+"/mtrack.gif"+info+'&We_ID=59'; 
}

function sendTextInfo(client, campaign, state, metro,ip, suffix)
{
	var info='';
	info = '?client='+client;
	info = info + '&website='+document.referrer;
	if(campaign)
	{
		info = info + '&campaign='+campaign;
	}
	if(state)
	{	
		info = info + '&state='+state;
	}
	if(metro)
	{
		info = info + '&metro='+metro;
	}
	info = info + '&datetime='+(new Date()).getTime()+'&ip='+ip;
	var obj = getObject('collect'+suffix);
	obj.src="http://www.cmtmdotasp.com/"+(new Date()).getTime()+"/mtrack.gif"+info+'&We_ID=59'; 	
}

function sendWebClickInfo(client, campaign, state, metro,ip, suffix)
{
	var info='';
	info = '?client='+client;
	info = info + '&website='+document.referrer;
	if(campaign)
	{
		info = info + '&campaign='+campaign;
	}
	if(state)
	{	
		info = info + '&state='+state;
	}
	if(metro)
	{
		info = info + '&metro='+metro;
	}
	info = info + '&datetime='+(new Date()).getTime()+'&ip='+ip;
	var obj = getObject('collect'+suffix);
	//alert("http://www.cmtmdotasp.com/"+(new Date()).getTime()+"/wtrack.gif"+info+'&We_ID=59');
	obj.src="http://www.cmtmdotasp.com/"+(new Date()).getTime()+"/wtrack.gif"+info+'&We_ID=59'; 	
}

function showphone(suffix)
{
	hideObject('phoneLink'+suffix);
	showObject('phoneLabel'+suffix);
	sendTextInfo(CLIENT, CAMPAIGN, STATE, METRO,IP, suffix);
}

function showweb(CLIENT, CAMPAIGN, STATE, METRO,IP,suffix,result)
{
	//hideObject('webLink'+suffix);
	//showObject('webLabel'+suffix);
	//alert('a'+result);
	sendWebClickInfo(CLIENT, CAMPAIGN, STATE, METRO,IP,suffix);
	//window.open(result);
	//window.location=result;
}

function showObject(objID)
{
	var obj = getObject(objID);
	var rtn = false;
	if (obj != null) 
	{
		obj.style.display = "inline";
		obj.style.position = "static";
		obj.style.width = "auto";
		obj.style.height = "auto";
		obj.style.overflow = "visible";
		rtn = true;
	}
}
function hideObject(objID)
{
	var obj = getObject(objID);
	var rtn = false;
	if (obj != null) 
	{
		obj.style.display = "none";
		rtn = true;
	}
}
function getObject(objID)
{
	if (document.all)
	{
		var obj = document.all[objID];
	}
	else if (document.getElementById)
	{
		var obj = document.getElementById(objID);
	}
	return obj;
}

function fillWebDiv(num, message, alt, result)
{
	theHTML='<a title="'+alt+'" href="#" onClick="javascript:showweb(';
	theHTML+='CLIENT, CAMPAIGN, STATE, METRO,IP,'+num;
	theHTML+=",'"+result+"'";
	theHTML+=');" target="_blank">'+message+'</a>';
	theHTML+='<img name="collect'+num+'" id="collect'+num+'" width="0" height="0" src="http://www.cmtmdotasp.com/empty.gif">';
	var obj = getObject('holder'+num);
	obj.innerHTML=theHTML
}

function fillDiv(num, message, alt, result)
{
	theHTML='<span id="phoneLink'+num+'">';
	theHTML+='	<a title="'+alt+'" href="javascript:showphone(';
	theHTML+="'"+num+"'";
	theHTML+=',CLIENT, CAMPAIGN, STATE, METRO,IP, '+num+');">'+message+'</a>';
	theHTML+='</span>';
	theHTML+='<span id="phoneLabel'+num+'" style="display: none">'+result+'</span>';
	theHTML+='<img name="collect1" id="collect'+num+'" width="0" height="0" src="http://www.cmtmdotasp.com/empty.gif">';
	var obj = getObject('holder'+num);
	obj.innerHTML=theHTML
}