  function setCookie (name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  }

  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);
  }

  function CatChange(id_1, id_2, type) {
    if (type == 'LR') {
      document.getElementById(id_1).style.width = '150px';
      document.getElementById(id_1).style.backgroundImage = 'url(/i/cat_left_.jpg)';
      document.getElementById(id_1 + '_1').style.display = 'none';
      document.getElementById(id_1 + '_2').style.display = 'block';

      document.getElementById(id_2).style.width = '492px';
      document.getElementById(id_2).style.backgroundImage = 'url(/i/cat_right_.jpg)';
      document.getElementById(id_2 + '_1').style.display = 'none';
      document.getElementById(id_2 + '_2').style.display = 'block';
      setCookie (id_1, "left", "Mon, 01-Jan-2009 00:00:00 GMT", "/");
      
    }
    if (type == 'RL') {
      document.getElementById(id_2).style.width = '150px';
      document.getElementById(id_2).style.backgroundImage = 'url(/i/cat_right.jpg)';
      document.getElementById(id_2 + '_2').style.display = 'none';
      document.getElementById(id_2 + '_1').style.display = 'block';

      document.getElementById(id_1).style.width = '492px';
      document.getElementById(id_1).style.backgroundImage = 'url(/i/cat_left.jpg)';
      document.getElementById(id_1 + '_2').style.display = 'none';
      document.getElementById(id_1 + '_1').style.display = 'block';
      setCookie (id_1, "right", "Mon, 01-Jan-2009 00:00:00 GMT", "/");
    }
  }
  function BgChange(id, bg_img) {
    document.getElementById(id).style.backgroundImage = 'url(' + bg_img + ')';
  }

  
  function ShowGameList(id_1, id_2, language) {
      if (document.getElementById(id_1).style.height != '515px') {
        document.getElementById(id_1).style.height = '515px';
        document.getElementById(id_2).innerHTML = 'Свернуть список всех игр';
        document.getElementById(id_2).style.backgroundImage = 'url(/i/glau.jpg)';
        setCookie ("gamelist", "open", "Mon, 01-Jan-2009 00:00:00 GMT", "/");
        trkset('', 'GAMELIST', 'OPEN', '', language);        
      }
      else {
        document.getElementById(id_1).style.height = '130px';
        document.getElementById(id_2).innerHTML = 'Развернуть список всех игр';
        document.getElementById(id_2).style.backgroundImage = 'url(/i/glad.jpg)';
        setCookie ("gamelist", "close", "Mon, 01-Jan-2009 00:00:00 GMT", "/");
        trkset('', 'GAMELIST', 'CLOSE', '', language);        
      }
  }
  
    function dropdownfunc(){
    var selectbox = document.dropdown.dropdownlist;
    if(selectbox.selectedIndex == 1){
      selectbox.selectedIndex=0;
     return;
    }; 
    var destination = selectbox.options[selectbox.selectedIndex].value;
    var subdestination = destination.substring(1,2);
    if(subdestination != ""){
       window.location.target = "_blank";
       window.location.href = destination;
    }
  }
  function dropdownfunc2(){
    var selectbox = document.dropdown2.dropdownlist2;
    if(selectbox.selectedIndex == 1){
      selectbox.selectedIndex=0;
     return;
    }; 
    var destination = selectbox.options[selectbox.selectedIndex].value;
    var subdestination = destination.substring(1,2);
    if(subdestination != ""){
       window.location.target = "_blank";
       window.location.href = destination;
    }
  }
  
ad_timer = 0;

function getFlashMovieObject(movieName)
{
	if(window.document[movieName])
	{
		return window.document[movieName];
	}
	if(navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if(document.embeds&&document.embeds[movieName])
		{
			return document.embeds[movieName];
		}
	}
	else
	{
		return document.getElementById(movieName);
	}
}
		
function HideAD()
{
		document.getElementById('flashdiv').style.display = 'block';
		document.getElementById('ad_with_progress').style.display = 'none';			
		document.getElementById('ad_lefter').style.display = 'none';													
}


function CheckFlashLoaded()
{
	var flashg = getFlashMovieObject('flashgame');		
	if(navigator.appName.indexOf("Microsoft Internet")==-1)
		percFlash = flashg.PercentLoaded;
	else
		percFlash = flashg.PercentLoaded();


	if (percFlash < 100)
	{
		document.getElementById('flash_status').innerHTML = 'Игра загружается';
		setTimeout("CheckFlashLoaded()", 100);
	}
	else if (ad_timer == 0)
	{
		document.getElementById('flash_status').innerHTML = '<a style="color: #000000;" href="javascript:void(0);" onclick="HideAD();">Игра загружена, щёлкните здесь чтобы начать игру</a>';
		ad_timer += 100;
		setTimeout("CheckFlashLoaded()", 100);
	}
	else if (ad_timer > 0 && ad_timer < 10000)
	{
		perc = ad_timer / 100;
	
		ad_timer += 100;
		document.getElementById('progressbar').style.width = String(perc * 2.8)+'px';
		document.getElementById('progress_perc').innerHTML = String(perc) +' %';		
		setTimeout("CheckFlashLoaded()", 100);
	}
	else if (ad_timer >= 10000)
	{
		HideAD();		
	}
}

