
/*overstate*/
$(document).ready(function() {



    $(".menuoverstate").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".jpg", "_o.jpg");

        $(this).hover(
            function() {
                if (this.src.indexOf("_o.jpg") == -1) {
                    this.src = this.src.replace(".jpg", "_o.jpg");
                }
            },

            function() {
                this.src = this.src.replace("_o.jpg", ".jpg");
            });
    }
        );

    $(".menuoverstate2").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".png", "_o.png");

        $(this).hover(
            function() {
                if (this.src.indexOf("_o.png") == -1) {
                    this.src = this.src.replace(".png", "_o.png");
                }
            },

            function() {
                this.src = this.src.replace("_o.png", ".png");

            });
    }
        );

    /* correct postback behaviour */

    Array.prototype.compare = function(testArr) {
        if (this.length != testArr.length) return false;
        for (var i = 0; i < testArr.length; i++) {
            if (this[i].compare) {
                if (!this[i].compare(testArr[i])) return false;
            }
            if (this[i] !== testArr[i]) return false;
        }
        return true;
    }


    /*image overstate*/

    $(".big-text, .small-text").hide();


    $(".home-image-big, .home-image-small").each(function() {
        var el = this;
        var triggered = false;
        var open = false;
        $(el).hover(function() {
            triggered = true;
            setTimeout(function() {
                if (triggered) {
                    $(el).children().children(".home-image-big img, .home-image-small img").animate({ opacity: 0.5 }, 200);
                    $(el).children().children(".big-text, .small-text").slideDown('200');
                    open = true;
                }
            }, 200);
        }, function() {
            if (open == true) {
                $(el).children().children(".home-image-big img, .home-image-small img").animate({ opacity: 1.0 }, 200);
                $(el).children().children(".big-text, .small-text").slideUp('200');
                open = false;
            }

            triggered = false;
        });
    });


    $(".group-item a").hover(function() {
        $(this).children().children(".group-item img").animate({ opacity: 0.5 }, 200);
    }, function() {
        $(this).children().children(".group-item img").animate({ opacity: 1.0 }, 200);
    });

    $(".hideme").hide();

    $(".openclose").click(function() {
        $(this).parent().next().slideToggle();
    },function() {
    $(this).parent().next().slideToggle();
    });

    // slideshow
    /*
    for (var i = 1; i < 20; i++) {        
        $('#group-wrapper' + i.toString()).cycle({
            fx: 'scrollHorz',
            timeout: 9999999999,
            nowrap: true,
            prev: '#prev' + i.toString(),
            next: '#next' + i.toString(),
            prevNextClick: function(isNext, zeroBasedSlideIndex, slideElement) {
                setTimeout(function() {
                    var el = $(slideElement);                
                    var cls = el.attr('class');
                    var index = cls.split('-')[1];
                    
                    if (cls.indexOf('last') > -1) 
                        $("#next" + index).addClass("nav-off").removeClass("btn");             
                    else
                        $("#next" + index).removeClass("nav-off").addClass("btn");               
                    
                    if (cls.indexOf('first') > -1) 
                        $("#prev" + index).addClass("nav-off").removeClass("btn");             
                    else
                        $("#prev" + index).removeClass("nav-off").addClass("btn");                                               
                }, 750);
            },
        });
    }
    */
    // last.fm

    $.getJSON('http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=deerfaced&api_key=9e7f5c941f081245f1a821953d4ead72&format=json&limit=2&callback=?', function(data) {
        var recentTracks = data['recenttracks']['track'];
        var lastFM = document.getElementById("lastfm");

        var track = recentTracks[0];
        var artist = document.createElement("span");
        artist.style.fontSize = '12px';
        var name = document.createElement("a");
        name.href = track.url;
        artist.innerHTML = track.artist["#text"];
        name.className = 'btn';
        name.innerHTML = track.name;
        name.target = '_blank';
        var br = document.createElement('br');
        lastFM.appendChild(artist);
        lastFM.appendChild(br);
        lastFM.appendChild(name);
    });

    $.getJSON('http://ws.audioscrobbler.com/2.0/?method=user.getInfo&user=deerfaced&api_key=9e7f5c941f081245f1a821953d4ead72&format=json&limit=2&callback=?', function(data) {
        var plays = data['user']['playcount'];
        $("#last-fm-plays").text(plays);

    });



});

/*

var WIDTH;
var HEIGHT;
var g;
var rightDown = false;
var leftDown = false;
var carray = new Array();


// Main Function To Start
function start()
{
	g = $('#canvas')[0].getContext("2d");
	WIDTH = $('#canvas').width();
	HEIGHT = $('#canvas').height();
	carray[0] = new Circle(150,150,50);
	return setInterval(draw, 10);
}

// Circle Class	
function Circle(x,y,r)
{
	this.x = x;
	this.y = y;
	this.r = r;
	this.dx = Math.ceil(Math.random()*7);
	this.dy = Math.ceil(Math.random()*7);
	
	this.draw = function()
	{
		g.beginPath();
		g.fillStyle = "#FF6666";
		g.arc(this.x / 1.4, this.y, this.r, 0, Math.PI*2, true);
		g.closePath();
		g.fill();
	}
	
	this.getX = function()
	{
		return x;
	}
	
	this.getY = function()
	{
		return this.y;
	}
	
	this.move = function()
	{	

		this.y += this.dy;
	

		
		if(this.y > HEIGHT - 75 || this.y < 75)
		{
			this.dy = this.dy*-1;
		}
	}
}

// Draw Function
function draw()
{
	clear();
	var i;
	for (i=0; i<carray.length; i++)
	{
		carray[i].move();
		carray[i].draw();
	}
}

function clear() 
{
	g.fillStyle = "#fff";
	g.fillRect(0, 0, WIDTH, HEIGHT);
}
*/
