function displayStaticMessage()
{
	hideAdvert=getCookie('hideAdvert');

	if (!hideAdvert)
	{
		var m = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
		var myDate = new Date();
		var month = myDate.getMonth();
		// writeAdvert('ALL PRICES REDUCED <br />THROUGH '+m[month].toUpperCase()+'!');
		displayModal('<h1>WE WILL MEET OR BEAT<br />ANY COMPETITOR\'S ADVERTISED PRICE!</h1><p>Restrictions apply, call for details. Valid Thru  ' + m[month] + '.</p><a href="javascript:closeModal()">Close</a></p>',500,170);
	}
}

function getBrowserSize()
{
	var bodyWidth = document.documentElement.clientWidth;
	var bodyHeight = document.documentElement.clientHeight;

	var bodyWidth, bodyHeight;
	if(self.innerHeight)
	{
		bodyWidth = self.innerWidth;
		bodyHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		bodyWidth = document.documentElement.clientWidth;
		bodyHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		bodyWidth = document.body.clientWidth;
		bodyHeight = document.body.clientHeight;
	}
	return [bodyWidth,bodyHeight];
}

function createTransparentDiv()
{

	var brSize = getBrowserSize();
	var bodyWidth = brSize[0];
	var bodyHeight = brSize[1];

	this.transparentDiv = document.createElement('DIV');
	this.transparentDiv.className = 'transparentDiv';
	this.transparentDiv.style.top = '0px';
	this.transparentDiv.style.left = '0px';
	this.transparentDiv.style.width = bodyWidth + 'px';
	this.transparentDiv.style.height = bodyHeight + 'px';
	this.transparentDiv.style.display = 'none';
	document.body.appendChild(this.transparentDiv);
	if (window.addEventListener)
	{
		window.addEventListener("scroll",repositionDivs,false);
		window.addEventListener("resize",repositionDivs,false);
	} else if (window.attachEvent) {
		window.attachEvent("onscroll",repositionDivs);
		window.attachEvent("onresize",repositionDivs);
	}

}

function repositionDivs()
{
	var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);

	this.transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
	this.transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';

	var brSize = getBrowserSize();
	var bodyWidth = brSize[0];
	var bodyHeight = brSize[1];

	this.transparentDiv.style.width = bodyWidth + 'px';
	this.transparentDiv.style.height = bodyHeight + 'px';		

	var tmpWidth = this.modalDiv.offsetWidth;	
	var tmpHeight = this.modalDiv.offsetHeight;
	this.modalDiv.style.left = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px';;
	this.modalDiv.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) +  topOffset) + 'px';
	

}

function createModalDiv(s,w,h)
{
	this.modalDiv = document.createElement('DIV');
	this.modalDiv.className = 'modalDiv';
	this.modalDiv.style.width = w + 'px';
	this.modalDiv.style.height = h + 'px';
	this.modalDiv.innerHTML = s;
	this.modalDiv.style.display = 'none';
	this.modalDiv.style.cursor = 'pointer';
	document.body.appendChild(this.modalDiv);


	if (modalDiv.addEventListener)
	{
		modalDiv.addEventListener("click",closeModal,true);
	} else if (modalDiv.attachEvent) {
		modalDiv.attachEvent("onclick",closeModal);
	}
}

function displayModal(s,w,h)
{
	if (!this.transparentDiv)
	{
		createTransparentDiv();
	}

	if (!this.modalDiv)
	{
		createModalDiv(s,w,h);
	}

	this.transparentDiv.style.display = 'block';
	this.modalDiv.style.display = 'block';
	
	this.repositionDivs();

	setTimeout('this.repositionDivs()',150);
}

function closeModal()
{
	window.modalDiv.style.display = 'none';
	window.transparentDiv.style.display = 'none';
	setCookie('hideAdvert',1,0,'/','folding-chairs-tables.net')

	var so = new SWFObject("/flash/movies/slideshow.swf","movie","380", "214","0","#000");
	so.write("flashMovie");
}

function setCookie(name,value,expires,path,domain)
{
	var expDate = new Date();
	expDate.setDate(expDate.getDate()+expires);
	document.cookie=name + "=" + escape(value);
	//document.cookie=name + "=" + escape(value) + " expires=" + expDate.toGMTString() + "path=" + path + "domain=" + domain;
}

function getCookie(name)
{
	if (document.cookie.length > 0)
	{
		cStart = document.cookie.indexOf(name + "=");
		if (cStart != -1)
		{
			cStart = cStart = name.length + 1;
			cEnd = document.cookie.indexOf(";",cStart);
			if (cEnd == -1) cEnd = document.cookie.length;
			return unescape(document.cookie.substring(cStart,cEnd));
		}
	}
}

