﻿// JScript File

	xmlhttp = false;

	if( window.XMLHttpRequest )
	{
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch(e) {}
	}
	else if( window.ActiveXObject )
	{
		try
		{
			xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP" );
		}
		catch(e)
		{
			try
			{
				xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
			}
			catch(e) {}
		}
	}
	window.onload=function load()
	{            
		getLinks();		
	}
	
	//Get RSS Links
	function getLinks()
	{
		var action = "actions.php?actions=getrsslink";
		xmlhttp.open( "GET", action, true );
		xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		xmlhttp.onreadystatechange = function()
		{
			if( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
			{
				var responsetext = xmlhttp.responseText;
				document.getElementById( "leflastdiv" ).innerHTML = responsetext;
				initToolTips();
			}
		}
		xmlhttp.send( null );
	}
	
	//Generate RSS File
	function getRSSFile()
	{
		window.open("http://www.securecollateral.com/rss/bpo-property-inspections.xml");
//		window.open( "rss/learn-futures-trading.xml","RSS Feed","width=900,height=800,location=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes");
	}	
	
	//browser detection
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

//tooltip Position
var offsetX = 0;
var offsetY = 5;
var opacity = 100;
var toolTipSTYLE;

function initToolTips(){
  if(document.getElementById){
          toolTipSTYLE = document.getElementById("toolTipLayer").style;
  }
  if(is_ie || is_nav6up)
  {
    toolTipSTYLE.visibility = "visible";
    toolTipSTYLE.display = "none";
    document.onmousemove = moveToMousePos;
  }
}
function moveToMousePos(e)
{
  if(!is_ie){
    x = e.pageX;
    y = e.pageY;
  }else{
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }

  toolTipSTYLE.left = x + offsetX+'px';
  toolTipSTYLE.top = y + offsetY+'px';
  return true;
}


function toolTip(msg, fg, bg)
{    
  if(toolTip.arguments.length < 1) // if no arguments are passed then hide the tootip
  {
    if(is_nav4)
        toolTipSTYLE.visibility = "hidden";
    else
        toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#ffffe5";
//    var content = "<table border='0' cellspacing='0' cellpadding='0' class='toolTip' width='auto'><tr><td bgcolor='" + fg + "'>" +
//                                  "<table border='0' cellspacing='1' cellpadding='0' width='auto'><tr><td bgcolor='" + bg + "' width='auto'>"+
//                                  "<font face='sans-serif' color='" + fg + "' size='2'>" + unescape(msg) +
//                                  "</font></td></tr></table>"+
//                                  "</td></tr></table>";

    var content = "<div class='toolTip' style='background-color:" + bg + "'>";    
    content += "<font face='sans-serif' color='" + fg + "' size='2'>" + unescape(msg) + "</font>";    
    content += "</div>";

   if(is_nav4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }

    else if(is_ie || is_nav6up)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block';
    }
  }
}

function toolTipWithImage(title, des,img)
{
    var s;
    s = "<table width='auto;' cellspacing='2' cellpadding='0' border='0'>";        
    s += "<tr><td><img src='" + img + "' border='0' width='100' height='50'/> </td><td valign='top' align='left'>" + title + "</td></tr>";
    s += "<tr><td colspan='2' class='Text'><hr/>" + des + "</td></tr>";
    s += "</table>";

    toolTip(s);
}

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="bpo.php">BPO</a>';
menu2[1]='<a href="valserv.php">Appraisal</a>';
		
var disappeardelay=350
var horizontaloffset=2

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
{
    document.write('<div id="dropmenudiv" style="visibility:hidden;width: 60px;" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>');
}

function getposOffset(what, offsettype)
{
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null)
    {
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function showhide(obj, e, visible, hidden, menuwidth)
{
    if (ie4||ns6)
    dropmenuobj.style.left=dropmenuobj.style.top=-500;
    dropmenuobj.widthobj=dropmenuobj.style;
    dropmenuobj.widthobj.width=menuwidth;
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
    obj.visibility=visible;
    else if (e.type=="click")
    obj.visibility=hidden;
}

function iecompattest()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge)
{
    var edgeoffset=0;
    if (whichedge=="rightedge")
    {
        var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;
        if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
            edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth;
    }
    else
    {
        var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset;
        var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        { //move menu up?
            edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight;
            if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
                edgeoffset=dropmenuobj.y;
        }
    }
    return edgeoffset;
}

function populatemenu(what)
{
    if (ie4||ns6)
        dropmenuobj.innerHTML=what.join("");
}


function dropdownmenu(obj, e, menucontents, menuwidth)
{
    if (window.event) event.cancelBubble=true;
    else if (e.stopPropagation) e.stopPropagation();
    clearhidemenu();
    dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv;
    populatemenu(menucontents);

    if (ie4||ns6)
    {
        showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth);
        dropmenuobj.x=getposOffset(obj, "left");
        dropmenuobj.y=getposOffset(obj, "top");
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px";
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px";
    }
    return clickreturnvalue();
}

function clickreturnvalue()
{
    if (ie4||ns6) return false;
    else return true;
}

function contains_ns6(a, b) 
{
    while (b.parentNode)
        if ((b = b.parentNode) == a)
        return true;
    return false;
}

function dynamichide(e)
{
    if (ie4&&!dropmenuobj.contains(e.toElement))
        delayhidemenu();
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
        delayhidemenu();
}

function hidemenu(e)
{
    if (typeof dropmenuobj!="undefined")
    {
        if (ie4||ns6)
            dropmenuobj.style.visibility="hidden";
    }
}

function delayhidemenu()
{
    if (ie4||ns6)
        delayhide=setTimeout("hidemenu()",disappeardelay);
}

function clearhidemenu()
{
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide);
}