function setCookie(name, value) {
	var date = new Date();
	date = new Date(date.getFullYear(), date.getMonth() + 3, date.getDate());
	document.cookie = name + "=" + escape(value) + "; expires=" + date.toGMTString();
}

function getCookie(name) {
	var cookies = document.cookie.split("; ");
	for(var i = 0; i < cookies.length; i++) {
		var cookie = cookies[i].split("=");
		if(name == cookie[0]) {
			return unescape(cookie[1]);
		}
	}
	return null;
}

function getPageScroll() {
	var pageScroll;
	if(self.pageYOffset) {
		pageScroll = self.pageYOffset;
	} else if(document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
		pageScroll = document.documentElement.scrollTop;
	} else if(document.body) { // all other Explorers
		pageScroll = document.body.scrollTop;
	}
	return pageScroll;
}

function getPageSize() {
	var xScroll, yScroll;
	var windowWidth, windowHeight;
	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;
	}
	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;
}

function detectBrowser() {
    var cssFix = function() {
        var u = navigator.userAgent.toLowerCase(),
        addClass = function(el,val){
        if(!el.className) {
            el.className = val;
        } else {
            var newCl = el.className;
            newCl+=(" "+val);
            el.className = newCl;
        }
    },
    is = function(t){return (u.indexOf(t)!=-1)};
    addClass(document.getElementsByTagName('html')[0],[
        (!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
        :is('firefox/2')?'gecko ff2'
        :is('firefox/3')?'gecko ff3'
        :is('gecko/')?'gecko'
        :is('chrome/')?'chrome'
        :is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
        :is('konqueror')?'konqueror'
        :is('applewebkit/')?'webkit safari'
        :is('mozilla/')?'gecko':'',
        (is('x11')||is('linux'))?' linux'
        :is('mac')?' mac'
        :is('win')?' win':''
    ].join(" "));
	}();
}

function detectSafariVersion() {
	if(navigator.appVersion.indexOf("Safari") != -1) {
		if(!window.getComputedStyle) document.body.className += " safari2";
		else document.body.className += " safari3";
	}
}

var titleLess = "&laquo; less";
var titleMore = "more &raquo;";

window.addEvent('domready', function() {
	//if js on
	$$('#total-info li.hidden').removeClass('hidden');
	detectBrowser();
	detectSafariVersion();
	try {
		$('link-slide-block').addEvent('click', function() {
			if($('more-slide-block'))
			{
				if($('more-slide-block').style.display == 'none')
				{
					$('more-slide-block').style.display = 'block';
					this.innerHTML = titleLess;
				}
				else
				{
					$('more-slide-block').style.display = 'none';
					this.innerHTML = titleMore;
				}
			}
			return false;
		});
		if($('faq-see'))
		{
			$('faq-see').addEvent('click', function(){
				if($('more-slide-block'))
				{
					$('more-slide-block').style.display = 'block';
					$('link-slide-block').innerHTML = titleLess;
				}
			});
		}
		var _location = window.location.href.toString();
		if(_location.indexOf("#faq") == -1)
		{
			$('link-slide-block').fireEvent('click');
		}
		else
		{
			if($('faq-see'))
			{
				$('faq-see').fireEvent('click');
			}
			else
			{
				$('link-slide-block').innerHTML = titleLess;
			}
		}
	} catch (e) {	}
/*
	try {
		var collapsible = new Fx.Slide($('more-slide-block'), {
			duration: 500,
			transition: Fx.Transitions.linear
		});
		$('link-slide-block').addEvent('click', function() {
			collapsible.toggle();
			if(this.innerHTML == 'more')
			{
				this.innerHTML = 'less';
			}
			else
			{
				this.innerHTML = 'more';
			}
			return false;
		});
		if($('faq-see'))
		{
			$('faq-see').addEvent('click', function(){
				collapsible.show();
				$('link-slide-block').innerHTML = 'less';
			});
		}
		var _location = window.location.href.toString();
		if(_location.indexOf("#faq") == -1)
		{
			$('link-slide-block').fireEvent('click');
		}
		else
		{
			if($('faq-see'))
			{
				$('faq-see').fireEvent('click');
			}
			else
			{
				$('link-slide-block').innerHTML = 'less';
			}
		}
	} catch (e) {	}
*/
});
