Widget = {

	addFlash: function(elementId,src,width,height) {
	var
		flashobj  = '<object width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
		flashobj += '<param value="'+src+'" name="movie" />';
		flashobj += '<param value="autohigh" name="quality" />';
		flashobj += '<param value="always" name="allowScriptAccess" />';
		flashobj += '<param value="opaque" name="wmode" />';
		flashobj += '<embed width="'+width+'" height="'+height+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" quality="autohigh" allowscriptaccess="always" src="'+src+'" /></object>',
		obj = (document.getElementById)?(document.getElementById(elementId)):null;
		obj && (obj.innerHTML = flashobj);
	},
	addYoutubeVideo: function(element,src,width,height,cls){
		var iframe = document.createElement('iframe');
		iframe.setAttribute('width',width);
		iframe.setAttribute('height',height);
		iframe.setAttribute('frameborder',0);
		iframe.setAttribute('allowfullscreen',1);
		iframe.setAttribute('src','http://www.youtube.com/embed/' + src);
		element.appendChild(iframe);
	},
	createMail: function(server,user){
		return '<a href="mail:'+user+'@'+server+'">'+user+'@'+server+'</a>';
	},

	imagePreload: function(imagelist){
	    for(var idx=0;idx<=imagelist.length;idx++){
	        preloadimgs[idx] = new Image();
	        preloadimgs[idx].src = '/images/'+imagelist[idx];
	    }
	},
	timer0 : null,
	moveTo: function(obj,x1,y1,milsec){
	    if(timer0 != null) clearInterval(timer0);
	    var
	        x0 = obj.offsetLeft,
	        y0 = obj.offsetTop,
	        freq = Math.PI / (2 * milsec),
	        xtav = x1-x0,
	        ytav = y1-y0,
	        t0 = new Date().getTime();
	        timer0 = setInterval(function(){
	            var elptime = new Date().getTime() - t0;
	            if(elptime < milsec){
	                obj.style.left = (Math.sin(elptime * freq) * xtav + x0) + 'px';
	                obj.style.top = (Math.sin(elptime * freq) * ytav + y0) + 'px';
	            }
	            else {
	                clearInterval(timer0);
	                timer0=null;
	                obj.style.left = x1 + 'px';
	                obj.style.top = y1 + 'px';
	            }
	        },14);
	},
    addClass: function(elm,cname) {
    	if (!this.hasClass(elm,cname)) elm.className += " "+cname;
    },

    removeClass: function(elm,cname) {
    	if (this.hasClass(elm,cname)) {
        	var r = new RegExp('(?:\\s|^)'+cname+'(?:\\s|$)');
    		elm.className=elm.className.replace(r,' ').replace(/^\s|\s$/,'');
    	}
    },
    hasClass: function(elm,cname) {
    	return elm.className.match(new RegExp('(?:\\s|^)'+cname+'(?:\\s|$)'));
    },
    addEvent: function (evt, elm, fnc){
    	return elm && (elm.attachEvent && elm.attachEvent('on'+evt,fnc)) || elm.addEventListener(evt,fnc,false);
    },
    Timer: function(seconds){
    	this.timelength = seconds;
    	return new this;
    }
}
Widget.Timer.prototype = {
	getTimer: function(){
    	return "ok";
    }
}
/*
window.onscroll = function(){
    var scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
    if(scrolltop>420){
        moveTo(document.getElementById('fixedleft'),650,scrolltop,1000);
    }
    else {
        moveTo(document.getElementById('fixedleft'),650,420,1000);
    }
}
*/

