/* Cufon Replace */
function cufonReplace() {
   Cufon.replace('.AvantGarde', { fontFamily: 'AvantGarde Md BT' });
}

// function to toggle the "share" button in and out
function toggleShare() {
    $("#shareIt").slideToggle('slow');
}

// "send" Message lightbox function.
function sendMessage() {        
	$('#sendToFriendDiv').modal({
		overlayClose: true,
		overlayCss: {backgroundColor:'#06204e'},
		escClose: true,
		onClose: function() {
			// reload modal on close, so that cufon doesn't break
            top.location.href = top.location.href;
		},
		minHeight: 200, // was 300
		minWidth: 440, // was 500
		maxWidth: 600 // was 500
    });	
}

// "send" Message ajax call function on the lightbox.
function submitSendMessage() {
	$('#sendMessageForm').validate();
	if ($('#sendMessageForm').valid()) {
		// ajax post the form
		$('#sendMessageForm').ajaxSubmit({
			url: "/includes/send_message.php",
			dataType: 'json',
			success: function(data) {
				if (data.status || data.status == 'true' || data.status == '1') {
					// success, show confirmation .div and hide form.
					$('#friendForm').hide();
					$('#friendConfirmation').show();
                    // make box smaller to clear the white space
                    $('#simplemodal-container').css('height','100px').css('top','238px');
					
					  _gaq.push(['_trackPageview', '/send-to-friend-confirmation/']);
				} else {
					// alert errors
					alert(data.error);
				}
			}
		});
	}
}

$(document).ready(function(){
    // run cufon
    cufonReplace();
	// pngFix for IE 5.5, 6 and 7
	if ($.browser.msie && ($.browser.version === '5.5' || $.browser.version === '6.0')) {
        $(document).pngFix();
	}
});
