var popwindow
var tisurl
var tiswidth
var tisheight
var tistopposition
var tisleftposition
var pause=20
var step=10
var marginright
var endposition
var timer



function openpopup(thisurl,thiswidth,thisheight,thistopposition,error_message) {
	tisurl=thisurl
	tiswidth=thiswidth
	tisheight=thisheight
	tistopposition=thistopposition
	//tisleftposition=-tiswidth
	tisleftposition=tiswidth
	
	if((user_fname=="")||(user_fname=="undefined")||(user_fname==null))
	{
	   
	   user_fname="";
	}
	//greating window error message
	
	text = ("<HEAD><TITLE>'Error Message'</TITLE></HEAD>");
	text = (text +"<BODY BGCOLOR =  'red' ><CENTER><B><FONT SIZE = 3>" + user_fname + " <FONT COLOR=BLUE>שם לב!</FONT></FONT></B>");
	text= (text +"<br></CENTER>");
	text=(text+"<hr>");
	text=(text+"<TABLE BORDER =0><TR VALIGN=Top><TD VALIGN=Top>");
	text=(text+error_message);
	text=(text+"<TD></TR></TABLE><hr>");
	text=(text+"<center><a href='javascript:self.close();'>סגור חלון</a></center>");
	text=(text+"</body></html>");
	popwindow=window.open(tisurl, "newwindow", "toolbar=no,width="+tiswidth+",height="+tisheight+",top="+tistopposition+",left="+(tisleftposition)+"");
    popwindow.document.write(text);
    popwindow.document.close();
	
	

	/*if (document.all) {
		marginright=screen.width
		endposition=marginright-thiswidth-100
		movewindow()
	}
	if (document.layers) {
    	marginright=window.innerWidth-100
		endposition=marginright-thiswidth
		movewindow()
	}*/
}

function movewindow() {
	if (tisleftposition<=endposition) {
		popwindow.moveTo(tisleftposition,tistopposition)
		tisleftposition+=step
		timer= setTimeout("movewindow()",pause)
	}
	else {
		clearTimeout(timer)
	}
}