/**Validations*/
function alphanumeric(alphane) {
    var numaric = alphane;
    for (var j = 0; j < numaric.length; j++) {
        var alphaa = numaric.charAt(j);
        var hh = alphaa.charCodeAt(0);
        if ((hh > 47 && hh < 58) || (hh > 64 && hh < 91) || (hh > 96 && hh < 123)) {
            return true;
        }
    }
    return false;
}
function ReplaceHTMLSpecialchars(alphane) {
    var numaric = alphane;
    alphane = '';
    for (var j = 0; j < numaric.length; j++) {
        switch (numaric.charAt(j)) {
            case '&':
                alphane += "&amp;";
                break;
            case '\"':
                alphane += "&quot;";
                break;
            case '\'':
                alphane += "\\'";
                break;
            case '<':
                alphane += "&lt;";
                break;
            case '>':
                alphane += "&gt;";
                break;
            default:
                alphane += numaric.charAt(j);
                break;
        }
    }
    return alphane;
}
function Filterkeydown(evt) {
    evt = (evt) ? evt : event;
    var charCode = parseInt((evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)));
    if ((charCode >= 33 && charCode < 45)
        || (charCode >= 58 && charCode <= 63)
        || (charCode >= 91 && charCode <= 96)
        || charCode == 124
        || charCode == 126 || charCode == 47) {
        return false;
    }
    else
        return true;
}
function DisableButton(btnID, value) {
    $("#" + btnID).attr("disabled", 'true'); //.val(value);
}
function EnableButton(btnID) {
    $("#" + btnID).removeAttr("disabled"); //.val(value);
}
function ValidatePlaylistName(textboxID) {
    var NewPlaylist = jQuery.trim($("#" + textboxID).val());
    if (NewPlaylist == '') {
        alert('Please enter playlist name.');
        document.getElementById(textboxID).focus();
        return false;
    }
    else if (!alphanumeric(NewPlaylist)) {
        alert('Please enter some alphanumeric value.\nOnly special characters are not allowed in playlist name.');
        document.getElementById(textboxID).focus();
        return false;
    }
    else if (IsPlaylistAlreadyExists(NewPlaylist)) {
        return false;
    }
    return true;
}
function Position(x, y) {
    this.X = x;
    this.Y = y;
    this.Add = function(val) {
        var newPos = new Position(this.X, this.Y);
        if (val != null) {
            if (!isNaN(val.X))
                newPos.X += val.X;
            if (!isNaN(val.Y))
                newPos.Y += val.Y
        }
        return newPos;
    }
    this.Subtract = function(val) {
        var newPos = new Position(this.X, this.Y);
        if (val != null) {
            if (!isNaN(val.X))
                newPos.X -= val.X;
            if (!isNaN(val.Y))
                newPos.Y -= val.Y
        }
        return newPos;
    }
    this.Min = function(val) {
        var newPos = new Position(this.X, this.Y)
        if (val == null)
            return newPos;
        if (!isNaN(val.X) && this.X > val.X)
            newPos.X = val.X;
        if (!isNaN(val.Y) && this.Y > val.Y)
            newPos.Y = val.Y;

        return newPos;
    }
    this.Max = function(val) {
        var newPos = new Position(this.X, this.Y)
        if (val == null)
            return newPos;

        if (!isNaN(val.X) && this.X < val.X)
            newPos.X = val.X;
        if (!isNaN(val.Y) && this.Y < val.Y)
            newPos.Y = val.Y;

        return newPos;
    }
    this.Bound = function(lower, upper) {
        var newPos = this.Max(lower);
        return newPos.Min(upper);
    }
    this.Check = function() {
        var newPos = new Position(this.X, this.Y);
        if (isNaN(newPos.X))
            newPos.X = 0;
        if (isNaN(newPos.Y))
            newPos.Y = 0;
        return newPos;
    }
    this.Apply = function(element) {
        if (typeof (element) == "string")
            element = document.getElementById(element);
        if (element == null)
            return;
        if (!isNaN(this.X))
            element.style.left = this.X + 'px';
        if (!isNaN(this.Y))
            element.style.top = this.Y + 'px';
    }
}
function hookEvent(element, eventName, callback) {
    if (typeof (element) == "string")
        element = document.getElementById(element);
    if (element == null)
        return;
    if (element.addEventListener) {
        element.addEventListener(eventName, callback, false);
    }
    else if (element.attachEvent)
        element.attachEvent("on" + eventName, callback);
}
function unhookEvent(element, eventName, callback) {
    if (typeof (element) == "string")
        element = document.getElementById(element);
    if (element == null)
        return;
    if (element.removeEventListener)
        element.removeEventListener(eventName, callback, false);
    else if (element.detachEvent)
        element.detachEvent("on" + eventName, callback);
}
function cancelEvent(e) {
    e = e ? e : window.event;
    if (e.stopPropagation)
        e.stopPropagation();
    if (e.preventDefault)
        e.preventDefault();
    e.cancelBubble = true;
    e.cancel = true;
    e.returnValue = false;
    return false;
}
function getEventTarget(e) {
    e = e ? e : window.event;
    return e.target ? e.target : e.srcElement;
}
function absoluteCursorPostion(eventObj) {
    eventObj = eventObj ? eventObj : window.event;

    if (isNaN(window.scrollX))
        return new Position(eventObj.clientX + document.documentElement.scrollLeft + document.body.scrollLeft,
      eventObj.clientY + document.documentElement.scrollTop + document.body.scrollTop);
    else
        return new Position(eventObj.clientX + window.scrollX, eventObj.clientY + window.scrollY);
}
function dragObject(element, attachElement, lowerBound, upperBound, startCallback, moveCallback, endCallback, attachLater) {
    if (typeof (element) == "string")
        element = document.getElementById(element);
    if (element == null)
        return;

    var cursorStartPos = null;
    var elementStartPos = null;
    var dragging = false;
    var listening = false;
    var disposed = false;

    function dragStart(eventObj) {
        if (dragging || !listening || disposed) return;
        dragging = true;

        if (startCallback != null)
            startCallback(eventObj, element);

        cursorStartPos = absoluteCursorPostion(eventObj);

        elementStartPos = new Position(parseInt(element.style.left), parseInt(element.style.top));

        elementStartPos = elementStartPos.Check();

        hookEvent(document, "mousemove", dragGo);
        hookEvent(document, "mouseup", dragStopHook);

        return cancelEvent(eventObj);
    }

    function dragGo(eventObj) {
        if (!dragging || disposed) return;

        var newPos = absoluteCursorPostion(eventObj);
        newPos = newPos.Add(elementStartPos).Subtract(cursorStartPos);
        newPos = newPos.Bound(lowerBound, upperBound)
        newPos.Apply(element);
        if (moveCallback != null)
            moveCallback(newPos, element);

        return cancelEvent(eventObj);
    }

    function dragStopHook(eventObj) {
        dragStop();
        return cancelEvent(eventObj);
    }

    function dragStop() {
        if (!dragging || disposed) return;
        unhookEvent(document, "mousemove", dragGo);
        unhookEvent(document, "mouseup", dragStopHook);
        cursorStartPos = null;
        elementStartPos = null;
        if (endCallback != null)
            endCallback(element);
        dragging = false;
    }

    this.Dispose = function() {
        if (disposed) return;
        this.StopListening(true);
        element = null;
        attachElement = null
        lowerBound = null;
        upperBound = null;
        startCallback = null;
        moveCallback = null
        endCallback = null;
        disposed = true;
    }

    this.GetLowerBound = function()
    { return lowerBound; }

    this.GetUpperBound = function()
    { return upperBound; }

    this.StartListening = function() {
        if (listening || disposed) return;
        listening = true;
        hookEvent(attachElement, "mousedown", dragStart);
    }

    this.StopListening = function(stopCurrentDragging) {
        if (!listening || disposed) return;
        unhookEvent(attachElement, "mousedown", dragStart);
        listening = false;

        if (stopCurrentDragging && dragging)
            dragStop();
    }

    this.IsDragging = function() { return dragging; }
    this.IsListening = function() { return listening; }
    this.IsDisposed = function() { return disposed; }

    if (typeof (attachElement) == "string")
        attachElement = document.getElementById(attachElement);
    if (attachElement == null)
        attachElement = element;

    if (!attachLater)
        this.StartListening();
}

/**
*
* Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
* 
*/

(function($) {
    /**
    * attaches a character counter to each textarea element in the jQuery object
    * usage: $("#myTextArea").charCounter(max, settings);
    */

    $.fn.charCounter = function(max, settings) {
        max = max || 100;
        settings = $.extend({
            container: "<span></span>",
            classname: "charcounter",
            format: "(%1 Characters remaining)",
            pulse: true,
            delay: 0
        }, settings);
        var p, timeout;

        function count(el, container) {
            el = $(el);
            if (el.val().length > max) {
                el.val(el.val().substring(0, max));
                if (settings.pulse && !p) {
                    pulse(container, true);
                };
            };
            if (settings.delay > 0) {
                if (timeout) {
                    window.clearTimeout(timeout);
                }
                timeout = window.setTimeout(function() {
                    container.html(settings.format.replace(/%1/, (max - el.val().length)));
                }, settings.delay);
            } else {
                container.html(settings.format.replace(/%1/, (max - el.val().length)));
            }
        };

        function pulse(el, again) {
            if (p) {
                window.clearTimeout(p);
                p = null;
            };
            el.animate({ opacity: 0.1 }, 100, function() {
                $(this).animate({ opacity: 1.0 }, 100);
            });
            if (again) {
                p = window.setTimeout(function() { pulse(el) }, 200);
            };
        };

        return this.each(function() {
            var container = (!settings.container.match(/^<.+>$/))
				? $(settings.container)
				: $(settings.container)
					.insertAfter(this)
					.addClass(settings.classname);
            $(this)
				.bind("keydown", function() { count(this, container); })
				.bind("keypress", function() { count(this, container); })
				.bind("keyup", function() { count(this, container); })
				.bind("focus", function() { count(this, container); })
				.bind("mouseover", function() { count(this, container); })
				.bind("mouseout", function() { count(this, container); })
				.bind("paste", function() {
				    var me = this;
				    setTimeout(function() { count(me, container); }, 10);
				});
            if (this.addEventListener) {
                this.addEventListener('input', function() { count(this, container); }, false);
            };
            count(this, container);
        });
    };

})(jQuery);

/*shabina - start*/
function InitDragable(parentID, isDroppable, cssClass) {
    /* if(cssClass!=null && jQuery.trim(cssClass)!=''){
    cssClass="."+cssClass;
    }
    else{
    cssClass='';
    }

    if (isDroppable) {
    //        $("#" + parentID + " tr" + cssClass).droppable({
    //                    drop: mediaDrop
    //                });
    //        debugger;
    //        $("#" + parentID + " tr").sortable();
        
    $("#" + parentID + " a" + cssClass).draggable({
    revert: 'invalid', helper: 'original',
    snap: true,
    snapMode: 'both',
    stop: function(event, ui) {
    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater');
    $(ui.helper[0]).css('color', '');
    },
    start: function(event, ui) {
    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater dragNo');
    $(ui.helper[0]).css('color', '#A4A9AD');
    $(ui.helper[0]).children('span').attr('class', 'span');
    }         
    });

    }
    else {
    $("#" + parentID + " a" + cssClass).draggable({
    revert: 'invalid', helper: 'clone',
    stop: function(event, ui) {
    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater');
    $(ui.helper[0]).css('color', '');
    },
    start: function(event, ui) {
    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater dragNo');
    $(ui.helper[0]).css('color', '#A4A9AD');
    $(ui.helper[0]).children('span').attr('class', 'span');
    }
    });
    }
    InitDroppable('divPlaylist');*/
}
function InitDroppable(parentID) {
    $('#' + parentID + ' td.playlistlabel').droppable({
        drop: mediaDrop,
        over: Droppable_over,
        out: Droppable_out
    });
}

function Droppable_over(event, ui) {

    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater dragDrop');
    $(ui.helper[0]).css('color', '#A4A9AD');
    //$(ui.helper[0].cells[0]).children('a.linkbuttonstyleinrepeater').css('color', 'black');
}
function Droppable_out(event, ui) {
    //$(ui.helper[0].cells[0]).children('a.linkbuttonstyleinrepeater').css('color', '');
    $(ui.helper[0]).attr('class', 'linkbuttonstyleinrepeater dragNo');
    $(ui.helper[0]).css('color', '#A4A9AD');
}

function mediaDrop(event, ui) {
    try {//debugger;
        var PlaylistID = '';
        var mediaID = '';
        var UpdateType = '';
        var parentTable = null;
        var tr = null;
        if (event.target != null) {
            tr = event.target;
            while (tr.tagName.toLowerCase() != 'tr') {
                tr = tr.parentNode;
            }
            parentTable = tr.parentNode;
            while (parentTable.tagName.toLowerCase() != 'table') {
                parentTable = parentTable.parentNode;
            }
            if (parentTable.id == "tblPlaylist") {
                UpdateType = 'reOrderPlaylist';
                PlaylistID = parseInt(tr.id);
            } else {
                UpdateType = 'Add_to_playlist';
                PlaylistID = $(tr.cells[0]).children('a').children('.playlistlabel')[0].id;
            }
        }
        if (ui.draggable[0].tagName != null && ui.draggable[0].tagName.toLowerCase() == 'a') {//ui.draggable[0].tagName.toLowerCase() == 'tr'
            //mediaID = $(ui.draggable[0].cells[0]).children('a.linkbuttonstyleinrepeater')[0].id;
            $(ui.draggable[0]).css({ position: '', left: '', top: '' });
            mediaID = ui.draggable[0].id;
            tr = ui.draggable[0];
        }
        if (UpdateType == 'Add_to_playlist' && PlaylistID != '' && mediaID != '') {
            AddSongtoPlaylist(mediaID, PlaylistID);
        }
        else if (UpdateType == 'reOrderPlaylist' && mediaID != '') {
            ReorderPlaylist(parentTable, tr, mediaID, PlaylistID);
        }
    } catch (ex) { }
}
/*shabina - end*/

/*animatedcollapse.js - start*/
//** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 24th, 08'- Script rewritten and updated to 2.0.
//** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves).

var animatedcollapse = {
    divholders: {}, //structure: {div.id, div.attrs, div.$divref}
    divgroups: {}, //structure: {groupname.count, groupname.lastactivedivid}
    lastactiveingroup: {}, //structure: {lastactivediv.id}

    show: function(divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++)
                this.showhide(divids[i], "show")
        }
        else
            this.showhide(divids, "show")
        var upperDiv = document.getElementById(divids.replace('Contents', '') + 'Heading');
        if (upperDiv != null) {
            upperDiv.className = 'showDownArrow';
        }
    },

    hide: function(divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++) {
                this.showhide(divids[i], "hide")
            }
        }
        else
            this.showhide(divids, "hide")
        var upperDiv = document.getElementById(divids.replace('Contents', '') + 'Heading');
        if (upperDiv != null) {
            upperDiv.className = 'showUpArrow'; ;
        }
    },

    toggle: function(divid) { //public method
        this.showhide(divid, "toggle")
        var upperDiv = document.getElementById(divid.replace('Contents', '') + 'Heading');
        if (upperDiv != null) {
            if (upperDiv.className == 'showUpArrow') {
                upperDiv.className = 'showDownArrow';
            }
            else {
                upperDiv.className = 'showUpArrow';
            }
        }
    },

    addDiv: function(divid, attrstring) { //public function
        this.divholders[divid] = ({ id: divid, $divref: null, attrs: attrstring })
        this.divholders[divid].getAttr = function(name) { //assign getAttr() function to each divholder object
            var attr = new RegExp(name + "=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
            return (attr.test(this.attrs) && parseInt(RegExp.$1) != 0) ? RegExp.$1 : null //return value portion (string), or 0 (false) if none found
        }
    },

    showhide: function(divid, action) {
        //debugger;
      // alert(this.divholders[divid] + '......' + this.divholders[divid].$divref);
        if (this.divholders[divid] != null) {
            var $divref = this.divholders[divid].$divref //reference collapsible DIV
            if (this.divholders[divid] && $divref.length == 1) { //if DIV exists
                var targetgroup = this.divgroups[$divref.attr('groupname')] //find out which group DIV belongs to (if any)
                if ($divref.attr('groupname') && targetgroup.count > 1 && (action == "show" || action == "toggle" && $divref.css('display') == 'none')) { //If current DIV belongs to a group
                    if (targetgroup.lastactivedivid && targetgroup.lastactivedivid != divid) //if last active DIV is set
                        this.slideengine(targetgroup.lastactivedivid, 'hide') //hide last active DIV within group first
                    this.slideengine(divid, 'show')
                    targetgroup.lastactivedivid = divid //remember last active DIV
                }
                else {
                    this.slideengine(divid, action)
                }
            }
        }
    },

    slideengine: function(divid, action) {
        var $divref = this.divholders[divid].$divref
        if (this.divholders[divid] && $divref.length == 1) { //if this DIV exists
            var animateSetting = { height: action }
            if ($divref.attr('fade'))
                animateSetting.opacity = action
            $divref.animate(animateSetting, $divref.attr('speed') ? parseInt($divref.attr('speed')) : 500)
            //debugger;


            return false
        }
    },

    generatemap: function() {
        var map = {}
        for (var i = 0; i < arguments.length; i++) {
            if (arguments[i][1] != null) {
                map[arguments[i][0]] = arguments[i][1]
            }
        }
        return map
    },

    init: function() {
        var ac = this
        jQuery(document).ready(function($) {
            var persistopenids = ac.getCookie('acopendivids') //Get list of div ids that should be expanded due to persistence ('div1,div2,etc')
            var groupswithpersist = ac.getCookie('acgroupswithpersist') //Get list of group names that have 1 or more divs with "persist" attribute defined
            if (persistopenids != null) //if cookie isn't null (is null if first time page loads, and cookie hasnt been set yet)
                persistopenids = (persistopenids == 'nada') ? [] : persistopenids.split(',') //if no divs are persisted, set to empty array, else, array of div ids
            groupswithpersist = (groupswithpersist == null || groupswithpersist == 'nada') ? [] : groupswithpersist.split(',') //Get list of groups with divs that are persisted
            jQuery.each(ac.divholders, function() { //loop through each collapsible DIV object
                this.$divref = $('#' + this.id)
                if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist) != -1) && persistopenids != null) {
                    var cssdisplay = (jQuery.inArray(this.id, persistopenids) != -1) ? 'block' : 'none'
                }
                else {
                    var cssdisplay = this.getAttr('hide') ? 'none' : null
                }
                this.$divref.css(ac.generatemap(['height', this.getAttr('height')], ['display', cssdisplay]))
                this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')]))
                if (this.getAttr('group')) { //if this DIV has the "group" attr defined
                    var targetgroup = ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')] = {}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in
                    targetgroup.count = (targetgroup.count || 0) + 1 //count # of DIVs within this group
                    if (!targetgroup.lastactivedivid && this.$divref.css('display') != 'none' || cssdisplay == "block") //if this DIV was open by default or should be open due to persistence								
                        targetgroup.lastactivedivid = this.id //remember this DIV as the last "active" DIV (this DIV will be expanded)
                    this.$divref.css({ display: 'none' }) //hide any DIV that's part of said group for now
                }
            }) //end divholders.each
            jQuery.each(ac.divgroups, function() { //loop through each group
                if (this.lastactivedivid)
                    ac.divholders[this.lastactivedivid].$divref.show() //and show last "active" DIV within each group (one that should be expanded)
            })
            var $allcontrols = $('*[rel]').filter('[rel^="collapse-"], [rel^="expand-"], [rel^="toggle-"]') //get all elements on page with rel="collapse-", "expand-" and "toggle-"
            var controlidentifiers = /(collapse-)|(expand-)|(toggle-)/
            $allcontrols.each(function() {
                $(this).click(function() {
                    var relattr = this.getAttribute('rel')
                    var divid = relattr.replace(controlidentifiers, '')
                    var doaction = (relattr.indexOf("collapse-") != -1) ? "hide" : (relattr.indexOf("expand-") != -1) ? "show" : "toggle"
                    return ac.showhide(divid, doaction)
                }) //end control.click
            })// end control.each
            $(window).bind('unload', function() {
                ac.uninit()
            })
        }) //end doc.ready()
    },

    uninit: function() {

        //debugger;
        var opendivids = '', groupswithpersist = ''
        jQuery.each(this.divholders, function() {
            if (this.$divref.css('display') != 'none') {
                opendivids += this.id + ',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc'
            }
            if (this.getAttr('group') && this.getAttr('persist'))
                groupswithpersist += this.getAttr('group') + ',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
        })
        opendivids = (opendivids == '') ? 'nada' : opendivids.replace(/,$/, '')
        groupswithpersist = (groupswithpersist == '') ? 'nada' : groupswithpersist.replace(/,$/, '')
        this.setCookie('acopendivids', opendivids)
        this.setCookie('acgroupswithpersist', groupswithpersist)
    },

    getCookie: function(Name) {
        var re = new RegExp(Name + "=[^;]*", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
            return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

    setCookie: function(name, value, days) {
        if (typeof days != "undefined") { //if set persistent cookie
            var expireDate = new Date()
            expireDate.setDate(expireDate.getDate() + days)
            document.cookie = name + "=" + value + "; path=/; expires=" + expireDate.toGMTString()
        }
        else //else if this is a session only cookie
            document.cookie = name + "=" + value + "; path=/"
    }

}
/*animatedcollapse.js - end*/

/*animatedcollapseLeft.js - start*/
//** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 24th, 08'- Script rewritten and updated to 2.0.
//** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves).

var animatedcollapseLeft = {
    divholders: {}, //structure: {div.id, div.attrs, div.$divref}
    divgroups: {}, //structure: {groupname.count, groupname.lastactivedivid}
    lastactiveingroup: {}, //structure: {lastactivediv.id}

    show: function(divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++)
                this.showhide(divids[i], "show")
        }
        else
            this.showhide(divids, "show")
    },

    hide: function(divids) { //public method
        if (typeof divids == "object") {
            for (var i = 0; i < divids.length; i++)
                this.showhide(divids[i], "hide")
        }
        else
            this.showhide(divids, "hide")
    },

    toggle: function(divid) { //public method
        this.showhide(divid, "toggle")
        var upperDiv = document.getElementById(divid.replace('Contents', '') + 'Heading');
        if (upperDiv != null) {
            if (upperDiv.className == 'showUpArrow') {
                upperDiv.className = 'showDownArrow';
            }
            else {
                upperDiv.className = 'showUpArrow';
            }
        }
    },

    addDiv: function(divid, attrstring) { //public function
        this.divholders[divid] = ({ id: divid, $divref: null, attrs: attrstring })
        this.divholders[divid].getAttr = function(name) { //assign getAttr() function to each divholder object
            var attr = new RegExp(name + "=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
            return (attr.test(this.attrs) && parseInt(RegExp.$1) != 0) ? RegExp.$1 : null //return value portion (string), or 0 (false) if none found
        }
    },

    showhide: function(divid, action) {
        //debugger;

        var $divref = this.divholders[divid].$divref //reference collapsible DIV
        if (this.divholders[divid] && $divref.length == 1) { //if DIV exists
            var targetgroup = this.divgroups[$divref.attr('groupname')] //find out which group DIV belongs to (if any)
            if ($divref.attr('groupname') && targetgroup.count > 1 && (action == "show" || action == "toggle" && $divref.css('display') == 'none')) { //If current DIV belongs to a group
                if (targetgroup.lastactivedivid && targetgroup.lastactivedivid != divid) //if last active DIV is set
                    this.slideengine(targetgroup.lastactivedivid, 'hide') //hide last active DIV within group first
                this.slideengine(divid, 'show')
                targetgroup.lastactivedivid = divid //remember last active DIV
            }
            else {
                this.slideengine(divid, action)
            }
        }
    },

    slideengine: function(divid, action) {
        var $divref = this.divholders[divid].$divref
        if (this.divholders[divid] && $divref.length == 1) { //if this DIV exists
            var animateSetting = { width: action }
            if ($divref.attr('fade'))
                animateSetting.opacity = action
            $divref.animate(animateSetting, $divref.attr('speed') ? parseInt($divref.attr('speed')) : 500)
            //debugger;


            return false
        }
    },

    generatemap: function() {
        var map = {}
        for (var i = 0; i < arguments.length; i++) {
            if (arguments[i][1] != null) {
                map[arguments[i][0]] = arguments[i][1]
            }
        }
        return map
    },

    init: function() {
        var ac = this
        jQuery(document).ready(function($) {
            var persistopenids = ac.getCookie('acopendivids') //Get list of div ids that should be expanded due to persistence ('div1,div2,etc')
            var groupswithpersist = ac.getCookie('acgroupswithpersist') //Get list of group names that have 1 or more divs with "persist" attribute defined
            if (persistopenids != null) //if cookie isn't null (is null if first time page loads, and cookie hasnt been set yet)
                persistopenids = (persistopenids == 'nada') ? [] : persistopenids.split(',') //if no divs are persisted, set to empty array, else, array of div ids
            groupswithpersist = (groupswithpersist == null || groupswithpersist == 'nada') ? [] : groupswithpersist.split(',') //Get list of groups with divs that are persisted
            jQuery.each(ac.divholders, function() { //loop through each collapsible DIV object
                this.$divref = $('#' + this.id)
                if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist) != -1) && persistopenids != null) {
                    var cssdisplay = (jQuery.inArray(this.id, persistopenids) != -1) ? 'block' : 'none'
                }
                else {
                    var cssdisplay = this.getAttr('hide') ? 'none' : null
                }
                this.$divref.css(ac.generatemap(['width', this.getAttr('width')], ['display', cssdisplay]))
                this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')]))
                if (this.getAttr('group')) { //if this DIV has the "group" attr defined
                    var targetgroup = ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')] = {}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in
                    targetgroup.count = (targetgroup.count || 0) + 1 //count # of DIVs within this group
                    if (!targetgroup.lastactivedivid && this.$divref.css('display') != 'none' || cssdisplay == "block") //if this DIV was open by default or should be open due to persistence								
                        targetgroup.lastactivedivid = this.id //remember this DIV as the last "active" DIV (this DIV will be expanded)
                    this.$divref.css({ display: 'none' }) //hide any DIV that's part of said group for now
                }
            }) //end divholders.each
            jQuery.each(ac.divgroups, function() { //loop through each group
                if (this.lastactivedivid)
                    ac.divholders[this.lastactivedivid].$divref.show() //and show last "active" DIV within each group (one that should be expanded)
            })
            var $allcontrols = $('*[rel]').filter('[rel^="collapse-"], [rel^="expand-"], [rel^="toggle-"]') //get all elements on page with rel="collapse-", "expand-" and "toggle-"
            var controlidentifiers = /(collapse-)|(expand-)|(toggle-)/
            $allcontrols.each(function() {
                $(this).click(function() {
                    var relattr = this.getAttribute('rel')
                    var divid = relattr.replace(controlidentifiers, '')
                    var doaction = (relattr.indexOf("collapse-") != -1) ? "hide" : (relattr.indexOf("expand-") != -1) ? "show" : "toggle"
                    return ac.showhide(divid, doaction)
                }) //end control.click
            })// end control.each
            $(window).bind('unload', function() {
                ac.uninit()
            })
        }) //end doc.ready()
    },

    uninit: function() {

        //debugger;
        var opendivids = '', groupswithpersist = ''
        jQuery.each(this.divholders, function() {
            if (this.$divref.css('display') != 'none') {
                opendivids += this.id + ',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc'
            }
            if (this.getAttr('group') && this.getAttr('persist'))
                groupswithpersist += this.getAttr('group') + ',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
        })
        opendivids = (opendivids == '') ? 'nada' : opendivids.replace(/,$/, '')
        groupswithpersist = (groupswithpersist == '') ? 'nada' : groupswithpersist.replace(/,$/, '')
        this.setCookie('acopendivids', opendivids)
        this.setCookie('acgroupswithpersist', groupswithpersist)
    },

    getCookie: function(Name) {
        var re = new RegExp(Name + "=[^;]*", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
            return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

    setCookie: function(name, value, days) {
        if (typeof days != "undefined") { //if set persistent cookie
            var expireDate = new Date()
            expireDate.setDate(expireDate.getDate() + days)
            document.cookie = name + "=" + value + "; path=/; expires=" + expireDate.toGMTString()
        }
        else //else if this is a session only cookie
            document.cookie = name + "=" + value + "; path=/"
    }

}
/*animatedcollapseLeft.js - end*/

/*MusicBrowser.js - start*/

function toggleLeftDiv() {
    slideLeftHide('leftSideBoxes');
}
function toggleLeftRightDiv() {
    slideRightShow('leftSideBoxes');
}
var leftDisplayMenu = "browsingTool";
function switchLeftMenu() {
    if (isDisplayingLeftMenu) {
        animatedcollapseLeft.hide('leftSideAllBoxes');
        isDisplayingLeftMenu = false;
        $("#imgLeftbar").attr('src', Theme_Img_Folder + 'arrow_right.jpg');
    }
    else {
        animatedcollapseLeft.show('leftSideAllBoxes');
        isDisplayingLeftMenu = true;
        $("#imgLeftbar").attr('src', Theme_Img_Folder + 'arrow_left.jpg');
    }
}

function showFeaturedBox() {
    if (isDisplayingLeftMenu) {
        hideLeftMenu();
    }
    else {
        if (leftDisplayMenu == 'leftSideBoxes') {
            showLeftMenu('leftSideBoxes');
        }
        else {
            showLeftMenu('browsingTool');
        }
    }
}

function showLeftMenu(varMenuToDisplay) {
    leftDisplayMenu = varMenuToDisplay;
    isDisplayingLeftMenu = true;

    if (varMenuToDisplay == "leftSideBoxes") {
        animatedcollapseLeft.show('leftSideBoxes');
        animatedcollapseLeft.hide('browsingTool');
    }
    else {
        animatedcollapseLeft.hide('leftSideBoxes');
        animatedcollapseLeft.show('browsingTool');
    }
}

function hideLeftMenu() {
    animatedcollapseLeft.hide(leftDisplayMenu);
    isDisplayingLeftMenu = false;
}
function showRightMenu() {
    animatedcollapseLeft.show("rightSideBoxes");
    isDisplayingRightMenu = true;
    $("#imgRightbar").attr('src', Theme_Img_Folder + 'arrow_right.jpg');
}
function hideRightMenu() {
    animatedcollapseLeft.hide("rightSideBoxes");
    isDisplayingRightMenu = false;
    $("#imgRightbar").attr('src', Theme_Img_Folder + 'arrow_left.jpg');
}
function showHideRightMenu() {
    if (isDisplayingRightMenu) {
        hideRightMenu();
    }
    else {
        showRightMenu();
    }
}

function browseOnOff() {
    if ($("#linkBrowseOff").hasClass("selectedItem")) {
        browseOn();
    }
    else if ($("#linkBrowseOn").hasClass("selectedItem")) {
        browseOff();
    }
}

function browseOff() {
    if ($("#linkBrowseOff").hasClass("selectedItem")) {
        return;
    }

    $("#linkBrowseOn").removeClass('selectedItem').removeClass('text16'); //.addClass('linkbuttonstyleinrepeater');
    $("#linkBrowseOff").addClass('selectedItem').addClass('text16'); //.removeClass('linkbuttonstyleinrepeater');

    var rightSideBoxes = document.getElementById('rightSideBoxes');
    var leftSideAllBoxes = document.getElementById('leftSideAllBoxes');
    if (rightSideBoxes.style.display != 'none' || leftSideAllBoxes.style.display != 'none') {
        if (leftSideAllBoxes.style.display != 'none') {
            switchLeftMenu();
        }
        if (rightSideBoxes.style.display != 'none') {
            showHideRightMenu();
        }
        window.setTimeout('browse_off()', 500);
    }
    else {
        browse_off();
    }
}
function browse_off() {
    $("#longBarDouble").hide();
    $("#longBarHalf").hide();
    $("#centerBoxContainer").insertAfter("#rightSideBoxes");
    $("#centre").hide();
    $("#rightSide").css('width', '364px').css('margin', 'auto').css('float', 'none');
    $("#player1 img").css({ position: '', right: '' });
    $("#imeemPlayer").attr({ width: 365 }).css('margin-left', '6px');
    $("#youtubePlayer").attr({ width: 365, height: 365 }).css('margin-left', '6px');
    $("#leftSide").hide();
    $("#player1").css('width', '365px').css('margin', '15px auto auto auto').css('padding-left', '0');
    $("#player1").css('text-align', 'center');
    $('#centerBoxContainer').css({ 'margin-left': '5px', 'width': '365px' });
}
function browseOn() {
    if ($("#linkBrowseOn").hasClass("selectedItem")) {
        return;
    }
    $("#longBarDouble").css('display', '');
    $("#longBarHalf").css('display', '');
    $("#leftSide").css('display', '');
    //$("#leftLinks").css('width', '');
    showHideRightMenu();
    //SetRightLongbarHeight();
    switchLeftMenu();
    $("#linkBrowseOff").removeClass('selectedItem').removeClass('text16'); //.addClass('linkbuttonstyleinrepeater');
    $("#linkBrowseOn").addClass('selectedItem').addClass('text16'); //.removeClass('linkbuttonstyleinrepeater');
    $("#centre").css('display', '');
    $("#centerBoxContainer").prependTo($("#centre"))
    if (iplayer == null && ytplayer == null) {
        $("#rightSide").css('width', '').css('float', '').css('margin', '');
    }
    else {
        $("#rightSide").css('width', '').css('float', '').css('margin', '').css('margin-top', '10px');
    }
    $("#player1 img").css({ position: 'relative', right: '115px' });
    $("#imeemPlayer").attr({ width: 270 }).css('margin-left', '');
    $("#youtubePlayer").attr({ width: 270, height: 240 }).css('margin-left', '');

    $("#player1").css('width', '').css('margin', '15px 0 0 0').css('padding-left', '10px').css('text-align', 'right');
    $('#centerBoxContainer').css({ 'margin-left': '', 'width': '' });
}

var browseGenresDisplayingMenu = "boxGenresContents";
function togglebrowseGenres() {
    $('#boxBrowse').show();
    //alert('boxBrowseContents') 
    animatedcollapse.show('boxBrowseContents');
//    if (browseGenresDisplayingMenu == "boxGenresContents") {
//        $('#boxBrowse').show();
//        animatedcollapse.hide('boxGenresContents');
//        animatedcollapse.show('boxBrowseContents');
//        browseGenresDisplayingMenu = "boxBrowseContents";
//        $('#boxGenres').hide();
//    }
//    else {
//        $('#boxGenres').show();
//        animatedcollapse.show('boxGenresContents');
//        animatedcollapse.hide('boxBrowseContents');
//        browseGenresDisplayingMenu = "boxGenresContents";
//        $('#boxBrowse').hide();
//    }
    
}

function showMusicSpotLight()
{
    var musicSpotlightID = $("#boxGenresContents a:first");
    if (musicSpotlightID.length > 0) {
        CurrentGenreID = musicSpotlightID[0].id;
        CurrentGenreName = musicSpotlightID[0].innerHTML;
        showRelatedBrowse(CurrentGenreID, CurrentGenreName)
    }
    else {
        musicSpotlightID = '';
    }
}

function showRelatedBrowse(id, genre) {
    $("#imgMainloading").remove();
    CurrentGenreID = id;
    CurrentGenreName = genre;
    BrowseMusic('MOST_PLAYED', 0, true);
    togglebrowseGenres();
}
//AvantGarde
function hideAlbumInfo() {
    $('.albumTitle label').addClass("hideAlbumArrow");
    $('.albumDetail label').addClass("hideAlbumArrow");

    $('#linkShowAlbumInfo').removeClass("selectedItem");
    $('#linkHideAlbumInfo').addClass("selectedItem");
}

function showAlbumInfo() {
    $('.albumTitle label').removeClass("hideAlbumArrow");
    $('.albumDetail label').removeClass("hideAlbumArrow");
    $('#linkShowAlbumInfo').addClass("selectedItem");
    $('#linkHideAlbumInfo').removeClass("selectedItem");

}
$.fn.center = function() {
    this.css("position", "absolute");
    this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
    this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
    return this;
}
function showMessage() {
    centerThis('messageBox');
    $('#messageBox').fadeIn(1500);
    setTimeout(hideMessageBox, 200);
}

function hideMessageBox() {
    $('#messageBox').fadeOut(1500);
}
function centerThis(div) {
    var winH = $(window).height();
    var winW = $(window).width();
    var centerDiv = $('#' + div);
    centerDiv.css('top', winH / 2 - centerDiv.height() / 2);
    centerDiv.css('left', winW / 2 - centerDiv.width() / 2);
}
/**
* Opacity function for jQuery
*
* @name   .opacity
* @cat    Plugins/Effects
* @author Woody Gilk/woody.gilk@gmail.com
*
* @example $(this).opacity(.2);
*/
$.fn.opacity = function(amount) {
    if (amount > 1) amount = 1;
    if (amount < 0) amount = 0;
    if ($.browser.msie) {
        amount = (parseFloat(amount) * 100);
        this.css('filter', 'alpha(opacity=' + amount + ')');
    } else {
        this.css('opacity', amount);
        this.css('-moz-opacity', amount);
    }
    return this;
}

$.fn.centerInClient = function(options) {
    /// <summary>Centers the selected items in the browser window. Takes into account scroll position.
    /// Ideally the selected set should only match a single element.
    /// </summary>    
    /// <param name="fn" type="Function">Optional function called when centering is complete. Passed DOM element as parameter</param>    
    /// <param name="forceAbsolute" type="Boolean">if true forces the element to be removed from the document flow 
    ///  and attached to the body element to ensure proper absolute positioning. 
    /// Be aware that this may cause ID hierachy for CSS styles to be affected.
    /// </param>
    /// <returns type="jQuery" />
    var opt = { forceAbsolute: false,
        container: window,    // selector of element to center in
        completeHandler: null
    };
    $.extend(opt, options);
    return this.each(function(x) {
        var el = $(this);
        var jWin = $(opt.container);
        var isWin = opt.container == window;
        // force to the top of document to ENSURE that 
        // document absolute positioning is available
        if (opt.forceAbsolute) {
            if (isWin)
                el.remove().appendTo("body");
            else
                el.remove().appendTo(jWin.get(0));
        }
        // have to make absolute
        el.css("position", "absolute");
        // height is off a bit so fudge it
        var heightFudge = isWin ? 2.0 : 1.8;
        el.css("left", x + jWin.scrollLeft());
        el.css("top", y + jWin.scrollTop());
        // if specified make callback and pass element
        if (opt.completeHandler)
            opt.completeHandler(this);
    });
}

$(function() {
    $(".jCarouselLite").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        scroll: 6,
        visible: 6,
        speed: 700,
        circular: false
    });
});

function triggerMenu(e) {
    if (g_RMenu == null) {
        g_RMenu = document.getElementById('radialContainer');
        g_RadialDragObj = new dragObject('radialContainer', 'radialCenter');
        g_LeafArray = new Array();
        g_LeafArray.push(document.getElementById('radialTop'));
        g_LeafArray.push(document.getElementById('radialLeft'));
        g_LeafArray.push(document.getElementById('radialBottom'));
        g_LeafArray.push(document.getElementById('radialRight'));
        g_LeafSubArray = new Array();
        g_LeafSubArray.push(document.getElementById('radialTopSubContent'));
        g_LeafSubArray.push(document.getElementById('radialLeftSubContent'));
        g_LeafSubArray.push(document.getElementById('radialBottomSubContent'));
        g_LeafSubArray.push(document.getElementById('radialRightSubContent'));
    }

    e = e ? e : window.event;
    if (g_RMenu.style.display == '' || e.button != 0)
        return;
    var pos = absoluteCursorPostion(e);
    g_RMenu.style.left = pos.X + 'px';
    g_RMenu.style.top = pos.Y + 'px';
    g_RMenu.style.display = '';
    hookEvent(document, "mousedown", testCloseMenu);
    hookEvent(document, "mousemove", subMenuActivate);
}

function testCloseMenu(e) {
    var tar = getEventTarget(e);

    do {
        if (tar == g_RMenu)
            return;
        tar = tar.parentNode;
    } while (tar != null);

    closeMenu();
}

function closeMenu() {
    unhookEvent(document, "mousedown", testCloseMenu);
    unhookEvent(document, "mousemove", subMenuActivate);

    g_RMenu.style.display = 'none';

    for (var x = 0; x < g_LeafArray.length; x++) {
        g_LeafArray[x].style.backgroundColor = '#203F5C';
        if (g_LeafSubArray[x] != null)
            g_LeafSubArray[x].style.display = 'none';
    }
}

function subMenuActivate(e) {
    var tar = getEventTarget(e);

    do {
        var found = false;
        for (var x = 0; x < g_LeafArray.length; x++)
            if (tar == g_LeafArray[x]) {
            found = true;
            break;
        }
        if (found)
            break;
        tar = tar.parentNode;
    } while (tar != null);

    for (var x = 0; x < g_LeafArray.length; x++) {
        if (g_LeafArray[x] == tar) {
            g_LeafArray[x].style.backgroundColor = '#BEBEBE';
            if (g_LeafSubArray[x] != null)
                g_LeafSubArray[x].style.display = '';
        }
        else {
            g_LeafArray[x].style.backgroundColor = '#203F5C';
            if (g_LeafSubArray[x] != null)
                g_LeafSubArray[x].style.display = 'none';
        }
    }
}
function Geturlforsong(url, title, type) {
    document.getElementById('typeofsong').innerHTML = type;
}
function Gettitleofsong() {
    var title = document.getElementById('Titleforsong').innerHTML;
    if (document.getElementById('lblTitleofSong') != null) {
        $('#lblTitleofSong').html(title);
        GetCurrentMediaTitle(30, 'lblTitleofSong', 195, title, false);
    }
}

function getaddmediaparams(album, albumArtUrl, artist, id, mbid, song, source, sourceFkid, title, url) {
    var allid = returnallid();
    document.getElementById(allid[0]).value = album;
    document.getElementById(allid[1]).value = albumArtUrl;
    document.getElementById(allid[2]).value = artist;
    document.getElementById(allid[3]).value = id;
    document.getElementById(allid[4]).value = mbid;
    document.getElementById(allid[5]).value = song;
    document.getElementById(allid[6]).value = source;
    document.getElementById(allid[7]).value = sourceFkid;
    document.getElementById(allid[8]).value = title;
    document.getElementById(allid[9]).value = url;

}

function bindplaylistidtohf(playlistId) {
    document.getElementById(gethfid()).value = playlistId;
}

function toggleclass(divid) {
    var classname = document.getElementById(divid).className;
    if (classname == 'showUpArrow') {
        document.getElementById(divid).className = 'showDownArrow';
    }
    else if (classname == 'showDownArrow') {
        document.getElementById(divid).className = 'showUpArrow';
    }
}
/*MusicBrowser.js - end*/

/*jcarousellite_1.0.1.js - start*/
(function($) {                                          // Compliant with jquery.noConflict()
    $.fn.jCarouselLite = function(o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,

            speed: 200,
            easing: null,

            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,

            beforeStart: null,
            afterEnd: null
        }, o || {});

        return this.each(function() {                           // Returns the element collection. Chainable.

            var running = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";
            var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone())
              .append(tLi.slice(0, v).clone());
                o.start += v;
            }

            var li = $("li", ul), itemLength = li.size(), curr = o.start;
            div.css("visibility", "visible");

            li.css({ overflow: "hidden", float: o.vertical ? "none" : "left" });
            ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });
            div.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });

            var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
            var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
            var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

            //debugger;
            li.css({ width: li.width(), height: li.height() }); //Adeel:Added +5 to the height
            ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));
            //debugger;
            div.css(sizeCss, divSize + "px");                     // Width of the DIV. length of visible images

            if (o.btnPrev)
                $(o.btnPrev).click(function() {
                    return go(curr - o.scroll);
                });

            if (o.btnNext)
                $(o.btnNext).click(function() {
                    return go(curr + o.scroll);
                });

            if (o.btnGo)
                $.each(o.btnGo, function(i, val) {
                    $(val).click(function() {
                        return go(o.circular ? o.visible + i : i);
                    });
                });

            if (o.mouseWheel && div.mousewheel)
                div.mousewheel(function(e, d) {
                    return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
                });

            if (o.auto)
                setInterval(function() {
                    go(curr + o.scroll);
                }, o.auto + o.speed);

            function vis() {
                return li.slice(curr).slice(0, v);
            };

            function go(to) {
                if (!running) {

                    if (o.beforeStart)
                        o.beforeStart.call(this, vis());

                    if (o.circular) {            // If circular we are in first or last, then goto the other end
                        if (to <= o.start - v - 1) {           // If first, then goto last
                            ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                            curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll;
                        } else if (to >= itemLength - v + 1) { // If last, then goto first
                            ul.css(animCss, -((v) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                            curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                        } else curr = to;
                    } else {                    // If non-circular and to points to first or last, we just return.
                        if (to < 0 || to > itemLength - v) return;
                        else curr = to;
                    }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                    running = true;

                    ul.animate(
                    animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing,
                    function() {
                        if (o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                    // Disable buttons when the carousel reaches the last/first, and enable when not
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        $(o.btnPrev + "," + o.btnNext).removeClass("hideAlbumArrow");
                        //debugger;
                        //$(o.btnPrev + "," + o.btnNext).style.display = "none";


                        $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                       (curr + o.scroll > itemLength - v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
                        $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                       (curr + o.scroll > itemLength - v && o.btnNext)
                        ||
                       []
                     ).addClass("hideAlbumArrow");
                    }

                }
                return false;
            };
        });
    };
    function css(el, prop) {
        return parseInt($.css(el[0], prop)) || 0;
    };
    function width(el) {
        return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
    };
    function height(el) {
        return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
    };

})(jQuery);
/*jcarousellite_1.0.1.js - end*/

/*nifty.js - start*/
function NiftyCheck() {
    if (!document.getElementById || !document.createElement)
        return (false);
    isXHTML = /html\:/.test(document.getElementsByTagName('body')[0].nodeName);
    if (Array.prototype.push == null) {
        Array.prototype.push = function() {
            this[this.length] = arguments[0]; return (this.length);
        }
    }
    return (true);
}

function Rounded(selector, wich, bk, color, opt) {
    var i, prefixt, prefixb, cn = "r", ecolor = "", edges = false, eclass = "", b = false, t = false;

    if (color == "transparent") {
        cn = cn + "x";
        ecolor = bk;
        bk = "transparent";
    }
    else if (opt && opt.indexOf("border") >= 0) {
        var optar = opt.split(" ");
        for (i = 0; i < optar.length; i++)
            if (optar[i].indexOf("#") >= 0) ecolor = optar[i];
        if (ecolor == "") ecolor = "#666";
        cn += "e";
        edges = true;
    }
    else if (opt && opt.indexOf("smooth") >= 0) {
        cn += "a";
        ecolor = Mix(bk, color);
    }
    if (opt && opt.indexOf("small") >= 0) cn += "s";
    prefixt = cn;
    prefixb = cn;
    if (wich.indexOf("all") >= 0) { t = true; b = true }
    else if (wich.indexOf("top") >= 0) t = "true";
    else if (wich.indexOf("tl") >= 0) {
        t = "true";
        if (wich.indexOf("tr") < 0) prefixt += "l";
    }
    else if (wich.indexOf("tr") >= 0) {
        t = "true";
        prefixt += "r";
    }
    if (wich.indexOf("bottom") >= 0) b = true;
    else if (wich.indexOf("bl") >= 0) {
        b = "true";
        if (wich.indexOf("br") < 0) prefixb += "l";
    }
    else if (wich.indexOf("br") >= 0) {
        b = "true";
        prefixb += "r";
    }
    var v = getElementsBySelector(selector);
    var l = v.length;
    for (i = 0; i < l; i++) {
        if (edges) AddBorder(v[i], ecolor);
        if (t) AddTop(v[i], bk, color, ecolor, prefixt);
        if (b) AddBottom(v[i], bk, color, ecolor, prefixb);
    }
}

function AddBorder(el, bc) {
    var i;
    if (!el.passed) {
        if (el.childNodes.length == 1 && el.childNodes[0].nodeType == 3) {
            var t = el.firstChild.nodeValue;
            el.removeChild(el.lastChild);
            var d = CreateEl("span");
            d.style.display = "block";
            d.appendChild(document.createTextNode(t));
            el.appendChild(d);
        }
        for (i = 0; i < el.childNodes.length; i++) {
            if (el.childNodes[i].nodeType == 1) {
                el.childNodes[i].style.borderLeft = "1px solid " + bc;
                el.childNodes[i].style.borderRight = "1px solid " + bc;
            }
        }
    }
    el.passed = true;
}

function AddTop(el, bk, color, bc, cn) {
    var i, lim = 4, d = CreateEl("b");

    if (cn.indexOf("s") >= 0) lim = 2;
    if (bc) d.className = "artop";
    else d.className = "rtop";
    d.style.backgroundColor = bk;
    for (i = 1; i <= lim; i++) {
        var x = CreateEl("b");
        x.className = cn + i;
        x.style.backgroundColor = color;
        if (bc) x.style.borderColor = bc;
        d.appendChild(x);
    }
    el.style.paddingTop = 0;
    el.insertBefore(d, el.firstChild);
}

function AddBottom(el, bk, color, bc, cn) {
    var i, lim = 4, d = CreateEl("b");

    if (cn.indexOf("s") >= 0) lim = 2;
    if (bc) d.className = "artop";
    else d.className = "rtop";
    d.style.backgroundColor = bk;
    for (i = lim; i > 0; i--) {
        var x = CreateEl("b");
        x.className = cn + i;
        x.style.backgroundColor = color;
        if (bc) x.style.borderColor = bc;
        d.appendChild(x);
    }
    el.style.paddingBottom = 0;
    el.appendChild(d);
}

function CreateEl(x) {
    if (isXHTML) return (document.createElementNS('http://www.w3.org/1999/xhtml', x));
    else return (document.createElement(x));
}

function getElementsBySelector(selector) {
    var i, selid = "", selclass = "", tag = selector, f, s = [], objlist = [];

    if (selector.indexOf(" ") > 0) {  //descendant selector like "tag#id tag"
        s = selector.split(" ");
        var fs = s[0].split("#");
        if (fs.length == 1) return (objlist);
        f = document.getElementById(fs[1]);
        if (f) return (f.getElementsByTagName(s[1]));
        return (objlist);
    }
    if (selector.indexOf("#") > 0) { //id selector like "tag#id"
        s = selector.split("#");
        tag = s[0];
        selid = s[1];
    }
    if (selid != "") {
        f = document.getElementById(selid);
        if (f) objlist.push(f);
        return (objlist);
    }
    if (selector.indexOf(".") > 0) {  //class selector like "tag.class"
        s = selector.split(".");
        tag = s[0];
        selclass = s[1];
    }
    var v = document.getElementsByTagName(tag);  // tag selector like "tag"
    if (selclass == "")
        return (v);
    for (i = 0; i < v.length; i++) {
        if (v[i].className.indexOf(selclass) >= 0) {
            objlist.push(v[i]);
        }
    }
    return (objlist);
}

function Mix(c1, c2) {
    var i, step1, step2, x, y, r = new Array(3);
    if (c1.length == 4) step1 = 1;
    else step1 = 2;
    if (c2.length == 4) step2 = 1;
    else step2 = 2;
    for (i = 0; i < 3; i++) {
        x = parseInt(c1.substr(1 + step1 * i, step1), 16);
        if (step1 == 1) x = 16 * x + x;
        y = parseInt(c2.substr(1 + step2 * i, step2), 16);
        if (step2 == 1) y = 16 * y + y;
        r[i] = Math.floor((x * 50 + y * 50) / 100);
    }
    return ("#" + r[0].toString(16) + r[1].toString(16) + r[2].toString(16));
}
/*nifty.js - end*/
/*jquery.jgrowl.js - start*/
(function($) {

    /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/
    $.jGrowl = function(m, o) {
        // To maintain compatibility with older version that only supported one instance we'll create the base container.
        if ($('#jGrowl').size() == 0) $('<div id="jGrowl"></div>').addClass($.jGrowl.defaults.position).appendTo('body');
        // Create a notification on the container.
        $('#jGrowl').jGrowl(m, o);
    };


    /** Raise jGrowl Notification on a jGrowl Container **/
    $.fn.jGrowl = function(m, o) {
        if ($.isFunction(this.each)) {
            var args = arguments;

            return this.each(function() {
                var self = this;

                /** Create a jGrowl Instance on the Container if it does not exist **/
                if ($(this).data('jGrowl.instance') == undefined) {
                    $(this).data('jGrowl.instance', new $.fn.jGrowl());
                    $(this).data('jGrowl.instance').startup(this);
                }

                /** Optionally call jGrowl instance methods, or just raise a normal notification **/
                if ($.isFunction($(this).data('jGrowl.instance')[m])) {
                    $(this).data('jGrowl.instance')[m].apply($(this).data('jGrowl.instance'), $.makeArray(args).slice(1));
                } else {
                    $(this).data('jGrowl.instance').notification(m, o);
                }
            });
        };
    };

    $.extend($.fn.jGrowl.prototype, {

        /** Default JGrowl Settings **/
        defaults: {
            header: '',
            sticky: false,
            position: 'top-right', // Is this still needed?
            glue: 'after',
            theme: 'default',
            corners: '10px',
            check: 500,
            life: 3000,
            speed: 'normal',
            easing: 'swing',
            closer: true,
            closeTemplate: '&times;',
            closerTemplate: '<div>[ close all ]</div>',
            log: function(e, m, o) { },
            beforeOpen: function(e, m, o) { },
            open: function(e, m, o) { },
            beforeClose: function(e, m, o) { },
            close: function(e, m, o) { },
            animateOpen: {
                opacity: 'show'
            },
            animateClose: {
                opacity: 'hide'
            }
        },

        /** jGrowl Container Node **/
        element: null,

        /** Interval Function **/
        interval: null,

        /** Create a Notification **/
        notification: function(message, o) {
            var self = this;
            var o = $.extend({}, this.defaults, o);

            o.log.apply(this.element, [this.element, message, o]);

            var notification = $('<div class="jGrowl-notification"><div class="close">' + o.closeTemplate + '</div><div class="header">' + o.header + '</div><div class="message">' + message + '</div></div>')
				.data("jGrowl", o).addClass(o.theme).children('div.close').bind("click.jGrowl", function() {
				    $(this).unbind('click.jGrowl').parent().trigger('jGrowl.beforeClose').animate(o.animateClose, o.speed, o.easing, function() {
				        $(this).trigger('jGrowl.close').remove();
				    });
				}).parent();

            (o.glue == 'after') ? $('div.jGrowl-notification:last', this.element).after(notification) : $('div.jGrowl-notification:first', this.element).before(notification);

            /** Notification Actions **/
            $(notification).bind("mouseover.jGrowl", function() {
                $(this).data("jGrowl").pause = true;
            }).bind("mouseout.jGrowl", function() {
                $(this).data("jGrowl").pause = false;
            }).bind('jGrowl.beforeOpen', function() {
                o.beforeOpen.apply(self.element, [self.element, message, o]);
            }).bind('jGrowl.open', function() {
                o.open.apply(self.element, [self.element, message, o]);
            }).bind('jGrowl.beforeClose', function() {
                o.beforeClose.apply(self.element, [self.element, message, o]);
            }).bind('jGrowl.close', function() {
                o.close.apply(self.element, [self.element, message, o]);
            }).trigger('jGrowl.beforeOpen').animate(o.animateOpen, o.speed, o.easing, function() {
                $(this).data("jGrowl").created = new Date();
            }).trigger('jGrowl.open');

            /** Optional Corners Plugin **/
            if ($.fn.corner != undefined) $(notification).corner(o.corners);

            /** Add a Global Closer if more than one notification exists **/
            if ($('div.jGrowl-notification:parent', this.element).size() > 1 && $('div.jGrowl-closer', this.element).size() == 0 && this.defaults.closer != false) {
                $(this.defaults.closerTemplate).addClass('jGrowl-closer').addClass(this.defaults.theme).appendTo(this.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing).bind("click.jGrowl", function() {
                    $(this).siblings().children('div.close').trigger("click.jGrowl");

                    if ($.isFunction(self.defaults.closer)) self.defaults.closer.apply($(this).parent()[0], [$(this).parent()[0]]);
                });
            };
        },

        /** Update the jGrowl Container, removing old jGrowl notifications **/
        update: function() {
            $(this.element).find('div.jGrowl-notification:parent').each(function() {
                if ($(this).data("jGrowl") != undefined && $(this).data("jGrowl").created != undefined && ($(this).data("jGrowl").created.getTime() + $(this).data("jGrowl").life) < (new Date()).getTime() && $(this).data("jGrowl").sticky != true &&
					 ($(this).data("jGrowl").pause == undefined || $(this).data("jGrowl").pause != true)) {
                    $(this).children('div.close').trigger('click.jGrowl');
                }
            });

            if ($(this.element).find('div.jGrowl-notification:parent').size() < 2) {
                $(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() {
                    $(this).remove();
                });
            };
        },

        /** Setup the jGrowl Notification Container **/
        startup: function(e) {
            this.element = $(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');
            this.interval = setInterval(function() { jQuery(e).data('jGrowl.instance').update(); }, this.defaults.check);

            if ($.browser.msie && parseInt($.browser.version) < 7 && !window["XMLHttpRequest"]) $(this.element).addClass('ie6');
        },

        /** Shutdown jGrowl, removing it and clearing the interval **/
        shutdown: function() {
            $(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove();
            clearInterval(this.interval);
        }
    });

    /** Reference the Defaults Object for compatibility with older versions of jGrowl **/
    $.jGrowl.defaults = $.fn.jGrowl.prototype.defaults;

})(jQuery);
/*jquery.jgrowl.js - end*/