var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	function recommend_section_close() {
			$('#recommend_overlay').hide();
			$('#recommend_section').hide();
			$('#recommend_content_bg').hide();
			$('#disclaimer_link').replaceWith('<div id=\"disclaimer_link\" onclick=\"addDisclaimer();\">' + disclaimer + '</div>');

            if ($('#required_fields').text()!='') {
					$('#required_fields').empty();
				}
			$('#required_fields').append(required_fields);
		}
		function recommend_section() {
 			var arrayPageSize = getPageSize();
			leftOffset = arrayPageSize[0]/2 - 105;
			$('#recommend_content_bg').css({'left':leftOffset + 'px'});
			$('#recommend_section').css({'left':leftOffset + 'px'});

            $('#recommend_overlay').show().animate({opacity: 0.5}, 'normal', function(){
                    $('#recommend_content_bg').fadeIn('normal');
                    $('#recommend_section').fadeIn('normal');

            });

			$('#button_submit').mouseover(function(){
            	this.className='submit_button_hover';})
			.mouseout(function(){
                this.className='submit_button';
            });
			$('#button_submit').mouseout = function(){this.className='submit_button'};
			$('#sender_name').blur(function () { if ( '' == this.value ) { this.value = your_name;}});
			$('#sender_name').focus(function () {if ( your_name == this.value ) { this.value = '';}});
			$('#recipient_name').blur(function () {if ( '' == this.value ) { this.value =your_friends_name ;}});
			$('#recipient_name').focus(function () {if( your_friends_name == this.value ) { this.value = '';}});
			$('#recipient_email').blur(function () {if ( '' == this.value ) { this.value = your_friends_email;}});
			$('#recipient_email').focus(function () {if( your_friends_email == this.value ) { this.value = '';}});
			$('#recipient_message').blur(function () {if ( '' == this.value ) { this.value = message;}});
			$('#recipient_message').focus(function () {if( message == this.value ) { this.value = '';}});
			if (arrayPageSize[1] < $('#wrapperNoShadow').clientHeight) {
				$('#recommend_overlay').css({'width':arrayPageSize[0] + 'px', 'height': $('#wrapperNoShadow').clientHeight + 'px' });
			} else {
				$('#recommend_overlay').css({'width': arrayPageSize[0] + 'px', 'height':arrayPageSize[1] + 'px' });
			}
		}
		function addDisclaimer() {
				$('#disclaimer_link').replaceWith('<div id=\"disclaimer_link\" onclick=\"removeDisclaimer();\">' + disclaimer + '<p id=\"disclaimer\">' + disclaimer_description + '</p></div>');
		}
		function removeDisclaimer() {
				$('#disclaimer_link').replaceWith('<div id=\"disclaimer_link\" onclick=\"addDisclaimer();\">' + disclaimer + '</div>');
		}
		function validateFields() {
			sender_name = $('#sender_name').val();
			recipient_name = $('#recipient_name').val();
			recipient_email = $('#recipient_email').val();
			recipient_message = $('#recipient_message').val();

			if ((recipient_email.length == 0)||(!recipient_email.match(re))) {

            if ($('#required_fields').text!='') {
					$('#required_fields').empty();
				}
				$('#required_fields').append(valid_email);
			}

			if ((recipient_email != your_friends_email )&&((recipient_email.length != 0)&&(recipient_email.match(re)))) {
	  			var param = new Object();
				param.recipientMail = recipient_email;
				if ((sender_name != '') && (sender_name !=your_name)) {
					param.senderName = sender_name;
				}
				if ((recipient_name != '') && (recipient_name != your_friends_name )) {
					param.recipientName = recipient_name;
				}
				if ((recipient_message != '') && (recipient_message != message)) {
					param.recipientMessage = recipient_message;
				}
                param.pageRecommend = escape(window.location);

                if ('pageRecommendURL' in window) {
	                if ((pageRecommendURL != '')&&(pageRecommendURL != undefined)) {
		                param.pageRecommend = escape(pageRecommendURL);
	                }
                }
				$('#indicator_green').show();
                $.ajax({
                    type: "POST",
                    url: page_recomend,
                    data: param,
                    success: function(transport){
						hideIndicator(); 
						recommend_section_close();
				    },
                    error: function(){
						hideIndicator(); 
                        alert(send_error);
                    }
                });

			}
		}

