function WidgetWindow(){
// main window height
	this.height = 300;
//  main window width
	this.width = 345;
// main window background color
	this.color = null;
// main window border color
	this.borderColor = null;
// x coordinate of left top edge main window 
	this.x = null;
// y coordinate of left top edge main window 
	this.y = null;
// title text
//	this.title = null;
// main text
	this.text = null;
// path to images
	this.imgPath = "img/";
// mode that defines window animation (n - none, l - left, t - top, r - right, b - bottom)
	this.mod = null;
// bottom image
	this.bottomImg = "";
// top image
	this.topImg = "";
// time to make animation from appearing till stop
	this.moveTime = 1;
// time from end of showing animation till beginning of hide animation
	this.closeTime = 2000;
// pointer to main window 
	this.mainDiv = null;
// pointer to shading layer
	this.shadingDiv = null;
// flag to know if main window exist
	this.isRender = false;
// symbol that splits name of array element from it’s value
	this.partSpliter = "###";
// symbol that splits array element from each other
	this.itemSpliter = "|||";
// inner array for storing ajax objects
	this.ajaxObjects = [];
// data source URL
	this.url = "http://localhost/library/widget/windowdata.php";
// interval between calls to server, uses only when listenServer function is called
	this.callInterval = 4000;
// private variable interval pointer
	this.intervalId;
// private variable use in anomation
	this.Dom=YAHOO.util.Dom;

	this.POSTvars = false;

	this.isTextResive = false;

	this.textEl = null;

	this.closeTimer = null;
// function initializes all properties from array, key is name of property value is it's value	
	this.init = function(params){
//		if (params['height']) this.height = parseInt(params['height']);
//		if (params['width']) this.width = parseInt(params['width']);
//		if (params['color']) this.color = params['color'];
		if (params['x']) this.x = parseInt(params['x']);
		if (params['y']) this.y = parseInt(params['y']);
		if (params['position']) this.initImg(params['position']);
		if (params['text']) this.text = params['text'];
		if (params['mod']) this.mod = params['mod'];
//		if (params['bordercolor']) this.borderColor = params['bordercolor'];
		if (params['movetime']) this.moveTime = params['movetime'];
		if (params['closetime']) this.closeTime = params['closetime'];			
	}
// creates HTML elements and attach them to body element	
	this.render = function(){
		var ext = "png";
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf("msie 6.0") > -1) ext = "gif";
		var mainDiv = document.createElement("div");
		mainDiv.style.position = "absolute";
		mainDiv.style.zIndex = "110";		
		mainDiv.style.left = this.modx()+"px";
		mainDiv.style.top = this.mody()+"px";
		mainDiv.style.width = "345px";
//		mainDiv.style.height = this.height+"px";
//		mainDiv.style.backgroundColor = "#"+this.color;
		var imgTop = document.createElement("img");
		imgTop.src = this.topImg;
		imgTop.style.width = "343px";
		imgTop.style.height = "71px";
		var imgBottom = document.createElement("img");
		imgBottom.src = this.bottomImg;
		imgBottom.style.width = "343px";
		imgBottom.style.height = "78px";
		var bodyDiv = document.createElement("div");
		bodyDiv.innerHTML = '<div style="margin-left: 25px; margin-right: 25px; width: 293px;">'+this.text+'</div>';
//		bodyDiv.style.height = "100%";
		bodyDiv.style.width = "100%";
		bodyDiv.style.marginLeft = "1px";
		bodyDiv.style.backgroundRepeat = "repeat";
		bodyDiv.style.backgroundImage = "url('"+this.imgPath+"center."+ext+"')";
		var leftImg = document.createElement("img");
		leftImg.src = this.imgSignUrl;
		leftImg.style.width = "15px";
		leftImg.style.height = "15px";
		leftImg.style.position = "absolute";
		leftImg.style.top = "5px";
		leftImg.style.left = "5px";
		var rightImg = document.createElement("img");
		var tmpwidth = 15;
		rightImg.style.width = tmpwidth+"px";
		rightImg.style.height = "15px";
		rightImg.style.position = "absolute";
		rightImg.style.top = "45px";
		rightImg.style.left = "305px";
		var tempobj = this;
		rightImg.onclick = function(){tempobj.hide();}
		rightImg.src = this.imgPath+"button.png";
		var titleText = document.createTextNode(this.title);

		mainDiv.appendChild(imgTop);
		this.textEl = mainDiv.appendChild(bodyDiv);
		mainDiv.appendChild(imgBottom);		
		mainDiv.appendChild(rightImg);

		var shadingDiv = document.createElement("div");
		shadingDiv.className = "widget_shading_layer";
		var indicatorImg = document.createElement("img");
		indicatorImg.src = "/img/indicator.gif";
		indicatorImg.className = "widget_shading_indicator";
		shadingDiv.appendChild(indicatorImg);
		this.shadingDiv = mainDiv.appendChild(shadingDiv);
		this.mainDiv = document.body.appendChild(mainDiv);
		this.isRender = true;
	}

	this.showShading = function() {
		if(this.shadingDiv != null) {
			var tmpHeight = this.textEl.clientHeight;
			this.shadingDiv.style.height = tmpHeight + "px";
			tmpHeight += 78;
			this.shadingDiv.style.top = (-tmpHeight) + "px";
			this.shadingDiv.style.visibility = 'visible';
		}
	}
	this.hideShading = function() {
		if(this.shadingDiv != null) {
			this.shadingDiv.style.visibility = 'hidden';
		}
	}

// private function, calculate x coordinate for animation	
	this.modx = function(){
		if (this.mod == "l") 
			return (-1)*(this.width + 20);
		if (this.mod == "r")
			return (window.screen.availWidth + this.width + 20)
		return this.x;
	}
/*
	this.wtext = function(text){
		text = text.replace("\n", " ");
		var arr = text.split(" ");
		for (var i = 0; i < arr.length; i++){
			if (arr[i].length > 32){

			}
		}
	} */
// private function, calculate y coordinate for animation	
	this.mody = function(){
		if (this.mod == "t") 
			return (-1)*(this.height + 20);
		if (this.mod == "b")
			return (window.screen.availHeight + this.height + 20)
		return this.y;
	}
// private function initiate top and bottom images names
	this.initImg = function(imgMod){
		var ext = "png";
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf("msie 6.0") > -1) ext = "gif";

		switch (imgMod){
			case 'tl': this.bottomImg = this.imgPath + "bottom."+ext;
				this.topImg = this.imgPath + "left_top."+ext;
			break;
			case 'tr': this.bottomImg = this.imgPath + "bottom."+ext;
				this.topImg = this.imgPath + "right_top."+ext; 
				break;
			case 'bl': this.bottomImg = this.imgPath + "left_bottom."+ext;
				this.topImg = this.imgPath + "top."+ext; 
				break;
			case 'br': this.bottomImg = this.imgPath + "right_bottom."+ext;
				this.topImg = this.imgPath + "top."+ext; 
				break;
			case 'n': this.bottomImg = this.imgPath + "bottom."+ext;
				this.topImg = this.imgPath + "top."+ext; 
				break;
			default: alert("error position");
			alert(this.topImg+'  '+this.bottomImg);
		}		
	}
//function makes animation, isback = false - forward, isback = true - backward
	this.move = function(isback){
		var sPos;
		if (isback){
			sPos = [this.modx(), this.mody()];
			}
		else{
			this.Dom.setXY(this.mainDiv, [this.modx(), this.mody()], false);
			sPos = [this.x, this.y];
			}
		var motion = new YAHOO.util.Motion( 
	       	this.mainDiv, { 
	           	points: { 
	               	to: sPos
	               }
	           }, 
	           this.moveTime, 
	           YAHOO.util.Easing.easeOut 
	        );
		if (isback){
			var tempobj = this;
			motion.onComplete.subscribe(function(){tempobj.clear()});
		} else {
			var tempobj = this;
			motion.onComplete.subscribe(function(){ tempobj.closeTimer = setTimeout(function(){if(!tempobj.isInput()) tempobj.hide();}, tempobj.closeTime); });
		}
		motion.animate();
	}
// function shows window and after close time hides window 
	this.show = function(){
		if (!this.isRender){
			var tempobj = this;
			this.render();
			if (this.mod == "r" || this.mod == "l" || this.mod == "t" || this.mod == "b")
				this.move();
			else
				this.closeTimer = setTimeout(function(){tempobj.hide();}, tempobj.closeTime); 			
		}
	}
// function hides window	
	this.hide = function(){
		if (this.mod == "r" || this.mod == "l" || this.mod == "t" || this.mod == "b")
			this.move(true);
		else 
			this.clear();		
	}
// removing HTML elements	
	this.clear = function(){
		if (this.mainDiv && this.isRender) {
			if (this.closeTimer != null) {
				clearTimeout(this.closeTimer);
				//alert(this.closeTimer);
			}
			if (this.mainDiv.parentNode) this.mainDiv.parentNode.removeChild(this.mainDiv);
			//document.body.removeChild(this.mainDiv);
			this.isRender = false;
		}
	}
// function parse data and returns array
	this.parseData = function(data){
		if (data != ""){
			var resArr = [];
			var temp = [];
			var itemArr = data.split(this.itemSpliter);
			if (itemArr.length > 0){
				for (var i = 0; i < itemArr.length; i++){
					temp = itemArr[i].split(this.partSpliter);
					resArr[temp[0].toLowerCase()] = temp[1];
				}
				return resArr;
			}else{
				return false;
			}
		}
		return false;
	}
// private function that handle server response
	this.servResp = function(data){
		var resArr = this.parseData(data);
		this.test = resArr;
		if (resArr){
			this.init(resArr);
			this.show();
			return true;
		} else return false
	}

	this.textResp = function(data){
		this.text = data;
		this.textEl.innerHTML = '<div style="margin-left: 25px; margin-right: 25px; width: 293px;">'+this.text+'</div>';
		this.hideShading();
	};
// function calls server for new information
	this.update = function(){
		var len = this.ajaxObjects.length;
		this.ajaxObjects[len] = new sack();
		this.ajaxObjects[len].requestFile = this.url;
		if (this.POSTvars)
		for(var key in this.POSTvars){
			this.ajaxObjects[len].setVar(key, this.POSTvars[key]);
		}
		var temp = this;
		if (this.isTextResive)
			this.ajaxObjects[len].onCompletion = function(){temp.textResp(this.response)};
		else
			this.ajaxObjects[len].onCompletion = function(){temp.servResp(this.response)};
		this.ajaxObjects[len].runAJAX();
		this.isTextResive = false;
		this.POSTvars = false;	
	}
// function start calling server for new information each time after call interval
	this.listenServer = function(){
		var temp = this;
		this.intervalId = setInterval(function(){temp.update()}, this.callInterval);
	}
// function stops calling server
	this.stopListenServer = function(){
		clearInterval(this.intervalId);
	}
	this.getInputs = function(el){
		this.POSTvars = [];
		var elArr = el.parentNode.getElementsByTagName('input');
		var textareaEl = el.parentNode.getElementsByTagName('textarea');
		for (var i = 0; i < elArr.length; i++ ){
			if (elArr[i].type != "button") {
				this.POSTvars[elArr[i].name] = elArr[i].value;
			}
		}
		if (textareaEl.length > 0)
			this.POSTvars[textareaEl[0].name] = textareaEl[0].value;
		this.isTextResive = true;
		this.showShading();
		this.update();
	}

	this.clearInputs = function(el){
		var elArr = el.parentNode.getElementsByTagName('input');
		var textareaEl = el.parentNode.getElementsByTagName('textarea');
		for (var i = 0; i < elArr.length; i++ ){
			if (elArr[i].type != "button" && elArr[i].type != "hidden") {
				elArr[i].value = "";
			}
		}
		if (textareaEl.length > 0)
			textareaEl[0].value = "";
	};

	this.isInput = function(){
		var res = false;
		var elArr = this.textEl.parentNode.getElementsByTagName('input');
		var textareaEl = this.textEl.parentNode.getElementsByTagName('textarea');
		for (var i = 0; i < elArr.length; i++ ){
			if (elArr[i].type != "button" && elArr[i].type != "hidden") {
				if (elArr[i].value.toString().length > 1) res = true;
			}
		}
		if (textareaEl.length > 1)
		if (textareaEl[0].value.toString().length > 0) res = true;
		return res;
	}

}
