﻿var bustcachevar = 1
var loadedobjects = ""
var rootdomain = "http://" + window.location.hostname
var bustcacheparameter = ""

function doSpinner(url, containerid, divstatus) {
    var oldHTML = document.getElementById(containerid).innerHTML;
    var newHTML = '<img src="/images/ajax-loader.gif" alt="loading..." border="0" />';
    //var newHTML = "This is a test";
    document.getElementById(containerid).innerHTML = newHTML
    //alert(newHTML);
    loadFragmentInToElement(url, containerid, divstatus)
}

function loadFragmentInToElement(url, containerid, divstatus) {
    var page_request = false

    if (window.XMLHttpRequest)
        page_request = new XMLHttpRequest()
    else if (window.ActiveXObject) {
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e) {
            try {
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e) { }
        }
    }
    else
        return false
    page_request.onreadystatechange = function() {
        loadpage(page_request, containerid, divstatus)
    }
    if (bustcachevar)
        bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
    page_request.open('GET', url + bustcacheparameter, true)
    page_request.send(null)
}

function loadpage(page_request, containerid, divstatus) {
    if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1))
        if (divstatus == undefined || divstatus == 'block') {
        showdiv(containerid);
    }
    else {
        hidediv(containerid)
    }
    document.getElementById(containerid).innerHTML = page_request.responseText;
}

function hidediv(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}
function showdiv(id) {
    //safe function to show an element with a specified id

    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}
function openCommentWindow() {
    var load = window.open('http://www.dondees.com/comment.asp', '', 'scrollbars=no,menubar=no,height=350,width=585,resizable=yes,toolbar=no,location=no,status=no');
}
function doMoveMap(coor) {
    var point = new GLatLng(coor.substr(0, 9), coor.substr(11, 10));
    map.setCenter(point, 15);
}
function doFillBiz(bizid) {
    loadFragmentInToElement('/common/get_biz.asp?bizid=' + bizid + '&opt=<% =Request("opt") %>', 'div_local', 'block');
}
function doFillEvent(bizid) {
    loadFragmentInToElement('/common/get_biz.asp?bizid=' + bizid + '&opt=<% =Request("opt") %>', 'div_bizname', 'block');
    loadFragmentInToElement('/common/lst_loc_events.asp?bizid=' + bizid + '&opt=<% =Request("opt") %>', 'div_list_events', 'block');
}
function doFillCity(cityid,ylat,xlon) {
    document.getElementById('xlon').value = xlon;
    document.getElementById('ylat').value = ylat;
    loadFragmentInToElement('/common/get_city.asp?cityid=' + cityid + '&opt=<% =Request("opt") %>', 'div_cityname', 'block');
}
function doFillAddress(bizname) {
    loadFragmentInToElement('/common/get_addressform.asp?q='+ bizname, 'div_local', 'block');
    hideElement('div_bizname_results');
}
function goToPage(url) {
    window.location = url;
}