//---------------------------------------------------------------------
// Function to return the value of the cookie specified by "name".

// Parameter:
//     name     String object containing the cookie name.

// Return:      String object containing the cookie value, or null if
//              the cookie does not exist.
//---------------------------------------------------------------------
function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
//---------------------------------------------------------------------
// Function to get a cookie.
//---------------------------------------------------------------------
function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function MyWindowSWOT1()
{

	if (GetCookie('MyWindowSWOT1'))
	{
		//do nothing
	}
	else
	{
		var width = 300;
		var height = 200;
		var left = 50;
		var top = 50;
		var wlink = "http://www.marketing-soft.ru/index.html";
		var img = "/IMG/i_sale.gif";
		var title = "Программы для маркетинга";
		var alt="www.marketing-soft.ru";

		var wname="popup";
		left = (document.body.clientWidth - width)/2;
		top = document.body.scrollTop + (document.body.clientHeight - height)/2;
		popup_win = window.open("", wname, 'scrollbars=0,resizable=0, top=225, left=50, width='+width+',height='+height);
		if (popup_win)
		{
				//popup_win.resizeTo(parseInt(width)+8,parseInt(height)+29);
                        	popup_buf = '';
				popup_buf += '<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>'+title+'</title>\n';
				popup_buf += '</head>';
				popup_buf += '<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n';
                        	popup_buf += '<table width=100% height=100% background="'+img+'" style="background-repeat: no-repeat;"><tr><td valign=middle align=center>\n';
				popup_buf += '<a href="'+wlink+'" target="_blank"><img src="/IMG/t.gif" width='+width+' height='+height+' border=0 alt="'+alt+'"></a>';
				popup_buf += '</td></tr></table></body>\n';
				popup_buf += '</HTML>\n';
				popup_win.document.writeln( popup_buf );
				popup_win.document.close();
	

		}

		var exp  = new Date();
		exp.setTime (exp.getTime() +(3*60*1000));
		document.cookie = "MyWindowSWOT1=Y;expires=" + exp.toUTCString();

	}

}
