function Country(code,name){

    //Methods
    this.addedToGroup       = _addedToGroup;
    this.setSelected        = _setCountrySelected;
    this.isSelected         = _isCountrySelected;
    this.displayCountry     = _displayCountry;

    //Properties
    this.name = name;
    this.code = code;
    this.parentGroups       = new Array();
    this.hidden_selected    = false;

}
function _addedToGroup(group){
    for( var i=0; i< this.parentGroups.length; i++){
        if( this.parentGroups[i].code == group.code)
            return;
    }
    this.parentGroups.push(group);
}
function _setCountrySelected(selected){
    this.hidden_selected = selected;
    this.displayCountry();
}
function _isCountrySelected(){
    return this.hidden_selected;
}

function _displayCountry(){
    //From the list fo parent groups. check which ones are selected, and
    //It sets its color accordingly.

    var selectedParentGroups = new Array();

    for( var i=0; i<this.parentGroups.length; i++){
        if(this.parentGroups[i].isSelected()){
            selectedParentGroups.push(this.parentGroups[i]);
        }
    }

    var countryPath = SVGDocument.getElementById(this.code);
    if( ! countryPath)
        return;

    if(selectedParentGroups.length == 0){
        //No selected parent groups
        countryPath.setAttribute('style',DefaultCountryStyle);
        return;
    }
    //If this country is part of more than one selected Groups, a commun
    // stroke and stroke-width and a pattern is used.
    // Other wise the fill color, stroke-width and stroke for the selected
    // group is used.

    var patternColors = new Array();
    for( var i=0; i< selectedParentGroups.length;i++){
        //get the list of colors to create the pattern
        patternColors.push(selectedParentGroups[i].getSelectedColor());
    }

    var pattern = "url(#"+getPattersName(patternColors) +")";

    if( selectedParentGroups.length == 1){
        countryPath.setAttribute('style',selectedParentGroups[0].getStyle());
    }else{
        countryPath.setAttribute('style',"fill:"+pattern+";stroke:blue;stroke-width:10");
    }
}
