﻿// JScript File

String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value) {
    this.strings = new Array("");
    this.append(value);
}

// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function(value) {
    if (value) {
        this.strings.push(value);
    }
}

// Clears the string buffer
StringBuilder.prototype.clear = function() {
    this.strings.length = 1;
}

// Converts this instance to a String.
StringBuilder.prototype.toString = function() {
    return this.strings.join("");
}
function test() {
    alert('test');
    return true;
}


/*********************************************************************************************
Popup window function
*********************************************************************************************/
function newWindow(url, width, height) {
    var popWin = window.open(url, '_blank', 'width=' + width + ',height=' + height + ',scrollbars=1,resizable=1');
    if (popWin != null) {
        popWin.focus();
    }
}

function SendScriptErrorEmail(url, status, message) {
    try {
        EDMC.ArtInstitute.Web.SendError.SendEmailErrorMessage(url, status, message, SucceededCallback);
    }
    catch (err) {
        //alert("A script error has occurred");
    }
}

function SucceededCallback(result) {

}
//This script will activate flash objects on load
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++) {
    objects[i].outerHTML = objects[i].outerHTML;
}

function firemodal(modalname) {
    try {
        //document.getElementById('inquiryDaemonHolder').style.display = 'block';
        $find(modalname).show();
        return false;
    }
    catch (e) {

    }
}

function GetFirstLevelDirectory() {
    var thisUrl = document.URL.toString().toLowerCase();

    thisUrl = thisUrl.replace("http://", "");
    thisUrl = thisUrl.replace("www.", "");
    thisUrl = thisUrl.replace(document.domain, "");

    var directories = thisUrl.split('/');
    for (i = 0; i < directories.length; i++) {
        if (directories[i].indexOf('.') < 0) {
            return directories[i];
        }
    }
    return "";
}

