var NV_HOST = 'www.netvibes.com';
var NV_PATH = '/';
var NV_STATIC = '';
var NV_MODULES = 'nvmodules.netvibes.com';


function UWAWidget(parameters){
	
	this.url_params = {};
	this.configuration = {	title : "UWA Widget",
							height: "250px",
							border: "0px",
							color:	"#000000",
							displayTitle: false,
							displayFooter: false,
							autoresize: false	};
	for(key in parameters) {
		this[key] = parameters[key];
	}
  	if(typeof this.container == undefined) {
		triggerEvent('OX_New_Error', 2 ,"No container defined for one or more UWA widgets");			
  	}
  	if(typeof this.moduleUrl == undefined) {
		triggerEvent('OX_New_Error', 2 ,"No URI defined for one or more UWA widgets");			  		
  	}	
  	if(typeof this.id == undefined) {
		triggerEvent('OX_New_Error', 2 ,"No id defined for one or more UWA widgets");			  		
  	}	  	
	this.iframe;
	this.renderWidget();  
	this.updateLayout();
}
UWAWidget.prototype = {

	setConfiguration : function (oConfiguration){
	    for(var sProp in oConfiguration) {
    	  this.configuration[sProp] = oConfiguration[sProp];
		 }
	    this.updateLayout();		
	},
	setBorderWidth : function (){
		
	},
	setBorder : function (){
		
	},
	setColor : function (){
		
	},
	setTitle : function (){
		
	},
	setHeight : function (sHeight){
		this.configuration.height = sHeight;
		this.updateLayout();
	},
	setCommUrl : function (){
		
	},
	setDatas : function (){
		
	},
	setPreferencesValues : function (url_params){
		this.url_params = url_params;
		this.updateIframeUrl();
	},
	diplayTitle : function (){
		
	},
	displayFooter : function (){
		
	},
	updateIframeUrl : function (){
		this.iframe.src = this.getIframeUrl();
	},
	getIframeUrl : function (){
	  var sUrl = "http://" + NV_HOST + "/api/uwa/frame/blog.php?id="
	  							 + (this.id + (new Date()).getTime()) + "&moduleUrl=" + this.moduleUrl;					 
	    for(var sParam in this.url_params) {
	      sUrl += ('&' + sParam + '=' + this.url_params[sParam]);
	    }
	    return sUrl;		
	},
	updateLayout : function (){
		//this.iframe.style.height = this.configuration.height;
		this.iframe.style.border =  this.configuration.border;
		this.iframe.style.color = this.configuration.color;
		this.iframe.setAttribute('height', this.configuration.height);
		this.iframe.setAttribute('frameBorder', 0);
	    this.iframe.setAttribute('scrolling', 'auto');
		this.iframe.style.width = '100%';
	},
	renderWidget : function (){
		this.iframe = newnode("iframe",0,{src:this.getIframeUrl()});
		this.container.appendChild(this.iframe);
	}
}