/*
	Simple JS by Misiur. I don't use frameworks, but i use own functions. 
*/
var i = 1;
function $(id)
{
	return document.getElementById(id);
}
function Load()
{
	var c1 = $('cc1').firstChild; //0
	var c2 = $('cc2').firstChild; //109               And 30
	var c3 = $('cc3').firstChild; //219
	var ldb = $('login_d_b');
	var sdb = $('ud_search_b');
	
	ldb.onmouseover = function(){ this.src = "img/login_h.png" };
	sdb.onmouseover = function(){ this.src = "img/s_bh.png" };
	
	ldb.onmouseout = function(){ this.src = "img/login.png" };
	sdb.onmouseout = function(){ this.src = "img/s_b.png" };

	var inti = setInterval('Cards();', 2000);
	c1.onclick = function() { i = 1; Cards(); clearInterval(inti); inti = setInterval('Cards();', 5000); return false;};
	c2.onclick = function() { i = 2; Cards(); clearInterval(inti); inti = setInterval('Cards();', 5000); return false;};
	c3.onclick = function() { i = 3; Cards(); clearInterval(inti); inti = setInterval('Cards();', 5000); return false;};
}

function Cards()
{
	var c1 = $('cc1').firstChild; //0
	var c2 = $('cc2').firstChild; //109               And 30
	var c3 = $('cc3').firstChild; //219
	var cc1 = $('ccc1');
	var cc2 = $('ccc2');
	var cc3 = $('ccc3');
	if (i <= 3) {
		if (i == 1)
		{
			c1.style.backgroundPosition = '0 -30px';
			c2.style.backgroundPosition = '109px 0';
			c3.style.backgroundPosition = '219px 0';
			cc1.style.display = 'block';
			cc2.style.display = 'none';
			cc3.style.display = 'none';
		}
		else if (i == 2) 
		{
			c1.style.backgroundPosition = '0 0';
			c2.style.backgroundPosition = '109px -30px';
			c3.style.backgroundPosition = '219px 0';
			cc1.style.display = 'none';
			cc2.style.display = 'block';
			cc3.style.display = 'none';
		}
		else if (i == 3)
		{
			c1.style.backgroundPosition = '0 0';
			c2.style.backgroundPosition = '109px 0';
			c3.style.backgroundPosition = '219px -30px';	
			cc1.style.display = 'none';
			cc2.style.display = 'none';
			cc3.style.display = 'block';
		}
		i++;
	}
	else if(i >= 4)
	{
		i = 2;
		c1.style.backgroundPosition = '0 -30px';
		c2.style.backgroundPosition = '109px 0';
		c3.style.backgroundPosition = '219px 0';
		cc1.style.display = 'block';
		cc2.style.display = 'none';
		cc3.style.display = 'none';
	}
}

window.onload = Load;
