function _load()
{
  _init();
}

function _init()
{
    winW = 1024;
    winH = 768;

    if(is_ie)
    {
        winW = document.body.offsetWidth;
        winH = document.body.offsetHeight;
    }
    else
    {
        winW = window.innerWidth;
        winH = window.innerHeight;
    }

    if(winW < 980)
        document.getElementById('main').style.width = "980px";
    else 
        document.getElementById('main').style.width = "100%";
}

function ieFixPreloader()
{
    if(!is_ie) return;
    
    document.getElementById('main').style.width = screen.availWidth - 46;
}


function tuneCurrency()
{   
    var o = document.getElementById('chCurrency');
    if(o.style.visibility == '' || o.style.visibility == 'hidden') 
        objOn(document.getElementById('chCurrency'));
    else     
        objOff(document.getElementById('chCurrency'));
}

function m_on(id, type)
{
    document.images['li'+id].src = im[type*2+1].src;
}

function m_off(id, type)
{
    document.images['li'+id].src = im[type*2].src;
}

var im = new Array();
for(var i=0; i<6; i++) im[i] = new Image();

im[0].src = '/img/site/li.gif';
im[1].src = '/img/site/li_.gif';
im[2].src = '/img/site/li2.gif';
im[3].src = '/img/site/li2_.gif';
im[4].src = '/img/site/li3.gif';
im[5].src = '/img/site/li3_.gif';

var _yearDiv = null;
var _yearDivOpened = false;

function openCalYear(cyear,e)
{   
    if (!e)e=window.event;
        
    if(_yearDiv == null) 
    {
       _yearDiv = document.createElement('div');
       _yearDiv.className = 'calendarDiv';
       document.getElementById('calendar').appendChild(_yearDiv);        
       
       var tmp = '';
       
       for(var i=2007; i<=cyear; i++)
       {
        tmp+= "<div onmouseover=\"hightLight(this)\" onmouseout=\"dehightLight(this)\" onclick=\"go('?setyear="+i+"')\">"+i+"</div> ";
       }
       _yearDiv.innerHTML = tmp;
       
       _yearDiv.onmouseover = stayOpenedYear;
       _yearDiv.onmouseout = closeCalYear;
    }
  
  /*
    _daysDiv.style.left = e.layerX || e.x + document.body.scrollLeft;
    _daysDiv.style.top = (e.layerY || e.y + document.body.scrollTop) - 20;        
  */  
    
    _yearDiv.style.left = (e.layerX || e.x) - 25;
    _yearDiv.style.top = (e.layerY || e.y) + 10;      
    objOn( _yearDiv); 
    _yearDivOpened = true;
}

function closeCalYear()
{
    _yearDivOpened = false;
    setTimeout('_closeCalYear()', 500);    
}

function _closeCalYear()
{
    if(!_yearDivOpened)  objOff(_yearDiv);
}

function stayOpenedYear()
{
   _yearDivOpened = true;
}

function hightLight(o)
{   
    o.style.backgroundColor = "#ffffff";
    o.style.color = "#000000";
    if(o.childNodes[0].nodeName == 'A')
        o.childNodes[0].style.color = "#000000";
}

function dehightLight(o)
{   
    o.style.backgroundColor = "#004bb2";
    o.style.color = "#ffffff";
    if(o.childNodes[0].nodeName == 'A')
        o.childNodes[0].style.color = "#ffffff";
}


var _monthDiv = null;
var _monthDivOpened = false;

function openCalMonth(mnum, e)
{
    if (!e)e=window.event;
    
    if(_monthDiv == null) 
    {
       _monthDiv = document.createElement('div');
       _monthDiv.className = 'calendarDiv';
       document.getElementById('calendar').appendChild(_monthDiv);
    
       var tmp = '';
       
       for(var i=0; i < monthA.length; i++)
       {
        tmp+= "<div onmouseover=\"hightLight(this)\" onmouseout=\"dehightLight(this)\" onclick=\"go('?setmonth="+(i+1)+"')\">"+monthA[i]+"</div> ";
       }
       _monthDiv.innerHTML = tmp;
       
       _monthDiv.onmouseover = stayOpenedMonth;
       _monthDiv.onmouseout = closeCalMonth;
    }
  
  /*
    _daysDiv.style.left = e.layerX || e.x + document.body.scrollLeft;
    _daysDiv.style.top = (e.layerY || e.y + document.body.scrollTop) - 20;        
  */  
    
    _monthDiv.style.left = (e.layerX || e.x) - 25;
    
    
    
    _monthDiv.style.top = (e.layerY || e.y) + 10;      
    objOn(_monthDiv); 
    _monthDivOpened = true;
    
    //alert(monthA[mnum-1]);
}

function closeCalMonth()
{
    _monthDivOpened = false;
    setTimeout('_closeCalMonth()', 500); 
}

function stayOpenedMonth()
{
   _monthDivOpened = true;
}

function _closeCalMonth()
{
    if(!_monthDivOpened) objOff(_monthDiv);
}


var nextSelBool = true;

function selAll(form,el_name)
{
	var form = document.forms[form];
	
	for(var i=0; i<form.length; i++)
	{
		if(form[i].name.substring(0,el_name.length) == el_name) form[i].checked = nextSelBool;
	}
	nextSelBool = nextSelBool == true ? false : true;
}


function _sort(o)
{
    document.location.search='sort='+o.value;
}

onload = _load;
onresize = _init;
