// JavaScript Document
var xmlHttp
function getVote(int)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Your browser do not support HTTP Request")
		 return
	 }
	var url="pic.php"
	url=url+"?pic="+int
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById("picture").innerHTML=xmlHttp.responseText;
	 }
	 if (xmlHttp.readyState==0 || xmlHttp.readyState==1  || xmlHttp.readyState==2 || xmlHttp.readyState==3)
	 {
		 var msg="<img src='loading.gif'>";
		 document.getElementById("picture").innerHTML=msg;
	 }
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	  	// Internet Explorer
		  try
    	{
	    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
		  catch (e)
	    {
		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
  	}
	return xmlHttp;
}
//window.onLoad=getVote('sec', -1);         // value in first dropdown
stories_num = 6;
active_story = 0;
call_hide = 0;
in_show = 0;
pause = 0;
function do_pause()
{
	obj = fetch_object("pause_button");
	obj.style.backgroundPosition = "0px -26px";
	pause = 1;
}
function do_resume()
{
	if(pause == 0)
	{
		do_pause();
		return ;
	}
	pause = 0;
	obj = fetch_object("pause_button");
	obj.style.backgroundPosition = "0px 0px";
	setTimeout("auto_next()", 1000);
}
function auto_next()
{
	if(pause == 0)
	{
		next_story();
		setTimeout("auto_next()", 5000);
	}
}
function show_story(i)
{
	do_pause();
	var story = fetch_object("story" + active_story);
	title = fetch_object("title" + active_story);
	if(call_hide == 0)
	{
		hide_slid_title("title" + active_story, 60);
		call_hide = 1;
	}
	if(parseInt(title.style.top) < 328)
	{
		setTimeout("show_story(" + i + ")", 1000);
		return ;
	}
	call_hide = 0;
	story.style.display = "none";
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "";
	active_story = i;
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "url('slide/selected.jpg')";
	var story = fetch_object("story" + active_story);
	story.style.display = "block";
	show_slid_title("title" + active_story, 60);
}
function next_story(manually)
{
	if(manually)
	{
		do_pause();
	}
	if(in_show == 1)
	{
		return ;
	}
	in_show = 1;
	var story = fetch_object("story" + active_story);
	title = fetch_object("title" + active_story);
	if(call_hide == 0)
	{
		hide_slid_title("title" + active_story, 60);
		call_hide = 1;
	}
	if(parseInt(title.style.top) < 328)
	{
		setTimeout("next_story()", 1000);
		return ;
	}
	call_hide = 0;
	story.style.display = "none";
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "";
	active_story = (active_story + 1 ) % stories_num;
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "url('slide/selected.jpg')";
	var story = fetch_object("story" + active_story);
	story.style.display = "block";
	show_slid_title("title" + active_story, 60);
}
function perv_story(manually)
{
	if(manually != null)
	{
		do_pause();
	}
	if(in_show == 1)
	{
		return ;
	}
	in_show = 1;
	var story = fetch_object("story" + active_story);
	title = fetch_object("title" + active_story);
	if(call_hide == 0)
	{
		hide_slid_title("title" + active_story, 60);
		call_hide = 1;
	}
	if(parseInt(title.style.top) < 328)
	{
		setTimeout("perv_story()", 1000);
		return ;
	}
	call_hide = 0;
	story.style.display = "none";
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "";
	active_story = (active_story - 1 ) % stories_num;
	if(active_story < 0)
	{
		active_story = stories_num + active_story;
	}
	var storyID = fetch_object("storyID" + (active_story + 1));
	storyID.style.backgroundImage = "url('slide/selected.jpg')";
	var story = fetch_object("story" + active_story);
	story.style.display = "block";
	show_slid_title("title" + active_story, 60);
}
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 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) + ")", 10);
}
function hide_slid_title(id, pix)
{
	title = fetch_object(id);
	if(pix <= 0 || parseInt(title.style.top) >= 328)
	{
		in_show = 0;
		return ;
	}
	new_top = parseInt(title.style.top) + 1;
	title.style.top = new_top + "px";
	setTimeout("hide_slid_title('" + id + "'," + (pix - 1) + ")", 10);
}
function show_alert_title(i)
{
	title = fetch_object("alert_title" + i);
	title.style.display = "block";
}

function hide_alert_title(i)
{
	title = fetch_object("alert_title" + i);
	title.style.display = "none";
}
function prnte(d)
{
	if(document.getElementById(d)){document.getElementById(d).style.display='block';}
}
function prrnt(d)
{
		if(document.getElementById(d)){document.getElementById(d).style.display='none';}
}

