var _openedToolTip = null;
function lnkAddr_OnMOut(sender)
{
    if (!$defined(sender._tmr))
        sender._tmr = hideToolTip.delay(500, sender._tooltip);
}
function lnkAddr_OnMOver(sender, ttID)
{
    if (_openedToolTip != null)
    {
        hideToolTip.attempt([], _openedToolTip);
    }
   	if (sender._tooltip == null)
   	{
    	sender._tooltip = $(ttID);
        sender._tooltip.owner = sender;
        sender._tooltip.setStyle('z-index', 1000);
       	sender._tooltip.addEvent('mouseenter', function(e)
        {
        	e = new Event(e);
            if ($defined(this.owner._tmr))
            	this.owner._tmr = $clear(this.owner._tmr);
           	e.stop();
       	}.bindWithEvent(sender._tooltip));

       	sender._tooltip.addEvent('mouseleave', function(e)
       	{
        	e = new Event(e);
           	if (!$defined(this.owner._tmr))
           		this.owner._tmr = hideToolTip.delay(1000, this);
          	e.stop();
		}.bindWithEvent(sender._tooltip));
	}
    sender.parentNode.parentNode.className = 'act';

    sender._tooltip.owner = sender;
    sender._tooltip.setStyle('display', 'block');

    sender._tmr = $clear(sender._tmr);
    _openedToolTip = sender._tooltip;
}
function hideToolTip()
{
    this.setStyle('display', 'none');
    this.owner.parentNode.parentNode.className = '';
    this.owner._tmr = $clear(this.owner._tmr);
}

var _previous = null;
function showBig(sender, url)
{
    if (sender._bigImg == null)
    {
        sender._tmpPath = sender.src
        new Asset.image(url, { onload: function()
            {
                sender._bigImg = this.src;
                changeBig(sender);
            }
        });
    }
    else
    {
        changeBig(sender);
    }
}
function changeBig(thumbnail)
{
    var img = $('img_BigPhoto');
    if ((img != null) && (thumbnail._bigImg != null))
    {
        if (_previous != null)
        {
            _previous.parentNode.style.background = '';
            $(_previous).removeClass('ramka');
            _previous.src = _previous._tmpPath;
        }
        img.src = thumbnail._bigImg;

        $(thumbnail).addClass('ramka');
        thumbnail.parentNode.style.background = "url('" + thumbnail._tmpPath + "') no-repeat top left";
        thumbnail.src = './i/i_pix.gif';
        _previous = thumbnail;
    }
}


function cabinet_chk(id,check)
{
    var _params = new Object();
    _params.villageID = id;
    _params.checked = (check) ? '1' : '0'; 
    var cab = new Ajax(wpath + 'ajax/?method=cabinet_chk&xml=0', {'method': 'post'});
    cab.request(_params);
}

function clearCookie(repath)
{
    //var exdate=new Date();
    //exdate.setDate(exdate.getDate()+expiredays);
    document.cookie='villages' + '=' + '';
    location.href = repath;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

    var yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){     // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }

    arrayPageScroll = new Array('',yScroll) 
    return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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;
}