var http_request = false;
var messageArea;
function send_request(url, msg) {
    http_request = false;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!http_request) {
        window.alert("XMLHttpRequest cannot work.");
        return false;
    }

    messageArea = msg;
    
    document.getElementById(messageArea).innerHTML = "Waiting for server...";

    http_request.onreadystatechange = processRequest;
    http_request.open("GET", url, true);
    http_request.send(null);
}
function processRequest() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            var returnStr = http_request.responseText;
            if (returnStr.indexOf("Error") == -1) {
                var result = document.getElementById(messageArea);
                if (result.type == "text") {
                    document.getElementById(messageArea).value = returnStr;
                }
                else {
                    document.getElementById(messageArea).innerHTML = returnStr;
                }
            }
            else {
                document.getElementById(messageArea).innerHTML = "Server doesn't response in right way.";
            }
        } else {
            alert("Web server doesn't response.");
        }
    }
}
function ChangePage(url, para1,para2,para3) {
    if (window.location.href.indexOf(url) > 0) {
        var service = "http://www.secretdata.info/service/readdynamiccontent.aspx" + "?p1=" + para1 + "&p2=" + para2 + "&p3=" + para3;
        send_request(service, "dContent");
    }
    else {
        window.location.href = "http://www.secretdata.info/base/" + url + "?p1=" + para1 + "&p2=" + para2 + "&p3=" + para3;
    }
}
function LoadParas() {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	
       if (hashes.length!=3)
	return;

        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        var service = "http://www.secretdata.info/service/readdynamiccontent.aspx" + "?p1=" + vars['p1'] + "&p2=" + vars['p2'] + "&p3=" + vars['p3'];
        send_request(service, "dContent");
}     
function BookMarkMe()
{
    if(document.all && !window.opera)
    { 
        window.external.AddFavorite(location.href, document.title);
    }
    else
    { 
        this.title = document.title; 
    }
}
function ContactUs()
{
   var url="http://www.secretdata.info/service/contact_store.aspx?typeId=1";
   window.open(url, '_blank', 'width=580, height=600,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, copyhistory=no,  resizable=no');

}

function ShowWelcome()
{
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var r= "Welcome to Tools of Secret Data, Today is " + year + "-" + month + "-" + day;
document.write(r);
}
function LinkToUs()
{
   var url="http://www.secretdata.info/linktous.htm";
   window.open(url, '_blank', 'width=780, height=400,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, copyhistory=no,  resizable=no');
}
                             
