$(document).ready(function() {
	$("#country").val(countryId);
	$("#country").change(function(){ showNextField(); });
});


function showNextField()
{
	switch( $("#country").children(":selected").val() )
	{
                case "0": // none selected
                        $("#fieldcity").hide();
                        $("#fieldzip").hide();
                        break;
                case "39": // canada
                        $("#fieldcity").hide();
                        $("#fieldzip").slideDown();
                        $("#city").attr("disabled", true);
                        $("#postalCode").removeAttr("disabled");
                        $("#fieldzip label").text("Postal Code:");
                        break;
                case "77": // UK
                        $("#fieldcity").hide();
                        $("#fieldzip").slideDown();
                        $("#city").attr("disabled", true);
                        $("#postalCode").removeAttr("disabled");
                        $("#fieldzip label").text("Post Code:");
                        break;
                case "231": // USA
                        $("#fieldcity").hide();
                        $("#fieldzip").slideDown();
                        $("#city").attr("disabled", true);
                        $("#postalCode").removeAttr("disabled");
                        $("#fieldzip label").text("Zip Code:");
                        break;
                default: // all others: show city field  
                        $("#fieldzip").hide();
                        $("#fieldcity").slideDown();
                        $("#postalCode").attr("disabled", true);
                        $("#city").removeAttr("disabled");
	}
}

/**
 * Popup window
 */
var newwindow = new Object();
var newwindowOldWidth = new Object();
var newwindowOldHeight = new Object();

function popUp(loc, imgWidth, imgHeight, boolScrollbars)
{
	strName = "Mate1Information";

	imgWidth = parseInt(imgWidth);
	imgHeight = parseInt(imgHeight);
	
	if (newwindow[strName] && !newwindow[strName].closed && newwindow[strName].location) {
		newwindow[strName].location.href = loc;
		var tmpWidth = imgWidth - newwindowOldWidth[strName];
		var tmpHeight = imgHeight - newwindowOldHeight[strName];
		newwindowOldWidth[strName] += tmpWidth;
		newwindowOldHeight[strName] += tmpHeight;
	} else {
	
		var width = screen.width;
		var height = screen.height;
							
		var winLeft = ((width - imgWidth) / 2);
		var winTop = ((height - imgHeight) / 2);
		
		newwindow[strName]=window.open(loc, strName, 'height='+imgHeight+',width='+imgWidth+',left='+winLeft+',right='+winTop+',location=0,scrollbars='+boolScrollbars+',menubar=0,toolbar=0,resizable=0');
		// if (!newwindow.opener) newwindow.opener = self;
		newwindowOldWidth[strName] = imgWidth;
		newwindowOldHeight[strName] = imgHeight;
	}
	if (window.focus) {newwindow[strName].focus()}
	return false;
}

