﻿var posx = 0;
var posy = 0;
document.onmousemove = getMousePos;
function getMousePos(e)
{
// get mouse cursor XY
	if(!e)
    { e = window.event; }

	if(e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if(e.clientX || e.clientY)
	{
        var strBrowser = navigator.userAgent.toLowerCase();
        if(strBrowser.indexOf("msie 7") > -1)
        {
        posx = e.clientX + document.documentElement.scrollLeft;
	    posy = e.clientY + document.documentElement.scrollTop;
        }
        else
        {
        posx = e.clientX + document.body.scrollLeft;
	    posy = e.clientY + document.body.scrollTop;
        }        
	}
	if(posy < 350)
	{
	posy = 350
	}

}

function PopSub(url)
{
var PopSub;
if(url.indexOf("getarticle.aspx")>=0|url.indexOf("getdynoboxarticle.aspx")>=0|url.indexOf("getrecipes.aspx")>=0|url.indexOf("getcontent.aspx")>=0)
{
mycurrel = document.getElementById("ajaxcontent");
ajel = document.getElementById("ajaxbg");
var t = eval(posy-320)+"px";
var l = eval(posx-300)+"px";
ajel.style.left = "25%";
ajel.style.top = t;
showhide('ajaxbg', 'show');
CreateXmlHttp();
    if(XmlHttp)
    {
    mycurrel.innerHTML = 'Loading data...';
    XmlHttp.onreadystatechange = HandleResponse;XmlHttp.open('GET', url,  true);
    XmlHttp.send(null);
    }
}
else
{
PopSub=window.open(url,"options","dependent,titlebar=no,resizable=yes,alwaysontop=yes,width=490,height=610,scrollbars=yes,left=20,top=20");
PopSub.focus();
}
}
function showhide(divshow, hide)
{
    divS = document.getElementById(divshow);
    if(hide=="show")
        {
        divS.style.visibility = "visible";
        divS.style.display = "block";
        }
    else
        {
        divS.style.visibility = "hidden";
        divS.style.display = "none";
        }
}

var XmlHttp;
var mycurrel;
function CreateXmlHttp()
{
    //Creating object of XMLHTTP in IE
    try
    {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari
    if(!XmlHttp && typeof XMLHttpRequest != "undefined")
    {
        XmlHttp = new XMLHttpRequest();
    }
    if(!XmlHttp)
	{
		// show error of some sort
	}
}
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{

		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			mycurrel.innerHTML = XmlHttp.responseText;
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
