function init_country_select(css_exp, button_names) {

	actual_buttons = {}
	actual_buttons[button_names.change_country] = function() {
		queryString = window.location.search;
		if (queryString.indexOf('current_country') >= 0) {
			queryString = queryString.replace(/current_country=\w\w/, 'current_country=' + $('#country_select_box').attr('value'));
		} else {
			queryString = '?current_country=' + $('#country_select_box').attr('value');
		}

		path = window.location.pathname;
		if (typeof(PAGE_REFRESH_PATH) == 'string') {
			path = PAGE_REFRESH_PATH;
		}
		window.location = path + queryString
	}
	
	actual_buttons[button_names.cancel] = function() {
		$(this).dialog('close');
	}

	$(css_exp).dialog({
		autoOpen: false,
		width: 500,
		draggable: false,
		resizable: false,
		bgiframe: true,
		modal: true,
		dialogClass: 'dialog_country_select',	
		buttons: actual_buttons
	});
	
}

/** 
 * cookie creating/reading functions
 * from http://www.quirksmode.org/js/cookies.html
 */
function createCookie(name,value,days) {
	var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		expires = "; expires=" + date.toGMTString();
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

