var ttcmbImg = new Image();
ttcmbImg.src="(http://www.traitel.com.au/callme/3.1/b7b.png";

function showCallMeButton(id,lim)
{

var scrolledX, scrolledY;
if( self.pageYOffset ) {
scrolledX = self.pageXOffset;
scrolledY = self.pageYOffset;
} 
else if( document.documentElement && document.documentElement.scrollTop ) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

var centerX, centerY;
if( self.innerHeight ) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if( document.body ) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}

var leftOffset = scrolledX + (centerX - 406) / 2;
var topOffset = scrolledY + (centerY - 450) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function

var exists=0;	
var di = document.getElementById("callmebutton" + id);
if (di)
	exists=1;
else
	di = document.createElement("div");

var r=di.style;
di.id="callmebutton" + id;
di.setAttribute("id","callmebutton"+id);
r.position='absolute';
r.top = topOffset + "px";
r.left = leftOffset + "px";
r.width="406px";
r.height="450px";
r.display = "block";

if (!exists)
{
	r.background="url(http://www.traitel.com.au/callme/3.1/b7b.png)";
	r.backgroundRepeat="repeat-x";
	r.fontFamily="Arial";
	r.fontSize="13px";
	r.color="#000000";
	r.lineHeight="150%";
	r.fontWeight="normal";
	r.zIndex="1000";        
	document.body.appendChild(di);

	var diClose = document.createElement("div");
	 di.appendChild(diClose);

	diClose.style.paddingTop="14px";
	diClose.style.width="390px";
	diClose.style.height="18px";
	diClose.innerHTML="<a href='javascript:hideCallMeButton(" + id + ")'><img align=right width=18 height=18 align=right border=0 src='http://www.traitel.com.au/callme/3.1/close2.png' onmouseover='ttcmbEnterClose(this)' onmouseout='ttcmbExitClose(this)'></a>";
	
	var diText =document.createElement("div");
	di.appendChild(diText);
	diText.style.padding="12px";
	diText.height="390px";
	diText.innerHTML="<IFRAME id='ttcmbOutFrame" + id +"' SCROLLING=NO WIDTH=385 HEIGHT=390 frameborder=0 src='http://www.traitel.com.au/callmenow_3.1.cgi?viewpage="+id+"&viewstyle=2031&viewlim="+lim+"' allowtransparency='true'></iframe>";
}
	else
	{
		var fr = document.getElementById("ttcmbOutFrame" + id);
		fr.src="http://www.traitel.com.au/callmenow_3.1.cgi?viewpage="+id+"&viewstyle=2031&viewlim="+lim;
	}
}
function ttcmbEnterClose(itm)
{
	
	itm.src="http://www.traitel.com.au/callme/3.1/close2.png";
}
function ttcmbExitClose(itm)
{
        itm.src="http://www.traitel.com.au/callme/3.1/close2b.png";
}


function hideCallMeButton(id)
{
 var di = document.getElementById("callmebutton" + id);
if (di) {
var r=di.style;
r.display="none";
 }
}

