﻿function $Element(id) {
    var obj = document.getElementById("ctl00_ContentPlaceHolder1_" + id);
    if (obj == null) obj = $get(id)
    return obj;
}

function getTimeStamp() {
    var when = new Date();
    var timeStamp = when.getFullYear();;
    timeStamp += (100+(when.getMonth()+1)+"").substr(1);
    timeStamp += (100+(when.getDate())+"").substr(1);
    timeStamp += (100+(when.getHours())+"").substr(1);
    timeStamp += (100+(when.getMinutes())+"").substr(1);
    timeStamp += (100 + (when.getSeconds()) + "").substr(1);
    return timeStamp;
}

function __validateSearchBox() {
    try {
        var txtSearch = $Element("txtSearchField");
        var dropDestinations = $Element("dropDestination");

        if (txtSearch != null && dropDestinations != null) {
            if (txtSearch.value.length == 0 && dropDestinations.selectedIndex == 0) {
                alert("Please enter a search text or select a Destination.");
                return false;
            }
        }

        document.getElementById('__btnSearch').value = 'yes';
        return true;
    }
    catch (e) {
        alert(e.message);
        return false;
    }
}

function DeleteConfirm() {
    if (!confirm("Are you sure you want to Delete?")) {
        return false;
    }
    return true;
}

function TriggerExport(name) {
    window.open("exportToExcel.aspx?name=" + name + "&timeStamp=" + getTimeStamp(), "exportToExcel", "location=1,status=1,scrollbars=1,width=0,height=0");
}
