var finalwidth;
var finalheight;
var finalxposn;
var finalyposn;
var posnx;
var posny;
var xinc;
var yinc;
var pop;
var popwidth;
var popheight;

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*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 popoverx(){

	var should = readCookie('popover');
	if (should == 'undefined') should = 0;
	else should = parseInt(should, '10') -1;
	if (should > 0) {
		createCookie('popover', should, 21);
		return;
	}
	createCookie('popover', 21, 21);
	var winW = 630, winH = 460;
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.clientWidth;
	  winH = document.body.clientHeight;
	 }
	}
	if (winH > 500) winH = 500;
	finalwidth = parseInt(winW *0.8);
	finalheight = parseInt(winH * 0.8)
	if (finalwidth > winW-320) finalwidth = winW-320;
	finalxposn = parseInt(winW *0.1);
	finalyposn = parseInt(winH *0.1);
	posnx = parseInt(winW * 0.5);
	posny = parseInt(winH * 0.5);
	popwidth = 0;
	popheight = 0;
	xinc = parseInt(finalwidth / 60);
	yinc = parseInt(finalheight / 60);
	
	
	pop = document.getElementById("popup");
//	pop.style.backgroundImage = "url('images/semitrans.gif')"
//	pop.style.zIndex = 4;
	pop.style.left = posnx + 'px';
	pop.style.top = posny + 'px';
	pop.style.width = '0px';
	pop.style.height = '0px';
//	pop.style.backgroundcolor = 'white';
	setTimeout('popover1()', 30);
}

function popover1() {
	posnx -= xinc;
	posny -= yinc;
	popheight += 2*yinc;
	popwidth += 2*xinc;
	pop.style.left = posnx + 'px';
	pop.style.top = posny + 'px';
	pop.style.width = popwidth+'px';
	pop.style.height = popheight+'px';
	pop.style.display = 'block';
	if (popwidth < finalwidth) setTimeout('popover1()', 30);
	else {
	 var txt = '<h1>Welcome to the Yukon 1000 and 360 Shop.</h1>';
	 txt += '<p class="mb">This store is operated by the Yukon 1000 Canoe Race Association.&nbsp; ';
	 txt += 'All profits go directly to the race to cover race costs and increase the prize money.</p>';
	 txt += '<p class="mb">This is different from many other race shops which are run by ';
	 txt += 'commercial organisations and where the share of the profit going to the race is ';
	 txt += 'much lower, as little as 5% of the profit going to the race.</p>';
	 txt += '<p class="mb">Our profit margins are modest, and I think we have a selection of goods ';
	 txt += 'that are very attractive.&nbsp; If you have suggestions let us know at ';
	 txt += 'info@yukon1000.com</p>';
     txt += '<button onclick="popdown()"><b>Close</b></button>';
	 pop.innerHTML = txt;
	 }
}

function popdown() {
	pop.innerHTML = '';
	pop.style.left = '0px';
	pop.style.top = '0px';
	pop.style.width = '0px';
	pop.style.height = '0px';
	pop.style.display = 'none';
}