// JavaScript Document
document.write('<style type="text/css">body{display:none}</style>');

$(document).ready(function() {
	
	$('style[type=text/css]').remove();
						   
	$('div.md_mid div:first').addClass('drop');
	$('form div.tld').css('display', 'block');
	$('div.tld p').addClass('light');
	
	closetld = false;
	
	$('div.tld').click( function() {
		$('form div.list').fadeIn('fast', function() {
			closetld = true;
			$(document).bind('keyup', function(e) {
				if (e.which == 27) {
					$('form div.list').fadeOut('fast');
					$(document).unbind('keyup');
					closetld = false;
				}
			});
		});
	});
	
	$('body *').not('div.list', 'div.list ul', 'div.tld *', 'div.tld').click( function() {
		if ( closetld == true ) {
			$('form div.list').fadeOut('fast');
			$(document).unbind('keyup');
			closetld = false;
		}
	});
	
	$('div.list ul li').hover( function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	$('div.list ul li').click( function() {
		var tld = $(this).attr('title');
		var ptld = $(this).html();
		$('input[name=tld]').val(tld);
		$('div.tld p').html(ptld).removeClass('light');
		$(document).unbind('keyup');
		$('form div.list').fadeOut('fast');
	});
						   
	$('input#mdn_domain').addClass('light').val('enter a domain');

	$('input#mdn_domain').focus(function() {
		if($(this).val()=='enter a domain') {
		$(this).val("");
		$(this).removeClass('light');
		}
	});

	$('input#mdn_domain').blur(function() {
		if($(this).val()=="") {
			$(this).val('enter a domain');
			$(this).addClass('light');
		}
	});

	$('input#mdn_submit').hover( function() {
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});

// This function gets the affiliate ID for the affiliate program

	var AID = '';
	var PID = '';
	var campn = '';
	var referer = '';
	
	if (jQuery.url.param('AID')) { AID = jQuery.url.param('AID').replace(/[^a-zA-Z0-9]/,''); }
	if (jQuery.url.param('aid')) { AID = jQuery.url.param('AID').replace(/[^a-zA-Z0-9]/,''); }
	if (jQuery.url.param('PID')) { PID = jQuery.url.param('PID').replace(/[^a-zA-Z0-9]/,''); }
	if (jQuery.url.param('pid')) { PID = jQuery.url.param('pid').replace(/[^a-zA-Z0-9]/,''); }
	if (jQuery.url.param('campn')) { campn = jQuery.url.param('campn').replace(/[^a-zA-Z0-9]/,''); }
	if (jQuery.url.param('refid')) { referer = escape(jQuery.url.param('refid')+';'+document.referrer+';20788'); }

	if ( AID != '' || PID != '' || campn != '' || referer != '' ) {
		$('body').append('<img src="https://secure.mydomain.com/affiliate.php?aid='+AID+'&pid='+PID+'&url='+referer+'&src_campn='+campn+'" alt="" style="position: absolute; width: 1px; height: 1px;" />');
	}

});