// JavaScript Documentfunction

function ADSPartnersList(container){
	var That = this;
	this.container = container;
	this.listings = new Array();
	
	this.addListing = function(label,desc,type,add, country){
		var listing = new ADSListing(label,desc,type, add, country);
		That.listings.push(listing);
		$(That.container).append(listing.getHTML());
		listing.setNode($(That.container).children('*').filter(':last-child').get(0));
		return listing;
	}

	function ADSListing(label,desc,type, add, country){
		var DOMNode;
		var label = label;
		var desc = desc;
		var type = type;
		var add = add;
		var country = country
		this.getHTML = function(){
			return '<div class="ADSListing"><div class=\"left_thing '+country+'\"></div><div class=\"right_thing\">'+desc+'</div></div>'	
		}
		this.getNode = function(){
			return DOMNode;	
		}
		this.setNode = function(node){
			DOMNode = node;
		}
		this.highlight = function(){
			$('.ADSListing').removeClass('selected');
			$(DOMNode).addClass('selected');
		}
		this.scrollTo = function(){
			$(That.container).scrollTop(0);
			$(That.container).scrollTop($(DOMNode).position().top-$(DOMNode).height()*2)
		}
	}
	
}
