function getCookie(name) {
	var pattern = '(' + name + '=)' + '(\\w{1,2})';
	var allCookies = document.cookie.match(pattern);

	if(allCookies != null) {
		var c = allCookies[0].replace(name + '=', '');
		return c.replace(/^\s+|\s+$/g, '');
	}

	return null;
}

function isShowPreroll(preroll) {
	var cookie = getCookie(preroll);

	if(cookie == null) {
		var date = new Date();
		date = new Date (date.getFullYear(), date.getMonth(), date.getDate(),  23, 59, 59);

		document.cookie = preroll + "= 1; expires="  + date.toUTCString();

		return 0;

	} else {
		return 1;
	}
}

function setRootFlash(category) {
	swfobject.embedSWF(
		'/index/container.swf', 'rootflash', '1000', '580', '8.0.0', '/images/expressInstall.swf',

		{ config: '/index/configXML.jsp' + (category ? '?category=' + category : ''),  'prerolls': isShowPreroll('preroll')},
		{ wmode: 'transparent', menu: 'false', allowScriptAccess: 'always'}
	);
}


function oldSetRootFlash(preroll, main) {
	var cookie = getCookie("showTime");
	var rootSwf = preroll;

	if(cookie == null) {
		var date = new Date();
		date = new Date (date.getFullYear(), date.getMonth(), date.getDate(),  23, 59, 59);

		document.cookie = "showTime = 1; expires="  + date.toUTCString();

	} else {
		rootSwf = main;
	}

	swfobject.embedSWF(
		rootSwf, 'rootflash', '1000', '580', '8.0.0', '/images/expressInstall.swf',
		{ _xmlpath: "/index/index.xml",  _xmlpathplayer: "/index/index.xml" },
		{ wmode: 'transparent', menu: 'false', allowScriptAccess: 'always'}
	);
}