﻿//<!--
function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    @else
      xmlhttp = false;
      @end
    @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object

//---------------------------------------------------------


function getContent(str) {

    var url = "Handlers/getContent.ashx?cid=" + str + "&d=" + Date.prototype.toString();
    http.open("GET", url, true);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {

            result = http.responseText;
            if (result.indexOf('false') == -1) {
                var div = document.getElementById("ContentBlock");
                div.innerHTML = result;
                if (str == 'elements') {
                    div.style.background = 'url(images/img_elements_btm.jpg) right 238px no-repeat';
                }
                else {
                    div.style.background = '';
                }
                getImg(str);
            }
            else {
                alert(result);
            }

            return false;
        }
    };
    http.send(null);
    
}

function getImg(str) {
    var url = "Handlers/getImage.ashx?CID=" + str;
    http.open("GET", url, true);
    http.onreadystatechange = function() {
        if (http.readyState == 4) {

            result = http.responseText;
            if (result.indexOf('false') == -1) {
                var div = document.getElementById("rightImg");
                if (result.indexOf('{0}') != -1) {
                    div.innerHTML = '';
                }
                else {                    
                    div.innerHTML = result;
                }
            }
            else {
                alert(result);
            }

            return false;
        }
    };
    http.send(null);

}


//style = "background:url(images/img_elements_btm.jpg) right 238px no-repeat"

//-->
