﻿var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();

if (BrowserDetect.browser == "Explorer")
{
    if (BrowserDetect.version <= 7)
    {
        window.location = "http://windows.microsoft.com/en-US/internet-explorer/products/ie/home";
    }
}


$(document).ready(function () {
    var myCaptions = new Array();
    var citem = 0;
    myCaptions[10] = 'Marilyn Manson at the SPIN Magazine VMA Party for D12';
    myCaptions[11] = 'Jason Mraz performs at the 2010 Freedom Awards';
    myCaptions[12] = 'Cedric the Entertainer and P Diddy celebrate with Q Tip at his birthday party';
    myCaptions[13] = 'Cee Lo Green at the STAR Lounge Gifting Suite';
    myCaptions[14] = 'Poker Pro Phil Hellmuth interviews Eric Bana at the All In Magazine & Ultimate Bet Celebrity Poker Tournament for Charity';
    myCaptions[15] = 'Bacardi Flavors girls at the STUFF VMA Party';
    myCaptions[16] = 'Quentin Tarantino at Ludacris\' GRAMMY Party';
    myCaptions[17] = 'Maria Menounos, Tianna Li and Denise Bayles at the Children\'s Hospital Los Angeles GRAMMY Party';
    myCaptions[18] = 'Joss Stone at the STAR Lounge Gifting Suite';
    myCaptions[19] = 'Kevin James and Justin Timberlake at the Make The Difference Network Holiday Party to benefit Children\'s Hospital Los Angeles';
    myCaptions[20] = 'Tichina Arnold and Regina King give Ludacris a smooch at his GRAMMY party';
    myCaptions[21] = 'Dave Meyers, Christina Milian, Ludacris and Jacob the Jeweler at the STUFF VMA Party';
	myCaptions[22] = 'The Tenors, Lee DeWyze and Taylor Hicks at the 2011 Life Changing Lives Gala';
	myCaptions[23] = 'Dmitry Chaplin and Karina Smirnoff at the 2011 Life Changing LIves Gala';
	myCaptions[24] = 'Muhammad Ali at the 2011 Life Changing Lives Gala';
    myCaptions[0] = 'Jessica Biel decorates a cupcake at the Children\'s Hospital Los Angeles Holiday Party';
    myCaptions[1] = 'LL Cool J serenades Patti Labelle at her birthday party';
    myCaptions[2] = 'Ashton Kutcher and Demi Moore at the 2010 Freedom Awards';
    myCaptions[3] = 'Debbie Gibson at the All In Magazine & Ultimate Bet Celebrity Poker Tournament for Charity';
    myCaptions[4] = 'Ed Lover and Missy Elliott at her \'The Road To Stardom\' TV show party';
    myCaptions[5] = 'Elliott Yamin performs at the 2009 Life Changing Lives Gala';
    myCaptions[6] = 'Forest Whitaker and Camilla Belle at the 2010 Freedom Awards';
    myCaptions[7] = 'India Arie and Chris Tucker at Ludacris\' GRAMMY Party';
    myCaptions[8] = 'Michael Rothman, Rich Sommer, Michael Gladis and Samm Levine at the Young Hollywood Celebrity Poker Tournament for Charity';
    myCaptions[9] = 'Sugar Ray Leonard at the 2009 Life Changing Lives Gala';
    $('#captiontext').html(myCaptions[citem]);
    var pos = 380;
    var sPos;
    $('#slideleft').click(function () {
        if (!$('#panel').is(':animated')) {
            $('#captioncontainer').fadeOut('fast', function () {
                if (citem == 0) {
                    citem = 24;
                }
                else {
                    citem--;
                }
                $('#captiontext').html(myCaptions[citem]);
                $('#captioncontainer').fadeIn('fast');
            });
            pos = pos + 332;
            sPos = pos + "px 0px";
            $('#panel').animate({
                backgroundPosition: sPos
            });
        }
        return false;
    });
    $('#slideright').click(function () {
        if (!$('#panel').is(':animated')) {
            $('#captioncontainer').fadeOut('fast', function () {
                if (citem == 24) {
                    citem = 0;
                }
                else {
                    citem++;
                }
                $('#captiontext').html(myCaptions[citem]);
                $('#captioncontainer').fadeIn('fast');
            });
            pos = pos - 332;
            sPos = pos + "px 0px";
            $('#panel').animate({
                backgroundPosition: sPos
            });
        }
        return false;
    });
    $('#sdnext').click(function () {
        $('.slidedeck').slidedeck().next();
    });
    $('#sdprev').click(function () {
        $('.slidedeck').slidedeck().prev();
    });
});
