var _request_path = './request/';
var required_border = '1px solid #e10500';
var lang = readCookie('lang');


$(document).ready(function() {

	$('.fb_share_count').hide();
	
	//manage login
	$('#loginBox input[name=login_username]').click(function() {
		if ($(this).val() == 'Username') 
			$(this).val('');
	})
	
	$('#loginBox input[name=login_password]').click(function() {
		if ($(this).val() == 'Password') 
			$(this).val('');
	})
	
	var web_referrer = replaceText(document.referrer);
	<!--
	istat = new Image(1, 1);
	istat.src = "http://www.madonnamedjugorje.com/stats/counter.php?sw=" + screen.width + "&sc=" + screen.colorDepth + "&referer=" + web_referrer + "&page=" + location.href;
	//-->
	
	//select country
	$('#mainColumn select[name=country_id]').change(function() {
		var country_id = $(this).val();
		
		//solo per Italia, Canada e USA
		if (country_id == 1 || country_id == 32 || country_id == 186) {
			$.ajax({
				type: 'POST',
				url: _request_path + 'fetch_region.request.php',
				data: 'country_id=' + country_id,
				success: function(msg) {
					//set the new list of regions and provinces
					$('#mainColumn select[name=region_id]').html(msg);
					if (country_id == 1) 
						$('#mainColumn select[name=province_id]').html('<option value="">---</option>');
					else 
						$('#mainColumn select[name=province_id]').html('<option value="">N/A</option>');
				}
			});
		}
		else {
			//disable regions and provinces
			$('#mainColumn select[name=region_id]').html('<option value="">N/A</option>');
			$('#mainColumn select[name=province_id]').html('<option value="">N/A</option>');
		}
		
	});
	
	//select region change
	$('#mainColumn select[name=region_id]').change(function() {
		var region_id = $(this).val();
		
		$.ajax({
			type: 'POST',
			url: _request_path + 'fetch_province.request.php',
			data: 'region_id=' + region_id,
			success: function(msg) {
				//set the new list of provinces
				$('#mainColumn select[name=province_id]').html(msg);
			}
		});
		
	});
	
	//select country
	$('#leftColumn select[name=country_id]').change(function() {
		var country_id = $(this).val();
		
		//solo per Italia, Canada e USA
		if (country_id == 1 || country_id == 32 || country_id == 186) {
			$.ajax({
				type: 'POST',
				url: _request_path + 'fetch_region.request.php',
				data: 'country_id=' + country_id,
				success: function(msg) {
					//set the new list of regions and provinces
					$('#leftColumn select[name=region_id]').html(msg);
					$('#leftColumn select[name=province_id]').html('<option value="">---</option>');
				}
			});
		}
		else {
			//disable regions and provinces
			$('#leftColumn select[name=region_id]').html('<option value="">N/A</option>');
			$('#leftColumn select[name=province_id]').html('<option value="">N/A</option>');
		}
		
	});
	
	//select region change
	$('#leftColumn select[name=region_id]').change(function() {
		var region_id = $(this).val();
		
		$.ajax({
			type: 'POST',
			url: _request_path + 'fetch_province.request.php',
			data: 'region_id=' + region_id,
			success: function(msg) {
				//set the new list of provinces
				$('#leftColumn select[name=province_id]').html(msg);
			}
		});
		
	});
	
});



