pause = 0;
stories_num = 4;
active_story = 0;
call_hide = 0;
in_show = 0;
pause = 0;
num_arts = 12;
auto_start = 0;

function vote()
{
	obj = fetch_object("poll_id");
	id = obj.value;
	s = 0;
	option = null;
	while (s < i)
	{
		obj = fetch_object("poll_option" + s);
		if(obj.checked)
		{
			option = obj.value;
		}
		s++;
	}
	if (option != null)
	{
		window.open("polls.php?actn=vote&id=" + id + "&option="+option, "poll", "height=400, width=600")
	}
	else
	{
		alert('<?=_PLEASE_SELECT_OPTION?>')
	}
}

function result()
{
	obj = fetch_object("poll_id");
	id = obj.value;
	window.open("polls.php?actn=result&id=" + id , "poll", "height=400, width=600")
}

function show_links(id)
{
	for(i = 0; i < 6 ; i++)
	{
		tab = fetch_object("links_tab" + i);
		links = fetch_object("links" + i);
		if(i == id)
		{
			tab.className = "slected_links_tab";
			links.style.display = "block";
		}
		else
		{
			tab.className = "unslected_links_tab";
			links.style.display = "none";
		}
	}
}

function first_cats_display(x)
{	
	for(i = 1 ;i < 4; i++)
	{
		obj = fetch_object("first_cats_tab" + i);
		obj2 = fetch_object("first_cats_main" + i);
		obj3 = fetch_object("first_cats_news" + i);
		if(i == x)
		{
			obj.style.backgroundImage = "url('images2/alltageer_16.gif')";
			obj2.style.display = "block";
			obj3.style.display = "block";
		}
		else
		{
			obj.style.backgroundImage = "";
			obj2.style.display = "none";
			obj3.style.display = "none";
		}
	}
}
function second_cats_display(x)
{
	for(i = 1 ;i < 4; i++)
	{
		obj = fetch_object("second_cats_tab" + i);
		obj2 = fetch_object("second_cats_main" + i);
		obj3 = fetch_object("second_cats_news" + i);
		if(i == x)
		{
			obj.style.backgroundImage = "url('images2/alltageer_16.gif')";
			obj2.style.display = "block";
			obj3.style.display = "block";
		}
		else
		{
			obj.style.backgroundImage = "";
			obj2.style.display = "none";
			obj3.style.display = "none";
		}
	}
}
function move_last_news_top(pix)
{
	if(pix == 0)
	{
		return;
	}
	obj = fetch_object("last_news");
	if(parseInt(obj.style.top) <= -430)
	{
		return;
	}
	obj.style.top = (parseInt(obj.style.top) - 1) + "px";
	setTimeout("move_last_news_top(" + (pix - 1) + ")", 1);
}

function move_last_news_down(pix)
{
	if(pix == 0)
	{
		return;
	}
	obj = fetch_object("last_news");
	if(parseInt(obj.style.top) >= 0)
	{
		return;
	}
	obj.style.top = (parseInt(obj.style.top) + 1) + "px";
	setTimeout("move_last_news_down(" + (pix - 1) + ")", 1);
}
function show_news(id)
{
	show_story(id - 1);
}
function do_pause()
{
	auto_start = 1;
	pause = 1;
}
function show_story(i)
{
	if(auto_start != 0 && i == active_story)
	{
		return ;
	}
	do_pause();
	var story = fetch_object("story" + active_story);
	title = fetch_object("title" + active_story);
	if(call_hide == 0 && in_show == 0)
	{
		hide_slid_title("title" + active_story, 60);
		call_hide = 1;
	}
	if(parseInt(title.style.top) < 320)
	{
		setTimeout("show_story(" + i + ")", 1000);
		return ;
	}
	call_hide = 0;
	if(in_show == 0)
	{
		in_show = 1;
		story.style.display = "none";
		active_story = i;
		for(i = 1; i <= 4; i++)
	{
		news = fetch_object("news_title"+i);
		arow = fetch_object("news_arow"+i);
		link = fetch_object("news_link"+i);
		if(i == active_story + 1)
		{
			arow.style.visibility = "visible";
			news.style.borderRight = "solid 1px #ff0000";
			news.style.borderLeft = "solid 1px #ff0000";
			news.style.borderBottom = "solid 1px #ff0000";
			link.style.color = "#ff0000";
		}
		else
		{
			arow.style.visibility = "hidden";
			news.style.borderRight = "solid 1px #FFFFFF";
			news.style.borderLeft = "solid 1px #FFFFFF";
			news.style.borderBottom = "solid 1px #FFFFFF";
			link.style.color = "#08254f";
		}
	}
		var story = fetch_object("story" + active_story);
		story.style.display = "block";
		show_slid_title("title" + active_story, 60);
	}
}
function show_slid_title(id, pix)
{
	title = fetch_object(id);
	if(pix <= 0)
	{
		in_show = 0;
		return ;
	}
	new_top = parseInt(title.style.top) - 1;
	title.style.top = new_top + "px";
	setTimeout("show_slid_title('" + id + "'," + (pix - 1) + ")", 5);
}
function hide_slid_title(id, pix)
{
	title = fetch_object(id);
	if(pix <= 0 || parseInt(title.style.top) >= 320)
	{
		call_hide = 0;
		in_show = 0;
		return ;
	}
	new_top = parseInt(title.style.top) + 1;
	title.style.top = new_top + "px";
	setTimeout("hide_slid_title('" + id + "'," + (pix - 1) + ")", 5);
}

function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}

function move_right(value)
{
	if(value <= 0)
	{
		return ;
	}
	for(i = 0; i < num_arts ; i++)
	{
		var obj = fetch_object("image" + i);
		new_right = parseInt(obj.style.right) - 5;
		if(new_right < -1720)
		{
			new_right = 860;
		}
		obj.style.right = new_right + "px";
	}
	value = value - 5 ;
	setTimeout("move_right(" + value + ")", 1)
}

function move_left(value)
{
	if(value <= 0)
	{
		return ;
	}
	for(i = num_arts - 1; i >= 0; i--)
	{
		var obj = fetch_object("image" + i);
		
		new_left = parseInt(obj.style.right) + 5;
		if(new_left > 2365)
		{
				new_left = -210;
		}
		obj.style.right = new_left + "px";
	}
	value = value - 5 ;
	setTimeout("move_left(" + value + ")", 1)
}

function next_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_right(215);
	}
}
function perv_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_left(215);
	}
}

//################################################################

num_cat1_news = 16;
selected_cat1 = 0;
num_cat2_news = 16;
selected_cat2 = 0;
function move_cat1_right(value)
{
	if(value <= 0)
	{
		return ;
	}
	for(i = 0; i < num_cat1_news ; i++)
	{
		var obj = fetch_object("cat1_" + i);
		new_right = parseInt(obj.style.right) - 6;
		if(new_right < -1344)
		{
			new_right = 1338;
		}
		obj.style.right = new_right + "px";
	}
	value = value - 6;
	setTimeout("move_cat1_right(" + value + ")", 1)
}

function move_cat1_left(value)
{
	
	if(value <= 0)
	{
		return ;
	}
	for(i = num_cat1_news - 1; i >= 0; i--)
	{
		var obj = fetch_object("cat1_" + i);
		new_left = parseInt(obj.style.right) + 6;
		if(new_left > 2520)
		{
				new_left = -162;
		}
		obj.style.right = new_left + "px";
	}
	value = value - 6;
	setTimeout("move_cat1_left(" + value + ")", 1)
}

function next_cat1_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_cat1_right(168);
	}
	obj = fetch_object("selected" + selected_cat1);
	obj.style.visibility = "hidden";
	selected_cat1 = (selected_cat1 + 1 ) % 4;
	obj = fetch_object("selected" + selected_cat1);
	obj.style.visibility = "visible";
}
function perv_cat1_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_cat1_left(168);
	}
	obj = fetch_object("selected" + selected_cat1);
	obj.style.visibility = "hidden";
	selected_cat1 = (selected_cat1 - 1 ) % 4;
	if(selected_cat1 < 0)
	{
		selected_cat1 = 4 - (selected_cat1 * -1);
	}
	obj = fetch_object("selected" + selected_cat1);
	obj.style.visibility = "visible";
}
function move_cat2_right(value)
{
	if(value <= 0)
	{
		return ;
	}
	for(i = 0; i < num_cat2_news ; i++)
	{
		var obj = fetch_object("cat2_" + i);
		new_right = parseInt(obj.style.right) - 6;
		if(new_right < -1344)
		{
			new_right = 1338;
		}
		obj.style.right = new_right + "px";
	}
	value = value - 6;
	setTimeout("move_cat2_right(" + value + ")", 1)
}

function move_cat2_left(value)
{
	if(value <= 0)
	{
		return ;
	}
	for(i = num_cat2_news - 1; i >= 0; i--)
	{
		var obj = fetch_object("cat2_" + i);
		new_left = parseInt(obj.style.right) + 6;
		if(new_left > 2520)
		{
				new_left = -162;
		}
		obj.style.right = new_left + "px";
	}
	value = value - 6;
	setTimeout("move_cat2_left(" + value + ")", 1)
}

function next_cat2_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_cat2_right(168);
	}
	obj = fetch_object("selected_2_" + selected_cat2);
	obj.style.visibility = "hidden";
	selected_cat2 = (selected_cat2 + 1 ) % 4;
	obj = fetch_object("selected_2_" + selected_cat2);
	obj.style.visibility = "visible";
}
function perv_cat2_slid(num)
{
	if(!num)
	{
		num = 4;
	}
	for(z = 0; z < num; z++)
	{
		move_cat2_left(168);
	}
	obj = fetch_object("selected_2_" + selected_cat2);
	obj.style.visibility = "hidden";
	selected_cat2 = (selected_cat2 - 1 ) % 4;
	if(selected_cat2 < 0)
	{
		selected_cat2 = 4 - (selected_cat2 * -1);
	}
	obj = fetch_object("selected_2_" + selected_cat2);
	obj.style.visibility = "visible";
}
disply_show_more = 0;
function contorol_more_cats()
{
	obj = fetch_object("more_cats");
	if(disply_show_more == 0)
	{
		
		disply_show_more = 1;
		obj.style.display = "block";
	}
	else
	{
		disply_show_more = 0;
		obj.style.display = "none";
	}
}
