var region = null;

function selectRegion() {
    if (region) {
        var regionSelect = document.getElementById('region');
   
        for (i=0; i < regionSelect.options.length; i++) {
            if (regionSelect.options[i].value == region) {
                 regionSelect.options[i].selected = true;
            } else {
                 regionSelect.options[i].selected = false;
            }
        }
    } 
}

function changeRegion(regionSelect, newLoc) {
	var expiry = new Date();
	expiry.setTime(expiry.getTime() + 365*24*60*60*1000);

    jQuery.cookie( 'region', regionSelect.value, {"expires":expiry.toGMTString(), "path":'/'});
    if(newLoc != null){
    	document.location = newLoc;
    }
}


jQuery(document).ready(

	/*
	This function gets loaded when all the HTML, not including the portlets, is
	loaded.
	*/

	function() {
		
	}
);

Liferay.Portlet.ready(

	/*
	This function gets loaded after each and every portlet on the page.

	portletId: the current portlet's id
	jQueryObj: the jQuery wrapped object of the current portlet
	*/

	function(portletId, jQueryObj) {
	}
);

jQuery(document).last(

	/*
	This function gets loaded when everything, including the portlets, is on
	the page.
	*/

	function() {
	}
);
