var expires = new Date();
expires.setMonth(expires.getMonth()+9);
var expiryString = "; expires="+expires.toGMTString();

updateCookies();

var openWindows=0;

// functions
function setCookie(name, value) {
		document.cookie = name+"="+value+expiryString;
}

function getCookie(name, pattern) {
	var ck = document.cookie.toString();
	var value = null;
	var search = new RegExp(name + "=(" + pattern + ")");
	var results = search.exec(ck);
	if (results != null) value = results[1];
	return value;
}

function updateCookies() {
	var visits = 0;
	var visitsString = getCookie("visits","\\d+");
	if (visitsString != null) visits = parseInt(visitsString)+1;

	var today = new Date();
	var todayString = today.getDate() + "-" + (today.getMonth()+1) + "-" + today.getFullYear();

	var firstVisit = getCookie("firstVisit","\\d+-\\d+-\\d+");
	if (firstVisit == null) firstVisit = todayString;

	var lastVisitString = getCookie("lastVisit","\\d+-\\d+-\\d+");
	if (todayString != lastVisitString) {
		setCookie("firstVisit", firstVisit);
		setCookie("lastVisit", todayString);
		setCookie("visits", visits);
	}
}

function showGalleryFile(src, width, height, numLines) {
	height = height + numLines*20;
	open(src,"file"+openWindows, "toolbar=no,location=no,status=no,menubar=no,resizable=no,width="+width+",height="+height);
	openWindows++;
}


function init() {
	id = "raly1";
	name = "main.swf";
	color = "#000000";
	height = "100%";
	width = "100%";

	paramString = "?";
 	if(document.cookie != "") {
  		cookies = document.cookie.split("; ");
		for (i = 0; i < cookies.length; i ++) {
  			paramString += cookies[i] + "&";
		}
 	}

	document.write("<object"
		+ " id='"+id+"' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'"
		+ " codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'"
		+ " width='"+width+"' height='"+height+"'>"
		+ " <param name='movie' value='" + name + paramString + "'>"
		+ " <param name='loop' value='false'><param name='menu' value='false'><param name='quality' value='high'>"
		+ " <param name='bgcolor' value='" + color + "'>"
		+ " <embed src='" + name + paramString + "' name='" + id + "' quality='high' bgcolor='" + color + "'"
		+ " width='" + width + "' height='" + height + "' loop='false' menu='false' type='application/x-shockwave-flash'"
		+ " pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>"
		+ " </embed></object>"
      );
}