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[obj];
}
/*----------------------------------------------------------------------------------------------
						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','ref','img','mp3','love');
	var margin = {std:'14',ref:'67',img:'129',mp3:'174',love:'225'};
	for (i=0; i<fields.length; i++) {
		ObjCtl(fields[i],'background','#d3d5d6');
		ObjCtl('pointer','marginLeft',margin[section]);
		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');
}
/*----------------------------------------------------------------------------------------------
						Submit aport form
//--------------------------------------------------------------------------------------------*/
function AddQuery(section) {
	with(document.forms.search) {
		if(That.value != section) {
			That.value = section;
			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');
	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;
		//alert(oheight+" | "+cheight);
		if(cheight < oheight) ObjCtl(target,'height',oheight);
		else if(cheight > oheight) {
			bheight = (cheight - 3) / 2;
			bheight1 = Math.floor(bheight);
			bheight2 = Math.ceil(bheight);
			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;
}
/*----------------------------------------------------------------------------------------------
						Initialization of newslinebox
//--------------------------------------------------------------------------------------------*/
function InitNewsLineBox(startvalue) {
	if(obj = getObj('newslinebox')) {
		if(!opera) obj.stop();
		newsspeed = GetCookie('newsspeed');
		if(!newsspeed) newsspeed = startvalue;
		if(newsspeed == 0) obj.behavior = 'alternate';
	}
}
/*----------------------------------------------------------------------------------------------
						Get cookie
//--------------------------------------------------------------------------------------------*/
function GetCookie(name) {
	var aCookie = document.cookie.split("; ");
	for (var i=0;i<aCookie.length;i++) {
		var aCrumb = aCookie[i].split("=");
		if (name == aCrumb[0]) 
		return unescape(aCrumb[1]);
	}
	return null;
}
/*----------------------------------------------------------------------------------------------
						Save cookie
//--------------------------------------------------------------------------------------------*/
function SaveCookie(name,value,expiredays,path,domain,secure) {
	var expdate = new Date();
    expdate.setTime(expdate.getTime() + (expiredays * 24 * 3600 * 1000));
	expdate = expdate.toGMTString();
	document.cookie = name + "=" + escape(value) + ((expiredays) ? "; expires=" + expdate : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
/*----------------------------------------------------------------------------------------------
						Speed of movement of newsline
//--------------------------------------------------------------------------------------------*/
function NewsLineBoxCtl(mode) {
	var amounts	= new Array ('0','1','2','2','3');
	var delays	= new Array ('25','25','30','15','15');
	if(obj = getObj('newslinebox')) {
		if(mode == 'up') newsspeed++;
		if(mode == 'down') newsspeed--;
		if(newsspeed > 4) newsspeed = 4;
		if(newsspeed < 0) newsspeed = 0;
		if((newsspeed == 0) && (netscape)) newsspeed = 1;
		if(!opera) {
			obj.scrollAmount = amounts[newsspeed];
			obj.scrollDelay = delays[newsspeed];
			if(newsspeed > 0) obj.behavior = 'scroll';
			if(mode = 'go') obj.start();
		}
	}
	SaveCookie('newsspeed',newsspeed,365,"/","","");
}
/*----------------------------------------------------------------------------------------------
						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");
}