
        function Port(pNO, pName, pOwner, pX, pY, pNotes) {
            this.outerIsSelected = false;
            this.innerIsSelected = false;
            this.portname = pName;
            this.portowner = pOwner;
            this.portID = pNO;
            this.nationimage = '';
            this.portno = pNO;
            this.flagurl = '';
            this.x = pX;
            this.y = pY;
            this.notes = pNotes;
            this.resources = new Array();
            function constructstring() {
	            var html='<table style="width: 100%; padding: 1px;"><tr><td><strong>' + this.portname + '</strong></td><td style="float: right;"><img src="'+nationflags[this.portowner]+'"></td><tr><td colspan="2">Resources:</tr></td>';
                for (x=0; x<this.resources.length; x++)
                {
                    if (this.resources[x] !== '' && this.resources[x]) {
                        html = html + '<tr><td style="height: 12px;" colspan="2">'+this.resources[x].returnAsString()+'</td></tr>';
                    }
                }
                if (EDITABLE) {
                    html = html + '<tr><td style="text-align: right;">(Click Port to Edit)</a></td></tr></table>';
                }
                html = html + '</table>';
                return html;
            }
            this.returnAsString = constructstring;
            function pedit() {
           		document.getElementById('portname').innerHTML = this.portname;
            	document.getElementById('portowner').innerHTML = '<img src=\''+this.flagurl+'\' \/>';
            	document.getElementById('portnotes').value  = this.notes;
            	for (var i=0; i < document.getElementById('dropNationSelect').length; i++) {
            	    if (document.getElementById('dropChangeNation')[i].text == this.portowner) {
                        document.getElementById('dropChangeNation')[i].selected = true;
                    }
                }
				var strPorts = '<table style="width: 100%; border: solid 0px; padding: 0px">';
				strPorts = strPorts + '<tr>';
				strPorts = strPorts + '<td style="width: 34%; text-align: left;"><strong>Resources</strong></td>';
				strPorts = strPorts + '<td style="width: 33%; text-align: center;"><strong>Price</strong></td>';
				strPorts = strPorts + '<td style="width: 33%; text-align: center;"><strong>Last Updated</strong></td>';
				strPorts = strPorts + '</tr>';
				for (x=0; x<this.resources.length; x++)
				{
					strPorts = strPorts + '<tr>';
					strPorts = strPorts + '<td style="width: 33%; text-align: left;">'+this.resources[x].name+'</td>';
					strPorts = strPorts + '<td style="width: 33%; text-align: center;"><input type="text" class="text_1" onkeydown="javascript:SetPortEdited()" style="width: 40px; height: 12px" value="'+this.resources[x].price+'" id=txtRes'+x+' /></td>';
					strPorts = strPorts + '<td style="width: 33%; text-align: center;">'+this.resources[x].lastupdated+'</td>';
					strPorts = strPorts + '</tr>';

				}
				strPorts = strPorts + '</table>'
				document.getElementById('portresources').innerHTML  = strPorts;
			}
            this.portedit = pedit; 
            function checkForResource(resId) {
                resourceFound = false;
                for (x=0; x<this.resources.length; x++)
                {
                    if (this.resources[x].userResID == resId) {
                       resourceFound = true;
                    }
                }
                return resourceFound;
            }
            this.hasResource = checkForResource;
            function getResourcePrice(resName) {
                rp = -1;
                for (m=0; m<this.resources.length; m++)
                {
                    if (this.resources[m].name == resName) {
                       rp = this.resources[m].price;
                    }
                }
                return rp;
            }
            this.returnResourcePrice = getResourcePrice;
            function addPortToAMap(map) {
                var newdiv = document.createElement('div');
                var divIdName = map+'port'+this.portno;
                newdiv.setAttribute('id',divIdName);
                newdiv.onmouseover=new Function("showPortPopup("+this.portno+", '"+map+"')");
                newdiv.onmouseout=new Function("hidePortPopup('"+map+"')");
                newdiv.onmousedown=new Function("selectPort(\'"+map+"\',\'"+ this.portno + "\')");
                //newdiv.innerHTML = '<img src="'+imgName+'" style="position: absolute;left: '+DIV_INNER_BORDER_OFFSET+'px; top: '+DIV_INNER_BORDER_OFFSET+'px;" id="pImg'+x+'">';
                newdiv.style.position = 'absolute';
                newdiv.style.z = 50;
                newdiv.style.lineHeight = '1px';
            	newdiv.style.backgroundColor = nationcolors[this.portowner];
            	if (map == 'smallmap') {
   	            newdiv.style.left = (this.x-2)+'px';
                    newdiv.style.top = (this.y-2)+'px';
                    newdiv.style.width= SMALLMAP_PORT_IMAGE_SIZE+'px';
                    newdiv.style.height = SMALLMAP_PORT_IMAGE_SIZE+'px';
                }
                else {
                    var num;
                    num = (this.x / 100) * 140;
   	            newdiv.style.left = (num-4)+'px';
   	            num = (this.y / 100) * 140;
                    newdiv.style.top = (num-4)+'px';                
                    newdiv.style.width= LARGEMAP_PORT_IMAGE_SIZE+'px';
                    newdiv.style.height = LARGEMAP_PORT_IMAGE_SIZE+'px';
                    
                }
                document.getElementById(map).appendChild(newdiv);                                        
            }
            this.addPortToMap = addPortToAMap;
            function selectThisPort(map, selectType) {
            	this.outerIsSelected = true;
            	var top = document.getElementById(map+'port'+this.portno).style.top;
		top = parseInt(String(top).substring(0,top.length-2));
		var left = document.getElementById(map+'port'+this.portno).style.left;
		left = parseInt(String(left).substring(0,left.length-2));            	
		if (map == 'smallmap') {
			top = top - 13;
			left = left - 13;
		}
		else {
			top = top - 11;
			left = left - 11;
		}            	

                var newdiv = document.createElement('div');
		var divIdName = map+'portSelect'+this.portno;
                newdiv.setAttribute('id',divIdName);
                if (selectType == 'inner') {
                	newdiv.style.background = "url('images/portSelect.png')";	
                }
                else {
                	newdiv.style.background = "url('images/resourceSelect.png')";
                }
                newdiv.style.left = left+'px';
                newdiv.style.top = top+'px';
                newdiv.style.z = 2;
                newdiv.style.width= '30px';
                newdiv.style.height = '30px';
                newdiv.style.position = 'absolute';
                document.getElementById(map).appendChild(newdiv); 
                //alert()
                
                
            }
            this.selected = selectThisPort;
            function deselectThisPort(map, selectType) {
            	this.outerIsSelected = false;
            	var divIdName = map+'portSelect'+this.portno;
		var d = document.getElementById(map);
		var olddiv = document.getElementById(divIdName);
		d.removeChild(olddiv);
		
	    }
            this.deselected = deselectThisPort;
        }

        
