function makeHomePage(object)
	{
	object.style.behavior='url(#default#homepage)';
	object.setHomePage('http://'+document.location.hostname);
	}

function addToFav()
	{
	window.external.AddFavorite('http://'+document.location.hostname,'storytv');
	}

function nopicsave()
	{
	alert('Amennyiben képekre van szüksége, kérjük szíveskedjen felvenni velünk a kapcsolatot a megadott elérhetőségek valamelyikén! Köszönjük!');
	return false;
	}

function zoomimg(img,action,e)
	{
	if (action=='toggle') {action=document.img_large_img.src.indexOf('hourglass.gif')==-1 ? 0 : 1;}

	if (action==1)
		{
		reg = /(id\=\d+\&ext\=[^&]+|id\=\d+|database_name\=.+\&database_id\=[^&]+)/g;
		imgid = reg.exec(img.src);

		document.img_large_img.src='/image/?'+imgid[1]+'&th=f';

		if (!e)
			{
			pos_large_x=0;
			pos_large_y=0;
			pos_str='';
			pos_obj=img;
			while(pos_obj)
				{
				pos_large_x+=pos_obj.offsetLeft;
				pos_large_y+=pos_obj.offsetTop;
				pos_str+='.offsetParent';
				eval('pos_obj=img'+pos_str);
				}

			document.getElementById('img_large').style.left = pos_large_x+'px';
			document.getElementById('img_large').style.top = pos_large_y+'px';
			}
		else
			{
			pos_large_y=e.clientY+document.body.scrollTop-10;
			pos_large_x=e.clientX+document.body.scrollLeft-10;

			img_large.style.left = pos_large_x+'px';
			img_large.style.top = pos_large_y+'px';
			}

		document.getElementById('img_large').style.display = 'block';
		document.getElementById('img_large').title=img.title;

		imgid = reg.exec('');
		}
	else
		{
		document.getElementById('img_large').style.display = 'none';
		document.img_large_img.src='/images/icons/hourglass.gif';
		}
	}


content_loaded=Array();
newscript=Array();

/// 2009-05-31 NEW with cache!
function loadContent(contentid,contentparam,forcereload,outputid,lang)
	{
	if (content_loaded[contentid]!=1 || forcereload==1)
		{
		if (lang=='uk' || contentparam.indexOf('lang=uk')!=-1)
			{
			loading_text='Loading...';
			}
		else if (lang=='de' || contentparam.indexOf('lang=de')!=-1)
			{
			loading_text='Loading...';
			}
		else
			{
			loading_text='Betöltés...';
			}
		document.getElementById('content_'+contentid).innerHTML='<br/><br/><center>'+loading_text+'</center>';

		content_loaded[contentid]=1;
		newscript[contentid]=document.createElement("script");
		outputparam=outputid ? '&outputid='+outputid : '';
		langparam=lang ? '&lang='+lang : '';
		newscript[contentid].src='/inc/functions/load_content.php?' + (contentparam.indexOf('contentid')==-1 ? 'contentid='+contentid+outputparam+langparam : '') + contentparam + '&nocache=' + nocache;
		document.getElementsByTagName("body")[0].appendChild(newscript[contentid]);
		}

	return true;
	}


function scrollBox(objname, dir, horizontal, step, auto, norewind)
	{
	dir=dir ? dir : 1;
	horizontal = horizontal ? 1 : 0;
	step = step ? step : 1;
	auto = (auto || auto===0) ? auto : 50;
	norewind=norewind ? norewind : 0; 

	if (document.getElementById)
		{
		// IE5+, DOM compatible
		objScroll=document.getElementById(objname+'_scroll');
		}
	else if (document.all)
		{ 
		// IE4
		objScroll=document.all[objname+'_scroll'];
		}
	else if (document.layers)
		{
		// NS4
		objScroll=document.layers[objname+'_scroll'];
		}
	else
		{
		// none
		}

	if (auto=='smooth')
		{
		step_half=Math.floor(((step*0.9)/2));
		step_smooth=1;
		step_smooth_round=1;
		i=1;
		while(i<step_half)
			{
			scrollBox(objname, dir, horizontal, step_smooth_round, 0, norewind);
			step_smooth=step_smooth+0.1;
			step_smooth_round=Math.round(step_smooth);
			i=i+step_smooth_round;
			}
		while(i<=step)
			{
			scrollBox(objname, dir, horizontal, step_smooth_round, 0, norewind);
			step_smooth=Math.max(1, (step_smooth-0.1));
			step_smooth_round=Math.round(step_smooth);
			i=i+step_smooth_round;
			}
		auto=0;
		}
	else if (horizontal)
		{
		objScroll.scrollLeft=objScroll.scrollLeft+(dir*step);
		if (objScroll.scrollLeft==objScrollPos[objname] && !norewind) 
			{
			objScroll.scrollLeft= (dir==1) ? 0 : (objScroll.scrollWidth-step);
			}
		objScrollPos[objname]=objScroll.scrollLeft;
		}
	else
		{
		objScroll.scrollTop=objScroll.scrollTop+(dir*step);
		if (objScroll.scrollTop==objScrollPos[objname] && !norewind) 
			{
			objScroll.scrollTop= (dir==1) ? 0 : (objScroll.scrollHeight-step);
			}
		objScrollPos[objname]=objScroll.scrollTop;
		}

	if (auto)
		{
		clearTimeout(scrollBoxTimer[objname]); 
		scrollBoxTimer[objname]=setTimeout("scrollBox('"+objname+"', "+dir+","+horizontal+","+step+","+auto+","+norewind+")", auto);
		}
	}

scrollBoxTimer = new Array();
objScrollPos = new Array();



function openwindow(pageurl,width,height,scroll,winname) 
	{
	scroll=scroll!='no' ? 'yes' : 'no';
	winname=winname ? winname : '_blank';
	if (width || height)
		{
		posleft=(screen.width-width)/2;
		postop=(screen.height-height)/2;
	   if (0>postop) postop=0; 
	   if (0>posleft) posleft=0;
		pos=',toolbar=no,location=no,directories=no,menubar=no,status=no,left='+posleft+',top='+postop+',width='+width+',height='+height;
	   }
	  else
	  	{
	  	pos='';
	  	}

	window.open(pageurl,winname,'scrollbars='+scroll+pos);
	}
	


function tvmusor(action, param) 
	{
	if (action=='load')
		{
		loadContent('tvmusor_middle','&cache_time=900&tv_date='+param, 1);
		}
	else if (action=='scroll_to_active')
		{
		if (document.getElementById('tvmusor_middle_scroll'))
			{
			scrollBox('tvmusor_middle', 1, 1, document.getElementById('tvmusor_middle_scroll').getAttribute('tvmusor_active_pos'), 0, 1);
			}
		else
			{
			setTimeout('tvmusor(\'scroll_to_active\')', 150);
			}
		}
	else if (action=='scroll')
		{
		accel=80;
		step_smooth=1;
		step_smooth_round=step_smooth;
		i=step_smooth_round;
		while(i<accel)
			{
			scrollBox('tvmusor_middle', param, 1, step_smooth_round, 0, 1);
			step_smooth=Math.min(10, step_smooth+0.2);
			step_smooth_round=Math.round(step_smooth);
			i=i+step_smooth_round;
			}
		scrollBox('tvmusor_middle', param, 1, step_smooth_round, 3, 1);
		}
	else if (action=='scroll_stop')
		{
		clearTimeout(scrollBoxTimer['tvmusor_middle']);
		decel=25;
		remainder=param==1 ? 185-(document.getElementById('tvmusor_middle_scroll').scrollLeft % 185) : (document.getElementById('tvmusor_middle_scroll').scrollLeft % 185);
		remainder=remainder-decel;
		step_smooth=10;
		step_smooth_round=step_smooth;
		i=step_smooth_round;
		while(i<remainder)
			{
			scrollBox('tvmusor_middle', param, 1, step_smooth_round, 0, 1);
			step_smooth=Math.max(1, (step_smooth-0.2));
			step_smooth_round=Math.round(step_smooth);
			i=i+step_smooth_round;
			}
		remainder=remainder-(i-step_smooth_round)+decel;
		step_smooth_round=1;
		i=1;
		while(i<=remainder)
			{
			scrollBox('tvmusor_middle', param, 1, step_smooth_round, 0, 1);
			i=i+step_smooth_round;
			}
		}
	else if (action=='day')
		{
		param2=param ? 0 : 1;
		document.getElementById('tvmusor_day_'+param2).style.display='none';
		document.getElementById('tvmusor_day_'+param).style.display='block';
		document.getElementById('tvmusor_left').style.backgroundImage='url(/images/bg/tvmusor_bg_day_'+param+'.png)';
		tvmusor('load', param);
		}
	}


function onloadtasks() 
	{
	/// flashfix
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++)
		{
		theObjects[i].outerHTML = theObjects[i].outerHTML;
		}

	tvmusor('load', '0');
	tvmusor('scroll_to_active');
	setTimeout('scrollBox(\'weather\', 1, 0, 16, 3000);', 3000);
	if (document.getElementById('content_promo'))
		{
		setTimeout('loadContent(\'promo\', \'&cache_time=21600\');', 200);
		setTimeout('scrollBox(\'promo\', 1, 1, 162, 3000);', 3000);
		}
	}

window.onload=onloadtasks;

