﻿
// XMLHTTP Object Creator
function GetXmlHttpObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try {
            return new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            return new ActiveXObject('Microsoft.XMLHTTP');
        }
    }
}

function XmlHttpGet(xmlhttp, url) {
    xmlhttp.open('GET', url, true);
    xmlhttp.send(null);
}

function XmlHttpResponseReady(objXmlHttp) {
    if (objXmlHttp.readyState == 4 || objXmlHttp.readyState == 'complete') {
        if (objXmlHttp.status == 200)/*OK*/{
            return objXmlHttp.responseText;
        }
        return null;
    }
}

function ClearImage(   imgPic,uploadPicture,UrlPath ) {
//    alert("Hi");
//    alert(UrlPath);
//     
//    document.getElementById('<%= lblUrlPath.ClientID %>').value = "";
//    document.getElementById('<%= imgPicture.ClientID %>').src = "";

//    var oldInput = document.getElementById("<%= UploadPicture.ClientID %>");
    //    var newInput = document.createElement("input");

    UrlPath.value = "";
    imgPic.src = "";

    var oldInput =uploadPicture;
    var newInput = document.createElement("input");

    newInput.type = "file";
    newInput.id = oldInput.id;
    newInput.name = oldInput.name;
    newInput.className = oldInput.className;
    newInput.style.cssText = oldInput.style.cssText;
    // copy any other relevant attributes
    oldInput.parentNode.replaceChild(newInput, oldInput);
}

//Disable Button
function DisableButton(ButtonID) {
    document.getElementById(ButtonID).disabled = true;
}

function Disable(ButtonID, Period) {
    window.setInterval("DisableButton('" + ButtonID + "')", Period);
}

// This function is used to open a popup window
function openNewWindow(url, width, height) {
    var left = Math.floor(screen.width / 2) - Math.floor(width / 2);
    var top = Math.floor(screen.height / 2) - Math.floor(height / 2);
    popwindow = window.open(url, "popwindow", " location=no, status=no,toolbar=no,titlebar=no,menubar=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
    popwindow.focus();
}

