﻿//******************************************************************************
// Author: Craig Andrews
// Date: 1/15/2007
// File: RunEzDataTypes.js
// Description: Defines all marker classes and methods (such as serializeToXml() and className)
//******************************************************************************

function copyPrototype(descendant, parent) {
    var sConstructor = parent.toString();
    var aMatch = sConstructor.match( /\s*function (.*)\(/ );
    if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }
    for (var m in parent.prototype) {
        descendant.prototype[m] = parent.prototype[m];
    }
};

function getNodeValue(tag,nodeName) {
    if(tag.getElementsByTagName(nodeName)[0] && tag.getElementsByTagName(nodeName)[0].firstChild){
        return tag.getElementsByTagName(nodeName)[0].firstChild.nodeValue;
    }else{
        return null;
    }
}

/*Define User*/
function User(){

}
User.prototype.className="User";
User.prototype.id=null;
User.prototype.email=null;
User.prototype.nickName=null;
User.prototype.passwordSalt=null;
User.prototype.passwordHash=null;
User.prototype.firstName=null;
User.prototype.lastName=null;
User.prototype.country=null;
User.prototype.optedIn=null;
User.prototype.postalCode=null;
User.prototype.gender=null;
User.prototype.birthDate=null
User.prototype.cellPhoneNumber=null;
User.prototype.aboutMe=null;
User.prototype.created=null;
User.prototype.myWebsite=null;
User.prototype.runEasyMeaning=null;
User.prototype.openId=null;
User.deserializeFromXml = function(tag){
    var o = new User();
    o.id = getNodeValue(tag,"Id");
    o.email = getNodeValue(tag,"Email");
    o.nickName = getNodeValue(tag,"NickName");
    o.passwordSalt = getNodeValue(tag,"PasswordSalt");
    o.passwordHash = getNodeValue(tag,"PasswordHash");
    o.firstName = getNodeValue(tag,"FirstName");
    o.lastName = getNodeValue(tag,"LastName");
    o.country = getNodeValue(tag,"Country");
    o.optedIn = getNodeValue(tag,"OptedIn");
    o.postalCode = getNodeValue(tag,"PostalCode");
    o.gender = getNodeValue(tag,"Gender");
    o.birthDate = getNodeValue(tag,"BirthDate");
    o.cellPhoneNumber = getNodeValue(tag,"CellPhoneNumber");
    o.aboutMe = getNodeValue(tag,"AboutMe");
    o.created = getNodeValue(tag,"Created");
    o.myWebsite = getNodeValue(tag,"MyWebsite");
    o.runEasyMeaning = getNodeValue(tag,"RunEasyMeaning");
    o.openId = getNodeValue(tag,"OpenId");
    return o;
}
User.prototype.serializeToXmlDoc = function() {
    var xmlDoc = GXml.parse("<" + this.className + " />");
    //TODO: This serializer need to be done... but I'm too lazy right now.
    var node;
    
    if(this.id!=null){
        node = xmlDoc.createElement("Id");
        node.appendChild(xmlDoc.createTextNode(this.id));
        xmlDoc.documentElement.appendChild(node);
    }
    
    return xmlDoc;
}

/*Define Route*/
function Route(){

}
Route.prototype.className="Route";
Route.prototype.name=null;
Route.prototype.id=null;
Route.prototype.description=null;
Route.prototype.authorId=null;
Route.prototype.points=null;
Route.prototype.distance=null;
Route.displayDistance=function(distance){
    if(typeof(distance)=="number"){
        return (distance*metersToDistanceUnitFactor).toFixed(2).replace(".",decimalSeparator) + ' ' + distanceUnit;
    }else{
        if(distance instanceof Route){
            return Route.displayDistance(distance.distance);
        }else{
            return Route.displayDistance(0);
        }
    }
}
Route.prototype.displayDistance = function(){
    return Route.displayDistance(this.distance);
}
Route.prototype.nbrOfVotes=null;
Route.prototype.rating=null;
Route.prototype.playlistId=null;
Route.prototype.playlistName=null;
Route.prototype.authorNickName=null;
Route.prototype.flagged=null;
Route.prototype.tags=new Object(); //tags is an associative array
Route.deserializeFromXml = function(tag,objectToUpdate){
    var o;
    if(typeof(objectToUpdate)=="undefined")
        var o = new Route();
    else
        o=objectToUpdate;
    o.id = getNodeValue(tag,"Id");
    o.name=getNodeValue(tag,"Name");
    o.description=getNodeValue(tag,"Description");
    o.authorId=getNodeValue(tag,"AuthorId");
    o.nbrOfVotes=getNodeValue(tag,"nbrOfVotes");
    o.rating=getNodeValue(tag,"Rating");
    o.distance=parseFloat(getNodeValue(tag,"Distance"));
    o.playlistName=getNodeValue(tag,"PlaylistName");
    o.playlistId=getNodeValue(tag,"PlaylistId");
    o.authorNickName=getNodeValue(tag,"AuthorNickName");
    o.flagged=getNodeValue(tag,"Flagged");
    
    o.tags=new Object();
    var tagElements = tag.getElementsByTagName("Tag");
    if(tagElements[0]){
        for(var i=0;i<tagElements.length;i++)
            o.tags[tagElements[i].firstChild.nodeValue]=true;
    }
    
    return o;
}
Route.prototype.serializeToXmlDoc = function() {
    var xmlDoc = GXml.parse("<" + this.className + " />");
    
    var node;
    
    if(this.id!=null){
        node = xmlDoc.createElement("Id");
        node.appendChild(xmlDoc.createTextNode(this.id));
        xmlDoc.documentElement.appendChild(node);
    }
    
        
    if(this.playlistId!=null){
        node = xmlDoc.createElement("PlaylistId");
        node.appendChild(xmlDoc.createTextNode(this.playlistId));
        xmlDoc.documentElement.appendChild(node);
    }
    
    node = xmlDoc.createElement("Name");
    node.appendChild(xmlDoc.createTextNode(this.name));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("Description");
    node.appendChild(xmlDoc.createTextNode(this.description));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("AuthorId");
    node.appendChild(xmlDoc.createTextNode(this.authorId));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("Distance");
    node.appendChild(xmlDoc.createTextNode(this.distance.toFixed(14)));
    xmlDoc.documentElement.appendChild(node);
    
    for(var tag in this.tags){
        node = xmlDoc.createElement("Tag");
        node.appendChild(xmlDoc.createTextNode(tag));
        xmlDoc.documentElement.appendChild(node);
    }
    
    return xmlDoc;
}

/*Define BaseMarker*/
function BaseMarker(pnt,opts){
    //call the parent constructor
    this._text="";
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        //icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
        icon.image = "Images/icon_smpin.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(12, 20);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(6, 20);
        icon.infoWindowAnchor = new GPoint(5, 1);
        opts["icon"] = icon;
    }
    GMarker.call(this,pnt,opts);
}

copyPrototype(BaseMarker, GMarker);
BaseMarker.prototype.className = "BaseMarker";
BaseMarker.prototype.id = null;
BaseMarker.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat=parseFloat(tag.getElementsByTagName("Latitude")[0].firstChild.nodeValue);
    var lng=parseFloat(tag.getElementsByTagName("Longitude")[0].firstChild.nodeValue);
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new BaseMarker(new GLatLng(lat,lng),opts);
    else{
        o = objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.id = getNodeValue(tag,"Id");
    return o;
}
BaseMarker.prototype.serializeToXmlDoc = function() {
    var xmlDoc = GXml.parse("<" + this.className + " />");
    
    if(this.id!=null){
        var idNode = xmlDoc.createElement("Id");
        idNode.appendChild(xmlDoc.createTextNode(this.id));
        xmlDoc.documentElement.appendChild(idNode);
    }
    
    var latNode = xmlDoc.createElement("Latitude");
    latNode.appendChild(xmlDoc.createTextNode(this.getPoint().lat().toFixed(14)));
    xmlDoc.documentElement.appendChild(latNode);
    
    var latNode = xmlDoc.createElement("Longitude");
    latNode.appendChild(xmlDoc.createTextNode(this.getPoint().lng().toFixed(14)));
    xmlDoc.documentElement.appendChild(latNode);
    
    return xmlDoc;
}

/*Define the Note class*/
function Note(pnt,opts){
    //call the parent constructor
    this._text="";
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/2/note.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(15, 25);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(15, 25);
        icon.infoWindowAnchor = new GPoint(8,11);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}
copyPrototype(Note, BaseMarker);
Note.prototype.className = "Note";
Note.prototype.text = "";
Note.prototype.authorId = null;
Note.prototype.routeId = null;
Note.prototype.authorNickName = "";
Note.prototype.flagged = "";
Note.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat;
    if(tag.getElementsByTagName("Latitude")[0].firstChild){
        lat = parseFloat(tag.getElementsByTagName("Latitude")[0].firstChild.nodeValue);
    }else{
        lng=0;
        lat=0;
    }
    var lng;
    if(tag.getElementsByTagName("Longitude")[0].firstChild){
        lng = parseFloat(tag.getElementsByTagName("Longitude")[0].firstChild.nodeValue);
    }else{
        lat=0;
        lng=0;
    }
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new Note(new GLatLng(lat,lng),opts);
    else{
        o = objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.id = getNodeValue(tag,"Id");
    o.text = getNodeValue(tag,"Text");
    o.authorId=getNodeValue(tag,"AuthorId");
    o.authorNickName=getNodeValue(tag,"AuthorNickName");
    
    
    o.flagged=getNodeValue(tag,"Flagged");
    o.updated=getNodeValue(tag,"Updated");
    o.updatedDesc=getNodeValue(tag,"UpdatedDesc");
    o.routeId = getNodeValue(tag,"RouteId");
    return o;
}
Note.prototype.serializeToXmlDoc = function() {
    var xmlDoc = BaseMarker.prototype.serializeToXmlDoc.call(this);
    
    var textNode = xmlDoc.createElement("Text");
    textNode.appendChild(xmlDoc.createTextNode(this.text));
    xmlDoc.documentElement.appendChild(textNode);
    
    var authorNode = xmlDoc.createElement("AuthorId");
    authorNode.appendChild(xmlDoc.createTextNode(this.authorId));
    xmlDoc.documentElement.appendChild(authorNode);
    
    if(this.routeId!=null){
        var routeNode = xmlDoc.createElement("RouteId");
        routeNode.appendChild(xmlDoc.createTextNode(this.routeId));
        xmlDoc.documentElement.appendChild(routeNode);
    }
    
    return xmlDoc;
}

/*Define the Picture class*/
function Picture(pnt,opts){
    //call the parent constructor
    this._text="";
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/2/photo.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(24, 21);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(23, 21);
        icon.infoWindowAnchor = new GPoint(12, 10);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}

copyPrototype(Picture, BaseMarker);
Picture.prototype.className = "Picture";
Picture.prototype.title = "";
Picture.prototype.authorId = null;
Picture.prototype.getThumbnailUrl = function(){
    return 'userpictures/thumb_' + this.id + '.jpg';
}
Picture.prototype.getSmallUrl = function(){
    return 'userpictures/small_' + this.id + '.jpg';
}
Picture.prototype.getBigUrl = function(){
    return 'userpictures/big_' + this.id + '.jpg';
}
Picture.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat=parseFloat(tag.getElementsByTagName("Latitude")[0].firstChild.nodeValue);
    var lng=parseFloat(tag.getElementsByTagName("Longitude")[0].firstChild.nodeValue);
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new Picture(new GLatLng(lat,lng),opts);
    else{
        o=objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.id = getNodeValue(tag,"Id");
    o.title=getNodeValue(tag,"Title");
    o.authorId=getNodeValue(tag,"AuthorId");
    o.authorNickName=getNodeValue(tag,"AuthorNickName");
    o.updatedDesc=getNodeValue(tag,"UpdatedDesc");
    return o;
}
Picture.prototype.serializeToXmlDoc = function() {
    var xmlDoc = BaseMarker.prototype.serializeToXmlDoc.call(this);
    
    var textNode = xmlDoc.createElement("Title");
    textNode.appendChild(xmlDoc.createTextNode(this.title));
    xmlDoc.documentElement.appendChild(textNode);
    
    var authorNode = xmlDoc.createElement("AuthorId");
    authorNode.appendChild(xmlDoc.createTextNode(this.authorId));
    xmlDoc.documentElement.appendChild(authorNode);
    
    return xmlDoc;
}

/*Define the Picture class*/
function FlickrPicture(pnt,opts){
    //call the parent constructor
    this._text="";
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/2/flickr.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(24, 21);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(23, 21);
        icon.infoWindowAnchor = new GPoint(12, 10);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}

copyPrototype(FlickrPicture, BaseMarker);
FlickrPicture.prototype.className = "FlickrPicture";
FlickrPicture.prototype.latitude = null;
FlickrPicture.prototype.longitude = null;
FlickrPicture.prototype.flickrId = null;
FlickrPicture.prototype.flickrUserId = null;
FlickrPicture.prototype.url = null;
FlickrPicture.prototype.thumbnailUrl = null;
FlickrPicture.prototype.smallUrl = null;
FlickrPicture.prototype.bigUrl = null;
FlickrPicture.prototype.title = "";
FlickrPicture.prototype.getThumbnailUrl = function(){
    return this.thumbnailUrl;
}
FlickrPicture.prototype.getSmallUrl = function(){
    return this.smallUrl;
}
FlickrPicture.prototype.getBigUrl = function(){
    return this.bigUrl;
}
FlickrPicture.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat=parseFloat(tag.getElementsByTagName("Latitude")[0].firstChild.nodeValue);
    var lng=parseFloat(tag.getElementsByTagName("Longitude")[0].firstChild.nodeValue);
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new FlickrPicture(new GLatLng(lat,lng),opts);
    else{
        o=objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    for(var key=0;key<tag.childNodes.length;key++){
        var node = tag.childNodes[key];
        if(node.nodeType == 1)
            o[node.nodeName.substring(0,1).toLowerCase() + node.nodeName.substring(1)]=node.firstChild.nodeValue;
    }
    return o;
}
FlickrPicture.prototype.serializeToXmlDoc = function() {
    var xmlDoc = BaseMarker.prototype.serializeToXmlDoc.call(this);
    
    var textNode;
    textNode = xmlDoc.createElement("Title");
    textNode.appendChild(xmlDoc.createTextNode(this.title));
    xmlDoc.documentElement.appendChild(textNode);

    textNode = xmlDoc.createElement("Id");
    textNode.appendChild(xmlDoc.createTextNode(this.id));
    xmlDoc.documentElement.appendChild(textNode);

    textNode = xmlDoc.createElement("FlickrUserId");
    textNode.appendChild(xmlDoc.createTextNode(this.flickrUserId));
    xmlDoc.documentElement.appendChild(textNode);

    textNode = xmlDoc.createElement("Url");
    textNode.appendChild(xmlDoc.createTextNode(this.url));
    xmlDoc.documentElement.appendChild(textNode);

    textNode = xmlDoc.createElement("ThumbnailUrl");
    textNode.appendChild(xmlDoc.createTextNode(this.thumbnailUrl));
    xmlDoc.documentElement.appendChild(textNode);
    
    return xmlDoc;
}


/*Define Waypoint class*/
function Waypoint(pnt,opts){
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/2/shoe.png";
        //icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(27, 20);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(26, 20);
        icon.infoWindowAnchor = new GPoint(8, 15);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}

copyPrototype(Waypoint, BaseMarker);
Waypoint.prototype.className = "Waypoint";
Waypoint.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat=parseFloat(getNodeValue(tag,"Latitude"));
    var lng=parseFloat(getNodeValue(tag,"Longitude"));
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new Waypoint(new GLatLng(lat,lng),opts);
    else{
        o=objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.id = getNodeValue(tag,"Id");
    return o;
}

/*Define SMSMessage class*/
function SMSMessage(pnt,opts){
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/2/cellphone.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(15, 25);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(14, 25);
        icon.infoWindowAnchor = new GPoint(10, 10);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}
copyPrototype(SMSMessage, BaseMarker);

SMSMessage.prototype.className = "SMSMessage";
SMSMessage.prototype.naId = null;
SMSMessage.prototype.mobileNumber = null;
SMSMessage.prototype.message = "";
SMSMessage.prototype.xmlData = null;
SMSMessage.prototype.dateSubmitted = null;
SMSMessage.prototype.country = null;
SMSMessage.prototype.threadId = null;
SMSMessage.prototype.campaignId = null;
SMSMessage.prototype.keyword = null;
SMSMessage.deserializeFromXml = function(tag,opts,objectToUpdate){
    var lat;
    if(tag.getElementsByTagName("Latitude")[0].firstChild){
        lat = parseFloat(tag.getElementsByTagName("Latitude")[0].firstChild.nodeValue);
    }else{
        lng=0;
        lat=0;
    }
    var lng;
    if(tag.getElementsByTagName("Longitude")[0].firstChild){
        lng = parseFloat(tag.getElementsByTagName("Longitude")[0].firstChild.nodeValue);
    }else{
        lat=0;
        lng=0;
    }
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new SMSMessage(new GLatLng(lat,lng),opts);
    else{
        o=objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.id = getNodeValue(tag,"Id");
    o.naId=getNodeValue(tag,"NaId");
    o.mobileNumber=getNodeValue(tag,"MobileNumber");
    o.message=getNodeValue(tag,"Message");
    o.xmlData=getNodeValue(tag,"XmlData");
    o.dateSubmitted=getNodeValue(tag,"DateSubmitted");
    o.country=getNodeValue(tag,"Country");
    o.threadId=getNodeValue(tag,"ThreadId");
    o.campaignId=getNodeValue(tag,"CampaignId");
    o.keyword=getNodeValue(tag,"Keyword");
    return o;
}
SMSMessage.prototype.serializeToXmlDoc = function() {
    var xmlDoc = BaseMarker.prototype.serializeToXmlDoc.call(this);
    var node;
    
    node = xmlDoc.createElement("NaId");
    node.appendChild(xmlDoc.createTextNode(this.naId));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("MobileNumber");
    node.appendChild(xmlDoc.createTextNode(this.mobileNumber));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("Message");
    node.appendChild(xmlDoc.createTextNode(this.message));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("XmlData");
    node.appendChild(xmlDoc.createTextNode(this.xmlData));
    xmlDoc.documentElement.appendChild(node);
    
    node = xmlDoc.createElement("DateSubmitted");
    node.appendChild(xmlDoc.createTextNode(this.dateSubmitted));
    xmlDoc.documentElement.appendChild(node);
    
    var authorNode = xmlDoc.createElement("Country");
    authorNode.appendChild(xmlDoc.createTextNode(this.country));
    xmlDoc.documentElement.appendChild(authorNode);
    
    var authorNode = xmlDoc.createElement("ThreadId");
    authorNode.appendChild(xmlDoc.createTextNode(this.threadId));
    xmlDoc.documentElement.appendChild(authorNode);
    
    var authorNode = xmlDoc.createElement("CampaignId");
    authorNode.appendChild(xmlDoc.createTextNode(this.campaignId));
    xmlDoc.documentElement.appendChild(authorNode);
    
    var authorNode = xmlDoc.createElement("Keyword");
    authorNode.appendChild(xmlDoc.createTextNode(this.keyword));
    xmlDoc.documentElement.appendChild(authorNode);
    
    if(this.routeId!=null){
        var routeNode = xmlDoc.createElement("RouteId");
        routeNode.appendChild(xmlDoc.createTextNode(this.routeId));
        xmlDoc.documentElement.appendChild(routeNode);
    }
    
    return xmlDoc;
}

/*Define the City class*/
function City(pnt,opts){
    //call the parent constructor
    this._text="";
    if(typeof(opts)=="undefined") opts = {};
    if(typeof(opts["icon"])=="undefined"){
        icon = new GIcon();
        icon.image = "Images/icon/comment.png";
        //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
        icon.iconSize = new GSize(26, 24);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(15, 22);
        icon.infoWindowAnchor = new GPoint(14, 19);
        opts["icon"] = icon;
    }
    BaseMarker.call(this,pnt,opts);
}
copyPrototype(City, BaseMarker);
City.prototype.className="City";
City.prototype.name=null;
City.prototype.id=null;
City.prototype.campaignId=null;
City.prototype.north=null;
City.prototype.east=null;
City.prototype.south=null;
City.prototype.west=null;
City.deserializeFromXml = function(tag,opts,objectToUpdate){
    var north = getNodeValue(tag,"North");
    var east = getNodeValue(tag,"East");
    var south = getNodeValue(tag,"South");
    var west = getNodeValue(tag,"West");
    var lat=north - (north-south)/2;
    var lng=east - (east-west)/2;
    var o;
    if(typeof(objectToUpdate)=="undefined")
        o = new City(new GLatLng(lat,lng),opts);
    else{
        o = objectToUpdate;
        o.setPoint(new GLatLng(lat,lng));
    }
    o.north=north;
    o.east=east;
    o.south=south;
    o.west=west;
    
    o.id = getNodeValue(tag,"Id");
    o.campaignId = getNodeValue(tag,"CampaignId");
    o.name=getNodeValue(tag,"Name");
    return o;
}