﻿window.addEvent('domready', function(){
	if($('downloadedtimes')){
		var downloadedTimes = function(){ 
			new Request.HTML({
				evalScripts: true,
				evalResponse: true,
				url: 'downloaded.php',
				onSuccess: function(html) { 
					$('downloadedtimes').set('html', this.response.text); 
				}
			}).post();
		};
		downloadedTimes.periodical(10000);
	}
	if($('loadfvhere')){
		if(Browser.Plugins.Flash.version>=9){
			$('loadfvhere').set('html', 'You currently have Flash version '+Browser.Plugins.Flash.version+'.'+Browser.Plugins.Flash.build+' which means you are ok to use JF MP3!');
		}
		else{
			$('loadfvhere').set('html', 'You currently have Flash version '+Browser.Plugins.Flash.version+'.'+Browser.Plugins.Flash.build+' which means you need to update immeditatly. <a href="http://www.adobe.com/products/flashplayer/">Click here to do so</a>.');
		}
	}
	if($('navtoscroll')){
		if(window.getScroll().y>=$('navtoscroll').getScrollSize().y && window.getScroll().y<(window.getScrollSize().y-$('navtoscroll').getSize().y)){
				$('navtoscroll').tween('top', ((window.getScroll().y)-314));
		}
		else if(window.getScroll().y<$('navtoscroll').getScrollSize().y && window.getScroll().y<(window.getScrollSize().y-$('navtoscroll').getSize().y)){
			$('navtoscroll').tween('top','0');
		}
		window.addEvent('scroll', function(){
			if(window.getScroll().y>=$('navtoscroll').getScrollSize().y && window.getScroll().y<(window.getScrollSize().y-$('navtoscroll').getSize().y)){
				$('navtoscroll').tween('top', ((window.getScroll().y)-314));
			}
			else if(window.getScroll().y<$('navtoscroll').getScrollSize().y && window.getScroll().y<(window.getScrollSize().y-$('navtoscroll').getSize().y)){
				$('navtoscroll').tween('top','0');
			}
		});
	}
	else if($('navtoscroll2')){
		var getIntSS = (window.getScrollSize().y-360);
		if(window.getScroll().y>=$('navtoscroll2').getScrollSize().y && window.getScroll().y<getIntSS){
				$('navtoscroll2').tween('top', ((window.getScroll().y)-314));
		}
		else if(window.getScroll().y<$('navtoscroll2').getScrollSize().y && window.getScroll().y<getIntSS){
			$('navtoscroll2').tween('top','0');
		}
		window.addEvent('scroll', function(){
			if(window.getScroll().y>=$('navtoscroll2').getScrollSize().y && window.getScroll().y<getIntSS){
				$('navtoscroll2').tween('top', ((window.getScroll().y)-314));
			}
			else if(window.getScroll().y<$('navtoscroll2').getScrollSize().y && window.getScroll().y<getIntSS){
				$('navtoscroll2').tween('top','0');
			}
		});
	}
});
var overlayLayer1 = null;
var overlayLayer2 = null;
function callOverlay(linkToCall, width, height){
	overlayLayer1 = new Element('div', {
		'class': 'overlaylayer1'
	}).inject(document.body, 'bottom');
	overlayLayer1.fade('hide');
	overlayLayer2 = new Element('div', {
		'class': 'overlaylayer2',
		'styles': {
			'width': width,
			'height': height,
			'margin': -(height/2)+'px 0 0 '+ -(width/2)+'px'
		}
	}).inject(overlayLayer1, 'after');
	overlayLayer2.fade('hide');
	overlayLayer1.fade(0.7);
	overlayLayer2.fade('in');
	var requestLinkToCall = new Request.HTML({
		url: linkToCall,
		evalScripts: true,
		evalResponse: true,
		onSuccess: function(html) { 
			overlayLayer2.set('html', requestLinkToCall.response.text);
			runOnLoad();
		}
	}).post();
}
function takeATour(){
	callOverlay('thetour.php',600,450);
}
function submitATestimonial(){
	callOverlay('submit.php',400,250);
}
function submitASkin(){
	callOverlay('submit2.php',400,470);
}
function deleteOverlay(){
	overlayLayer1.destroy();
	overlayLayer2.destroy();
}
function leaveOverlay(){
	overlayLayer1.fade('out');
	overlayLayer2.fade('out');
	deleteOverlay.delay(1000);
}
function downloaD(url){
if(confirm('You must accept the following before continuing:\nI am not going to use JF MP3 Player for commercial use.\n\nIf I want to use it for commercial use, I understand that I MUST purchase a license for the domain I plan to use JF MP3 Player under.\n\nClick "OK" if you agree.')){
	window.location = url;
}
else{
	alert('You must agree to our terms to download JF MP3 Player!');
}
}