//<![CDATA[
var oWnd = null;
var urlBox = null;

function pageLoad() {
    //openWin();
    urlBox = $get("urlBox");
}
function openWin() {
    var oWnd = radopen("/images/jibe.png", "ExternalLinkContainer");
}
function openWin(target) {
    var oWnd = radopen(target, "ExternalLinkContainer");
}
function controlWindowButtons() {

}

function OnClientActivate(sender) {
    //get a reference to the RadWindow object
    oWnd = sender;
    //set the value of the Url textbox to the current RadWindow's NavigateUrl
    urlBox.value = oWnd.get_navigateUrl();
    configureUI(oWnd);
}

function SetWindowBehavior(sender) {
    oWnd = sender;
    urlBox.value = oWnd.get_navigateUrl();
    oWnd.setActive(true);
    configureUI(oWnd);
}

function configureUI(oWnd) {

}

function OnClientValueChangedHeight(sender, args) {
    //get a reference to the window and set its height
    var newHeight = sender.get_value();
    var result = oWnd.set_height(newHeight);

    //Update the label, showing the current value of the slider.
    updateLabel(sender, args, lblHeight);
}

function OnClientValueChangedWidth(sender, args) {

}

function OnClientValueChangedMoveVertically(sender, args) {

}

function OnClientValueChangedMoveHorizontally(sender, args) {

}

function OnClientPageLoad(oWnd) {

    //dynamically change the title of RadWindow so it matches the current URL
    //this must be done in OnClientPageLoad, otherwise the window will get the title
    //that is set in the title section of content page's head. 
    var originalUrl = oWnd.get_navigateUrl();
    var websiteName = getWebsiteName(originalUrl);
    oWnd.set_title(websiteName);

    //Change RadWindow icon to the favicon.ico icon of the opened site
    var icon = $telerik.getElementByClassName(oWnd.get_popupElement(), "windowicon", "A");
    if (icon) {
        icon.style.background = "url(" + originalUrl + "/favicon.ico) no-repeat 0 0";
    }
}

function updateLabel(slider, args, label) {

}

function getWebsiteName(websiteName) {
    url = websiteName.replace("http://www.", "");
    url = url.substr(0, url.indexOf("."));
    url = url.charAt(0).toUpperCase() + url.substr(1);
    return url;
}

function unityChangeUrl(newUrl) {
    oWnd.setUrl(newUrl);
    configureUI(oWnd);
}

function LoadExternal(newUrl) {
    openWin(newUrl);
    //alert("Default page: " + newUrl);
    oWnd.setUrl(newUrl);
    configureUI(oWnd);
}
//]]>
