var fs = 0;

function set_fs(s){
	var obj = document.getElementById('content-main');

	if(s==0) {
		fs = 0;
		obj.className='';
	}
	else if(s>0) {
		fs = ((fs+1)<5) ? fs+1 : 5;
		obj.className='fs'+fs;
	}
	else {
		fs = ((fs-1)>0) ? fs-1 : 0;
		if (fs==0) obj.className='';
		else obj.className='fs'+fs;
	}
}

function open_gallery (t,gid,pc) {
	var gallery = window.open('xpop_gallery.php?t='+t+'&id='+gid+'&pic_path='+pc,'gallery','width=760,height=540,innerWidth=760,innerHeight=540,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	gallery.focus();
	if (!gallery) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function open_map (gid) {
	var gallery = window.open('xpop_map.php?id='+gid,'gallery','width=760,height=540,innerWidth=760,innerHeight=540,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	gallery.focus();
	if (!gallery) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function open_video (trl,gid,pc) {
	var gallery = window.open('xpop_video.php?id='+gid+'&trl_id='+trl+'&pic_path='+pc,'gallery','width=760,height=625,innerWidth=760,innerHeight=625,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	gallery.focus();
	if (!gallery) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function send2friend () {
	var send2friend = window.open('xpop_send2friend.php','send2friend','width=760,height=435,innerWidth=760,innerHeight=435,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	send2friend.focus();
	if (!send2friend) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function livegame (mid) {
	var livegame = window.open('xpop_livegame.php?mid='+mid,'Livegame_'+mid,'width=760,height=545,innerWidth=760,innerHeight=545,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	livegame.focus();
	if (!livegame) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function open_hotel (hid) {
	var hotel = window.open('/xpop_hotel.php?id='+hid,'hotel','innerWidth=760,innerHeight=535,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	hotel.focus();
	if (!hotel) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}
function open_pricelist (oid) {
	var hotel = window.open('/xpop_pricelist.php?id='+oid,'offer','innerWidth=800,innerHeight=600,menubar=0,location=0,resizable=0,scrollbars=1,status=0,directories=0');
	hotel.focus();
	if (!hotel) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function open_hotel_preview (hid) {
	var hotel = window.open('/preview/xpop_hotel.php?id='+hid,'hotel','innerWidth=760,innerHeight=535,menubar=0,location=0,resizable=0,scrollbars=0,status=0,directories=0');
	hotel.focus();
	if (!hotel) alert ('Моля, разрешете отварянето на pop up прозорци от този сайт!');
}

function show_tab(tab){
	var t_art = document.getElementById('srch_art');
	var t_prs = document.getElementById('srch_person');
	var t_itm = document.getElementById('srch_items');

	var a_art = document.getElementById('a_srch_art');
	var a_prs = document.getElementById('a_srch_person');
	var a_itm = document.getElementById('a_srch_items');
	var act = document.getElementById('actions');

	if (t_art) t_art.style.display='none';
	if (t_prs) t_prs.style.display='none';
	if (t_itm) t_itm.style.display='none';
	document.getElementById('srch_'+tab).style.display='block';

	if (a_art) a_art.className='default';
	if (a_prs) a_prs.className='default';
	if (a_itm) a_itm.className='default';
	document.getElementById('a_srch_'+tab).className='selected';

	if (act) act.style.top = (document.getElementById('page-content').offsetHeight - act.offsetHeight) +'px';
}

function show_hide(){
	var frm = document.getElementById('srch_frm');
	var lbl = document.getElementById('srch_lbl');
	var cnt = document.getElementById('srch_cnt');
	var act = document.getElementById('actions');

	var vis= frm.style.display == 'none';
	frm.style.display=(vis)?'block':'none';
	lbl.style.display=(!vis)?'block':'none';
	cnt.style.display=(!vis)?'block':'none';

	if (act) act.style.top = (document.getElementById('page-content').offsetHeight - act.offsetHeight) +'px';
}

function set_font_size(dr)
 {
   if(dr==0)
    {
	 font_size=0;
     document.getElementById('content').className='fs'+font_size;
	}
   font_size=font_size+dr;
   if(font_size>3) font_size=3;
   if(font_size<0) font_size=0;
   document.getElementById('content').className='content fs'+font_size;
   document.getElementById('iframe_refresh').src='/font_size'+font_size+'/empty.php';
   document.getElementById('actions').style.top = (document.getElementById('page-content').offsetHeight-document.getElementById('actions').offsetHeight) +'px';
   return false;
 }

 function show(objid,id){
    hide_all_ads();
    var obj = document.getElementById(objid);
	obj.style.visibility="visible";
	obj.onmouseover= function () { eval(' if(top.timer'+this.id+') top.clearTimeout(timer'+this.id+');'); }
	obj.onmouseout= function () {  eval(' if(top.timer'+this.id+') top.clearTimeout(timer'+this.id+'); top.timer'+this.id+' = top.setTimeout(\'hidetimer(\\\''+this.id+'\\\')\',2000);'); }
    document.body.onclick= function () { hide_all_ads(); }

	obj.style.top = (document.getElementById(id).offsetTop - (obj.offsetHeight-10))+'px';
	obj.style.left = (document.getElementById(id).offsetLeft  - 35)+'px';
	}

function hidetimer(objid){
 document.getElementById(objid).style.visibility="hidden";
}

function hide(objid){
 eval(' if(top.timer'+objid+') top.clearTimeout(timer'+objid+'); top.timer'+objid+' = top.setTimeout(\'hidetimer(\\\''+objid+'\\\')\',2000);');
}

function hide_all_ads()
 {
  var advs = document.getElementsByTagName('div');
  for(var i=0; i<advs.length; i++)
   if(advs[i].id.substring(0,8)=='advpopup')
    {
 	 document.getElementById(advs[i].id).style.visibility="hidden";
	}
 }

function ext_links(){
	if(document.getElementsByTagName('a')){
		var obja = document.getElementsByTagName('a');
		for(var i=0; i<obja.length; i++){
			if(obja[i].getAttribute('rel')=='external'){
				obja[i].onclick = function(){
					window.open(this.href);
					return false;
				}
			}
		}
	}
}

function init_2level_tabs(){
	if(document.getElementById("sport_news")){
		var sfEls = document.getElementById("sport_news").getElementsByTagName("li");
		var tsbCnt=0;
		for(var i=0; i<sfEls.length; i++) if((sfEls[i].className=='tab') || (sfEls[i].className=='tab selected')) tsbCnt++;
		for(var i=0; i<sfEls.length; i++) {
			if((sfEls[i].className=='tab') || (sfEls[i].className=='tab selected')) {
				if(sfEls[i].className=='tab selected') {
					document.getElementById(sfEls[i].id+'_cnt').style.display='block';
				}
				sfEls[i].onclick = function() {
					var obj = document.getElementById(this.id+'_cnt');
					if((obj.style.display == 'none') || (obj.style.display == '')){
						for(var j=0; j<tsbCnt; j++){
							document.getElementById('mt'+(j+1)).className='tab';
							document.getElementById('mt'+(j+1)+'_cnt').style.display='none';
						}
						obj.style.display = 'block';
						this.className='tab selected';
					}
				}
			}
		}
	}
}


var original_common_load = window.onload;
window.onload = function(){
	init_2level_tabs();
	if(original_common_load) original_common_load();
}