
var KFS_PopUp;
var KFS_PopUpFrame;



//test to see whether browser is of type 
function KFS_IsRubbishBrowser(){
    
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    return ( navigator.appName=="Microsoft Internet Explorer" && version < 7 );
} 

function KFS_ShowPopUp( e,title, content, footer,width,left){

    //if not exists then create
    if(KFS_PopUp == null){
       KFS_PopUp = document.createElement('div');
       KFS_PopUp.setAttribute('id','KFS_PopUpContainer');
       KFS_PopUp.innerHTML = "<div id='PopUpHeader'></div><div id='PopUpContent'></div> <div id='PopUpFooter'></div>"
       document.body.appendChild(KFS_PopUp);
    }
    
    //set the width if one is supplied
    if (width){
       KFS_PopUp.style.width = width;
    } else {
       KFS_PopUp.style.width = '250px';
    }
	
	//make the block visible
	KFS_PopUp.style.display = 'block';
	
	var x;
	
	if(left)
	    KFS_PopUp.style.left = ( e.clientX - 300 ) + "px";
	else
        KFS_PopUp.style.left = ( e.clientX + 10 + getBody().scrollLeft ) + "px";
	
//	KFS_PopUp.style.left = ( e.clientX + 10 + getBody().scrollLeft ) + "px";//- 23 + getBody().scrollLeft ) + "px";
	KFS_PopUp.style.top = ( e.clientY + 10 + getBody().scrollTop )  + "px";//- 185 + getBody().scrollTop )  + "px";
	document.getElementById( "PopUpHeader" ).innerHTML = "<img src='/images/icons/information_blueBG.gif' alt='' class='StdIcon'/>&nbsp;" + unescape(title);
	document.getElementById( "PopUpContent" ).innerHTML = unescape(content);
	if (footer){
	    document.getElementById( "PopUpFooter" ).innerHTML = footer;
	}
	
	//check to see whether IE6 or less 
	if(KFS_IsRubbishBrowser()){
	    KFS_DisplayPopUpFrame();
	    //KFS_applyPNGFix();
	    
	    
	} 
	
	
}

function KFS_HidePopUp(){
	KFS_PopUp.style.left = "0px";
	KFS_PopUp.style.top = "0px";
	KFS_PopUp.style.display = "none";
	
	if(KFS_PopUpFrame)
	    KFS_PopUpFrame.style.display = "none";
	
}

function getBody(){
	if(document.compatMode && document.compatMode!="BackCompat"){
		return document.documentElement;
	}else{
		return document.body;
	}
}


function KFS_DisplayPopUpFrame(){
    
    //if not created then create
    if(KFS_PopUpFrame == null){
    
        //becuase <IE6 won't render over combo boxes ie <select>, then create frame to go under popup div
	    KFS_PopUpFrame = document.createElement("IFRAME");
        KFS_PopUpFrame.setAttribute('id','KFS_PopUpFrame');
        KFS_PopUpFrame.setAttribute("src", "");

        document.body.appendChild(KFS_PopUpFrame);
        
    }
    
    //Match IFrame position with divPopup
    KFS_PopUpFrame.style.position="absolute";
    KFS_PopUpFrame.style.left =KFS_PopUp.offsetLeft + 'px';
    KFS_PopUpFrame.style.top =KFS_PopUp.offsetTop + 'px';
    KFS_PopUpFrame.style.width =KFS_PopUp.offsetWidth + 'px';
    KFS_PopUpFrame.style.height =KFS_PopUp.offsetHeight + 'px';

    KFS_PopUpFrame.style.display = "block"

}



