//function detectIE(){
//  var browser = navigator.appName;
//  var b_version = navigator.appVersion;
//  var version = parseFloat(b_version);
//  if ((browser == "Microsoft Internet Explorer") && (version <= 6)){
//    return true;
//  }else{
//    return false;
//  }
//}
var Browser = {
  Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}
/********** Adriver AsyncJS loader core2 *************/
function adriver(ph, prm, defer){ 
	if(this instanceof adriver){
		var p = null;
		if (typeof(ph) == "string"){
			p = document.getElementById(ph);
		}else{
			p = ph;ph = p.id;
		}

		if (!p) {
			if (!adriver.isDomReady) adriver.onDomReady(function(){new adriver(ph, prm, defer)});
			return null
		}
		if (adriver.items[ph]){return adriver.items[ph]}

		adriver.items[ph] = this;
		this.p = p;
		this.defer = defer;
		this.prm = adriver.extend(prm, {ph: ph});

		this.loadCompleteQueue = new adriver.queue();
		this.domReadyQueue = new adriver.queue(adriver.isDomReady);
		var my = this;
		adriver.initQueue.push(function(){my.init()});
		return this;
	}else{
		return arguments.length ? adriver.items[ph] : adriver.items;
	}
}

adriver.prototype = {
	isLoading: 0,

	init: function(){},
	loadComplete: function(){},
	domReady: function(){},

	onLoadComplete: function(f){
		var my = this;
		this.loadCompleteQueue.push(function(){f.call(my)});
		return this;
	},
	onDomReady: function(f){
		this.domReadyQueue.push(f);
		return this;
	},
	reset: function(){
		this.loadCompleteQueue.flush();
		this.domReadyQueue.flush(adriver.isDomReady);
		return this;
	}
}

adriver.loadScript = function(req){
	try {
		req = req.replace(/!\[rnd\]/,Math.round(Math.random()*9999999));
		var head = document.getElementsByTagName("head")[0];
		var s = document.createElement("script");
		s.setAttribute("type", "text/javascript");
		s.setAttribute("charset", "windows-1251");
		s.setAttribute("src", req);
		s.onreadystatechange = function(){if(/loaded|complete/.test(this.readyState))head.removeChild(s)};
		s.onload = function(e){head.removeChild(s)};
		head.insertBefore(s, head.firstChild);
	}catch(e){}
}

adriver.extend = function(){
	var l = arguments[0];
	for (var i = 1, len = arguments.length; i<len; i++){
		var r = arguments[i];
		for (var j in r){
			if(r.hasOwnProperty(j)){
				if(r[j] instanceof Object){if(l[j]){adriver.extend(l[j], r[j]);}else{l[j] = adriver.extend(r[j] instanceof Array ? [] : {}, r[j]);}}else{l[j] = r[j];}
			}
		}
	}
	return l
}

adriver.queue = function(flag){this.q = [];this.flag = flag ? true: false}
adriver.queue.prototype = {
	push: function(f){this.flag ? f() : this.q.push(f)},
	unshift: function(f){this.flag ? f() : this.q.unshift(f)},
	execute: function(flag){var f;var undefined;while (f = this.q.shift()) f();if(flag == undefined) flag=true;this.flag = flag ? true : false},
	flush: function(flag){this.q.length = 0;this.flag = flag ? true: false}
}

adriver.Plugin = function(id){
	if(this instanceof adriver.Plugin){
		if(id && !adriver.plugins[id]){
			this.id = id;
			this.q = new adriver.queue();
			this.loadingStatus = 0;
			adriver.plugins[id] = this;
			return this;
		}
	}
	return adriver.plugins[id];
}
adriver.Plugin.prototype = {
	load: function(){
		this.loadingStatus = 1;
		var suffix = this.id.substr(this.id.lastIndexOf('.')+1);
		var pluginPath = adriver.pluginPath[suffix] || adriver.defaultMirror + "/plugins/";
		adriver.loadScript(pluginPath + this.id + ".js");
	},
	loadComplete: function(){this.loadingStatus = 2;this.q.execute();return this},
	onLoadComplete: function(f){this.q.push(f);return this}
}
adriver.Plugin.require = function(){
	var me = this, counter = 0;
	this.q = new adriver.queue();

	for (var i = 0, len = arguments.length; i < len; i ++){
		var p = new adriver.Plugin(arguments[i]);
		if(p.loadingStatus != 2){
			counter++;
			p.onLoadComplete(function(){if(counter-- == 1){me.q.execute()}});
			if(!p.loadingStatus) p.load();
		}
	}
	if(!counter){this.q.execute()}
}
adriver.Plugin.require.prototype.onLoadComplete = function(f){this.q.push(f);return this}

adriver.onDomReady = function(f){
	adriver.domReadyQueue.push(f);
}
adriver.onBeforeDomReady = function(f){
	adriver.domReadyQueue.unshift(f);
}
adriver.domReady = function(){
	adriver.isDomReady = true;
	adriver.domReadyQueue.execute();
}
adriver.checkDomReady = function(f){
	try {
		var d = document, oldOnload = window.onload;
		if(/WebKit/i.test(navigator.userAgent)){(function(){/loaded|complete/.test(d.readyState) ? f() : setTimeout (arguments.callee, 100)})()}
		else if(d.addEventListener){d.addEventListener("DOMContentLoaded", f, false)}
		else if(d.all && !window.opera){
			document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
			document.getElementById("__onDOMContentLoaded").onreadystatechange = function(){if(this.readyState == "complete" ){f()}}
		}
		window.onload = function(){if(oldOnload) oldOnload();f()}
	} catch (e){}
}

adriver.onLoadComplete = function(f){
	adriver.loadCompleteQueue.push(f);
	return adriver;
}
adriver.loadComplete = function(){
	adriver.loadCompleteQueue.execute();
	return adriver;
}

adriver.setDefaults = function(defaults){adriver.extend(adriver.defaults, defaults)}
adriver.setOptions = function(options){adriver.extend(adriver.options, options)}
adriver.setPluginPath = function(path){adriver.extend(adriver.pluginPath, path)}

adriver.start = function(){
	adriver.version = "2.3.1";
	adriver.items = {};
	adriver.defaults = {tail256: escape(document.referrer || 'unknown')};
	adriver.options = {};
	adriver.plugins = {};
	adriver.pluginPath = {};
	adriver.redirectHost = "http://ad.adriver.ru";
	adriver.defaultMirror = "http://content.adriver.ru";
	adriver.isDomReady = false;
	adriver.domReadyQueue = new adriver.queue();
	adriver.loadCompleteQueue = new adriver.queue();
	adriver.initQueue = new adriver.queue();

	adriver.checkDomReady(adriver.domReady); 

	new adriver.Plugin.require("autoUpdate.adriver").onLoadComplete(function(){
		adriver.initQueue.execute();
	});
}

adriver.start();

//============optional components=================//
if(typeof searchlang == 'undefined') searchlang = 'ru';
var Delays={};
// config
Delays.newsRefresh = 300000; // refresh news on index page, default = 300000
Delays.freemailUserDataRefresh = 180000; // refresh freemail + edisk info in login block, default = 180000
//Delays.rotateDelay = 420000; // refresh banners timeout, default = 420000
Delays.idleTimeout = 425000; // stop timeout, default = 425000

function $(id) {return (document.all)?document.all[id]:document.getElementById(id)}

var videos = new Array();
var trailers = new Array();
var kinos = new Array();
var ononasy = new Array();

var formclick=false;
var makeBigState=false;

var ar_cn=1; //need for banners, don't remove!
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_SEARCH: {
  'ru': 'Не задан текст для поиска',
  'ua': 'Не вказано текст для пошуку'
 },
 ELEC_HIDE: {
    'ru': 'Скрыть результаты',
    'ua': 'Приховати результати'
 },
 ELEC_SHOW: {
    '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 buildCalendar() {
    if(!$('sc-date')) return;
	var currDate = new Date();
	currDate.setTime(currDate.getTime()+difference);
    $('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>':'';
	$('sc-day').innerHTML=dayValue;
	$('sc-month').innerHTML=monthes[currDate.getMonth()];
	//$('sc-time').innerHTML=currDate.getHours()+':'+currDate.getMinutes();
}

function click_count(id, t, c_id) {
	var link;
	rnd = new Date();
	if(c_id)catsCookie(c_id);
    //img = new Image();
    switch (t) {
        case 14: //ukr.net new news
            link = base_url+'counter.php?type=4&md5_id=' + id+'&c_id='+c_id+'&rnd='+rnd;
        	radar_count(c_id, 1);
            break;
        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+'&c_id='+c_id+'&rnd='+rnd;
            radar_count(c_id, 0);
            break;
    }
    __send_script(link);
}

function catsCookie(catId) {
	
	var countDay = 7;
    if(!GetCookie('category')){
        SetCookie('category', 'c_'+catId, countDay);
        SetCookie('categoryUpdateTime', (new Date()).getTime() + countDay*24*3600*1000, countDay);
    } else {
       //var daysToExpire = parseInt(GetCookie('categoryUpdateTime'));
	   var category = GetCookie('category');
	   var catArray = category.split("c_");
	   var newCategory = 'c_'+catId;
	   for(i=0;i<catArray.length;i++){if(catArray[i]==catId)newCategory='';}
       if (GetCookie('categoryUpdateTime')) {
          SetCookie('category', (category + newCategory), parseInt(GetCookie('categoryUpdateTime')));
       }
	   else{
          SetCookie('category', (category + newCategory), countDay);
       }
    }
//return false;	
}

function click_count_news(id, t, c_id) {
    rnd = new Date();
    if(c_id)catsCookie(c_id);    
    switch (t) {
        case 1:
            radar_count(c_id, 0);
            break;
        case 11:
            __send_script('http://stat1.ukr.net/sn_new.php?l_id=' + id+'&rnd='+rnd);
            break;
    }
}

function news_click_count(md5, eid, cid, rid, sid, pos, nid, aid, mp) {
	if(cid)catsCookie(cid);
	var rnd = new Date();
	var link = base_url+'counter.php?type=5&md5_id='+md5+'&c_id='+cid+
		'&nid='+eid+'&cid='+cid+'&rid='+rid+'&sid='+sid+'&pos='+pos+
		'&newsid='+nid+'&srcid='+aid+'&ismain='+mp+'&rnd='+rnd;
	__send_script(link);
	radar_count(cid, mp==1?0:1);
}

function radar_count(cid, page) {
       n=navigator;
       var a='';
       a+='&r='+escape(d.referrer);
       a+='&p='+escape(window.location.href);
       d.cookie="co=1;path=/";a+="&c="+(d.cookie?'y':'n');
       d.cookie="co=1; expires=Thu, 01-Jan-70 00:00:01 GMT";
       fr=(self!=top)?'y':'n';
       a+='&fr='+fr;
       tz=(new Date()).getTimezoneOffset();
       a+='&tz='+tz;
       a+='&j='+(n.javaEnabled()?'y':'n');
       s=screen;
       a+='&s='+s.width+'*'+s.height;
       a+='&d='+(s.colorDepth?s.colorDepth:s.pixelDepth);
       a+='&js=y';
	   a+='&cid='+cid;
	   a+='&page='+page;
       var link = 'http://counter.ukr.net/news/cnt.php?'+a;
       __send_script(link);
}

function __send_script(link) {
    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+')');}

/* detect user OS */
var isUserOSWin = (/windows|win32/i).test(navigator.userAgent);
var isUserOSMac = (/macintosh/i).test(navigator.userAgent);

/* detect user lang */
var userLng = (navigator.language) ? navigator.language.substring(0,2) : navigator.userLanguage.substring(0,2);

var JobLang;

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() {
	$('cityPreload').innerHTML='<img src="'+base_url+'img/ajax-loader-o.gif">';
	//$('jobsCont').style.visibility='hidden';
	}
Ajax.stopPreload=function() {
	$('cityPreload').innerHTML='';
	//$('jobsCont').style.visibility='visible';
	}
Ajax.onSuccess=function() {
	$('cityholder').innerHTML=Ajax.response().txt;
	$('b_city').style.display = 'block';
	}
Ajax.onFailure=function() {eval(failure);}
Ajax.Initialize(base_url+'get_ajax.php?connector_type=9&city_region_id='+cityid+'&rnd='+rndDate);
}
/*
function ShowWeather(cityid, failure, notActive) {
notActive = notActive || false;
var localLang = (UnPortal.lang === 'ua')? 'ua':'ru';
cityIdc = cityid;
rndDate = new Date();
Ajax.JSONP(base_url+'get_ajax.php?connector_type=3&region_id='+cityid+'&lang='+localLang+'&rnd='+rndDate);
if(!notActive)ShowCurrency(cityIdc,'document.location=\'?city='+cityIdc+'\'', true);
}
function getAjaxWeather(resp){
	if(resp){
	$('weatherWrap').innerHTML=resp.txt;
	hideWeatherTowns();
	buildCalendar();
	getWeatherFlash();
	} return true;
}
*/

function ShowCurrency(cityid, failure, notActive) {
notActive = notActive || false;
var localLang = (UnPortal.lang === 'ua')? 'ua':'ru';
cityIdc = cityid;
rndDate = new Date();
Ajax.JSONP(base_url+'get_ajax.php?connector_type=2&region_id='+cityid+'&lang='+localLang+'&rnd='+rndDate);
   // if(!notActive)ShowWeather(cityIdc,'document.location=\'?city='+cityIdc+'\'', true);
}
function getAjaxCurrency(resp){
	if(resp.txt){
	$('currencyWrap').innerHTML=resp.txt;
	hideCurTowns();
	buildCalendar();
	 }return true;
	}
var currstep=0;

var ononasyKeys = new Array();
ononasyKeys['link']=/\{link\}/g;
ononasyKeys['image']='{image}';
ononasyKeys['f_name']=/\{f_name\}/g;
ononasyKeys['name']='{name}';
ononasyKeys['age']=/\{age\}/g;
ononasyKeys['city']=/\{city\}/g;
ononasyKeys['lookfor']='{lookfor}';
ononasyKeys['sex']='{sex}';

var ononasyHtml='<div class="item"><div class="wphoto {sex}"><div><a  rel="nofollow" onmousedown="click_count(718, 2);" target="_blank" href="{link}" title="{f_name}, {age}, {city}"><img src="{image}" width="110" height="150" alt="{f_name}, {age}, {city}" /></a></div></div><div class="user"><div><a  rel="nofollow" onmousedown="click_count(718, 2);" target="_blank" href="{link}">{name}</a>,&nbsp;{age}</div></div><div class="g-cl"></div></div>';

cookexp = new Date();
cookexp.setYear(1901+cookexp.getYear());;

function PlayOnona(region_id, type) {
var rndDate = new Date();
			Ajax.startPreload=function() {
				$(type+'Preload').innerHTML='<img src="'+base_url+'img/ajax-loader.gif">';
				//$(type+'Frame').style.visibility='hidden';
				}
			Ajax.stopPreload=function() {
				$(type+'Preload').innerHTML='';
				//$(type+'Frame').style.visibility='visible';
				}
			Ajax.onSuccess=function() {
				eval(type+'=Ajax.response().'+type);
				PlayStep(0,type);
			}
			Ajax.Initialize(base_url+'get_ajax.php?connector_type=10&region='+region_id+'&rnd='+rndDate);
}

function PlayMe(step,type,ifRegNews) {
var rndDate = new Date();
	if (eval('!'+type+'.length') || ifRegNews) {
			Ajax.startPreload=function() {
				$(type+'Preload').innerHTML='<img src="'+base_url+'img/ajax-loader.gif">';
				//$(type+'Frame').style.visibility='hidden';
				}
			Ajax.stopPreload=function() {
				$(type+'Preload').innerHTML='';
				//$(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(base_url+'get_ajax.php?connector_type='+ajatype+'&rnd='+rndDate);
		}else{
			PlayStep(step,type);
		}
}
function PlayStep(step,type) {
    if(step===0) return;
    if(type === 'ononasy') {
        currPlayHtml = '';
        for(var jj=0;jj<3;jj++) {
            if(jj===0) {
                currstep=currstep+step;
            } else {
                currstep=currstep+(step/3);
            }
            if (currstep<0) {
                currstep = eval(type+'.length-1');
            }else{
                if (currstep>=eval(type+'.length')) currstep = 0;
            }
            var tcurrPlayHtml=eval(type+'Html');
            for (var i in eval(type+'Keys')) {
                tcurrPlayHtml=tcurrPlayHtml.replace(eval(type+'Keys[i]'), eval(type+'[currstep][i]'));
            }
            currPlayHtml += tcurrPlayHtml;
        }
        $(type+'Frame').innerHTML=currPlayHtml;
    } else {
        currstep=currstep+step;
        if (currstep<0) {
            currstep = eval(type+'.length-1');
        }else{
            if (currstep>=eval(type+'.length')) currstep = 0;
        }
        currPlayHtml=eval(type+'Html');
        for (var i in eval(type+'Keys')) {
            currPlayHtml=currPlayHtml.replace(eval(type+'Keys[i]'), eval(type+'[currstep][i]'));
        }
        $(type+'Frame').innerHTML=currPlayHtml;
    }

}

/* -------------- Onona search form ----------------- */
function getCityfromWeather(){
		var arr_ids_cities = {1:'9908_9909_9916',2:'9908_10094_10103',3:'9908_9964_9977',4:'9908_10002_10029',5:'9908_10061_10076',6:'9908_10094_10108',7:'9908_10111_10119',8:'9908_10133_10151',9:'9908_10165_10184',10:'9908_10201_10214',11:'9908_10227_10252',12:'9908_10259_10299',13:'9908_10318_10337',14:'9908_10354_10367',15:'9908_10373_10398',16:'9908_10407_10430',17:'9908_10437_10452',18:'9908_10455_10475',19:'9908_10480_10501',20:'9908_10504_10532',21:'9908_10535_10556',22:'9908_10559_10579',23:'9908_10583_10603',24:'9908_10607_10631',25:'9908_10633_10647'};
		city_local = GetCookie('un_city_city');
		city_chosen = GetCookie('onona_s_c');
		if(city_chosen && city_chosen != '' && city_chosen != '0_0_0'){
			for(var i in arr_ids_cities) {
				var value = arr_ids_cities[i];
				if(city_chosen == value)city = value;
			}
		}else{
			for(var i in arr_ids_cities) {
				var value = arr_ids_cities[i];
				if(city_local == i)city = value;
				}
		}
		return city;
		}
	function getCookiesOnOna(){
		var f = document.msearch;
		onona_ia = GetCookie('onona_ia') || 'N';
		onona_lf = GetCookie('onona_lf') || 'N';
		onona_af = GetCookie('onona_af') || '';
		onona_at = GetCookie('onona_at') || '';
		onona_s_c = getCityfromWeather() || '9908_0_0';
		onona_s_tg = GetCookie('onona_s_tg') || '';
		onona_wp = GetCookie('onona_wp') || 'checked';
		onona_wr = GetCookie('onona_wr') || '';
		onona_ni = GetCookie('onona_ni') || '';
		for(var i=0;i<f.ia.length;i++){if(f.ia.options[i].value == onona_ia)f.ia.options[i].selected = true;}
		for(var i=0;i<f.lf.length;i++){if(f.lf.options[i].value == onona_lf)f.lf.options[i].selected = true;}
		f.af.value = onona_af;
		f.at.value = onona_at;
		for(var i=0;i<f.s_c.length;i++){if(f.s_c.options[i].value == onona_s_c)f.s_c.options[i].selected = true;}
		for(var i=0;i<f.s_tg.length;i++){if(f.s_tg.options[i].value == onona_s_tg)f.s_tg.options[i].selected = true;}
		f.wp.value = onona_wp;if(onona_wp=='checked')f.wp.checked = true; else f.wp.checked = false;
		f.wr.value = onona_wr;if(onona_wr=='checked')f.wr.checked = true; else f.wr.checked = false;
		f.ni.value = onona_ni;if(onona_ni=='checked')f.ni.checked = true; else f.ni.checked = false;
		}
	function setCookiesOnOna(form){
		SetCookie('onona_ia', form.ia.value, 2);
		SetCookie('onona_lf', form.lf.value, 2);
		SetCookie('onona_af', form.af.value, 2);
		SetCookie('onona_at', form.at.value, 2);
		SetCookie('onona_s_c', form.s_c.value, 2);
		SetCookie('onona_s_tg', form.s_tg.value, 2);
		SetCookie('onona_wp', form.wp.value, 2);
		SetCookie('onona_wr', form.wr.value, 2);
		SetCookie('onona_ni', form.ni.value, 2);
		}

/* --------------- Onona search form ---------------*/

/* 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; 
   if((expires+'').length < 6){   //this arg is countDays 
      var ExpireDate = new Date ();
	  ExpireDate.setTime(ExpireDate.getTime() + (expires * 24 * 3600 * 1000));  
   }else { // this arg is expire Timestamp
       var ExpireDate = new Date(expires);
   }
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + ExpireDate.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));
   }

var getLoginBoxResponseFirst = false;
function getLoginBoxResponse(resp) {

    if($('freemailPreload'))
        setTimeout(function() {$('freemailPreload').innerHTML='<a class="freemail_loader" href="#" onclick="getLoginBox();return false;"><img src="'+base_url+'img/t.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') {
        $('unpanel_user_toolbar').style.display = 'none';
        $('unpanel_logged-user_toolbar').style.display = 'block';
        $('unpanel_logged-user_name').style.display = 'none';
        $('unpanel_logged-user_name').style.display = 'block';
        $('unpanel_logged-user_name').innerHTML = userLoginData.freemail['email'];
    } else {
        $('unpanel_user_toolbar').style.display = 'block';
        $('unpanel_logged-user_toolbar').style.display = 'none';
        $('unpanel_logged-user_name').style.display = 'block';
        $('unpanel_logged-user_name').style.display = 'none';
    }

    if (userLoginData.status && userLoginData.status == '1') {
        $('freeLoginForm').style.display = 'none';
        $('logged-user').style.display = 'block';
        if(userLoginData.freemail['new'] != '0' && userLoginData.freemail['new'] != '' && $('logged-emails_new_count')) {
            $('logged-emails_new_count').innerHTML = '<a href="http://freemail.ukr.net/" class="check">'+UnPortal.localize('NEW_EMAILS')+': <b>'+userLoginData.freemail['new']+'</b></a>';
        } else {
            $('logged-emails_new_count').innerHTML = '<a href="#" onclick="getLoginBox();return false;" class="check">'+UnPortal.localize('NO_NEW_EMAILS')+'</a>';
        }
        if($('logged-emails_count')) {
            if(userLoginData.freemail['unread'] != '0' && userLoginData.freemail['unread'] != '')
                $('logged-emails_count').innerHTML = '<b>' + userLoginData.freemail['unread'] + '</b>' + '&nbsp;/&nbsp;' + userLoginData.freemail['messages'];
            else
                $('logged-emails_count').innerHTML = userLoginData.freemail['messages'];
        }
        $('logged-user_name_title').innerHTML = userLoginData.freemail['email'];
		//if logged user hide freemail, eDisc icons
		$('mail_service_box_ico').style.display='none';
		$('edisc_service_box_ico').style.display='none';
		$('city1').style.display='block';
		$('city3').style.display='none';

		 if(!getLoginBoxResponseFirst) {
        getLoginBoxResponseFirst = true; 
        if (location.hash.indexOf('#addlink:') == 0) { 
          zakl_windowModal('organizeall','addbook',{addlink: true});
        }
        zakl_display();
    }

    } else {
        $('logged-user').style.display = 'none';
        $('freeLoginForm').style.display = 'block';
    }
	
	
}
function getLoginBox() {
    var rnd = new Date();
    if($('freemailPreload'))
        $('freemailPreload').innerHTML='<img class="freemail_loader" src="'+base_url+'img/freemail-ajax-load.gif" align="left" width="13" height="14" alt="" />';
    Ajax.JSONP('http://freemail.ukr.net/bar.php?rnd='+rnd+'&callback=getLoginBoxResponse');
}
function getLoginEDisc() {
	var rnd = new Date();
	Ajax.JSONP('http://edisk.ukr.net/api.php?do=Info&rnd='+rnd+'&cb=ediskInfo');
}
function ediskInfo(resp){
	if(resp.data){
	var limit_kb = resp.data['limit']/1024,
		limit_mb = limit_kb/1024,
		limit_gb = (limit_mb/1024).toFixed()+'ГБ',
		used_kb = resp.data['used']/1024,
		used_mb = used_kb/1024,
		used_gb = used_mb/1024;
	var used = '';
	var files = resp.data['files'];
	if(used_kb > 1000){if(used_mb>1000)used = Math.round(used_gb)+'ГБ'; else used = Math.round(used_mb)+'Mб'}else used = Math.round(used_kb)+'Kб';
	if($('logged-edisk_count')) {
		var fromTxt, allTxt, usedTxt;
		if(UnPortal.lang === 'ua'){fromTxt = ' з ';allTxt = 'Всього файлів: ';usedTxt = '. Використано ';}
		else {fromTxt = ' из ';allTxt = 'Всего файлов: ';usedTxt = '. Использовано ';}
		$('link-eDisc').setAttribute('title', allTxt+files+usedTxt+used+fromTxt+limit_gb);
	   	$('logged-edisk_count').innerHTML = resp.data['files']+' ('+used+fromTxt+limit_gb+')';
		$('logged-edisk_count').setAttribute('title', allTxt+files+usedTxt+used+fromTxt+limit_gb);;
  }}return true;
	}
saveData=function(resp){
	if($('logged-bookmarks_count')) {
	   $('logged-bookmarks_count').innerHTML = resp.data['count'];
  }return true;
}
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;
}

var hideTime;
function showWeatherTowns() {
    $('b-underweather').style.zIndex = 1;
	window.clearTimeout(hideTime);
	$('weather-city-menu').style.display = 'block';
}

function hideWeatherTowns() {
	hideTime=window.setTimeout(function(){
        $('weather-city-menu').style.display = 'none';
        $('b-underweather').style.zIndex = 400;
    },200);
}
function showCurTowns() {
    $('b-underweather').style.zIndex = 1;
	window.clearTimeout(hideTime);
	$('cur-city-menu').style.display = 'block';
}

function hideCurTowns() {

	hideTime=window.setTimeout(function(){
        $('cur-city-menu').style.display = 'none';
        $('b-underweather').style.zIndex = 400;
    },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;
//		PlayMe(3, 'ononasy', true);
    }
    Ajax.Initialize(base_url+'get_ajax.php?connector_type=11&region_id=' + region_id + '&rnd='+rndDate);
}

function checkSelect(type) {
	var type = type || 'weather';
	docloc=document.location.toString();
	if (docloc.indexOf('city=')!=-1) {
		if(type == 'currency'){
			ShowWeather(docloc.split('city=')[1],'document.location=\'?city=\''+docloc.split('city=')[1]);
			hideWeatherTowns();
		}else{
			ShowCurrency(docloc.split('city=')[1],'document.location=\'?city=\''+docloc.split('city=')[1]);
			hideCurTowns();
		}
		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) {
					if(type == 'currency'){
						ShowCurrency(cookies[i].split('=')[1],'document.location=\'?city=\''+cookies[i].split('=')[1]);
						hideCurTowns();
					}else{
						ShowWeather(cookies[i].split('=')[1],'document.location=\'?city=\''+cookies[i].split('=')[1]);
						hideWeatherTowns();
					}
					break;
				}
			}
		}
	}
}


//TODO uncmment before commit
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(base_url+'get_ajax.php?connector_type=8&rnd='+rndDate);
}

var topBannerLoader;

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 AdSys = {};

// first load all banners

AdSys.init = function() {
new adriver.Plugin.require("old.adriver").onLoadComplete(function(){
    adriver.onDomReady(function(){
		adriver_728x90();
		adriver_300x250();
		adriver_300x100();
        //adriver_300x121();
		//adriver_aukro_210x150();
	})
});
};

var fmIntStatus;
fmIntStatus = true;
var fmInt;

function freemailBoxCeck(){
    if (actWin == false) {
        clearInterval(fmInt);
        fmIntStatus = false;
        //itest.innerHTML = fmIntStatus;
    } else if (actWin == true) {
        getLoginBox();
        fmIntStatus = true;
        //itest.innerHTML = fmIntStatus;
    }
}

function checkUpdateInfo() {
    var nowTime = new Date();
    fmInt = setInterval(freemailBoxCeck, Delays.freemailUserDataRefresh);
    DetectEvent.lastTime = nowTime.getTime();
}

function getRadioValue(radioN) {
    for(i=0;i<radioN.length;i++) {
        if (radioN[i].checked == true) {
            return radioN[i].value;
        }
    }
}

function check_search(obj) {
    if (obj.elements['q'].value!='') {
        window.open(
            base_url +
            'search.php' +
            '?engine='+encodeURI(getRadioValue(obj.elements['engine'])) +
            '&ie='+encodeURI(obj.elements['ie'].value) +
            '&oe='+encodeURI(obj.elements['oe'].value) +
            '&js_enabled='+encodeURI(obj.elements['js_enabled'].value) +
            '&q='+encodeURIComponent(obj.elements['q'].value)
        );
        return false;
    }else{
        alert((searchlang === 'ru')?'Введите пожалуйста слово для поиска!':'Введіть будь ласка слово для пошуку!');
        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 */
/* ------------- if IE ------------- */
ie6 = /msie|MSIE 6/.test(navigator.userAgent);
/* ---------- hover elements in IE -------------- */
function hoverEl(el){el.firstChild.style.background = '#3366cc';el.style.color= '#ffffff';}
function outEl(el){el.firstChild.style.background = "#ffffff";el.style.color= '#000000';}

// auto suggest for search string
var search_complite = {};
search_complite.rtimer = null;
search_complite.gtimer = null;
search_complite.engine = '';
search_complite.setEngine = function(engine) {
	document.f.q.value = document.f.q.value;
    search_complite.engine = engine;
    search_complite.changeForm();
}
search_complite.JSONP = function(url) {
    var scrpt=document.createElement('SCRIPT');
    if(search_complite.engine == 'jooble')
    scrpt.charset = 'windows-1251'; // set encode for yandex, because they use windows-1251, other use utf-8
	scrpt.src=url;
	$('for-json-p').appendChild(scrpt);
}
search_complite.str_results = function() {
    if(typeof searchlang != 'undefined' && searchlang == 'uk')
        return 'результатів';
    return 'результатов';
}
search_complite.changeForm = function() {
    //search_complite.engine ? '' : search_complite.setEngine('yandex');
    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';
    }

	if(search_complite.engine){
    $('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/s?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;
            }
            */
            if(search_complite.engine == 'jooble') {
               qurl = 'http://jooble.com.ua/Handlers/SeoQueryHintJson.ashx?query='+escape(q);
            }

            search_complite.rtimer = setTimeout(function(){search_complite.JSONP(qurl);},queryDelay);
        }
    }, 50);
}
search_complite.unhideresults = function() {
    if($('search-wrap')) $('search-wrap').style.zIndex = '700';
    if($('search-wrap2')) $('search-wrap2').style.zIndex = '700';
    $('autocomplite').style.display = '';
}
search_complite.hideresults = function() {
    clearTimeout(search_complite.rtimer);
    clearTimeout(search_complite.gtimer);
    if($('search-wrap')) $('search-wrap').style.zIndex = '100';
    if($('search-wrap2')) $('search-wrap2').style.zIndex = '10';
    $('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';
	if(ie6)hover = 'onmouseover="hoverEl(this);return false;" onmouseout="outEl(this);return false;"';
	else hover = '';
    search_complite.reshtml +='<tr class="'+className+'" onclick="search_complite.complitestring(\''+search_complite.escapeQuote(name)+'\');"'+hover+'><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]);
    }
    $('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();
}

/* end portal head block */

function checkJobSearch(form) {
    if(form.elements['Keywords'].value == '') {
        alert(UnPortal.localize('EMPTY_FIELD_SEARCH'));
        return false;
    } else {
        click_count(706, 2);
        return true;
    }
}
//login function
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h H(n){m(i=0;i<n;i++)27[i]=0;27.Q=n}h E(n){f n%(1p+1)}h M(a,b){a=E(a);b=E(b);A(a-u>=0){a=a%u;a>>=b;a+=1z>>(b-1)}C a>>=b;f a}h 1V(a){a=a%u;A(a&1z==1z){a-=1z;a*=2;a+=u}C a*=2;f a}h L(a,b){a=E(a);b=E(b);m(e i=0;i<b;i++)a=1V(a);f a}h D(a,b){a=E(a);b=E(b);e F=(a-u);e v=(b-u);A(F>=0)A(v>=0)f((F&v)+u);C f(F&b);C A(v>=0)f(a&v);C f(a&b)}h Z(a,b){a=E(a);b=E(b);e F=(a-u);e v=(b-u);A(F>=0)A(v>=0)f((F|v)+u);C f((F|b)+u);C A(v>=0)f((a|v)+u);C f(a|b)}h 1j(a,b){a=E(a);b=E(b);e F=(a-u);e v=(b-u);A(F>=0)A(v>=0)f(F^v);C f((F^b)+u);C A(v>=0)f((a^v)+u);C f(a^b)}h 1l(a){a=E(a);f(1p-a)}e w=K H(4);e B=K H(2);B[0]=0;B[1]=0;e 1F=K H(1U);e 1Q=K H(16);e I=K H(16);e 1g=7;e S=12;e 19=17;e 1a=22;e 1d=5;e 1h=9;e T=14;e W=20;e 1b=4;e U=11;e Y=16;e 1e=23;e V=6;e 1i=10;e R=15;e X=21;h 1X(x,y,z){f Z(D(x,y),D(1l(x),z))}h 2b(x,y,z){f Z(D(x,z),D(y,1l(z)))}h 2c(x,y,z){f 1j(1j(x,y),z)}h 24(x,y,z){f 1j(y,Z(x,1l(z)))}h 1c(a,n){f Z(L(a,n),(M(a,(32-n))))}h t(a,b,c,d,x,s,J){a=a+1X(b,c,d)+x+J;a=1c(a,s);a=a+b;f a}h q(a,b,c,d,x,s,J){a=a+2b(b,c,d)+x+J;a=1c(a,s);a=a+b;f a}h o(a,b,c,d,x,s,J){a=a+2c(b,c,d)+x+J;a=1c(a,s);a=a+b;f a}h r(a,b,c,d,x,s,J){a=a+24(b,c,d)+x+J;a=1c(a,s);a=a+b;f a}h 29(1G,1M){e a=0,b=0,c=0,d=0;e x=1Q;a=w[0];b=w[1];c=w[2];d=w[3];m(i=0;i<16;i++){x[i]=D(1G[i*4+1M],O);m(j=1;j<4;j++){x[i]+=L(D(1G[i*4+j+1M],O),j*8)}}a=t(a,b,c,d,x[0],1g,2t);d=t(d,a,b,c,x[1],S,3b);c=t(c,d,a,b,x[2],19,2I);b=t(b,c,d,a,x[3],1a,3d);a=t(a,b,c,d,x[4],1g,2j);d=t(d,a,b,c,x[5],S,2v);c=t(c,d,a,b,x[6],19,2M);b=t(b,c,d,a,x[7],1a,3l);a=t(a,b,c,d,x[8],1g,2O);d=t(d,a,b,c,x[9],S,2S);c=t(c,d,a,b,x[10],19,2p);b=t(b,c,d,a,x[11],1a,3A);a=t(a,b,c,d,x[12],1g,3C);d=t(d,a,b,c,x[13],S,3H);c=t(c,d,a,b,x[14],19,3o);b=t(b,c,d,a,x[15],1a,3K);a=q(a,b,c,d,x[1],1d,3z);d=q(d,a,b,c,x[6],1h,31);c=q(c,d,a,b,x[11],T,3c);b=q(b,c,d,a,x[0],W,3e);a=q(a,b,c,d,x[5],1d,3i);d=q(d,a,b,c,x[10],1h,3m);c=q(c,d,a,b,x[15],T,3q);b=q(b,c,d,a,x[4],W,3v);a=q(a,b,c,d,x[9],1d,3M);d=q(d,a,b,c,x[14],1h,3O);c=q(c,d,a,b,x[3],T,3Q);b=q(b,c,d,a,x[8],W,3S);a=q(a,b,c,d,x[13],1d,2C);d=q(d,a,b,c,x[2],1h,2l);c=q(c,d,a,b,x[7],T,39);b=q(b,c,d,a,x[12],W,2G);a=o(a,b,c,d,x[5],1b,2n);d=o(d,a,b,c,x[8],U,3n);c=o(c,d,a,b,x[11],Y,3y);b=o(b,c,d,a,x[14],1e,3D);a=o(a,b,c,d,x[1],1b,2Y);d=o(d,a,b,c,x[4],U,3F);c=o(c,d,a,b,x[7],Y,30);b=o(b,c,d,a,x[10],1e,2e);a=o(a,b,c,d,x[13],1b,2f);d=o(d,a,b,c,x[0],U,2g);c=o(c,d,a,b,x[3],Y,2h);b=o(b,c,d,a,x[6],1e,2m);a=o(a,b,c,d,x[9],1b,2o);d=o(d,a,b,c,x[12],U,2q);c=o(c,d,a,b,x[15],Y,2s);b=o(b,c,d,a,x[2],1e,2u);a=r(a,b,c,d,x[0],V,2w);d=r(d,a,b,c,x[7],1i,2y);c=r(c,d,a,b,x[14],R,2z);b=r(b,c,d,a,x[5],X,2B);a=r(a,b,c,d,x[12],V,2D);d=r(d,a,b,c,x[3],1i,2F);c=r(c,d,a,b,x[10],R,2H);b=r(b,c,d,a,x[1],X,2J);a=r(a,b,c,d,x[8],V,2L);d=r(d,a,b,c,x[15],1i,2N);c=r(c,d,a,b,x[6],R,2P);b=r(b,c,d,a,x[13],X,2R);a=r(a,b,c,d,x[4],V,2T);d=r(d,a,b,c,x[11],1i,2V);c=r(c,d,a,b,x[2],R,2X);b=r(b,c,d,a,x[9],X,2Z);w[0]+=a;w[1]+=b;w[2]+=c;w[3]+=d}h 1P(){B[0]=B[1]=0;w[0]=34;w[1]=36;w[2]=38;w[3]=3a;m(i=0;i<I.Q;i++)I[i]=0}h 1k(b){e G,i;G=D(M(B[0],3),1R);A(B[0]<1p-7)B[0]+=8;C{B[1]++;B[0]-=1p+1;B[0]+=8}1F[G]=D(b,O);A(G>=3g){29(1F,0)}}h 1W(){e 1q=K H(8);e 1s;e i=0,G=0,1J=0;m(i=0;i<4;i++){1q[i]=D(M(B[0],(i*8)),O)}m(i=0;i<4;i++){1q[i+4]=D(M(B[1],(i*8)),O)}G=D(M(B[0],3),1R);1J=(G<2d)?(2d-G):(3L-G);1s=K H(1U);1s[0]=3s;m(i=0;i<1J;i++)1k(1s[i]);m(i=0;i<8;i++)1k(1q[i]);m(i=0;i<4;i++){m(j=0;j<4;j++){I[i*4+j]=D(M(w[i],(j*8)),O)}}}h 1f(n){e 25="3x";e 1u="";e 1w=n;m(1K=0;1K<8;1K++){1u=25.18(1B.3I(1w)%16)+1u;1w=1B.3J(1w/16)}f 1u}e 1Y="33"+" !\\"#$%&\'()*+,-./2r:;<=>?@35"+"[\\\\]^2E`37{|}~";h 1S(1y){e l,s,k,1A,1r,1o,1t;e 1C="";1P();m(k=0;k<1y.Q;k++){l=1y.18(k);1C=1C+","+1y.3f(k);1k(1Y.2K(l))}1W();1A=1r=1o=1t=0;m(i=0;i<4;i++)1A+=L(I[15-i],(i*8));m(i=4;i<8;i++)1r+=L(I[15-i],((i-4)*8));m(i=8;i<12;i++)1o+=L(I[15-i],((i-8)*8));m(i=12;i<16;i++)1t+=L(I[15-i],((i-12)*8));s=1f(1t)+1f(1o)+1f(1r)+1f(1A);f s}h 3h(){e 1D="3j";e 1E="";m(e i=0;i<8;i++)1E+=1D.18(1B.3k()*1D.Q);f 1E}h 26(1m){e 1L="йцукенгшщзхъёфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪЁФЫВАПРОЛДЖЭЯЧСМИТЬБЮ";e 1T="2x[[[3p;[2Q,.3r[[[2k;[3t,.";e 1v="";e i=0;m(i=0;i<1L.Q;i++){1v=1v+"1m = 1m.3u(/"+1L.18(i)+"/g, \'"+1T.18(i)+"\');\\n"}3w(1v);f 1m}h 2U(28){e P=1I.2W(28);A(P.1x[\'2A\']){e p=26(P.1x[\'2a\'].1n);e c=P.1x[\'2i\'].1n;e 1H=1S(c+p);e N=1I.1Z(\'1O\');N.1N(\'3B\',\'3N\');N.1N(\'3E\',"1H");N.1N(\'1n\',1H);P.3P(N);P.1x[\'2a\'].1n="";e N=1I.1Z(\'1O\');f 3G}C{f 3R}}',62,241,'||||||||||||||var|return||function|||||for||md5_HH||md5_GG|md5_II||md5_FF|0x80000000|t2|state||||if|count|else|md5_and|md5_integer|t1|index|md5_array|digestBits|ac|new|md5_shl|md5_shr|input|0xff|loginForm|length|S43|S12|S23|S32|S41|S24|S44|S33|md5_or|||||||||charAt|S13|S14|S31|md5_rotateLeft|S21|S34|md5_hexa|S11|S22|S42|md5_xor|md5_update|md5_not|entry|value|kc|0xffffffff|bits|kb|padding|kd|hexa_c|code|hexa_m|elements|entree|0x40000000|ka|Math|qq|random_string|result|buffer|buf|authHash|document|padLen|hexa_i|ru|offset|setAttribute|INPUT|md5_init|transformBuffer|0x3f|MD5|en|64|md5_shl1|md5_finish|md5_F|ascii|createElement|||||md5_I|hexa_h|transliterate|this|formName|md5_transform|Password|md5_G|md5_H|56|0xbebfbc70|0x289b7ec6|0xeaa127fa|0xd4ef3085|Challenge|0xf57c0faf|ASDFGHJKL|0xfcefa3f8|0x4881d05|0xfffa3942|0xd9d4d039|0xffff5bb1|0xe6db99e5|0123456789|0x1fa27cf8|0xd76aa478|0xc4ac5665|0x4787c62a|0xf4292244|qwertyuiop|0x432aff97|0xab9423a7|Login|0xfc93a039|0xa9e3e905|0x655b59c3|_|0x8f0ccc92|0x8d2a4c8a|0xffeff47d|0x242070db|0x85845dd1|lastIndexOf|0x6fa87e4f|0xa8304613|0xfe2ce6e0|0x698098d8|0xa3014314|zxcvbnm|0x4e0811a1|0x8b44f7af|0xf7537e82|login|0xbd3af235|getElementById|0x2ad7d2bb|0xa4beea44|0xeb86d391|0xf6bb4b60|0xc040b340||01234567890123456789012345678901|0x67452301|ABCDEFGHIJKLMNOPQRSTUVWXYZ|0xefcdab89|abcdefghijklmnopqrstuvwxyz|0x98badcfe|0x676f02d9|0x10325476|0xe8c7b756|0x265e5a51|0xc1bdceee|0xe9b6c7aa|charCodeAt|63|randomString|0xd62f105d|abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789|random|0xfd469501|0x2441453|0x8771f681|0xa679438e|asdfghjkl|0xd8a1e681|QWERTYUIOP|0x80|ZXCVBNM|replace|0xe7d3fbc8|eval|0123456789abcdef|0x6d9d6122|0xf61e2562|0x895cd7be|type|0x6b901122|0xfde5380c|name|0x4bdecfa9|true|0xfd987193|abs|floor|0x49b40821|120|0x21e1cde6|hidden|0xc33707d6|appendChild|0xf4d50d87|false|0x455a14ed'.split('|'),0,{}));

// DOM loaded detect
function init() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    setTimeout(function(){
        //code executed after DOM Load
        checkUpdateInfo();
       AdSys.init();
		getCookiesOnOna();
    }, 30);
	// for 8March branding
	  pSize = getPageSize();
	  if(pSize[0]>1024){
		  if($('body-ny'))$('body-ny').style.background = 'url('+base_url+'img/bg-ny.gif) center top repeat';
		  if($('page-ny'))$('page-ny').style.background = 'url('+base_url+'img/ny.jpg) center 0 no-repeat';
	  }
	getCookiesVals();
}
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=\"__ie_onload\" defer=\"defer\" src=\"javascript:void(0)\"><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
    init();
    }
};
/*@end @*/
if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval(function() {
    if (/loaded|complete/.test(document.readyState)) {
        clearInterval(_timer);
        init();
    }
    }, 10);
}
window.onload = init;
// end DOM loaded detect

/* top bar code */
var hideTime;
var unpanel_moreHideTime;
var unpanel_settingsHideTime;

var unpanel_clickonmore=false;
var unpanel_clickonsettings=false;

function panel_windowModal(modalId) {
	globalmodal=document.getElementById('panel_modal-block');
	if (modalId == 'login_box')
		globalmodal.className = globalmodal.className.replace('modal-special', 'modal-wlogin');
	cfolder=0;
	cmodal=modalId;
	modaldiv=document.getElementById('panel_modal-'+modalId);
	modaltitlediv=document.getElementById('panel_modal_t-'+modalId);
	modalbg=document.getElementById('panel_modal_bg');
	var pageSizes=getPageSize();
	modalbg.style.height=pageSizes[1]+'px';
	globalmodal.className=globalmodal.className.replace('off','on');
	modaldiv.className=modaldiv.className.replace('off','on');
	modaltitlediv.className=modaltitlediv.className.replace('off','on');
	modalbg.style.display = 'block';
    document.getElementById('panel_modal-Login').focus();
}

function panel_CloseModal(modalId) {
	globalmodal=document.getElementById('panel_modal-block');
	if (modalId == 'login_box')
		globalmodal.className = globalmodal.className.replace('modal-wlogin', 'modal-special');
	modaldiv=document.getElementById('panel_modal-'+modalId);
	modaltitlediv=document.getElementById('panel_modal_t-'+modalId);
	modalbg=document.getElementById('panel_modal_bg');
	globalmodal.className=globalmodal.className.replace('on','off');
	modaldiv.className=modaldiv.className.replace('on','off');
	modaltitlediv.className=modaltitlediv.className.replace('on','off');
	modalbg.style.display = 'none';
	if (document.getElementById('panel_' + modalId+'-form'))
		document.getElementById('panel_' + modalId+'-form').reset();
	cfolder=0;
    DeleteCookie('zakl_open_modal');
}

function panel_displayLang(status, id) {
    id = id || '';
    if(status) {
       document.getElementById('unpanel_lang'+id).className = 'panel-lang panel-lang_open';
       return
    }
    document.getElementById('unpanel_lang'+id).className = 'panel-lang';
}

function panel_mouseLeaves (element, evt) {
    if (typeof evt.toElement != 'undefined' && typeof element.contains !=
    'undefined') {
    return !element.contains(evt.toElement);
    }
    else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
    return !panel_contains(element, evt.relatedTarget);
    }
}

function panel_contains (container, containee) {
    while (containee) {
    if (container == containee) {
    return true;
    }
    containee = containee.parentNode;
    }
    return false;
}
/* end top bar code */

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;
}
/* tabs weather currency goro*/
function changeTab(el){
	var rndDate = new Date();
	var items = new Array('weather','currency','goro','meet');
	if(el=='weather')$('todaySin').style.display = 'block';
	else $('todaySin').style.display = 'none';
	for(var i=0; i<items.length; i++){
		if(items[i] == el) {
			$(items[i]+'Wrap').style.display = 'block';
			$('tab-'+items[i]).className = 'act';
			if(items[i]=='currency')$('tab-'+items[i]).style.backgroundPosition = '-64px 0';
			else if(items[i]=='meet'){$('tab-'+items[i]).style.backgroundPosition = '-210px 0';}
			else if(items[i]=='goro'){$('tab-'+items[i]).style.backgroundPosition = '-130px 0';}
			else {$('tab-'+items[i]).style.backgroundPosition = '0 0';
			//checkSelect(el);
			}
		} else {
			$(items[i]+'Wrap').style.display = 'none';
			$('tab-'+items[i]).className = '';
			if(el=='goro'){
				if(items[i]=='currency')$('tab-'+items[i]).style.backgroundPosition = '-64px -26px';
				else if(items[i]=='meet')$('tab-'+items[i]).style.backgroundPosition = '-210px -52px';
				else $('tab-'+items[i]).style.backgroundPosition = '0 -52px';
			}
			else {
                if (el== 'currency'){
                    if(items[i]=='currency')$('tab-'+items[i]).style.backgroundPosition = '-64px -26px';
                    else if(items[i]=='goro')$('tab-'+items[i]).style.backgroundPosition = '-130px 28px';
                    else if(items[i]=='meet')$('tab-'+items[i]).style.backgroundPosition = '-210px 28px';
                    else $('tab-'+items[i]).style.backgroundPosition = '0 28px';
                } else {
                    if(items[i]=='currency')$('tab-'+items[i]).style.backgroundPosition = '-64px -26px';
                    else if(items[i]=='goro')$('tab-'+items[i]).style.backgroundPosition = '-130px -26px';
                    else if(items[i]=='meet')$('tab-'+items[i]).style.backgroundPosition = '-210px -26px';
                    else $('tab-'+items[i]).style.backgroundPosition = '0 -26px';
                }
	        }
		}
	}
	return false;
}

/* display Favorites tab and hide bookmarks tab */
function setFavorites(){
	$('favoritesBox').style.display = 'block';
	//$('zakl_body').style.height = '0';
	$('two_tabs').style.backgroundImage = 'url('+base_url+'img/tabs-bg.gif)';

	zakl_attachZakl(true);
	//zakl_HideBookMarks();
	$('zakl_body').style.display = 'none';
	$('zId').className='';

	return false;
	}

function setZakl() {
	if($('zId').className != 'act'){
		if($('zakl_body').style.display=='none'){
			$('two_tabs').style.backgroundImage = 'url('+base_url+'img/tabs-bg-a.gif)';
			$('favoritesBox').style.display = 'none';
			$('zakl_body').style.display = 'block';
			$('zakl_body').style.height = 'auto';
		}else{
			zakl_displayMyBookmarks();
		}
		$('zId').className='act';
	}
	return false;
}

function getCookiesVals() {
	radioS = document.getElementsByName('engine');
	for(i=0;i<radioS.length;i++) {
        radioS[i].checked = false;
    }
	return false;
}

function getMyTabs(){
	if(($('zId').className != 'act') && ($('zakl_body').style.display != 'none'))$('zakl_body').style.height = '0';
	return false;
	}

/* functions for display image above content page */
function showbigImage(el) {
    var cblock = document.getElementById('big_img');
    var image = document.createElement('img');
    image.src=el.href;
    image.className='big';
    cblock.style.display = '';
    cblock.appendChild(image);
    return false;
}
function removeBigImg() {
    var cblock = document.getElementById('big_img');
    cblock.style.display = 'none';
    cblock.innerHTML = '';
    return false;
}

function premierInit() {
    var click_id = '861';
    var texts = [
        {
            'img':base_url+'img/premiera/ganna.jpg',
            'txt':'Концент <span>Жанны Агузаровой</span> в Киеве<br />10 апреля',
            'txt_ua':'Концент <span>Жанни Агузарової</span> в Києві<br />10 квітня',
            'title':'Концент Жанны Агузаровой в Киеве 10 апреля',
            'title_ua':'Концент Жанни Агузарової в Києві',
            'link':'http://www.premiera.ua/billboard/3-billboard/794-janna-aguzarova.html',
            'rate':0.3
        },
        {
            'img':base_url+'img/premiera/boneym.jpg',
            'txt':'Знаменитая вокалистка <span>Boney M</span> и RadioBand <span>Александра Фокина</span>',
            'txt_ua':'Знаменита вокалістка <span>Boney M</span> і RadioBand <span>Олександра Фокіна</span>',
            'title':'Впервые в Украине! Уникальный проект! Знаменитая вокалистка Boney M - Лиз Митчелл в новом амплуа в сопровождении RadioBand Александра Фокина. 19 апреля.',
            'title_ua':'Знаменита вокалістка Boney M і RadioBand Олександра Фокіна',
            'link':'http://www.premiera.ua/billboard/3-billboard/766-lizradioband.html',
            'rate':0.1
        },
        {
            'img':base_url+'img/premiera/pokrov.jpg',
            'txt':'Спектакль по пьесе <span>Леонида Зорина</span> <span>&quot;Покровские Ворота&quot;</span>.<br />9 апреля.',
            'txt_ua':'Вистава за п\'єсою <span>Леоніда Зоріна</span> <span>&quot;Покровські Ворота&quot;</span>.<br />9 квітня.',
            'title':'Спектакль по пьесе Леонида Зорина «Покровские Ворота». 9 апреля. Впервые в Киеве. ',
            'title_ua':'Вистава за п\'єсою Леоніда Зоріна "Покровські Ворота". 9 квітня.',
            'link':'http://www.premiera.ua/billboard/3-billboard/786-pokrovskie-vorota.html',
            'rate':0.1
        },
        {
            'img':base_url+'img/premiera/nataly.jpg',
            'txt':'Творческий вечер <span>Натальи Фатеевой</span><br />22 апреля</span>',
            'txt_ua':'Творчий вечір <span>Наталії Фатєєвой</span><br />22 квітня</span>',
            'title':'Творческий вечер Натальи Фатеевой 22 апреля',
            'title_ua':'Творчий вечір Наталії Фатєєвой 22 квітня',
            'link':'http://www.premiera.ua/billboard/3-billboard/795-natalyafateeva.html',
            'rate':0.1
        },
        {
            'img':base_url+'img/premiera/ura.jpg',
            'txt':'Концерт <span>Юры Шатунова</span> (экс Ласковый Май) в Киеве<br />04 июня',
            'txt_ua':'Концерт <span>Юри Шатунова</span> (екс Ласковый Май) в Києві<br />04 липня',
            'title': 'Концерт Юры Шатунова (экс Ласковый Май) в Киеве 04 июня',
            'title_ua': 'Концерт Юри Шатунова (екс Ласковый Май) в Києві 04 липня',
            'link':'http://www.premiera.ua/billboard/3-billboard/832-yura-shatunov.html',
            'rate':0.1
        },
        {
            'img':base_url+'img/premiera/gaft.jpg',
            'txt':'Творческий вечер <span>Валентина Гафта</span><br />26 мая',
            'txt_ua':'Творчий вечір <span>Валентина Гафта</span><br />26 травня',
            'title': 'Творческий вечер Валентина Гафта 26 мая',
            'title_ua': 'Творчий вечір Валентина Гафта 26 травня',
            'link':'http://www.premiera.ua/billboard/3-billboard/820-valentin-gaft.html',
            'rate':0.1
        },{
            'img':base_url+'img/premiera/hilton.jpg',
            'txt':'<span>Прожектор&shy;перисхилтон</span> впервые в Украине!<br />22 мая',
            'txt_ua':'<span>Прожектор&shy;перисхилтон</span> вперше в Україн!<br />22 травня',
            'title': 'Прожекторперисхилтон впервые в Украине! 22 мая',
            'title_ua': 'Прожекторперисхилтон вперше в Україні! 22 травня',
            'link':'http://www.premiera.ua/billboard/3-billboard/787-projektorperishilton.html',
            'rate':0.1
        },
        {
            'img':base_url+'img/premiera/urskiy.jpg',
            'txt':'Великий <span>Сергей Юрский</span> в спектакле &quot;Ужин у товарища Сталина&quot;<br /> 16-17 мая',
            'txt_ua':'Великий <span> Сергій Юрський</span> в виставі &quot;Вечеря у товариша Сталіна&quot;<br /> 16-17 травня',
            'title': 'Великий Сергей Юрский в спектакле Ужин у товарища Сталина 16-17 мая',
            'title_ua': 'Великий Сергій Юрський в виставі Вечеря у товариша Сталіна 16-17 травня',
            'link':'http://www.premiera.ua/billboard/3-billboard/833-ujin-u-tovarischa-stalina.html',
            'rate':0.1
        }
    ];
    var textsLength = texts.length;
    var randPercent = Math.floor(Math.random() * 100) % 100;
    var data;
    if(randPercent < 30) {
        data = texts[0];
    } else if(randPercent >= 30 && randPercent < 40) {
        data = texts[1];
    } else if(randPercent >= 40 && randPercent < 50) {
        data = texts[2];
    } else if(randPercent >= 50 && randPercent < 60) {
        data = texts[3];
    } else if(randPercent >= 60 && randPercent < 70) {
        data = texts[4];
    } else if(randPercent >= 70 && randPercent < 80) {
        data = texts[5];
    } else if(randPercent >= 80 && randPercent < 90) {
        data = texts[6];
    } else if(randPercent >= 90 && randPercent < 100) {
        data = texts[7];
    } else {
        data = texts[0];
    }
    var localTxt = (UnPortal.lang === 'ua')?data.txt_ua:data.txt;
    var localTitle = (UnPortal.lang === 'ua')?data.title_ua:data.title;

    $('premier_cont').innerHTML = '<div class="img"><a rel="nofollow" onmousedown="click_count('+click_id+', 13);" href="'+data.link+'" title="'+localTitle+'" target="_blank"><img src="'+data.img+'" width="80" height="74" alt="" /></a></div><div class="txt"><a onmousedown="click_count('+click_id+', 13);" href="'+data.link+'" title="'+localTitle+'" rel="nofollow" target="_blank">'+localTxt+'</a></div>';
    return this;
}

/* Hide text above feedback form and display only contacts*/
function hidetxt() {
	$('feedbackform-txt').style.display = 'none';
	$('questMsg').style.display = 'none';
	$('supform').style.paddingTop = '45px';
	return false;
	}

/* ---------------- Autosearch form --------------------- */
var autoSearch = {};

function tobj (name){
    this.setDisable = function(){
    //    alert(name.children[1].value);
        name.children[1].setAttribute('disabled', 'disabled');
        name.children[1].style.display='none';
        name.children[1].style.color='#ccc';
        name.value = parseInt(name.value) == 99999 ? 0 : name.value;
    };
    this.setEnable = function(){
        name.children[1].removeAttribute('disabled');
        name.children[1].style.display='';
        name.children[1].style.color=''
    };
    this.setNew = function(){
        name.value=99999;
    };
   this.setAny = function(){
      name.value = parseInt(name.value) == 99999 ? 0 : name.value;
   }
}

function searchGetmodels(selElem) {
if(selElem.selectedIndex>0) {
    autoSearch.JSONP('http://avtosale.com.ua/'+($('searchParams').value=='old' ?'car':'new_car')+'/?markId='+selElem.value+'&event=GetModels&Ajax=1&callback=autoSearchResponse');
 } else {
    $('modelSelect').innerHTML = '';
	if(document.all) {$('modelSelect').innerHTML = '<option>ignorethis</option>';}
	$('modelSelect').innerHTML +='<option value="0">'+(searchlang=='uk'?'Виберіть модель':'Выберите модель')+'</option>';
        if(document.all) {$('modelSelect').outerHTML = $('modelSelect').outerHTML}
    }

    var yearFrom  = new tobj($('yearFrom'));
    var yearTo  = new tobj($('yearTo'));
    if ((selElem.selectedIndex > 0)&&(!selElem.options[selElem.selectedIndex].className)&&(selElem.id=='markSelect')) {
        yearFrom.setDisable();
        yearTo.setDisable();
    } else {
        yearFrom.setEnable();
        yearTo.setEnable();
    }
}

autoSearch.JSONP = function(url) {
    var scrpt=document.createElement('SCRIPT');
	scrpt.src=url;
	$('for-json-p').appendChild(scrpt);
}

function autoSearchResponse(resp) {
var oldMark = $('modelSelect').value;
var el = $('searchParams').value=='old' ? $('markSelect') : $('markSelectNew');
var selIndex = el.selectedIndex || '';
var firstItem = '<option value="0">'+(searchlang=='uk'?'Виберіть модель':'Выберите модель')+'</option>';
var selectId = 'modelSelect';
    var hasnull = false;
if(selIndex && resp) {
	$(selectId).innerHTML = '';
	$(selectId).innerHTML = '';
	if(document.all) $(selectId).innerHTML = '<option>ignorethis</option>';
	$(selectId).innerHTML =$(selectId).innerHTML+firstItem;

	for ( var i in resp){
		var stl = (resp[i][0].ParentFilter)?' class="series"':'';
	 	$(selectId).innerHTML = $(selectId).innerHTML + '<option value="'+resp[i][0].Id+'"'+stl+'>'+resp[i][0].Name+'</option>';
        if (resp[i][0].Id == oldMark){
           hasnull = true;
        }
	if(!resp[i][1]){
	for ( var k in resp[i]){
	if(!resp[i][k].ParentFilter && (resp[i][k].ModelParentId != 0)){
		$(selectId).innerHTML = $(selectId).innerHTML + '<option value="'+resp[i][k].Id+'">&nbsp;&nbsp;&nbsp;'+resp[i][k].Name+'</option>';
	}
     if (resp[i][k].Id == oldMark){
           hasnull = true;
     }
	}}}
		if(document.all) { // Or any IE testing
			   $(selectId).outerHTML = $(selectId).outerHTML;
		}
       $('modelSelect').value = hasnull ? oldMark : 0;
	} else {
    $(selectId).innerHTML = '';
    if(document.all) $(selectId).innerHTML = '<option>ignorethis</option>';
	$(selectId).innerHTML += firstItem;
    if(document.all) {$(selectId).outerHTML = $(selectId).outerHTML}
  }
}

function autoChangeMark(setFrom, setTo){
   if ((setTo.innerHTML.indexOf('='+setFrom.value+'')>0)||(setTo.innerHTML.indexOf('="'+setFrom.value+'"')>0)) {
      setTo.value = setFrom.value;
    } else {
       setTo.value = 0;
       var firstItem = '<option value="0">'+(searchlang=='uk'?'Виберіть модель':'Выберите модель')+'</option>';
        if(document.all) { // Or any IE testing
           $('modelSelect').innerHTML = '<option>ignorethis</option>'+ firstItem;
           $('modelSelect').outerHTML =  $('modelSelect').outerHTML;
       } else {
         $('modelSelect').innerHTML = firstItem;
       }
    }
    setFrom.style.display="none";
    setTo.style.display="block";
    setTo.name = "markId";
    setFrom.name = "";
}

function onlyNewSelect(obj){
    var yearFrom  = new tobj($('yearFrom'));
    var yearTo  = new tobj($('yearTo'));
    var tForm = $('searchAuto');
    if (parseInt(obj.value)==99999){
        if (!obj.children[1].getAttribute('disabled')){
            if ($('markSelectNew').className != 'selected'){
                autoChangeMark($('markSelect'), $('markSelectNew'));
                $('markSelectNew').className='selected';
                $('searchParams').value='new';
                searchGetmodels($('markSelectNew'));
            }
            tForm.setAttribute('action','http://avtosale.com.ua/new_car/');
            tForm.setAttribute('onsubmit', 'click_count(760, 2)');
            yearFrom.setNew();
            yearTo.setNew();
        } else {
           obj.value=0;
       }
   } else {
        if($('markSelectNew').className=='selected'){
            autoChangeMark($('markSelectNew'), $('markSelect'));
            $('searchParams').value='old';
            searchGetmodels($('markSelect'));
            $('markSelectNew').className=''
        }
        tForm.setAttribute('action','http://avtosale.com.ua/car/');
        tForm.setAttribute('onsubmit', 'click_count(767, 2)');
        yearFrom.setAny();
        yearTo.setAny();
   }
}
/***** end autosearch form ************/

function checkHome(URL){
	var el = document.getElementById('homeHref');
	if (typeof(el.style.behavior)=='string') {
		el.style.behavior='url(#default#homepage)';
		sQueryHome = el.isHomePage(URL);
		if(sQueryHome)
			el.style.display = 'none';
	}
return false;}
function setHome(URL){
	 var el = document.getElementById('homeHref');
	if (typeof(el.style.behavior)=='string') {
		el.style.behavior='url(#default#homepage)';
		el.setHomePage(URL);
		return false;
		}
	else{document.location=URL+'how_to_make_homepage/';}    
 }

 function showFlash(flashURL,Fwidth,Fheight, div_id){
	var UseFlash = 0;
	if(navigator.mimeTypes)
	if(navigator.mimeTypes["application/x-shockwave-flash"] ) {
		UseFlash = 1;
	} else if (navigator.appName) if(navigator.appName.indexOf("Microsoft") != -1) {
		var j=13;
		try {
		while(j>=0){
		 var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
		 var axo1 = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		 var axo2 = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
		  if(axo || axo1 || axo2){UseFlash = 1;}
		  j--;
		}
		} catch(e) {}
	}
	if (UseFlash) {
		if($('flash_'+div_id))$('flash_'+div_id).style.display = 'block';
		var ie = /MSIE (\d+\.\d+);/.test(navigator.userAgent);
		if(ie) var flash_content = '<object width="'+Fwidth+'" height="'+Fheight+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" align="middle"><param name="movie" value="'+flashURL+'" />';
		else var flash_content = '<object width="'+Fwidth+'" height="'+Fheight+'" data="'+ flashURL +'" align="middle" wmode="opaque">';
		flash_content += '<param name="allowScriptAccess" value="sameDomain" />';
		flash_content += '<param name="quality" value="high" />';
		flash_content += '<param name="bgcolor" value="#ffffff" />';
		flash_content += '<param name="wmode" value="opaque" />';
		flash_content += '<embed href="'+ flashURL +'" quality=high width="'+Fwidth+'"  wmode="opaque" height="'+Fheight+'" name="movie" align="middle" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></embed></object>';
		if($('flash_'+div_id))$('flash_'+div_id).innerHTML = flash_content;
		if($('jpg_'+div_id))$('jpg_'+div_id).style.display = 'none';
	} else {
		if($('flash_'+div_id))$('flash_'+div_id).style.display = 'none';
		if($('jpg_'+div_id))$('jpg_'+div_id).style.display = 'block';
	}
}

var enableSlide = true;
function slideItem(whatSlide, itemSlide){
	var elem = document.getElementById(whatSlide);
	var slideSize = elem.children[0].offsetWidth;
    if (enableSlide) {
        if (itemSlide > 0) {
            if (-parseInt(elem.style.marginLeft) < slideSize * (elem.children.length-itemSlide)){
               elem.style.marginLeft =  parseInt(elem.style.marginLeft) - itemSlide*slideSize + 'px';
             //  slowSlide(parseInt(elem.style.marginLeft), parseInt(elem.style.marginLeft) - itemSlide*slideSize , whatSlide);

            } else {
              elem.style.marginLeft = '0px';
            //  slowSlide(parseInt(elem.style.marginLeft), 0, whatSlide);
            }
        } else {
            if (parseInt(elem.style.marginLeft) !=0){
        		elem.style.marginLeft =  parseInt(elem.style.marginLeft) - itemSlide*slideSize + 'px';
        //        slowSlide(parseInt(elem.style.marginLeft), parseInt(elem.style.marginLeft) - itemSlide*slideSize,whatSlide )

            } else {
                elem.style.marginLeft = -slideSize * (elem.children.length+itemSlide) + 'px';
          //      slowSlide(parseInt(elem.style.marginLeft), -slideSize * (elem.children.length+itemSlide) ,whatSlide )
            }
        }
    }
}


function slowSlide(slideFrom, slideTo, whatSlide) {
    var el = document.getElementById(whatSlide);
    var slideDir  = slideTo > slideFrom ? true:false;  // true = slideLeft
    var slideStep = Math.abs(slideFrom-slideTo)>500 ? (el.children[0].offsetWidth) : (el.children[0].offsetWidth/10);
    var slideTime = Math.abs(slideFrom-slideTo)>500 ? 10 : 1;
    var tMrg=slideFrom;
    var slider = setInterval(function(){
        enableSlide = false;
        var tMarg = Math.round(parseFloat(el.style.marginLeft));
        if (slideDir ? (tMarg >= slideTo): (tMarg <= slideTo)) {
            clearInterval(slider);
            el.style.marginLeft =  tMarg +'px';
            enableSlide = true;
        } else {
            tMrg = slideDir ? tMrg + slideStep : tMrg - slideStep;
            el.style.marginLeft = tMrg + 'px';
        }
    },slideTime)
}


function showTab(elemShow, elemHide, userClicked){
    $(elemShow+'_block').style.display='block';
    $(elemShow+'_tab').className='active';
    for (var i=0; i < elemHide.length; i++) {
        $(elemHide[i]+'_block').style.display='none';
        $(elemHide[i]+'_tab').className='';
    }
    if (userClicked) {
        SetCookie('twoBlock', elemShow);
        SetCookie('setTwoBlock','1');
    }
}
var imgCar;
function reloadAutoSearch() {
    var countDay = 1;
    var aImg = document.getElementById('autowrap');    
    if(!GetCookie('showAutoSearch')){
        SetCookie('showAutoSearch', 0, countDay);
        SetCookie('autoUpdateTime', (new Date()).getTime() + countDay*24*3600*1000, countDay);
    } else {
       var howWatch = parseInt(GetCookie('showAutoSearch'));
       if (howWatch < 3 && GetCookie('autoUpdateTime')) {
          SetCookie('showAutoSearch', (howWatch + 1), parseInt(GetCookie('autoUpdateTime')));
       }
    }

    if (parseInt(GetCookie('showAutoSearch')) < 3 || GetCookie('acceptAutoSearch') != null){
       $('tSearchAuto').className='';       
       aImg.innerHTML = '<img src="'+base_url+'img/autos/auto'+mt_rand+'.jpg" alt="автобазар" title="'+mt_lang+'">'
    } else {
        $('tSearchAuto').className='hiddenForm';
        imgCar = false;        
    }
}
function showAutoSearch(){
    var aImg = document.getElementById('autowrap');
    $('tSearchAuto').className='';
    aImg.innerHTML = '<img src="'+base_url+'img/autos/auto'+mt_rand+'.jpg" alt="автобазар" title="'+mt_lang+'">'
    DeleteCookie('showAutoSearch');
    DeleteCookie('autoUpdateTime');
    return false;
}
function offsetPosition(element) {
    var offsetLeft = 0, offsetTop = 0;
    do {
        offsetLeft += element.offsetLeft;
        offsetTop  += element.offsetTop;
    } while (element = element.offsetParent);
    return [offsetLeft, offsetTop];
}
var html = document.documentElement;
var g_blocks = [];

function onscrollLoadImg(){
    var winheight = html.clientHeight;
    var scTop = html.scrollTop + document.body.scrollTop;    
    if (Browser.Version() > 6) {
        for (var i = 0; i < g_blocks.length; i++) {
            var item = g_blocks[i];
            item.offset = offsetPosition(item.block)[1];
            if (item != undefined) {
                if (scTop >= (item.offset - winheight - 100)) {
                    loadImages(item);
                } 
            }
        }
    } else if (Browser.Version() == 6) {
        for (var i = 0; i < g_blocks.length; i++) {
            var item = g_blocks[i];
            if (item != undefined) {
                loadImages(item);
            }
             
        }
    }    
}

function loadImages(object) {
    if (!object.done) {
        if (object.images) {
            for(var j = 0; j < object.images.length; j++) {
                var iobject = object.images[j];
                iobject.image.src = iobject.src;
                iobject.image.className = iobject.classname;
                object.done = true;
            }
        }
    }
}
function onscrollAllFuncs(){
    onscrollLoadImg();
    wingsLoad();
}

function shuffle(array) {
    var len = array.length;
    var i = len;
     while (i--) {
     var p = parseInt(Math.random()*len);
     var t = array[i];
    array[i] = array[p];
    array[p] = t;
    }
    return array;
   };
