var FDN_ALL_LINKS = '';

function fdn_load_all(ref_id)
{
	fdn_run_scan();
	fdn_pop(FDN_ALL_LINKS,ref_id);
}
	
function fdn_pop(url,ref_id)
{
	if ( (/filedownloader/i.test( navigator.userAgent.toLowerCase()) ) || ((/fdnet/i.test( navigator.userAgent.toLowerCase()) )))
	{
		if ( url != '' ){
		document.location.href='fdn://filedownloader.net/?'+url;
		alert('Links passed to the Filedownloader Program!');
		}
		else{
		alert('There are no supported links on this page!');
		}
	}
	else
	{
		if (confirm("Your system does not have Filedownloader installed to use this button.\n\r\n\r"+
					"Do you want to visit official Filedownloader`s site to download latest version?"))
		{
			document.location.href = 'http://filedownloader.net/'+(ref_id ? ref_id+'/' : '');
		}
	}
	return false;
}

function fdn_run_scan()
{
	var s = '';
	for (i in document.getElementsByTagName('A'))
	{
		var el = document.getElementsByTagName('A')[i];
		var link = el.href;
		if (
			( /^http:\/\/([\s\S]+\.)?rapidshare\.com\//i.test( link ) ) ||
			( /^http:\/\/([\s\S]+\.)?rapidshare\.de\//i.test( link ) ) ||
			( /^http:\/\/([\s\S]+\.)?megaupload\.com\//i.test( link ) ) ||
			( /^http:\/\/([\s\S]+\.)?megarotic\.com\//i.test( link ) ) ||
			( /^http:\/\/([\s\S]+\.)?sendspace\.com\//i.test( link ) )  ||
			( /^http:\/\/([\s\S]+\.)?depositfiles\.com\//i.test( link ) ) 
		)
		{
			s += ( s != '' ? ';' : '')+link;
		}
	}
	FDN_ALL_LINKS = s;
}
