var Xoffset = -200;
var Yoffset = 20;
var isNewEnoughBrowser = document.getElementById;		
var nav = (navigator.appName == "Netscape");
if (nav) document.captureEvents(Event.MOUSEMOVE);
var mouseXpos;
var mouseYpos;
function initPopup(){
	window.setTimeout("runInitPopup()", 1000);
}

function runInitPopup()
{
	try{
	    window.document.onmousemove = getMousePosition;
	    if(!document.getElementById('popupDiv')){
	        var popupDivElement = document.createElement("div");
	        popupDivElement.id = "popupDiv";
	        popupDivElement.style.position = "absolute";
	        popupDivElement.style.visibility = "hidden";
	        popupDivElement.style.zIndex = 200;
	        document.getElementsByTagName("body")[0].appendChild(popupDivElement);
	    }
	} catch (e) {
	}
}



function popup(title, msg)
{
	var content = "<div "
	var strLoc = window.location.pathname.toLowerCase();
         
    if(strLoc.indexOf("prepaidcards") >0 || strLoc.indexOf("prepaidcardsp") >0)
	{
		content += "style=\"background:#FFC; text-align: left; border:1px solid #000066; font-family:Verdana, Helvetica, sans-serif; font-size:11px; padding:10px;\" >";
    }else{
		content += "style=\"width:370px; text-align: left; border:1px solid #000066; background-color:#FFFFFF; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:5px;\">"
    }
                              
 
   content += msg + "</div>"
	
	if (!isNewEnoughBrowser)
		return false;
	else
	{
		var popupDiv = document.getElementById("popupDiv");
		if (popupDiv)
		{
			//display & visibility avoids odd scrollbar appearances
			popupDiv.innerHTML = content;
			checkPosition(mouseXpos,mouseYpos);
			popupDiv.style.visibility = "visible";
			popupDiv.style.display = "block";
		}
	}
}


//ensure the popup doesn't fall off the right hand side
function checkPosition(x,y){
	var popupDiv = document.getElementById("popupDiv");
	if(popupDiv){
	
	    var rightCorner = parseInt(x) + parseInt(popupDiv.firstChild.style.width);
	
	    var intLeftScroll = leftScroll()
		if(rightCorner > (parseInt(windowWidth()) + intLeftScroll) - 20){
	    	popupDiv.style.left = (parseInt(windowWidth()) + intLeftScroll) - parseInt(popupDiv.firstChild.style.width) - 20 + "px";
		}else{
			popupDiv.style.left = x;
		}
		popupDiv.style.top = y;
	}
}

function leftScroll(){
    if(window.pageXOffset){
        return window.pageXOffset;   // Mozilla
    }else if(document.documentElement.scrollLeft){
        return document.documentElement.scrollLeft; // IE6
    }else if(document.getElementsByTagName("body")[0].scrollLeft){
        return document.getElementsByTagName("body")[0].scrollLeft; // IE DHTML-compliant any other
    }else{
        return 0;
    }
}


function windowWidth(){

    if (window.innerWidth){
        if (document.getElementsByTagName("body")[0].offsetWidth){
            if (window.innerWidth!=document.getElementsByTagName("body")[0].offsetWidth)
                return document.getElementsByTagName("body")[0].offsetWidth;
            }
        return (window.innerWidth);                     // Mozilla
    }
    if (document.documentElement.clientWidth){
        return document.documentElement.clientWidth;    // IE6
    }
    if (document.getElementsByTagName("body")[0].clientWidth){
        return document.getElementsByTagName("body")[0].clientWidth;               // IE DHTML-compliant any other
    }
}

function getMousePosition(e)
{
	if (!isNewEnoughBrowser)
		return false;
	else
	{
	
		var popupDiv = document.getElementById("popupDiv");
		if (popupDiv)
		{
			try	{			
				mouseXpos = (nav) ? (mouseX(e) + 10 + "px") : mouseX(window.event) + 10;
				mouseYpos = (nav) ? (mouseY(e) + 10 + "px")  : mouseY(window.event) + 10;
				checkPosition(mouseXpos,mouseYpos);
			} catch (ex) {}
		}
	}
}

function mouseX(evt) {
    if (evt.pageX){
        return evt.pageX;
    }else if (evt.clientX){
       return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.getElementsByTagName("body")[0].scrollLeft);
    }else{
        return 0;
    }
}
function mouseY(evt) {
    if (evt.pageY){
        return evt.pageY;
    }else if (evt.clientY){
        return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.getElementsByTagName("body")[0].scrollTop);
    }else{
        return 0;
    }
}

function kill()
{
	if (!isNewEnoughBrowser)
		return false;
	else
	{
		var popupDiv = document.getElementById("popupDiv");
		if (popupDiv)
		{
			popupDiv.innerHTML = "";
			//display none avoids odd scrollbar appearances - must start off as visibility hidden though
			popupDiv.style.display = "none"
			popupDiv.style.visibility = "hidden";
		}
	}
}
