/*--- Функция для записи в cookies ---*/
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/*--- Функция для чтения из cookies ---*/
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

/*--- Функция аналог print_r ---*/
function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}


/*--- Функция для получения размеров страницы ---*/
function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		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
	if(document.documentElement.clientWidth){
		windowWidth = document.documentElement.clientWidth;
	} else {
		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 = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function flashbegin () {
			// <![CDATA[
			var fo = new FlashObject("menu.swf", "bigflash", "990", "780", "9", "#ffffff");
				fo.addVariable("xml_url","orsoten.xml");
				fo.write("bigbanners");
			// ]]>
}

function flashbegin2 () {$('#div4information').slideUp(500,function () {$('#mask4top').fadeOut(500,flashbegin());})}
function flashbegin3 () {$('#div4information').slideUp(500,function () {$('#mask4top').fadeOut(500);});}
function flashbegin4 () {
	if ($('#div4information').css('display')!='none') {
		$('#div4information').slideUp(500,function () {$('#mask4top').fadeOut(500,flashbegin());})
	}
}


onload = function () {

  	var block = '';
  	var timer = 5000000;
	var pageSize = Array();
	infoblock = getCookie('infoblock');
	pageSize = getPageSize();
	left = pageSize[0]/2 - 400;
	if (infoblock != 1) {
		setCookie("infoblock", 1, "", "/");
		$('#div4information').css('left',left + 'px');
		$('#div4information').css('display','block');
		$('#mask4top').css('display','block');
		$('#mask4top').css('height',pageSize[1]+'px');
		setInterval(function() {if (timer>0) {timer = timer -1;} $('#timer').text(timer);},1000);
		if 	($('#bigbanners').css('width')=='990px') {
//			setTimeout("flashbegin4()",4950);
//			setTimeout("$('#div4information').slideUp(500,function () {$('#mask4top').fadeOut(500);})",5000);

		} else {
//			setTimeout("$('#div4information').slideUp(500,function () {$('#mask4top').fadeOut(500);})",5000);
		}
	} else {
		if 	($('#bigbanners').css('width')=='990px') {
			// <![CDATA[
			var fo = new FlashObject("menu.swf", "bigflash", "990", "780", "9", "#ffffff");
				fo.addVariable("xml_url","orsoten.xml");
				fo.write("bigbanners");
			// ]]>
		}

	}

}

