
var _isIE = (((navigator.appName).indexOf('Microsoft') > -1) ? true : false);
var ajaxX = -1;
var ajaxY = -1;
var mouseOver = 0;
var divid;

var paneWidth = 450;
var paneHeight = 450;

    function displayappCallback() 
    {
      if (req.readyState == 4) 
      {
        if (req.status == 200) 
        {
      		setHTML(document, 'appdiv', req.responseText);
        } 
        else 
        {
	}
      }
    }
   function displayapp(url)
   {
      if (window.XMLHttpRequest) 
      {
        req = new XMLHttpRequest();
      } 
      else if (window.ActiveXObject) 
      {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      req.onreadystatechange = displayappCallback;
      req.open("GET", url, true);
      req.send(null);
    }
    function fetchapp(baseurl)
    {
var x=document.getElementById("catform");
var y = "";
for (var i=0;i<x.length;i++)
{
if ( i != 0)
  y+="&";
y+=x.elements[i].name+"="+x.elements[i].value;
}
y = "&"+y;
y = escape(y);
      displayapp(baseurl);
    }
    function appiframe(site)
    {
	var content = "<iframe  height='1000'  width='100%' frameborder='yes'  src='"+site+"'  name='iframe1' > </iframe> ";  

      setHTML(document, 'appdiv', content);
    }
    function setHTML(document, id, content)
    {
      try 
      {
	document.getElementById(id).innerHTML = content;
      }
      catch (e) 
      {
        window.status = exceptionMsg(e);
      }
    }

    function disp_something(str)
    {
      obj=document.all(str);
      if(obj)
      {
        obj.style.display="";
      }
    }

    function hide_something(str)
    {
      obj=document.all(str);
      if(obj)
      {
        obj.style.display="none";
      }
    }

    function hideDiv(id)
    {
      if (!_isIE) 
      {
        document.getElementById(id).style.height = 2;
        document.getElementById(id).style.visibility = 'hidden';
      }
      else 
      {		     
        document.getElementById(id).style.visibility = 'hidden';
      }
      return;
    }

    function showDiv(id)
    {
      if (!_isIE) 
      {
        // document.getElementById(id).style.height = 'auto';
        document.getElementById(id).style.visibility = 'visible';
      }
      else 
      {
        document.getElementById(id).style.visibility = 'visible';			
      }
      return;
    }

    function showAjaxDiv(str)
    {
	var id = 'ajaxDiv';
	var scrollTop = document.body.scrollTop;
	var scrollLeft = document.body.scrollLeft;
 
	// set left     
	var left = scrollLeft+ajaxX+50;
	if (ajaxX > 500)
		left = 20;
	if (ajaxX > 600)
		left = 100;
	if (ajaxX > 800)
		left = 300;
	document.getElementById(id).style.left = left;

	var substract = 100;
	if (str.length < 100)
		substract = 50;
	substract = 50;
	var top = scrollTop+ajaxY-substract ;
	document.getElementById(id).style.top = top;

	document.getElementById(id).style.width = 450;
	showDiv(id);
	setHTML(document, id, str);
    }
    function showAjaxDiv111(str)
    {
	var id = 'ajaxDiv';
	var scrollTop = document.body.scrollTop;
 
	// set left     
	// take care of the case when ajaxX is far to the right
	var left = ajaxX+30;
	if (left > 450)
		left = 350;
	document.getElementById(id).style.left = left;

	var substract = 150;
	substract = str.length / 4;
	if (substract < 50)
		substract = 50;
	var top = scrollTop+ajaxY-substract ;
	document.getElementById(id).style.top = top;

	document.getElementById(id).style.width = 450;
	showDiv(id);
	setHTML(document, id, str);
    }
    function hideAjaxDiv()
    {
      hideDiv('ajaxDiv');
    }
    function exceptionMsg(e)
    {
      var smsg = "Exception debug:" + (typeof e == "string")
		    ? e : ((e.message) ? e.message : "Unknown Error");
      return smsg;
    }

    function ajaxOnMouseOut() 
    {
      mouseOver = 0;
      hideAjaxDiv();
    }

    function ajaxOnMouseOverSmt(event, mt, smt) 
    {
      var baseurl = "http://127.0.0.1:8080/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";
      else if (_isPROD == 1 && _site == 'follownews')
        baseurl = "http://www.follownews.com/Ajax?";

      var url = baseurl+"mt="+mt+"&smt="+smt;

      ajaxOnMouseOver(event, url);
    }

    function ajaxOnMouseOver2(event, mt, p1, p2) 
    {
      var baseurl = "http://localhost:8080/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";
      else if (_isPROD == 1 && _site == 'follownews')
        baseurl = "http://www.follownews.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1="+p1+"&p2="+p2;

      ajaxOnMouseOver(event, url);
    }

    function ajaxOnMouseOver3(event, mt, p1, p2, p3) 
    {
      var baseurl = "http://localhost:8080/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";
      else if (_isPROD == 1 && _site == 'follownews')
        baseurl = "http://www.follownews.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1="+p1+"&p2="+p2+"&p3="+p3;

      ajaxOnMouseOver(event, url);
    }

    function ajaxOnMouseOver4(event, mt, p1, p2, p3, p4) 
    {

      var url = baseurl+"mt="+mt+"&p1="+p1+"&p2="+p2;

      ajaxOnMouseOver(event, url);
    }

    function ajaxOnMouseOver3(event, mt, p1, p2, p3) 
    {
      var baseurl = "http://localhost:8080/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";
      else if (_isPROD == 1 && _site == 'follownews')
        baseurl = "http://www.follownews.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1="+p1+"&p2="+p2+"&p3="+p3;

      ajaxOnMouseOver(event, url);
    }

    function ajaxOnMouseOver4(event, mt, p1, p2, p3, p4) 
    {
      var baseurl = "http://localhost:8080/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";
      else if (_isPROD == 1 && _site == 'follownews')
        baseurl = "http://www.follownews.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1="+p1+"&p2="+p2+"&p3="+p3+"&p4="+p4;

      ajaxOnMouseOver(event, url);
    }

    function nextpage2(event, tdivid, mt, p1str, p1, p2) 
    {
      divid = tdivid;

      var baseurl = "http://127.0.0.1/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1str="+p1str+"&p1="+p1+"&p2="+p2;

      nextpage(event, url);
   }

    function nextpage3(event, tdivid, mt, p1str, p2str, p1, p2, p3) 
    {
      divid = tdivid;

      var baseurl = "http://127.0.0.1/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1str="+p1str+"&p2str="+p2str+"&p1="+p1+"&p2="+p2+"&p3="+p3;

      nextpage(event, url);
   }

    function nextpage4(event, tdivid, mt, p1str, p1, p2, p3, p4) 
    {
      divid = tdivid;

      var baseurl = "http://127.0.0.1/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1str="+p1str+"&p1="+p1+"&p2="+p2+"&p3="+p3+"&p4="+p4;
      nextpage(event, url);
   }
   function nextpage(event, url)
   {
      if (window.XMLHttpRequest) 
      {
        req = new XMLHttpRequest();
      } 
      else if (window.ActiveXObject) 
      {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      req.onreadystatechange = nextpageCallback;
      req.open("GET", url, true);
      req.send(null);
    }
    function showpane1(event, tdivid, mt, p1str, p1) 
    {
      divid = tdivid;

      var baseurl = "http://127.0.0.1/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1str="+p1str+"&p1="+p1;
      showpane(event, url);
   }
    function showpane4(event, tdivid, mt, p1str, p1, p2, p3, p4) 
    {
      divid = tdivid;

      var baseurl = "http://127.0.0.1/servlet/Ajax?";
      if (_isPROD == 1 && _site == 'Indnav')
        baseurl = "http://www.indnav.com/Ajax?";

      var url = baseurl+"mt="+mt+"&p1str="+p1str+"&p1="+p1+"&p2="+p2+"&p3="+p3+"&p4="+p4;
      showpane(event, url);
   }
   function showpane(event, url)
   {
      if (window.XMLHttpRequest) 
      {
        req = new XMLHttpRequest();
      } 
      else if (window.ActiveXObject) 
      {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      req.onreadystatechange = showpaneCallback;
      req.open("GET", url, true);
      req.send(null);
    }
    function showpaneCallback() 
    {

      if (req.readyState == 4) 
      {
        if (req.status == 200) 
        {
	    showpaneDiv(req.responseText);
        } 
        else 
        {
          //alert( req.status );
	}
      }
    }
    function showpaneDiv(str)
    {
	var id = 'ajaxDiv';
	var scrollTop = document.body.scrollTop;
	var scrollLeft = document.body.scrollLeft;
 
	// set left     
	var left = scrollLeft+50;
	document.getElementById(id).style.left = left;

	var top = scrollTop+50 ;
	document.getElementById(id).style.top = top;

	document.getElementById(id).style.width = paneWidth;
	document.getElementById(id).style.height = paneHeight;
	showDiv(id);
	setHTML(document, id, str);
    }

    function ajaxOnMouseOver(event, url)
    {
      mouseOver = 1;
      ajaxX = event.clientX;
      ajaxY = event.clientY;

      if (window.XMLHttpRequest) 
      {
        req = new XMLHttpRequest();
      } 
      else if (window.ActiveXObject) 
      {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      req.onreadystatechange = ajaxCallback;
      req.open("GET", url, true);
      req.send(null);
    }

    function nextpageCallback() 
    {

      if (req.readyState == 4) 
      {
        if (req.status == 200) 
        {
	    id = 'vthumbnaildiv';
	    setHTML(document, divid, req.responseText);
        } 
        else 
        {
          //alert( req.status );
          //alert ( "Not able to retrieve description" );
	}
      }
    }

    function ajaxCallback() 
    {
      if (req.readyState == 4) 
      {
        if (req.status == 200) 
        {
          processSuccessAjaxCallback();
        } 
        else 
        {
          //alert ( "Not able to retrieve description" );
	}
      }
    }

    function processSuccessAjaxCallback() 
    {
      //alert(req.responseText);
      if (mouseOver == 1)
         showAjaxDiv(req.responseText);
    }
