﻿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");
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." );
		}
	}
}