﻿// Safari 3 AJAX "issue". It no longer needs JavaScript hacks that are still implemented
// http://forums.asp.net/p/1252014/2392110.aspx
// also seems to fix radeditor problems in chrome /AT

Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
if (navigator.userAgent.indexOf('WebKit/') > -1) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = parseFloat(
        navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = 'WebKit';
}

////////////////////////////////////////////

function setBorder(id, border) {
    var obj = document.getElementById(id);

    if (obj != null) {
        obj.style.border = border;
    }
}

function togglePlayImage(obj) {
    toggleImage(obj, "/client/images/control_play.png", "/client/images/control_pause.png");
}

function toggleImage(obj, srcOn, srcOff) {
    obj.src = (obj.src.match(srcOn) ? srcOff : srcOn);
}

function OnEditorClientCommandExecuting(editor, args) {
    var name = args.get_name();
    var val = args.get_value();

    if (name == "DynamicDropdown") {
        editor.pasteHtml(val + new Date().getTime() + "\" />");
        //Cancel the further execution of the command as such a command does not exist in the editor command list
        args.set_cancel(true);
    }
}

function imageViewerNavigation() {
    //lets do some magic!

    $('.thumbs li').hide();
    var total = $(".thumbs li").size() - 1;
    //alert(total);
    var i = 3;
    var x = 1;
    var a = 0;
    //show the first 4 items
    $('.thumbs li:eq(0), .thumbs li:eq(1), .thumbs li:eq(2), .thumbs li:eq(3)').show();

    //next event
    $('a.nav-next').click(function () {
        if (i != total) {
            $('.thumbs li:eq(' + i + ')').next().show();
            $('.thumbs li:eq(' + x + ')').prev().hide();
            i++;
            x++;
            a++;
        }
    });
    //prev event
    $('a.nav-prev').click(function () {
        if (i > 3) {
            $('.thumbs li:eq(' + a + ')').prev().show();
            $('.thumbs li:eq(' + x + ')').next().hide();
            a--;
            i--;
            x--;
        }
    });
}

function twToggle(isVisible, id) {
    var obj = document.getElementById(id);
    if (obj) {
        obj.style.display = (isVisible ? "" : "none"); 
    }
}

