// JavaScript Document

//hide reveal functionality for ramp header

function getTotalWidth() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    }
    else {
        return document.documentElement.clientWidth;
    }
}

function SetCookie(name,value,expires,path,domain,secure)
{
	var expDays = expires*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + expDays);	
	var expString = (expires == null?"":(";expires=" + expDate.toGMTString()));
	var pathString = (path==null?"":(";path=" + path));
	var domainString = (domain==null?"":(";domain=" + domain));
	var secureString = (secure==true?"=secure":"");
	document.cookie = name + "=" + escape(value) + expString + pathString + domainString + secureString;
}

function GetCookie(name)
{
	var result = null;
	var myCookie = document.cookie + ";";
	var searchName = name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1)
	{
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";",startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}

function TopListReady()
{
	if($('.toplist'))
	{
		var IsShow = 1;
		var IsStatic = 0;
		if(GetCookie("RAMP") != null && GetCookie("RAMP") != "")
		{
			if(GetCookie("RAMP") == 0)
			{
				IsShow = 0;
			}
			
			IsStatic = 1;
		}
		
		if(IsShow == 0)
		{
			$('.toplist, .toplist_left, .toplist_fill').animate({ height: 'hide', opacity: 'hide' }, 'medium');
			$('.collapsed, .collapsed_left').animate({ opacity: 'show' }, 'slow');
			SetCookie("RAMP", 0, 300, null, null, false);
		}
		else
		{
			if(IsStatic == 1)
			{
				$('.toplist, .toplist_left, .toplist_fill').show();
			}
			else
			{
				$('.toplist, .toplist_left, .toplist_fill').animate({ height: 'show', opacity: 'show' }, 'slow');
			}
			$('.collapsed, .collapsed_left').animate({ opacity: 'hide' }, 'fast');
			SetCookie("RAMP", 1, 300, null, null, false);
		}
		
		$('.close').click(
			function(){
				$('.toplist, .toplist_left, .toplist_fill').animate({ height: 'hide', opacity: 'hide' }, 'medium');
				$('.collapsed, .collapsed_left').animate({ opacity: 'show' }, 'slow');
				SetCookie("RAMP", 0, 300, null, null, false);
			}
		);
		$('.collapsed, .collapsed_left').click(
			function(){
				$('.toplist, .toplist_left, .toplist_fill').animate({ height: 'show', opacity: 'show' }, 'slow');
				$('.collapsed, .collapsed_left').animate({ opacity: 'hide' }, 'fast');
				if($.browser.msie === true && $.browser.version.substr(0,1) === '8'){
					$('.toplist').width(getTotalWidth());
				}
				else if($.browser.msie === true && $.browser.version.substr(0,1) === '6'){
					$('.toplist').width(getTotalWidth() - 15);
				}
				SetCookie("RAMP", 1, 300, null, null, false);
			}
		);
	}
}

$(document).ready( function(){
	if($('.toplist'))
	{
		if($.browser.msie === true && $.browser.version.substr(0,1) === '8'){
			$('.toplist').width(getTotalWidth());
		}
		else if($.browser.msie === true && $.browser.version.substr(0,1) === '6')
		{
			$('.toplist').width(getTotalWidth() - 15);
		}
	}
});

$(window).resize(function(){
	if($('.toplist'))
	{
		$('.toplist').width(getTotalWidth());
	}
}); 
