
function viewport_width()
{
	return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
}

function viewport_height()
{
	return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
}

function scrollsize_height()
{
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2)
	{
		return document.body.scrollHeight;
	}
	else
	{
		return document.body.offsetHeight;
	}
}

function scrollsize_width()
{
	return self.scrollWidth || (document.documentElement.scrollWidth || document.body.scrollWidth);
}

function my_scroll_top()
{
	return self.scrollTop || (document.documentElement.scrollTop || document.body.scrollTop);
}

function viewport_size()
{
	return { width: viewport_width(), height: viewport_height() };
}

function hide_adwrapper()
{
	var hadwrapper = document.getElementById('hide_adwrapper');
	if (hadwrapper)
	{
		if (hadwrapper.style.visibility = 'visible')
		{
			hadwrapper.style.visibility = 'hidden';
		}
	}
}

function show_adwrapper()
{
	var hadwrapper = document.getElementById('hide_adwrapper');
	if (hadwrapper)
	{
		if (hadwrapper.style.visibility = 'hidden')
		{
			hadwrapper.style.visibility = 'visible';
		}
	}
}

function hide_naughty_wmps()
{
	var wmps = new Array('wmp_vid_player', 'fl_vid_player');
	for (var i = 0; i < wmps.length; i++)
	{
		var owmps = document.getElementById(wmps[i]);
		if (owmps)
		{
			owmps.style.visibility='hidden';
		}
	}
}

function reveal_naughty_wmps()
{
	var wmps = new Array('wmp_vid_player', 'fl_vid_player');
	for (var i = 0; i < wmps.length; i++)
	{
		var owmps = document.getElementById(wmps[i]);
		if (owmps)
		{
			owmps.style.visibility='visible';
		}
	}
}

function hide_naughty_iframes()
{
	var adFrames = new Array("2894", "2892");
	for (var h = 0; h < adFrames.length; h++)
	{
		if (document.getElementById(adFrames[h]))
		{
			document.getElementById(adFrames[h]).style.visibility = "hidden";
		}
	}
}

function reveal_naughty_iframes()
{
	var adFrames = new Array("2894","2892");
	for (var h = 0; h < adFrames.length; h++)
	{
		if (document.getElementById(adFrames[h]))
		{
			document.getElementById(adFrames[h]).style.visibility = "visible";
		}
	}
}

function hide_naughty_tags()
{
	var types = ['embed'];
	for (var i=0;i<types.length;i++)
	{
		var tags = document.getElementsByTagName(types[i]);
		for (var j=0;j<tags.length;j++)
		{
			var tag = tags[j];
			if (tag.style.visibility = 'visible')
			{
				tag.style.visibility = 'hidden';
				tag.setAttribute('forced_hidden',true);
			}
		}
	}
}

function reveal_naughty_tags()
{
	var types = ['embed'];

	for (var i=0;i<types.length;i++)
	{
		var tags = document.getElementsByTagName(types[i]);
		for (var j=0;j<tags.length;j++)
		{
			var tag = tags[j];
			if (tag.getAttribute('forced_hidden'))
			{
				tag.style.visibility = 'visible';
				tag.setAttribute('forced_hidden',false);
			}
		}
	}
}

function hide_login()
{
	var loginCont = $('login_cont');
	var modalCover = $('modal_cover');
	reveal_naughty_iframes();
	reveal_naughty_wmps();
	reveal_naughty_tags();
	show_adwrapper();
	loginCont.style.display  = 'none';
	modalCover.style.display = 'none';

	// for IE 6, we hide the dropdowns
	if (navigator.userAgent.indexOf("MSIE 6") > 0)
	{
		login_show_dropdowns();
	}
}

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=/";
}


var url_redir2;
function show_login(url_redir)
{
        url_redir2 = url_redir;
	//var vW = 2500;
	var vW = viewport_width();
	var vH = viewport_height();
	var vS = viewport_size();
	var sH = scrollsize_height();
	var sW = scrollsize_width();
	var sT = my_scroll_top();
	var loginCont = $('login_cont');
	var modalCover = $('modal_cover');
	var closeLogin = $('close_login');
	closeLogin.onclick = hide_login;
	window.onscroll = window.onresize = function (e)
	{
		var Client =
		{
			myScrollTop: function()
			{
				return self.scrollTop || (document.documentElement.scrollTop || document.body.scrollTop);
			}
		};
		var sT = Client.myScrollTop();
		loginCont.style.top = ((vH - 295)/2) + sT + 'px';
	};

	hide_naughty_iframes();
	hide_naughty_wmps();
	hide_naughty_tags();
	hide_adwrapper();

	// for IE 6, we hide the dropdowns.
	if (navigator.userAgent.indexOf("MSIE 6") > 0)
	{
		login_hide_dropdowns();
	}

	document.getElementById('login_error').innerHTML = '';
	document.getElementById('login_error').style.display = 'block';
	loginCont.style.width = '600px';
	loginCont.style.height = '295px';
	loginCont.style.clear = 'all';
	loginCont.style.left = (vW - 600) / 2 + 'px';
	loginCont.style.top = (vH - 295) / 2 + 'px';
	loginCont.style.display = 'block';

	if (sH < vH)
	{
		modalCover.style.height = vH + 'px';
	}
	else
	{
		modalCover.style.height = sH + 'px';
	}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{
		// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight)
	{
		// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth)
	{
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

var arrayPageSize = getPageSize();
//modalCover.setWidth('modal_cover', arrayPageSize[0]);
//modalCover.style.width = 100 + '%';
//modalCover.style.width = 'auto';

if (navigator.userAgent.indexOf("MSIE 6") > 0)
{
	modalCover.style.width = arrayPageSize[0] + 'px';
	//modalCover.style.width = '100%';
}
else
{
	modalCover.style.width = 100 + '%';
	modalCover.style.minWidth = 968 + 'px';
}

modalCover.style.position = 'absolute';
modalCover.style.top = '0px';
modalCover.style.left = '0px';
modalCover.style.display = 'block';
modalCover.style.overflow = 'hidden';
loginCont.style.display = 'block';
//Element.toggle(modalCover);
//Element.toggle(loginCont);

//$('__syn_login_username').focus();
}

