/*  The anatomy of a URL
** <protocol>//<hostname>:<port>/<pathname><search><hash>
*/// Get the full path to the siteSkin folder
var domain = window.location.hostname;
var portal = "/Portals/_default/Skins/siteSkin/";
var dnnPath = domain + portal;
//alert(dnnPath)


//start jQuery functions
$(document).ready(function() {
	
	// Drop tokens from top to bottom
	var _body = $('body');
	var _ypos = $(document).height() - 130;
	var _sides = ['/Portals/_default/Skins/simisterortho/images/coin_heads.png','/Portals/_default/Skins/simisterortho/images/coin_tails.png','/Portals/_default/Skins/simisterortho/images/coin_heads.png']
	var _total = 3;
	/*
	* The delay() method requires jQuery 1.4
	*/
	_body.bind('drop', function(e, token, timer) {
		$(token).delay(timer * 200).animate({top: _ypos}, _ypos*3);
	});
	
	function dropTokens() {
		var _rand = Math.floor(Math.random()*2);
		for(i=0; i<_total; i++) {
			_body.append(
				$('<a href="/PatientInfo/BraceBucks.aspx"><img src="'+ _sides[i%2] +'" class="token coin'+i+'" /></a>')
			).trigger('drop', ['img.coin'+i, i]);
		}
		setTimeout(removeTokens, _ypos * 15);
	}
	function removeTokens() {
		for(i=0; i<_total; i++) {
			$('img.coin'+i).delay(i * 400).animate(
				{opacity: 0}, 'slow', function() {
					$(this).remove();
			});
		}
		setTimeout(dropTokens, 4000);
	}
	
	setTimeout(dropTokens, 2000);
	
});
