var videos = new Array();
var trailers = new Array();
var kinos = new Array();
var ononasy = new Array();

var formclick=false;
var makeBigState=false;
var ajaimg1 = new Image();
ajaimg1.src=base_url+'img/ajax-loader.gif'
var ajaimg2 = new Image();
ajaimg2.src=base_url+'img/ajax-loader-y.gif'
var ajaimg3 = new Image();
ajaimg2.src=base_url+'img/ajax-loader-o.gif'

var ar_cn=1;
var userLoginData = '';
var zakl_backURL = base_url;


UnPortal = {};
UnPortal.lang = 'ru';
UnPortal.localize = function (msg,args) {
 var strings = this.messages[msg];
 if (!strings) return msg;
 var tmpl = strings[this.lang];
 if (!tmpl) tmpl = strings['ru'];
 return typeof(tmpl) == 'function' ? tmpl(msg) : tmpl;
}
UnPortal.messages = {
 NEW_EMAILS: {
  'ru': 'Новых писем',
  'ua': 'Нових листів'
 },
 NO_NEW_EMAILS: {
  'ru': 'Проверить почту',
  'ua': 'Перевірити пошту'
 },
 EMPTY_FIELD_TRANSLATE: {
  'ru': 'Не задан текст для перевода',
  'ua': 'Не вказано текст для перекладу'
 }
}



var monthes = new Array();
	monthes[0]='Января';
	monthes[1]='Февраля';
	monthes[2]='Марта';
	monthes[3]='Апреля';
	monthes[4]='Мая';
	monthes[5]='Июня';
	monthes[6]='Июля';
	monthes[7]='Августа';
	monthes[8]='Сентября';
	monthes[9]='Октября';
	monthes[10]='Ноября';
	monthes[11]='Декабря';

var days = new Array();
	days[0]='Вс';
	days[1]='Пн';
	days[2]='Вт';
	days[3]='Ср';
	days[4]='Чт';
	days[5]='Пт';
	days[6]='Сб';


function getLayer(id) {
	return document.getElementById(id);
	}

function PasteHoroDate() {
	var currDate = new Date();
	date=currDate.getDate();
	month=monthes[currDate.getMonth()];
	year=currDate.getFullYear();
	document.getElementById('horodate').innerHTML=date+'&nbsp;'+month+'&nbsp;'+year;
}

function buildCalendar() {
    if(!document.getElementById('sc-date')) return;
	var currDate = new Date();
	currDate.setTime(currDate.getTime()+difference);
    document.getElementById('sc-date').innerHTML=currDate.getDate();
	var dayValue='';
	dayValue+=(currDate.getDay()==0 || currDate.getDay()==6)?'<span class="weekends">':'';
	dayValue+=days[currDate.getDay()];
	dayValue+=(currDate.getDay()==0 || currDate.getDay()==6)?'</span>':'';
	document.getElementById('sc-day').innerHTML=dayValue;
	document.getElementById('sc-month').innerHTML=monthes[currDate.getMonth()];
	}
function VesChange(obj) {
}

function click_count(id, t) {
	var link;
	rnd = new Date();
    //img = new Image();
    switch (t) {
        case 16: //market links
            link = 'http://mod.ukr.net/market/counter.php?type=2&id=' + id+'&rnd='+rnd;;
            break;
        case 15: //job links
            link = 'http://informers.ukr.net/informer.php?url=' + escape(id.href) + '&rnd='+rnd;;
            break;
        case 14: //auctions links
            link = base_url+'counter.php?type=2&url=' + escape(id.href) + '&rnd='+rnd;;
            break;
        case 13: //favorites links
            link = 'http://mod.ukr.net/favorites/counter.php?id=' + id+'&rnd='+rnd;;
            break;
        case 12: //ukr.net vip news
            link = base_url+'counter.php?type=1&rnd='+rnd;
            break;
        case 11: //ukr.net vip news
            link = 'http://stat1.ukr.net/sn_new.php?l_id=' + id+'&rnd='+rnd;
            break;
        case 10: //dom.ukr.net news
            link = 'http://dom.ukr.net/counter.php?id=' + id + '&t=2&rnd='+rnd;
            break;
        case 9: //dom.ukr.net links
            link = 'http://dom.ukr.net/counter.php?id=' + escape(id.href) + '&t=1&rnd='+rnd;
            break;
        case 8: //dom.ukr.net items
            link = 'http://dom.ukr.net/counter.php?url=' + id + '&rnd='+rnd;
            break;
        case 7: //symbolic links
            link = 'http://stat1.ukr.net/getlinkse_new.php?url=' + escape(id.href)+'&rnd='+rnd;
            break;
        case 6: //restoran url tracker
            link = 'http://stat4.ukr.net/go_new.php?url=' + escape(id.href)+'&rnd='+rnd;
            break;
        case 5: //restoran id tracker
            link = 'http://stat4.ukr.net/go_new.php?id=' + id+'&rnd='+rnd;
            break;
        case 4: //forex news tracker
            link = 'http://stat2.ukr.net/go_new.php?id=' + id+'&rnd='+rnd;
            break;
        case 3: //forex url tracker
            link = 'http://stat2.ukr.net/gl_new.php?url=' + escape(id.href)+'&rnd='+rnd;
            break;
        case 2: //links
            link = 'http://stat1.ukr.net/lid_new.php?linkid=' + id+'&rnd='+rnd;
            break;
        default: //ukr.net news
            //link = 'http://stat1.ukr.net/rid_new.php?newsid=' + id+'&rnd='+rnd;
            link = base_url+'counter.php?type=4&id=' + id+'&rnd='+rnd;
            break;
    }
    script = document.createElement('script');
    script.src = link;
    document.body.appendChild(script);

    // stop rotate
    var nowTime = new Date();
    currentTime = nowTime.getTime();
    DetectEvent.lastTime = (parseInt(currentTime) - 2*Delays.idleTimeout);
    rotate();
}

var Ajax=new Object();
Ajax.JSONP=function(url){
	var scrpt=document.createElement('SCRIPT');
	scrpt.src=url;
	$('for-json-p').appendChild(scrpt);
	}
Ajax.onSuccess=function(){}
Ajax.onFailure=function(){}
Ajax.startPreload=function(){}
Ajax.stopPreload=function(){}

Ajax.Initialize=function(url,method) {
	try {// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		try {// Internet Explorer
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				Ajax.onFailure();
			}
		}
	}
xmlHttp.onreadystatechange=function() {
	switch(xmlHttp.readyState) {
		case 1 :
			Ajax.startPreload();
			break;
		case 4 :
			Ajax.stopPreload();
			Ajax.onSuccess();
			break;
		}
	}
method=(method)?method:"GET";
xmlHttp.open(method,url,true);
xmlHttp.send(null);
}

Ajax.response=function() {return eval('('+xmlHttp.responseText+')');}

var JobLang;
function ShowJobs(cityid, failure) {
var keywords = $('job_search_keywords').value;
rndDate = new Date();
Ajax.startPreload=function() {
	document.getElementById('jobsPreload').innerHTML='<img src="'+base_url+'img/ajax-loader-o.gif">';
	//document.getElementById('jobsCont').style.visibility='hidden';
	}
Ajax.stopPreload=function() {
	document.getElementById('jobsPreload').innerHTML='';
	//document.getElementById('jobsCont').style.visibility='visible';
	}
Ajax.onSuccess=function() {
	document.getElementById('b_job').innerHTML=Ajax.response().txt;
    $('job_search_keywords').value = keywords;
    JobSetSample(JobLang);
	}
Ajax.onFailure=function() {eval(failure);}
Ajax.Initialize('/get_ajax.php?connector_type=1&job_region_id='+cityid+'&rnd='+rndDate);
}

function JobSetSample(lang) {
    JobLang = lang;
    var sampleArray;
    if (lang == 'ru')
        sampleArray = new Array('администратор', 'экономист', 'бухгалтер', 'переводчик', 'директор', 'офис-менеджер', 'руководитель', 'продавец', 'юрисконсульт', 'юрист', 'программист', 'мерчендайзер', 'архитектор', 'журналист', 'маркетолог', 'дизайнер', 'водитель', 'стоматолог', 'парикмахер', 'финансист');
    else
        sampleArray = new Array('адміністратор', 'економіст', 'бухгалтер', 'перекладач', 'директор', 'офіс-менеджер', 'керівник', 'продавець', 'юрисконсульт', 'юрист', 'программіст', 'мерчендайзер', 'архитектор', 'журналіст', 'маркетолог', 'дизайнер', 'водій', 'стоматолог', 'перукар', 'фінансист');
    var sampleArrayLength = sampleArray.length;
    var str = sampleArray[Math.floor(Math.random() * sampleArrayLength) % sampleArrayLength];

    if($('job_search_sample')) {
        $('job_search_sample').innerHTML = str;
        $('job_search_sample').onclick = function() {JobPasteSample(str);return false;};
    }
}

function JobPasteSample(str) {
    $('job_search_keywords').value = str;
}

function CityChange(cityid, failure) {
rndDate = new Date();
Ajax.startPreload=function() {
	document.getElementById('cityPreload').innerHTML='<img src="'+base_url+'img/ajax-loader-o.gif">';
	//document.getElementById('jobsCont').style.visibility='hidden';
	}
Ajax.stopPreload=function() {
	document.getElementById('cityPreload').innerHTML='';
	//document.getElementById('jobsCont').style.visibility='visible';
	}
Ajax.onSuccess=function() {
	document.getElementById('cityholder').innerHTML=Ajax.response().txt;
	$('b_city').style.display = 'block';
	}
Ajax.onFailure=function() {eval(failure);}
Ajax.Initialize('/get_ajax.php?connector_type=9&city_region_id='+cityid+'&rnd='+rndDate);
}


var marketTabs_active = new Array();
function clearMarketChapters() {
	for (var item in marketTabs_active) {
		document.getElementById(marketTabs_active[item]).className = 'off';
		document.getElementById(marketTabs_active[item] + '_short').className = 'on';
	}
	marketTabs_active = new Array();
}
function marketTabs_onclick (tab, marketId) {

	if (document.getElementById('market_block-' + marketId).className == 'off') {
		clearMarketChapters();
		document.getElementById('market_block-' + marketId).className = 'on';
		var blockHeight = document.getElementById('market_block-' + marketId).offsetHeight;
		document.getElementById('market_block-' + marketId).style.height = '0px';
		vSlideOut(document.getElementById('market_block-' + marketId), blockHeight);
		document.getElementById('market_block-' + marketId + '_short').className = 'off';
		marketTabs_active[marketId] = 'market_block-' + marketId;

	}
	return false;
}

function ShowWeather(cityid, failure) {
rndDate = new Date();
Ajax.startPreload=function() {
	document.getElementById('wPreload').innerHTML='<img src="'+base_url+'img/ajax-loader-y.gif">';
	//document.getElementById('wPreloadBody').style.visibility='hidden';
	}
Ajax.stopPreload=function() {
	document.getElementById('wPreload').innerHTML='';
	//document.getElementById('wPreloadBody').style.visibility='visible';
	}
Ajax.onSuccess=function() {
	document.getElementById('weatherWrap').innerHTML=Ajax.response().txt;
	hideWeatherTowns();
	buildCalendar();
	}
Ajax.onFailure=function() {eval(failure);}
Ajax.Initialize('/get_ajax.php?connector_type=3&region_id='+cityid+'&rnd='+rndDate);
}

var atab = 'tab1';
function ChangeTab(obj, tabId, no_store) {
    if (tabId!=atab) {
    	if (tabId=='tab1') {
    		if (document.getElementById('tabconholder').className.indexOf(' ftab')==-1) document.getElementById('tabconholder').className+=' ftab';
    	}else{
    		if (document.getElementById('tabconholder').className.indexOf(' ftab')!=-1) document.getElementById('tabconholder').className=document.getElementById('tabconholder').className.replace(' ftab','');
    	}
    	alltabs=obj.parentNode.parentNode.childNodes;
    	for (i=0;i<alltabs.length;i++) {
    		(alltabs[i].className.indexOf(' act')!=-1) ? alltabs[i].className=alltabs[i].className.replace(' act','') : [];
    	}
    	document.getElementById(atab).style.className.replace('on', 'off');
    	obj.parentNode.className=obj.parentNode.className+' act';
    	document.getElementById(tabId).className.replace('off', 'on');
    	atab=tabId;
    	if (!no_store) {
    	   var expt = new Date();
    	   expt.setMinutes(expt.getMinutes() + 5);
    	   SetCookie('c_tab',atab, expt);
    	}
	}
}
function ActivateTab() {
	if (GetCookie('c_tab')) {
		ChangeTab(document.getElementById('s'+GetCookie('c_tab')).childNodes[0], GetCookie('c_tab'), true);
    }else{
	    //rndtab='tab'+(3+Math.round(Math.random()));
        rndtab='tab'+4;
        ChangeTab(document.getElementById('s'+rndtab).childNodes[0], rndtab, true);
    }
}

var currstep=0;
var videosHtml='<div class="play-clip"><a rel="nofollow" target="_blank" href="{link}" onmousedown="click_count(414, 2);" class="player"><div class="corn"></div><img src="{image}" /></a></div><div class="play-info"><a rel="nofollow" target="_blank" href="{link}" onmousedown="click_count(414, 2);" class="link_title">{title}</a></div><div class="g-cl"></div>';

var videosKeys = new Array ();
videosKeys['link']=/\{link\}/g;
videosKeys['image']='{image}';
videosKeys['title']='{title}';
videosKeys['ratio']='{ratio}';
videosKeys['stars']='{stars}';

var kinosKeys = new Array();
kinosKeys['link']=/\{link\}/g;
kinosKeys['image']='{image}';
kinosKeys['title']='{title}';
kinosKeys['ratio']='{ratio}';
kinosKeys['stars']='{stars}';
kinosKeys['country']='{country}';
kinosKeys['year']='{year}';
kinosKeys['gender']='{gender}';
kinosKeys['director']='{director}';
kinosKeys['actors']='{actors}';

var ononasyKeys = new Array();
ononasyKeys['link']=/\{link\}/g;
ononasyKeys['image']='{image}';
ononasyKeys['f_name']='{f_name}';
ononasyKeys['name']='{name}';
ononasyKeys['age']='{age}';
ononasyKeys['city']='{city}';
ononasyKeys['lookfor']='{lookfor}';
ononasyKeys['sex']='{sex}';


var trailersHtml='<div class="play-clip"><a rel="nofollow" target="_blank" href="{link}" onmousedown="click_count(614, 2);" class="player"><div class="corn"></div><img src="{image}" /></a></div><div class="play-info"><a rel="nofollow" target="_blank" href="{link}" onmousedown="click_count(614, 2);" class="link_title">{title}</a><div class="days days_num{days_left}"><div>до проката</div><div><span class="count">{days_left}</span> <span class="day">{days_name}</span></div></div><div class="g-cl"></div></div><div class="g-cl"></div>';

var trailersKeys = new Array ();
trailersKeys['link']=/\{link\}/g;
trailersKeys['image']='{image}';
trailersKeys['title']='{title}';
trailersKeys['days_left']=/\{days_left\}/g;
trailersKeys['days_name']=/\{days_name\}/g;

var ononasyHtml='<div class="wphoto {sex}"><div><a target="_blank" href="{link}"><img src="{image}" width="110" height="150" alt="{f_name}" /></a></div></div><div class="user"><a href="#" onclick="PlayMe(-1,\'ononasy\');return false;" class="go_l"><img src="'+base_url+'img/t.gif" width="1" height="1" alt="" /></a><div><a target="_blank" href="{link}">{name}</a>,&nbsp;{age}<br />{city}</div><a href="#" onclick="PlayMe(1,\'ononasy\');return false;" class="go_r"><img src="'+base_url+'img/t.gif" width="1" height="1" alt="" /></a></div>';

cookexp = new Date();
cookexp.setYear(1901+cookexp.getYear());;

function PlayOnona(region_id, type) {
var rndDate = new Date();
			Ajax.startPreload=function() {
				document.getElementById(type+'Preload').innerHTML='<img src="'+base_url+'img/ajax-loader.gif">';
				//document.getElementById(type+'Frame').style.visibility='hidden';
				}
			Ajax.stopPreload=function() {
				document.getElementById(type+'Preload').innerHTML='';
				//document.getElementById(type+'Frame').style.visibility='visible';
				}
			Ajax.onSuccess=function() {
				eval(type+'=Ajax.response().'+type);
				PlayStep(0,type);
			}
			Ajax.Initialize('/get_ajax.php?connector_type=10&region='+region_id+'&rnd='+rndDate);
}

function PlayMe(step,type) {
var rndDate = new Date();
	if (eval('!'+type+'.length')) {
			Ajax.startPreload=function() {
				document.getElementById(type+'Preload').innerHTML='<img src="'+base_url+'img/ajax-loader.gif">';
				//document.getElementById(type+'Frame').style.visibility='hidden';
				}
			Ajax.stopPreload=function() {
				document.getElementById(type+'Preload').innerHTML='';
				//document.getElementById(type+'Frame').style.visibility='visible';
				}
			Ajax.onSuccess=function() {
				eval(type+'=Ajax.response().'+type);
				PlayStep(step,type);
			}
			ajatype=(type=='kinos')?'6':(type=='trailers')?'13':(type=='videos')?'5':'10';
			Ajax.Initialize('/get_ajax.php?connector_type='+ajatype+'&rnd='+rndDate);
		}else{
			PlayStep(step,type);
		}
}
function PlayStep(step,type) {
    currstep=currstep+step;
    if (currstep<0) {
        currstep = eval(type+'.length-1');
        }else{
        if (currstep>=eval(type+'.length')) currstep = 0;
    }
    	currPlayHtml=eval(type+'Html');
        var kinosHtml='<div class="img"><a target="_blank" href="http://kino.ukr.net/movie/{link}/" onmousedown="click_count({link}, 2);" class="player"><img src="http://kino.ukr.net/i/{image}" /></a></div><div class="val"><div class="tholder"><a target="_blank" href="http://kino.ukr.net/movie/{link}/" onmousedown="click_count({link}, 2);">{title}</a><div class="info">{country} ({year})</div><div class="ico"><img src="{stars}" alt="{ratio}" title="{ratio}" /></div>';
    	for (var i in eval(type+'Keys')) {
            if (type == 'kinos') {
                if (eval(type+'[currstep][i]') && i == 'gender') {
                    kinosHtml += '<div class="info"><span class="info-title">Жанр:</span> {gender}</div>'
                }
                if (eval(type+'[currstep][i]') && i == 'director') {
                    kinosHtml += '<div class="info"><span class="info-title">Режиссер:</span> {director}</div>'
                }
                if (eval(type+'[currstep][i]') && i == 'actors') {
                    kinosHtml += '<div class="info"><span class="info-title">Актеры:</span> {actors}</div>'
                }

                kinosHtml=kinosHtml.replace(eval(type+'Keys[i]'), eval(type+'[currstep][i]'));
            } else {
                currPlayHtml=currPlayHtml.replace(eval(type+'Keys[i]'), eval(type+'[currstep][i]'));
            }
        }
        if (type == 'kinos') {
            kinosHtml += '</div>';
            currPlayHtml=eval(type+'Html');
            for (var i in eval(type+'Keys')) {
            currPlayHtml=currPlayHtml.replace(eval(type+'Keys[i]'), eval(type+'[currstep][i]'));
            }
        }
    document.getElementById(type+'Frame').innerHTML=currPlayHtml;
}

function ShowHoro(horoid) {
	rndDate = new Date();
	Ajax.startPreload=function() {
		document.getElementById('horoPreload').innerHTML='<img src="'+base_url+'img/ajax-loader.gif">';
		//document.getElementById('horoPreloadBody').style.visibility='hidden';
		}
	Ajax.stopPreload=function() {
		document.getElementById('horoPreload').innerHTML='';
		//document.getElementById('horoPreloadBody').style.visibility='visible';
		}
	Ajax.onSuccess=function() {
		document.getElementById('b_horo').innerHTML=Ajax.response().txt;
		PasteHoroDate();
		}
	Ajax.Initialize('/get_ajax.php?connector_type=4&horoid='+horoid+'&rnd='+rndDate);
	}

/* cookies work */
function GetCookie (name)
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
      }
   return null;
   }

function SetCookie (name, value)
   {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path =   '/';//(argc > 3) ? argv[3] : null;
   var domain = '.ukr.net'; //(argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
   }

function DeleteCookie (name)
   {
   var expt = new Date();
   expt.setTime (expt.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
   var cval = GetCookie (name);
   document.cookie = name + "=" + cval + "; expires=" + expt.toGMTString() + "; path=/; domain=.ukr.net";
	}
function getCookieVal (offset)
   {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
   }

function TranslateTab(val) {
	var tab='';
	switch (val) {
		case "play" :
			tab = 'tab1';
			break;
		case "kino" :
			tab = 'tab2';
			break;
		case "orakul" :
			tab = 'tab3';
			break;
		case "weather" :
			tab = 'tab4';
			break;
		case "sms" :
			tab = 'tab5';
			break;
    }
    //var exp = new Date();
    //exp.setMinutes( exp.getMinutes() + 1);
    //if (tab!='') SetCookie('ctab',tab,exp);
}

var curloc=document.location.toString();
if (curloc.indexOf('#')!=-1) TranslateTab(curloc.split('#')[1]);
var getLoginBoxResponseFirst = false;
function getLoginBoxResponse(resp) {

    if(document.getElementById('freemailPreload'))
        setTimeout(function() {document.getElementById('freemailPreload').innerHTML='<a class="freemail_loader" href="#" onclick="getLoginBox();return false;"><img src="'+base_url+'img/freemail-ajax.gif" width="13" height="14" alt="" /></a>'}, 1000);

    userLoginData = eval('('+resp+')');
    if (userLoginData.status && userLoginData.status == '2') {
        return false;
    }
    if (userLoginData.status && userLoginData.status == '1') {
        document.getElementById('unpanel_user_toolbar').style.display = 'none';
        document.getElementById('unpanel_logged-user_toolbar').style.display = 'block';
        document.getElementById('unpanel_logged-user_name').style.display = 'none';
        document.getElementById('unpanel_logged-user_name').style.display = 'block';
        document.getElementById('unpanel_logged-user_name').innerHTML = userLoginData.freemail['email'];
    } else {
        document.getElementById('unpanel_user_toolbar').style.display = 'block';
        document.getElementById('unpanel_logged-user_toolbar').style.display = 'none';
        document.getElementById('unpanel_logged-user_name').style.display = 'block';
        document.getElementById('unpanel_logged-user_name').style.display = 'none';
    }

    if (userLoginData.status && userLoginData.status == '1') {
        document.getElementById('freeLoginForm').style.display = 'none';
        document.getElementById('logged-user').style.display = 'block';
        if(userLoginData.freemail['new'] != '0' && userLoginData.freemail['new'] != '' && document.getElementById('logged-emails_new_count')) {
            document.getElementById('logged-emails_new_count').innerHTML = '<a href="http://freemail.ukr.net/q/msglist?folder=0">'+UnPortal.localize('NEW_EMAILS')+': <b>'+userLoginData.freemail['new']+'</b></a>';
        } else {
            document.getElementById('logged-emails_new_count').innerHTML = '<a href="#" onclick="getLoginBox();return false;">'+UnPortal.localize('NO_NEW_EMAILS')+'</a>';
        }
        if(document.getElementById('logged-emails_count')) {
            if(userLoginData.freemail['unread'] != '0' && userLoginData.freemail['unread'] != '')
                document.getElementById('logged-emails_count').innerHTML = '<b>' + userLoginData.freemail['unread'] + '</b>' + '&nbsp;/&nbsp;' + userLoginData.freemail['messages'];
            else
                document.getElementById('logged-emails_count').innerHTML = userLoginData.freemail['messages'];
        }
        document.getElementById('logged-user_name_title').innerHTML = userLoginData.freemail['email'];
    } else {
        document.getElementById('logged-user').style.display = 'none';
        document.getElementById('freeLoginForm').style.display = 'block';
    }

    if(!getLoginBoxResponseFirst) {
        getLoginBoxResponseFirst = true;
        if (location.hash.indexOf('#addlink:') == 0) {
          zakl_windowModal('organizeall','addbook',{addlink: true });
        }
        zakl_display();
    }
}
function getLoginBox() {
    var rnd = new Date();
    if(document.getElementById('freemailPreload'))
        document.getElementById('freemailPreload').innerHTML='<img class="freemail_loader" src="'+base_url+'img/freemail-ajax-load.gif" width="13" height="14" alt="" />';
    Ajax.JSONP('http://www.ukr.net/bar.php?rnd='+rnd+'&callback=getLoginBoxResponse');
}
function getPanelBoxResponse(resp) {
		userLoginData = eval('('+resp+')');
        if (userLoginData.status && userLoginData.status == '2') {
            return false;
        }
		if (userLoginData.status && userLoginData.status == '1') {
			document.getElementById('unpanel_user_toolbar').style.display = 'none';
			document.getElementById('unpanel_logged-user_toolbar').style.display = 'block';
			document.getElementById('unpanel_logged-user_name').style.display = 'none';
			document.getElementById('unpanel_logged-user_name').style.display = 'block';
			document.getElementById('unpanel_logged-user_name').innerHTML = userLoginData.freemail['email'];
		} else {
			document.getElementById('unpanel_user_toolbar').style.display = 'block';
			document.getElementById('unpanel_logged-user_toolbar').style.display = 'none';
			document.getElementById('unpanel_logged-user_name').style.display = 'block';
			document.getElementById('unpanel_logged-user_name').style.display = 'none';
		}
	}
function getPanelBox() {
    var rnd = new Date();
	Ajax.JSONP('http://www.ukr.net/bar.php?rnd='+rnd+'&callback=getPanelBoxResponse');
}

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;
}


function $(id) {return (document.all)?document.all[id]:document.getElementById(id)}

function displayTab(showBox) {
    var tabs = new Array();
    tabs[0] = 'job';
    tabs[1] = 'tv';
    tabs[2] = 'kino';
    tabs[3] = 'horo';
    tabs[4] = 'city';
    tabs[5] = 'play';
	SetCookie('unportal_v2_rtab_a', showBox);
    for (var i=0;i<tabs.length;i++) {
        var hideBox = tabs[i];
        if($('b_' + hideBox))
            $('b_' + hideBox).style.display = 'none';
        if($('tab_' + hideBox))
            $('tab_' + hideBox).className = 'tab';
    }
    if($('b_' + showBox)) $('b_' + showBox).style.display = 'block';
	if($('tab_' + showBox)) $('tab_' + showBox).className = 'tab-s';
	return false;
}

function displayTab2(showBox) {
    var tabs = new Array();
    tabs[0] = 'trailers';
    tabs[1] = 'clips';
    tabs[2] = 'work';
    if (!showBox) {
        showBox = tabs[Math.floor(Math.random() * tabs.length) % tabs.length];
    } else {
        var expt = new Date();
        expt.setHours(expt.getHours() + 24);
        SetCookie('unportal_righttab2_active', showBox, expt);
    }
    for (var i=0;i<tabs.length;i++) {
        var hideBox = tabs[i];
        if($('b_' + hideBox))
            $('b_' + hideBox).style.display = 'none';
        if($('tab_' + hideBox))
            $('tab_' + hideBox).className = 'tab';
    }
    $('b_' + showBox).style.display = 'block';
	$('tab_' + showBox).className = 'tab-s';
	return false;
}

function setRightTab() {
	if (GetCookie('unportal_v2_rtab_a')) {
		var activeTab = GetCookie('unportal_v2_rtab_a');
        displayTab(activeTab);
	} else {
        displayTab('job');
    }
}
function setRightTab2() {
	if (GetCookie('unportal_righttab2_active')) {
		var activeTab = GetCookie('unportal_righttab2_active');
        if (activeTab != 'city')
            displayTab2(activeTab);
	} else {
        displayTab2('trailers');
    }
}
function setRightTabWeather() {
	if (GetCookie('unportal_righttab_active')) {
		var activeTab = GetCookie('unportal_righttab_active');
        if (activeTab == 'favorites' || activeTab == 'city')
            displayTab(activeTab);
	}
}
var hideTime;
function showWeatherTowns() {
	window.clearTimeout(hideTime);
	$('weather-city-menu').style.display = 'block';
}

function hideWeatherTowns() {
	hideTime=window.setTimeout(function(){$('weather-city-menu').style.display = 'none';},200);
}

function showNewsChapters() {
	window.clearTimeout(hideTime);
	$('news-chapters-menu').style.display = 'block';
}

function hideNewsChapters() {
	hideTime=window.setTimeout(function(){$('news-chapters-menu').style.display = 'none';},200);
}

function getAjaxRegionNews(region_id) {
    var rndDate = new Date();
    Ajax.onSuccess=function() {
        if ($('mainRegionNews'))
            $('mainRegionNews').innerHTML = Ajax.response().txt;
        PlayOnona(region_id, 'ononasy');
    }
    Ajax.Initialize('/get_ajax.php?connector_type=11&region_id=' + region_id + '&rnd='+rndDate);
}

function selectSettings() {
	window.clearTimeout(hideTime);
	$('logged-settings').style.display = 'block';
}
function closeSettings() {
	hideTime=window.setTimeout(function(){$('logged-settings').style.display = 'none';},200);
}

function checkSelect() {
	docloc=document.location.toString();
	if (docloc.indexOf('city=')!=-1) {
		ShowWeather(docloc.split('city=')[1],'document.location=\'?city=\''+docloc.split('city=')[1]);
		hideWeatherTowns();
		return false;
		} else {
		if (document.cookie.indexOf('un_weather_city')!=-1) {
			cookies=document.cookie.split(';');
			for (var i = 0;i<cookies.length;i++) {
				if (cookies[i].split('=')[0]=='un_weather_city' || cookies[i].split('=')[0].indexOf('un_weather_city')!=-1) {
					ShowWeather(cookies[i].split('=')[1],'document.location=\'?city=\''+cookies[i].split('=')[1]);
					hideWeatherTowns();
					break;
				}
			}
		}
	}
}

function MakeAGetString(arr) {
	str='?';
	for (var i in arr) {
		str+=i+'='+arr[i]+'&';
		}
	return str;
}
window.onerror = new Function("return true;");

function setNewNews() {
    var rndDate = new Date();
    Ajax.onSuccess=function() {
        if (Ajax.response().txt != '') {
            var nowTime = new Date();

            $('news-main-block').removeChild($('news-main-block').childNodes[0]);
            $('news-main-block').innerHTML = Ajax.response().txt;
        }
    }
    Ajax.Initialize('/get_ajax.php?connector_type=8&rnd='+rndDate);
}

var topBannerLoader;

var Delays=new Object();
Delays.newsRefresh = 300000; // refresh news on index page, default = 300000
Delays.freemailDataRefresh = 300000; // refresh freemail + edisk info in login block, default = 300000
Delays.freemailUserDataRefresh = 60000; // refresh freemail + edisk info in login block, default = 300000
Delays.rotateDelay = 420000; // refresh banners timeout
Delays.idleTimeout = 425000; // stop timeout

var DetectEvent = new Object();
DetectEvent.clientX = false;
DetectEvent.clientY = false;
DetectEvent.lastTime = false;
DetectEvent.bodyHeight = 0;
DetectEvent.bodyWidth = 0;
DetectEvent.scrollStatus = false;

DetectEvent.bodyonmove=function(event){
    if (!event)event=window.event;
    if (DetectEvent.clientY != event.clientY && DetectEvent.clientX != event.clientX) {
        var nowTime = new Date();
        DetectEvent.lastTime = nowTime.getTime();
    }
    DetectEvent.clientY = event.clientY;
    DetectEvent.clientX = event.clientX;

    if (window.navigator.userAgent.indexOf("MSIE ") > 0) {
        DetectEvent.bodyHeight = window.document.body.offsetHeight;
        DetectEvent.bodyWidth = window.document.body.offsetWidth;
    } else {
        DetectEvent.bodyHeight = window.innerHeight;
        DetectEvent.bodyWidth = window.innerWidth;
    }
}

DetectEvent.bodyonscroll=function(){
  var x = 0, y = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    // Netscape
    y = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    // DOM
    y = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    // IE6 standards compliant mode
    y = document.documentElement.scrollTop;
  }
  if (y > 450) {
    DetectEvent.scrollStatus = true;
    var nowTime = new Date();
    currentTime = nowTime.getTime();
    DetectEvent.lastTime = (parseInt(currentTime) - 2*Delays.idleTimeout);
    rotate();
  } else {
    DetectEvent.scrollStatus = false;
  }
  return true;
}

var ar_cn;
function getRestaurantBanner() {
    if(typeof(ar_cn)=="undefined") ar_cn=1;
    var ar_Tail='unknown'; if (document.referrer) ar_Tail = escape(document.referrer);
    var ar_link="http://ua.adriver.ru/cgi-bin/erle.cgi?sid=118832&target=blank&bt=49&pz=0&tail256=" + ar_Tail;
    function ar_getDoc(t,n,l){
    var doc;
    if(t<100){if(document.all && !window.opera){doc = window.frames['ar_container_'+n].document;}
    else if(document.getElementById){doc=document.getElementById('ar_container_'+n).contentDocument;}
    if(!doc){setTimeout('ar_getDoc('+(++t)+','+n+',"'+l+'")', 100);}
    else {var RndNum4NoCash = Math.round(Math.random() * 1000000000);
    doc.write ('<sc'+'ript language="JavaScript" type="text/javascript">var ar_bnum='+n+';<\/sc'+'ript>');
    doc.write ('<sc'+'ript language="JavaScript" type="text/javascript" src="'+l+'&rnd='+RndNum4NoCash+'"><\/sc'+'ript>');}}}
    function ar_putContainer(n){document.write('<div style="visibility:hidden;height:0px;"><iframe id="ar_container_'+n+'" width=1 height=1 marginwidth=0 marginheight=0 scrolling=no frameborder=0><\/iframe><\/div>');}
    function ar_putDiv(n, f){document.write('<div id="ad_ph_'+n+'" style="'+(f?'position:absolute;':'')+'display:none"><\/div>');}
    ar_putContainer(ar_cn);ar_putDiv(ar_cn,0);ar_getDoc(0,ar_cn++,ar_link);
}

/* AdRiver code START. Type:extension Site: ukr.net PZ: 2 BN: 1 */
function getUnderSearchBanner() {
    
    if(typeof(ar_cn)=="undefined") var ar_cn=55;
    var ar_Tail='unknown'; if (document.referrer) ar_Tail = escape(document.referrer);
    var ar_link="http://ua.adriver.ru/cgi-bin/erle.cgi?sid=105780&bn=1&target=blank&bt=43&pz=2&tail256=" + ar_Tail;
    function ar_getDoc(t,n,l){
    var doc;
    if(t<100){if(document.all && !window.opera){doc = window.frames['ar_container_'+n].document;}
    else if(document.getElementById){doc=document.getElementById('ar_container_'+n).contentDocument;}
    if(!doc){setTimeout('ar_getDoc('+(++t)+','+n+',"'+l+'")', 100);}
    else {var RndNum4NoCash = Math.round(Math.random() * 1000000000);
    doc.write ('<sc'+'ript language="JavaScript" type="text/javascript">var ar_bnum='+n+';<\/sc'+'ript>');
    doc.write ('<sc'+'ript language="JavaScript" type="text/javascript" src="'+l+'&rnd='+RndNum4NoCash+'"><\/sc'+'ript>');}}}
    function ar_putContainer(n){document.write('<div style="visibility:hidden;height:0px;position:absolute;"><iframe id="ar_container_'+n+'" width=1 height=1 marginwidth=0 marginheight=0 scrolling=no frameborder=0><\/iframe><\/div>');}
    function ar_putDiv(n, f){document.write('<div id="ad_ph_'+n+'" style="'+(f?'position:absolute;':'')+'display:none"><\/div>');}
    ar_putContainer(ar_cn);ar_putDiv(ar_cn,0);ar_getDoc(0,ar_cn++,ar_link);
}


var checkId;
var gRotateUkrNet = false;

function rotateDo(rotateUkrNet) {
    gRotateUkrNet = rotateUkrNet;
    getTopBanner(rotateUkrNet);
    checkPlayerStatus();
    //getLeftBanner(rotateUkrNet);
}

function rotate() {
    if (DetectEvent.scrollStatus)
        return;
    var startRotate = true;
    var nowTime = new Date();
    currentTime = nowTime.getTime();
    if (DetectEvent.lastTime < (parseInt(currentTime) - Delays.idleTimeout)) {
        // need stop
        startRotate = false;
    }
    var outZone = 35;
    if(DetectEvent.clientX && DetectEvent.clientY) {
        if (parseInt(DetectEvent.clientX) < outZone || parseInt(DetectEvent.clientX) > (parseInt(DetectEvent.bodyWidth) - outZone) ||
            parseInt(DetectEvent.clientY) < outZone || parseInt(DetectEvent.clientY) > (parseInt(DetectEvent.bodyHeight) - outZone)) {
            // mouse out of window
            startRotate = false;
        }
    }
    if (startRotate) {
        rotateDo(false);
    } else {
        rotateDo(true);
    }
}

function checkUpdateInfo() {
    var nowTime = new Date();
    setInterval(getLoginBox, Delays.freemailUserDataRefresh);
    DetectEvent.lastTime = nowTime.getTime();
    //getRestaurantBanner();
    checkId = setInterval("rotate()",Delays.rotateDelay);
}

var NOTICE_CHOISE_ANSWER = 'Выберите вариант ответа';

var votehidetime;
var Vote=new Object();
Vote.value=false;
Vote.process=false;
Vote.displayMore=function(id){
    $(id).className = $(id).className.replace('g-off', 'g-on');
    clearTimeout(votehidetime);
}
Vote.hideMore=function(id){
    votehidetime=setTimeout(function(){$(id).className = $(id).className.replace('g-on', 'g-off');},500);
}
Vote.submit=function(){
    if (Vote.process) return;
    if(!Vote.value) {
        alert(NOTICE_CHOISE_ANSWER);
        return;
    }
    Vote.process = true;
    var rndDate = new Date();
    Ajax.onSuccess=function() {
        Vote.process = false;
        $('vote-block').innerHTML = Ajax.response().txt;
        $('vote_more_res').className=$('vote_more_res').className.replace('g-off','g-on');
    }
    Ajax.Initialize('/get_ajax.php?connector_type=12&v_item=3&v_num=3&v_val='+Vote.value+'&rnd='+rndDate);
}

var VoteC=new Object();
VoteC.process=false;
VoteC.count=0;
VoteC.displayMore=function(id) {
    $(id).className = $(id).className.replace('g-off', 'g-on');
}
VoteC.add=function(){

    VoteC.count = 0;
    for (var i=0;i < $('vote_c_form').elements.length;i++) {
        if ($('vote_c_form').elements[i].checked)
            VoteC.count++;
    }

    if (VoteC.count > 1) {
        for (var i=0;i < $('vote_c_form').elements.length;i++) {
            if (!$('vote_c_form').elements[i].checked && $('vote_c_form').elements[i].type == 'checkbox')
                $('vote_c_form').elements[i].disabled = true;
        }
    } else {
        for (var i=0;i < $('vote_c_form').elements.length;i++) {
            $('vote_c_form').elements[i].disabled = false;
        }
    }
}
VoteC.submit=function() {
    if (VoteC.process) return;
    VoteC.count = 0;
    var ids='';
    for (var i=0;i < $('vote_c_form').elements.length;i++) {
        if ($('vote_c_form').elements[i].checked) {
            VoteC.count++;
            ids += '&v_val[]=' + $('vote_c_form').elements[i].value;
        }
    }
    if(VoteC.count == 0) {
        alert(NOTICE_CHOISE_ANSWER);
        return;
    }
    VoteC.process = true;
    var rndDate = new Date();
    Ajax.onSuccess=function() {
        VoteC.process = false;
        $('vote_c-block').innerHTML = Ajax.response().txt;
    }
    Ajax.Initialize('/get_ajax.php?connector_type=12&v_item=4&v_num=4'+ids+'&rnd='+rndDate);
}

function check_search(obj) {
    if (obj.elements['q'].value!='') {
        return true;
    }else{
        alert('Введите пожалуйста слово для поиска!');
        return false;
    }
}

function $import(src){
    var scriptElem = document.createElement('script');
    scriptElem.setAttribute('src',src);
    scriptElem.setAttribute('type','text/javascript');
    document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

/* portal head block */
// auto suggest for search string
var search_complite = {};
search_complite.rtimer = null;
search_complite.gtimer = null;
search_complite.engine = 'yandex';
search_complite.setEngine = function(engine) {
    search_complite.engine = engine;
    search_complite.changeForm();
}
search_complite.JSONP = function(url) {
    var scrpt=document.createElement('SCRIPT');
    //if(search_complite.engine == 'yandex')
    //    scrpt.charset = 'windows-1251'; // set encode for yandex, because they use windows-1251, other use utf-8
	scrpt.src=url;
	document.getElementById('for-json-p').appendChild(scrpt);
}
search_complite.str_results = function() {
    if(typeof searchlang != 'undefined' && searchlang == 'uk')
        return 'результатів';
    return 'результатов';
}
search_complite.changeForm = function() {
    for (var i=0, tabsNum = $('search-tabs').childNodes.length; i<tabsNum; i++) {
        if($('search-tabs').childNodes[i].className && $('search-tabs').childNodes[i].className.toString().indexOf('tab-s')!=-1)
            $('search-tabs').childNodes[i].className = 'tab';
    }
    $('tab-' + search_complite.engine).className = 'tab tab-s';
    $('engine-' + search_complite.engine).checked = 'checked';

    if(search_complite.selectedText) {
        document.f.q.value = search_complite.selectedText;
    }
    if(search_complite.engine == 'google') {
        document.f.search_query.value = '';
    }
    else if(search_complite.engine == 'yandex') {
        if(document.f.search_query) document.f.search_query.value = document.f.q.value;
    } else {
        document.f.search_query.value = '';
    }
}
search_complite.complitestring = function(q) {
    search_complite.hideresults();
    document.f.q.value = q;
    search_complite.changeForm();
    document.f.submit();
}
search_complite.escapeQuote = function(str) {
    return (str+'').replace(/([\\'])/g, "\\$1"); // escape quots
}
search_complite.autocomplite = function(el, evt) {
    var keyCode =
        document.layers ? evt.which :
        document.all ? event.keyCode :
        document.getElementById ? evt.keyCode : 0;
    if(keyCode == 12 || keyCode == 27 || keyCode == 40 || keyCode == 38) { // don't need request new data
        return true;
    }
    search_complite.selected = null;
    search_complite.rowNum = 0;
    clearTimeout(search_complite.rtimer);
    search_complite.gtimer = setTimeout(function() {
        var q = el.value;
        if(q == '') {
            setTimeout(function(){search_complite.hideresults();},500);
        } else {
            var queryDelay = 100;
            if(typeof searchlang == 'undefined') searchlang = 'ru';
            var qurl = 'http://clients1.google.com/complete/search?hl='+searchlang+'&q='+q;
            /*
            if(search_complite.engine == 'google') {
                qurl = 'http://clients1.google.com/complete/search?hl='+searchlang+'&q='+q;
            } else if(search_complite.engine == 'yandex') {
                qurl = 'http://suggest.yandex.ru/suggest-ya.cgi?ct=text/html&part='+q+'&v=2';
            } else if(search_complite.engine == 'rambler') {
                qurl = 'http://nova.rambler.ru/suggest?callback=suggest.apply&query='+q;
            } else if(search_complite.engine == 'yahoo') {
                qurl = 'http://sugg.search.yahoo.net/sg/?output=fxjsonp&nresults=10&command='+q;
            }
            */
            search_complite.rtimer = setTimeout(function(){search_complite.JSONP(qurl);},queryDelay);
        }
    }, 50);
}
search_complite.unhideresults = function() {
    if(document.getElementById('search-wrap')) document.getElementById('search-wrap').style.zIndex = '700';
    if(document.getElementById('search-wrap2')) document.getElementById('search-wrap2').style.zIndex = '700';
    document.getElementById('autocomplite').style.display = '';
}
search_complite.hideresults = function() {
    clearTimeout(search_complite.rtimer);
    clearTimeout(search_complite.gtimer);
    if(document.getElementById('search-wrap')) document.getElementById('search-wrap').style.zIndex = '100';
    if(document.getElementById('search-wrap2')) document.getElementById('search-wrap2').style.zIndex = '10';
    document.getElementById('autocomplite').style.display = 'none';
    search_complite.userText = document.f.q.value;
    search_complite.startSuggest = false;
}
search_complite.reshtml = '';
search_complite.rowNum = 0;
search_complite.userText = '';
search_complite.selectedText = '';
search_complite.buildRow = function(data) {
    var name = data[0] || '';
    if(name == '') return;
    //var num = data[1] || '';
    var num = '';
    search_complite.rowNum++;
    if(search_complite.selected && search_complite.rowNum == search_complite.selected) {
        var className = 'res-selected';
        search_complite.selectedText = name;
    } else {
        var className = '';
    }
    var nameClass = 'long';
    if(num != '') nameClass = 'short';
    search_complite.reshtml +='<tr class="'+className+'" onclick="search_complite.complitestring(\''+search_complite.escapeQuote(name)+'\');"><td class="name"><span class="'+nameClass+'">'+name+'</span></td><td class="res">'+num+'</td></tr>';
}
search_complite.buildResults = function() {
    search_complite.selectedText = '';
    search_complite.reshtml = '';
    search_complite.rowNum = 0;
    if(search_complite.data.length == 0)
        return
    for (var i=0,len = search_complite.data.length;i<len;i++) {
        search_complite.buildRow(search_complite.data[i]);
    }
    document.getElementById('autocomplite').innerHTML = '<table cellpadding="0" cellspacing="0" border="0">' + search_complite.reshtml + '</table>';
    search_complite.unhideresults();
}
search_complite.startSuggest = false;
search_complite.selected = null;
search_complite.checkArrows = function(field, evt) {
    var keyCode =
        document.layers ? evt.which :
        document.all ? event.keyCode :
        document.getElementById ? evt.keyCode : 0;
    switch(keyCode) {
        case 12: // key "Enter"
            search_complite.userText = document.f.q.value;
            if(search_complite.selectedText)
                document.f.q.value = search_complite.selectedText;
            break;
        case 27: // key "Esc"
            document.f.q.value = search_complite.userText;
            search_complite.hideresults();
            break;
        case 40: // key "Arrow Down"
            if(!search_complite.startSuggest)
                search_complite.userText = document.f.q.value;
            search_complite.startSuggest = true;
            if(search_complite.rowNum == 0 && search_complite.selected + 1 <= 10 ||
               search_complite.rowNum > 0 && search_complite.selected + 1 <= 10 && search_complite.selected + 1 <= search_complite.rowNum) {
                search_complite.selected = search_complite.selected + 1;
            } else {
                search_complite.selected = 0;
                if(search_complite.userText) {
                    document.f.q.value = search_complite.userText;
                }
                search_complite.buildResults();
                return;
            }
            search_complite.buildResults();
            document.f.q.value = search_complite.selectedText;
            break;
        case 38: // key "Arrow Up"
            if(search_complite.selected == 0 && search_complite.rowNum) {
                search_complite.selected = search_complite.rowNum;
            } else if(search_complite.selected - 1 > 0) {
                search_complite.selected = search_complite.selected - 1;
            } else {
                search_complite.selected = 0;
                search_complite.buildResults();
                if(search_complite.userText) {
                    document.f.q.value = search_complite.userText;
                }
                return;
            }
            search_complite.buildResults();
            document.f.q.value = search_complite.selectedText;
            break;
    }
    return true;
}
search_complite.data = []; // array of suggested words and counts
// yahoo
function fxsearch(response) {
    search_complite.data = [];
    if (typeof response != 'undefined' && response && response[1]) {
        for (var i=0,ilength=response[1].length;i<ilength;i++) {
            if(typeof response[1][i] == 'string')
                search_complite.data.push([response[1][i],null]);
        }
    }
    if(search_complite.data.length==0)
        search_complite.hideresults();
    else
        search_complite.buildResults();
}
// yandex & rambler
var suggest = {};
suggest.apply = function(response, data) {
    search_complite.data = [];
    if(typeof data != 'undefined') {
        for (var i=0,ilength=data.length;i<ilength;i++) {
            if(typeof data[i] == 'string') {
                search_complite.data.push([data[i],null])
            } else if(typeof data[i] != 'undefined') {
                if(data[i][0] && data[i][1])
                    search_complite.data.push([data[i][0],data[i][1]+' '+search_complite.str_results()]);
                else if(data[i][0])
                    search_complite.data.push([data[i][0],null]);
            }
        }
    }
    if(search_complite.data.length==0)
        search_complite.hideresults();
    else
        search_complite.buildResults();
}
// google
var google = {};
google.ac = {};
google.ac.h = function(response) {
    search_complite.data = [];
    for (var i=0,ilength=response.length;i<ilength;i++) {
        for (var j=0,jlength=response[i].length;j<jlength;j++) {
            if(typeof response[i][j] == 'object')
                search_complite.data.push([response[i][j][0],response[i][j][1]]);
        }
    }
    if(search_complite.data.length==0)
        search_complite.hideresults();
    else
        search_complite.buildResults();
}

function showMoreServices(force) {
    if(!document.getElementById('ukrnet-resources-size')) return;
    if(document.getElementById('ukrnet-resources-size').className.toString().indexOf('wrap-s')!=-1 || force)
        document.getElementById('ukrnet-resources-size').className = 'wrap-h wrap-l';
    else
        document.getElementById('ukrnet-resources-size').className = 'wrap-h wrap-s';
}

/* end portal head block */



function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

var currencyLine = {
    status : '',
    _fadeStat: '',
    rows : ['usd', 'eur', 'rub'],
    n : 0,
    start : function() {
        var step = function(){
            clearTimeout(currencyLine._fadeStat);
            fade('currency-content');
            currencyLine._fadeStat = setTimeout(function(){
                for (var i=0;i<currencyLine.rows.length;i++) {
                    if($('currency-content-' + currencyLine.rows[i]))
                        $('currency-content-' + currencyLine.rows[i]).style.display = 'none';
                }
                if($('currency-content-' + currencyLine.rows[currencyLine.n]))
                    $('currency-content-' + currencyLine.rows[currencyLine.n]).style.display = '';
                currencyLine.n++;
                if(currencyLine.n > 2)
                    currencyLine.n=0;
                fade('currency-content');
            }, 500);
        }
        step();
        currencyLine.status = setTimeout(currencyLine.start, 3000);
    }
}


/* clipboard functions - IE only */
function copyToClipboard(s) {
	if( window.clipboardData && clipboardData.setData ) {
		clipboardData.setData("Text", s);
    }
}
function pasteFromClipboard(element) {
  element.focus();
  element.select();
  var therange=element.createTextRange();
  therange.execCommand("Paste");
}

function checkTransForm(_form) {
    if (!_form.Text.value || _form.Text.value == '' || _form.Text.value == 'Перевод текста' || _form.Text.value == 'Переклад тексту') {
        alert(UnPortal.localize('EMPTY_FIELD_TRANSLATE'));
        return false;
    }
    return true;
}


var TimeToFade = 500;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null
        || element.style.opacity == ''
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
   
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}

function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
 
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(opacity='
        + (element.FadeState == 1 ? '1' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(opacity=' + (newOpVal*1) + ')';
 
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}


/* player block */
    var curBigpoliticsTab = 1;
    var playerObj;
    function bigpoliticsTab(tabid) {
        if(curBigpoliticsTab == tabid)
            return;
        var stream = 'main';
        if (tabid == 2) {
            stream = 'web1';    
        } else if (tabid == 3) {
            stream = 'web2';
        }
        
        if (document.embeds.length) {
            playerObj = document.embeds['player'];
        } else {
            playerObj = document.getElementById('player');
        }
        playerObj.SwitchStream(stream);
        
        curBigpoliticsTab = tabid;
        for (var bigpolitics_i =1;bigpolitics_i < 4; bigpolitics_i++) {
            document.getElementById('bigpolitics-tab-'+bigpolitics_i).className = '';
        }
        document.getElementById('bigpolitics-tab-' + tabid).className = 'bigpolitics-current';
    }
    
    var videoEnabled = false;
    function setVideoBlock(state) {
        if(state) {
            if(videoEnabled) return;
            videoEnabled = true;
            $('videoPlayer').style.position='static';
            $('videoPlayer').style.left='0px';
        } else {
            videoEnabled = false;
            $('videoPlayer').style.position='absolute';
            $('videoPlayer').style.left='-10000px';
        }
    }
    function checkPlayerStatus() {
        var rnd = new Date();
        Ajax.JSONP('http://stat1.ukr.net/mod/actv.mod?rnd='+rnd);
    }
    var player_fired = false;
    function parsePlayerStatus(resp) {
        var _data = eval('('+resp+')');
        if(typeof _data == 'object' &&
           typeof _data.player_status != 'undefined') {
            playerStatus = _data.player_status;
            if(playerStatus == 1) {
                player_fired = true;
                setVideoBlock(true);
                $('rightBannerContent').className = $('rightBannerContent').className.replace('g-on','g-off');
            } else {
                setVideoBlock(false);
                $('rightBannerContent').className = $('rightBannerContent').className.replace('g-off','g-on');
                getRightBanner(gRotateUkrNet);
                if(player_fired) {
                    $('videoPlayer').innerHTML = '';
                }
            }
        }
    }
/* end player block */