DOMAssistant.DOMReady(function() {
	
	if ($$('title_other')) {
		$$('title_other').setStyle({'display': 'none'});
	}
	if ($$('title_other1')) {
		$$('title_other1').setStyle({'display': 'none'});
	}
	if ($$('representative_title_other')) {
		$$('representative_title_other').setStyle({'display': 'none'});
	}
	if ($$('your_title_other')) {
		$$('your_title_other').setStyle({'display': 'none'});
	}

	var msglength = 100;
	
	if ($$("gift_message")) {
		$$("gift_message").value = '';
	}
	if ($$("joint_details")) {
		$$("joint_details").setStyle({'position': 'absolute', 'left': '-9999em', 'height': '0'});
		$("div#content input.joint").each(function () {
			$(this).addEvent("click", function() {
				$$("joint_details").setStyle({'display': 'block', 'position': 'relative', 'left': '0', 'height': 'auto'});
			})
		});
		
		$("div#content input.single").each(function () {
			$(this).addEvent("click", function() {
				$$("joint_details").setStyle({'position': 'absolute', 'left': '-9999em', 'height': '0'});
			})
		}); 
	}
	
	if ($$('gift_message')) {
		$$('gift_message').addEvent("keyup", function() {
			var currentmsglength = $(this).value.length;
			var charsleft = msglength-currentmsglength;
			if ( charsleft == 0 ) {
				$(this).value = $(this).value.substring(0, msglength);
				$$('num_chars').innerHTML = charsleft + " - you have reached the maximum amount of characters allowed";
			} else if ( charsleft < 0 ) {
				charsleft = 0;
				$(this).value = $(this).value.substring(0, msglength);
				$$('num_chars').innerHTML = charsleft + " - you have reached the maximum amount of characters allowed";
			} 
			else {
				$$('num_chars').innerHTML = charsleft;
			}
		});
	}
	
	if ($$('title')) {
		$$('title').addEvent('change', function () {
			if ($(this).value.toLowerCase() == 'other') {
				$$('title_other').value = '[Enter title here]';
				$$('title_other').setStyle({'display': 'block', 'color': '#555555'});
				$$('title_other').addEvent('focus', function () {
					if ($(this).value == '[Enter title here]') {
						$(this).setStyle({'color': '#000000'});
						$(this).value = '';
					} 
				});
				$$('title_other').addEvent('blur', function () {
					if ($(this).value == '') {
						$(this).setStyle({'color': '#555555'});
						$(this).value = '[Enter title here]';
					} 
				});
			} else {
				$$('title_other').setStyle({'display': 'none'});
			}
		});
	}
	
	if ($$('title1')) {
		$$('title1').addEvent('change', function () {
			if ($(this).value.toLowerCase() == 'other') {
				$$('title_other1').value = '[Enter title here]';
				$$('title_other1').setStyle({'display': 'block', 'color': '#555555'});
				$$('title_other1').addEvent('focus', function () {
					if ($(this).value == '[Enter title here]') {
						$(this).setStyle({'color': '#000000'});
						$(this).value = '';
					} 
				});
				$$('title_other1').addEvent('blur', function () {
					if ($(this).value == '') {
						$(this).setStyle({'color': '#555555'});
						$(this).value = '[Enter title here]';
					} 
				});
			} else {
				$$('title_other1').setStyle({'display': 'none'});
			}
		});
	}
	
	if ($$('your_title')) {
		$$('your_title').addEvent('change', function () {
			if ($(this).value.toLowerCase() == 'other') {
				$$('your_title_other').value = '[Enter title here]';
				$$('your_title_other').setStyle({'display': 'block', 'color': '#555555'});
				$$('your_title_other').addEvent('focus', function () {
					if ($(this).value == '[Enter title here]') {
						$(this).setStyle({'color': '#000000'});
						$(this).value = '';
					} 
				});
				$$('your_title_other').addEvent('blur', function () {
					if ($(this).value == '') {
						$(this).setStyle({'color': '#555555'});
						$(this).value = '[Enter title here]';
					} 
				});
			} else {
				$$('your_title_other').setStyle({'display': 'none'});
			}
		});
	}
	
	if ($$('representative_title')) {
		$$('representative_title').addEvent('change', function () {
			if ($(this).value.toLowerCase() == 'other') {
				$$('representative_title_other').value = '[Enter title here]';
				$$('representative_title_other').setStyle({'display': 'block', 'color': '#555555'});
				$$('representative_title_other').addEvent('focus', function () {
					if ($(this).value == '[Enter title here]') {
						$(this).setStyle({'color': '#000000'});
						$(this).value = '';
					} 
				});
				$$('representative_title_other').addEvent('blur', function () {
					if ($(this).value == '') {
						$(this).setStyle({'color': '#555555'});
						$(this).value = '[Enter title here]';
					} 
				});
			} else {
				$$('representative_title_other').setStyle({'display': 'none'});
			}
		});
	}
});