// Calls all neccessary functions on document ready state

$(document).ready(function()
{
	/* DEACTIVATED
	// footer always at the bottom of the site
	var footer_height	= 30;
	var content_height = $(window).height() - footer_height;
	// override firefox display bug
	if($.browser.mozilla)
	{
		$('#footer-container').css('bottom', '-4px');
	}
	$('#site-wrapper').css('height', content_height);
	*/
	
	$("div[id^='charity_sel_']").click(function()
	{
    	var id 		= parseInt(this.id.replace('charity_sel_', ''));
		var old_id	= parseInt($('#charity_selected').val());
		$('#charity_sel_' + old_id).removeClass('selected_charity');
   		$('#charity_sel_' + old_id).addClass('charity-item');
		$('#charity_sel_' + id).removeClass('charity-item');
    	$('#charity_sel_' + id).addClass('selected_charity');
		$('#charity_selected').val(id);
	});
	
	$('#login-dummy-text').click(function()
	{
		$(this).remove();
		$('#login_user').focus();
	});
	
	/* DEACTIVATED
	$(window).resize(function()
	{
		// footer always at the bottom of the site
		var footer_height	= 30;
		var content_height = $(window).height() - footer_height;
		// override firefox display bug
		if($.browser.mozilla)
		{
			$('#footer-container').css('bottom', '-4px');
		}
		$('#site-wrapper').css('height', content_height);
	});
	*/
	
	/* DEACTIVATED
	// set charity image vertically centered (if chartity start page is active)
	if ( typeof $('#inner_charity_logo').height() !== "undefined" && $('#inner_charity_logo').height())
	{
		var cImgHeight = $('#inner_charity_logo').height();
		var cImgWrapper = $('#charity_logo_wrapper').height();
		var cImgTop	= ((cImgWrapper - cImgHeight) / 2);
		$('#inner_charity_logo').css('margin-top', cImgTop);
	}
	
	$('#index-charity-container img').scaleImage({
        scale: 'fit',
        center: true});
	
	$('#charity_logo_wrapper img').scaleImage({
        scale: 'fit',
        center: true});
	*/
	
	$('.active-country li a').click(function()
	{
		if ($('.active-country li a.country-link').hasClass('open'))
		{
			$('#country-selector').stop().animate({height: '25px'}, 1000);
			$('.active-country li a.country-link').removeClass('open');
		}
		else
		{
			$('#country-selector').stop().animate({height: '120px'}, 1000); // 200px
			$('.active-country li a.country-link').addClass('open');
		}
	});
	
	$('#clear-search').click(function() {
		window.location.href = $('#page-url').val();
	});
	
	$('#sppadgsf').focusin(function() {
		var stdtext = $('#sppadgsf').val();
		$('#sppadgsf').val('');
	});
	$('#sppadgsf').focusout(function () {
		if ($('#sppadgsf').val() == '')
		{
			$('#sppadgsf').val($('#sppadgsfstd').val());
		}
	});
	
	
});
