﻿$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

$(document).ready(function() {

	if ( typeof(from_blog)  == 'undefined')
	{
		from_blog = false;
	}
	
	var path_prefix = "";
	if ( from_blog)
	{
		path_prefix = "../";
	}
	
	// dynamic text loading
	var wd_drama = $('<img src="' + path_prefix + 'image/word_drama.png" alt="drama" id="word_drama" style="display: none;"/>');
	var wd_composer = $('<img src="' + path_prefix + 'image/word_composer.png" alt="composer" id="word_composer" style="display: none;"/>');
	var wd_arranger = $('<img src="' + path_prefix + 'image/word_arranger.png" alt="arranger" id="word_arranger" style="display: none;"/>');
	var wd_soundtracks = $('<img src="' + path_prefix + 'image/word_soundtracks.png" alt="soundtracks" id="word_soundtracks" style="display: none;"/>');
	var wd_emotion = $('<img src="' + path_prefix + 'image/word_emotion.png" alt="emotion" id="word_emotion" style="display: none;"/>');
			
	$('#header').append(wd_drama);
	$('#word_drama').fadeIn(1000);

	setTimeout(function() {
		$('#header').append(wd_composer);
		$('#word_composer').fadeIn(1000);
	}, (500));
	
	setTimeout(function() {
		$('#header').append(wd_arranger);
		$('#word_arranger').fadeIn(1000);
	}, (1000));
	
	setTimeout(function() {
		$('#header').append(wd_soundtracks);
		$('#word_soundtracks').fadeIn(1000);
	}, (1500));
	
	setTimeout(function() {
		$('#header').append(wd_emotion);
		$('#word_emotion').fadeIn(0500);
	}, (2000));
	
	$('#buy_links_content').load('./buy_links.html');
	
	$('.buy_links').tabSlideOut({
	    tabHandle: '.handle',                              //class of the element that will be your tab
	    pathToTabImage: path_prefix + 'image/buy_button.png',           //path to the image for the tab *required*
	    imageHeight: '120px',                               //height of tab image *required*
	    imageWidth: '40px',                               //width of tab image *required*    
	    tabLocation: 'left',                               //side of screen where tab lives, top, right, bottom, or left
	    speed: 300,                                        //speed of animation
	    action: 'click',                                   //options: 'click' or 'hover', action to trigger animation
	    topPos: '200px',                                   //position from the top
	    fixedPosition: true                               //options: true makes it stick(fixed position) on scroll
	});

	animate_buy();
});

function animate_buy()
{

	if (parseInt( $('.buy_links').css('left')) < -10)
		$('.buy_links').animate({left: '+=10'}, 500, function(){$('.buy_links').animate({left: '-=10'}, 500);});
	
	setTimeout(function(){animate_buy();}, 30000);
	
}
function load_release_content(page)
{
	$('article#release_detail').html('');
	
	$('article#release_detail').load('./release_content/' + page + '.html');
}


