var flink  = 'http://give.com.ua/';
var ftype  = 0;
var fname  = 'Ангелина';
var ftext  = 'Привет! Сообщество щедрых украинцев приглашает тебя на сайт, где все отдается совершенно бесплатно, ДАРОМ! Здесь ты также можешь отдать ненужные вещи тому, кто действительно в них нуждается.';
var fpic   = 'http://img517.imageshack.us/img517/9894/girla3647.jpg';
var fstime = 30;
var fcook  = 0;
var fclive = 86400;

switch(ftype) {
	case 0:
		var html = '<a href="#" id="wnd1_close" onclick="return hide_icq_popup1()" >&nbsp;</a><div id="wnd1" class="fwnd" onclick="clck(1)"><div id="nick">'+fname+' - message</div><div class="bg"><div id="content"><img src="'+fpic+'"/>'+ftext+'</div></div><div id="niz">Ответить '+fname+'</div></div>';
		var height = 111;
		var wid = "wnd1";
		break;
	case 1:
		var html = '<a href="#" id="wnd2_close" onclick="return hide_icq_popup2()" >&nbsp;</a><div id="wnd2" class="fwnd" onclick="clck(2)"><div id="qipnick">'+fname+'</div><div id="qiptext"><img src="'+fpic+'"/>'+ftext+'</div></div>';
		var height = 181;
		var wid = "wnd2";
		break;
}

if(readCookie("fwnd") == null) {
	document.writeln(html);
	setTimeout("doAnimation()", fstime);
	if(fcook == 1) createCookie("fwnd", "1", fclive);
}

var b = 0;
var bottom = -height;
var step = 1;
var time = 50;
var wnd = document.getElementById(wid);
function hide_icq_popup1() {
    document.getElementById('wnd1').style.display='none';
    document.getElementById('wnd1_close').style.display='none';
    return false;
}
function hide_icq_popup2() {
    document.getElementById('wnd2').style.display='none';
    document.getElementById('wnd2_close').style.display='none';
    return false;
}
function doAnimation() {
	if(window.step == window.time) {
		window.wnd.style.bottom = window.b + 'px';
	}
	
	if(window.step <= window.time) {
		window.wnd.style.bottom = Math.round(window.bottom + ((window.b-window.bottom)/time) * window.step)+'px';
		window.step++;
		setTimeout(doAnimation, 1);
	}
}

function clck(id) {
	window.open(window.flink);
	document.getElementById("wnd"+id).style.display = "none";
	if(fcook == 0) createCookie("fwnd", "1", window.fclive);
}

function createCookie(name,value,seconds) {
	if(seconds) {
		var date = new Date();
		date.setTime(date.getTime() + (seconds*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i];
		while(c.charAt(0)==' ') c = c.substring(1,c.length);
		if(c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name, "", -1);
}

