var httpC;
var iInterval = 1000;

//var productArray = new Array();

var xqInfoEnabled = true;
var now;

/*
function showClock() {

    if (xqInfoEnabled) {
        setTimeout(showClock,iInterval);
        //setTimeout(showinfo,1000);

        var r = document.getElementById('clock');


        try {
            if (!httpC) {
                //http1=GetXmlHttpObject();
                httpC=createXMLHTTPObject();
            } else if (httpC.readyState != 0) {
                httpC.abort();
            }
            var d = new Date();
            var url="../inc/getTime.php?&dtm="+d.getTime();

            url = encodeURI(url);
            httpC.open("GET",url,true);
            httpC.setRequestHeader('Cache-Control','no-cche');
            httpC.send(null);

            httpC.onreadystatechange=function() {
                    if (httpC.readyState == 4) {
                        if (httpC.status == 200 || httpC.status == 304) {
                            var data = httpC.responseText;
                            r.innerHTML = data;
                        }
                    }
            };
        } catch (err) {
            //r.innerHTML = err.description;
            xqCheckDipEnabled = false;
            //alert("Error");
        }

    }

}
*/

function showClock() {

    if (xqInfoEnabled) {
        try {
            if (!httpC) {
                httpC=createXMLHTTPObject();
            } else if (httpC.readyState != 0) {
                httpC.abort();
            }
            var d = new Date();
            var url="../inc/getTime.php?&dtm="+d.getTime();

            url = encodeURI(url);
            httpC.open("GET",url,true);
            httpC.setRequestHeader('Cache-Control','no-cche');
            httpC.send(null);

            httpC.onreadystatechange=function() {
                    if (httpC.readyState == 4) {
                        if (httpC.status == 200 || httpC.status == 304) {
                            var data = httpC.responseText;
                            var darray = data.split(',');
                            now = new Date(parseInt(darray[0]),parseInt(darray[1]),parseInt(darray[2]),parseInt(darray[3]),parseInt(darray[4]),parseInt(darray[5]));
                            addSeconds();
                        }
                    }
            };
        } catch (err) {
            xqCheckDipEnabled = false;
        }

    }

}

function show1() {
    now = new Date(2010,2,16,23,59,0);
    addSeconds();
}

function addSeconds() {
    setTimeout(addSeconds,1000);
    var sec = now.getSeconds();
    var min = now.getMinutes();
    var hrs = now.getHours();
    var time_str="";

    sec++;
    if (sec >= 60) {
        sec = sec %60;
        min++;
        if (min >= 60) {
            min = min % 60;
            hrs++;
            if (hrs >= 24) {
                hrs = hrs % 24;
            }
        }
    }
    
    now.setSeconds(sec);
    now.setMinutes(min);
    now.setHours(hrs);

    if (now.getHours() < 10)
        if (now.getHours() == 0)
            time_str = "12:";
        else
            time_str = "0"+now.getHours() % 12 + ":";
    else {
        thrs = now.getHours() % 12;
        time_str = (thrs == 0 ? 12 : (thrs < 10 ? "0"+thrs : thrs)) + ":";
    }
    if (now.getMinutes() < 10)
        time_str += "0"+now.getMinutes()+":";
    else
        time_str += now.getMinutes()+":";

    if (now.getSeconds() < 10)
        time_str += "0"+now.getSeconds();
    else
        time_str += now.getSeconds();

    if (now.getHours() > 11)
        time_str += ' PM';
    else
        time_str += ' AM';

    document.getElementById('clock').innerHTML = time_str;
}


var XMLHttpFactories = [
	function () {return new XMLHttpRequest()},
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
	var xmlhttp = false;
	for (var i=0;i<XMLHttpFactories.length;i++) {
		try {
			xmlhttp = XMLHttpFactories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}

