var MarketplacePaginatedWidget = function(){
	this.name = "Generic Widget";
	this.swfURL = "http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/MarketplaceWidgetCarousel.swf";
	this.width = 300;
	this.styleSheet;
	this.title;
	this.footerLinkText;
	this.footerLinkURL;
	this.sponsorImageURL;
	this.sponsorLinkURL;
	this.wmode = "window";
	
	//needs to be _self, _blank, _parent, or _top
	this.linkTarget;
}//end prototype

MarketplacePaginatedWidget.prototype.write = function(elementId){
	if(typeof(elementId) != "undefined"){
		this.so = new SWFObject(this.swfURL, this.elementId + "SWF",  this.width, 250, "9", "#EFEFEF");
		
		if(typeof(this.styleSheet) == "undefined") this.styleSheet = this.getDefaultStyleSheet(this.brand);
		this.so.addVariable("styleSheet", this.styleSheet);
		this.so.addVariable("brand", this.getBrand());
		this.so.addVariable("name", this.name);
		if(typeof(document.globalPageSponsorship) != "undefined") this.so.addVariable("sponsorship", escape(document.globalPageSponsorship));
		if(typeof(this.wishlist) != "undefined") this.so.addVariable("wishlist", escape(this.wishlist));
		if(typeof(this.keywords) != "undefined") this.so.addVariable("keywords", this.keywords);
		if(typeof(this.listingIDs) != "undefined") this.so.addVariable("listingIds", this.listingIDs);
		if(typeof(this.title) != "undefined") this.so.addVariable("widgetTitle", this.title);
		if(typeof(this.footerLinkText) != "undefined") this.so.addVariable("footerLinkText", this.footerLinkText);
		if(typeof(this.footerLinkURL) != "undefined") this.so.addVariable("footerLinkURL", escape(this.footerLinkURL));
		if(typeof(this.sponsorImageURL) != "undefined") this.so.addVariable("sponsorImageURL", escape(this.sponsorImageURL)); 
		if(typeof(this.sponsorLinkURL) != "undefined") this.so.addVariable("sponsorLinkURL", escape(this.sponsorLinkURL));
		if(typeof(this.linkTarget) != "undefined"){
			if(this.linkTarget == "_self" || this.linkTarget == "_blank" || this.linkTarget == "_parent" || this.linkTarget == "_top"){
				this.so.addVariable("linkTarget", escape(this.linkTarget));
			}
			else{
				alert("You have specified an invalid linkTarget. Your options are: \n_blank\n_self\n_parent\n_top");
			}
		}//end if
		this.so.addParam("wmode", this.wmode);
		this.so.addParam("AllowScriptAccess", "always");
		this.so.write(elementId);
	}//end if
}//end write

MarketplacePaginatedWidget.prototype.getBrand = function(){
	var brand = "";
	var url = String(window.location);
	var domain = url.split(".com")[0];
	if(domain.indexOf("hgtvpro") != -1){
		brand="hgtvpro";
	}//end if
	else if(domain.indexOf("hgtv") != -1){
		brand="hgtv";
	}//end else if
	else if(domain.indexOf("diynetwork") != -1){
		brand="diynetwork";
	}//end else if
	else if(domain.indexOf("fineliving") != -1){
		brand="fineliving";
	}//end else if
	else{
		brand="hgtv";
	}//end else
	return brand;
}//end getBrand

MarketplacePaginatedWidget.prototype.getDefaultStyleSheet = function(brand){
	var defaultStyleSheet = "";
	switch(brand){
		case "hgtv": 
			defaultStyleSheet="http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/stylesheets/defaultHGTVStyles.xml";
			break;
		case "diynetwork":
			defaultStyleSheet="http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/stylesheets/defaultDIYStyles.xml";
			break;
		case "hgtvpro":
			defaultStyleSheet="http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/stylesheets/defaultHGTVPROStyles.xml";
			break;
		case "fineliving":
			defaultStyleSheet="http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/stylesheets/defaultFINELIVINGStyles.xml";
			break;
		default:
			defaultStyleSheet="http://common.scrippsnetworks.com/common/marketplace/paginatedwidget/stylesheets/defaultStyles.xml";
	}//end switch
	return defaultStyleSheet;
}//end	getDefaultStyleSheet