

var fontsIncrease = 1;
/**
 * Change size of all fonts on the page inside the tag with id "main_content_body".
 * Only tags with class "not_resize" and their children won't be resized even if they are in 
 * tag with id main_content_body.
 *
 * @param integer $fontSize The relative increase of fonts sizes.
 * @param object $e this (the dom object which was clicked)
 */
function changeFontSize(fontSize, e)
{
	//handle which link should have class active (was clicked and is black)
	var links = $('a.size_change');
	
	for (var i = 0; i < links.length; i++)
	{
		$(links[i]).removeClass('active');
	}
	
	$(e).addClass('active');

	//If the the size was changed before to 3, and now I want it to be resized to 4, the real incrementationo will be 1
	fontSize = fontSize - fontsIncrease;
	fontsIncrease += fontSize;
	
	//Changes font-size css property in each element in tag with id main_content_body
	$("#main_content_body *").each( function() {
		//skip elements that should not be resized
		if ( $(this).hasClass('not_resize') ) return;
		if ( $(this).parents('.not_resize').length > 0 ) return;
		
		//to avoid changing font-size property of tags which have no content
		var val = $(this).html();	
		val = jQuery.trim(val);		
		if ( (val[0] == '<') && (val[val.length-1] == '>') ) return;	//jQuery returns also inner tags,
																		//check if it's content arent only them				
		//change it's font-size
		var cssProp = $(this).css('font-size');
		var oldSize = cssProp.substr(0,cssProp.length-2);
		var newSize = (oldSize*1)+(fontSize*1);
		$(this).css('font-size', newSize+'px');
	 }
	);
}

//------------------------------------------------------

/**
 * show/hide window to send a link to current page to a friend
 *
 * @param object $e clicked link
 * @param string $url what ajax should call
 */
function sendALinkToFriend(e, url)
{
	if ($('#ajax_div_send_link_friend').length)
	{
		$('#ajax_div_send_link_friend').remove();
		return;
	}

	var newDiv = document.createElement('div');
	$('#c_column').prepend(newDiv);
	
	newDiv.setAttribute("id", "ajax_div_send_link_friend");

	$.ajax({ 
		type: "POST", 
		url: url,
		data: $("#form_send_link_friend_initial").serialize(),
		dataType: "html", 
		success: ajaxLoading("#ajax_div_send_link_friend"),
		complete: function(requestObject, successType){ 
			$("#ajax_div_send_link_friend").html(requestObject.responseText);
		} 
	});
}

//------------------------------------------------------

//what to show while loading the new data via ajax
function ajaxLoading(divName)
{
	$(divName).html('<p class="loading">' + js_text_ajax_loading + '</p>');
}

//------------------------------------------------------

/*
 * send a form via ajax
 *
 * @param string $formId id of form which will be serialized and sent via ajax
 * @param string $url where the form will be sent
 * @param string $divId in which element the result should appear
 */
function sendFormGeneral(formId, url, divId)
{
	$.ajax({ 
		type: "POST", 
		url: url,
		data: $("#" + formId).serialize(),
		dataType: "html", 
		success: ajaxLoading("#" + divId),
		complete: function(requestObject, successType){ 
			$("#" + divId).html(requestObject.responseText);
		} 
	});
	
	return false;
}


//------------------------------------------------------

/**
 * show/hide window to send a link to current page to a friend
 *
 * @param object $e clicked link
 * @param string $url what ajax should call
 */
function showCaptchaForm(e, url, element_id, names)
{
	elem = document.getElementById('show_button');
	box = document.getElementById('show_button_box')
	if ($('#ajax_div_captcha_form').length)
	{
		$('#ajax_div_captcha_form').remove();
		elem.innerHTML = names[0];
		box.style.paddingRight = '200px';
		email = document.getElementById('email_address');
		email.innerHTML = '';
		return;
	}

	var newDiv = document.createElement('div');
	$('#'+element_id).prepend(newDiv);
	
	newDiv.setAttribute("id", "ajax_div_captcha_form");
	elem.innerHTML = names[1];
	
	$.ajax({ 
		type: "POST", 
		url: url,
		data: $("#form_captcha_form_initial").serialize(),
		dataType: "html", 
		success: ajaxLoading("#ajax_div_captcha_form"),
		complete: function(requestObject, successType){ 
			$("#ajax_div_captcha_form").html(requestObject.responseText);
		} 
	});
}


