ie = (document.all) ? true: false;
opera = (window.opera) ? true : false;
netscape = (navigator.appName == 'Netscape') ? true : false;
/*----------------------------------------------------------------------------------------------
						Looking for resize of window while document is loading
----------------------------------------------------------------------------------------------*/
loaded=false;
function resizerWhileLoad() {
	Modify('common');
	if (!loaded) setTimeout("resizerWhileLoad()",1);
}
resizerWhileLoad();
/*----------------------------------------------------------------------------------------------
						Changes width of common block
----------------------------------------------------------------------------------------------*/
function Modify(objid) {
	if ((document.body) && ((w = document.body.clientWidth) || (w = innerWidth))) {
		if(obj = getObj(objid)) obj.style.width = SizeIs(w);
	}
}
/*----------------------------------------------------------------------------------------------
						Define optimal width of common block
----------------------------------------------------------------------------------------------*/
function SizeIs(w) {
	if (w > 950) return '950';
	else if (w > 774) return '100%';
	else return '774';
}
/*----------------------------------------------------------------------------------------------
						Initialization of aport form (needs for 'back' operation)
//--------------------------------------------------------------------------------------------*/
function _Do(section) {
	section = (section) ? section : 'std';
	Switch(section);
}
/*----------------------------------------------------------------------------------------------
						Get object
----------------------------------------------------------------------------------------------*/
function getObj(obj){
	return (o = document.getElementById(obj))? o : (document.all) ? document.all[obj] : null;
}
/*----------------------------------------------------------------------------------------------
						Control of object properties
//--------------------------------------------------------------------------------------------*/
function ObjCtl(obj,property,value) {
	if(obj = getObj(obj)) obj.style[property] = value;
}
/*----------------------------------------------------------------------------------------------
						Switch between sections of aport form
//--------------------------------------------------------------------------------------------*/
function Switch(section) {
	var fields = new Array ('std','news','audio','video'); /* 'mp3','love'); */
	for (i=0; i<fields.length; i++) {
		ObjCtl(fields[i],'background','#d3d5d6');
		if (navigator.userAgent.indexOf ("MSIE 5") != -1) ObjCtl(fields[i],'cursor','hand');
		else ObjCtl(fields[i],'cursor','pointer');
	}
	ObjCtl(section,'background','#f9fafb');
	ObjCtl(section,'cursor','default');
}

function EnableNewsFields(state)
{
	state = state?false:true
	with(document.forms.search) {
		Rt.disabled=state
		Tn.disabled=state
		Base.disabled=state
	}
}

/*----------------------------------------------------------------------------------------------
						Submit aport form
//--------------------------------------------------------------------------------------------*/
function AddQuery(section) {
	with(document.forms.search) {
		if(That.value != section) {
			That.value = section;
			EnableNewsFields(That.value == 'rolnews')
			if(r.value) {
				Switch(section);
				submit();
			}
			else {
				Switch(section);
			}
		}
	}
}
/*----------------------------------------------------------------------------------------------
						Filter for images
//--------------------------------------------------------------------------------------------*/
function opacity(obj,mode) {
	if(mode) obj.style.filter='alpha(opacity=60)';
	else obj.style.filter='alpha(opacity=40)';
}
/*----------------------------------------------------------------------------------------------
						Apply transformations for index
//--------------------------------------------------------------------------------------------*/
function Do_SameHeightBlocks() {
	SameHeightBlock(1,4);
	SameHeightBlock(2,4);
	SpecialAlignment('newsblock',1,2);
	SameHeightBlock(4,3);
}
/*----------------------------------------------------------------------------------------------
						Control of hot news block
//--------------------------------------------------------------------------------------------*/
function ShowHotNews(section) {
	var bgcolors = new Array ('#a1b6e3','#b8a6d5','#68d9db','#8997a6','#e08f55','#d3b461','#A5CF65'); // pink #a5cf65
	for(i=0;i<7;i++) ObjCtl('hot'+i,'display','none');
	ObjCtl('block_3_2','backgroundColor',bgcolors[section]);
	ObjCtl('hot'+section,'display','block');
	if(obj = getObj('hot'+section)) oheight = obj.offsetHeight + 22; // Current height of hot block
	ObjCtl('block_3_2','height',oheight);
}
/*----------------------------------------------------------------------------------------------
						Alignment of blocks by height
//--------------------------------------------------------------------------------------------*/
function SameHeightBlock(row,number,maxval) {
	if(arguments[2]) {
		for (i=1; i<=number; i++) {
			ObjCtl('block_'+row+'_'+i,'height',maxval);
			if(document.getElementById('detail_'+row+'_'+i)) ObjCtl('detail_'+row+'_'+i,'top',maxval-9);
		}
	}
	else {
		var maxheight = 0;
		for (i=1; i<=number; i++) {
			if(obj = getObj('block_'+row+'_'+i)) maxheight = (maxheight > obj.offsetHeight) ? maxheight : obj.offsetHeight;
		}
		for (i=1; i<=number; i++) {
			ObjCtl('block_'+row+'_'+i,'height',maxheight);
			if(document.getElementById('detail_'+row+'_'+i)) ObjCtl('detail_'+row+'_'+i,'top',maxheight-9);

		}
	}
}
/*----------------------------------------------------------------------------------------------
						Special alignment of blocks with rowspan
//--------------------------------------------------------------------------------------------*/
function SpecialAlignment(target,row1,row2) {
	if((cobj = getObj(target)) && (obj1 = getObj('block_'+row1+'_1')) && (obj2 = getObj('block_'+row2+'_1'))) {
		cheight = cobj.offsetHeight;
		oheight = obj1.offsetHeight + obj2.offsetHeight + 3;
		if(cheight < oheight) ObjCtl(target,'height',oheight);
		else if(cheight > oheight) {
			var delta = cheight - oheight;
			bheight1 = obj1.offsetHeight + Math.ceil(delta/2);
			bheight2 = obj2.offsetHeight + Math.floor(delta/2);			
			SameHeightBlock(1,4,bheight1);
			SameHeightBlock(2,4,bheight2);
		}
	}
}
/*----------------------------------------------------------------------------------------------
						Changes style properties of the object
//--------------------------------------------------------------------------------------------*/
function Dynamic(obj,property,minvalue,maxvalue,step,delay,mode) {
	ismove = true;
	minvalue += step;
	if(mode == 'opp') ObjCtl(obj,property,'alpha(opacity='+minvalue+')');
	else ObjCtl(obj,property,minvalue);
	if(minvalue != maxvalue) setTimeout("Dynamic('"+obj+"','"+property+"',"+minvalue+","+maxvalue+","+step+","+delay+",'"+mode+"')",delay);
	else ismove = false;
}
/*----------------------------------------------------------------------------------------------
						Alignment of the page blocks
//--------------------------------------------------------------------------------------------*/
function AlignPageBlocks(obj1,iobj1,obj2,iobj2,increase) {
	if((oobj1 = getObj(obj1)) && (oobj2 = getObj(obj2))) {
		if(document.getElementById(increase)) {incobj = getObj(increase); var incheight = incobj.offsetHeight + 4}
		else var incheight = 0;
		var height1 = oobj1.offsetHeight;
		var height2 = oobj2.offsetHeight + incheight;
		var delta = height2 - height1;
		if((iheight1 = getObj(iobj1).offsetHeight) && (iheight2 = getObj(iobj2).offsetHeight)) {
			if(delta > 0) ObjCtl(iobj1,'height',iheight1 + delta);
			else ObjCtl(iobj2,'height',(iheight2 + Math.abs(delta)));
			// Prevent flooding pixels
			if (iheight1 > 1 && iheight2 > 1) {
				if(iheight2 > iheight1) {
					ObjCtl(iobj1,'height',1);
					ObjCtl(iobj2,'height',iheight2 - iheight1 + 1);
				}
				else {
					ObjCtl(iobj1,'height',iheight1 - iheight2 + 1);
					ObjCtl(iobj2,'height',1);
				}
			}
		}
	}
}
/*----------------------------------------------------------------------------------------------
						Print size of block
//--------------------------------------------------------------------------------------------*/
function test(obj) {
	obj = document.getElementById(obj);
	document.write("<br>"+obj.id+" - "+obj.offsetWidth+" x "+obj.offsetHeight+"px");
}