http_request = false;

var file_id = 1;

function next_file()
{
	file_id++;
	
	document.getElementById('file' + file_id).style.display = 'block';
	
	if (file_id > 7)
		document.getElementById('next_file').innerHTML = '';
	
	return 1;
}


function url (order)
{
	var gourl = order.options[order.selectedIndex].value; 
	window.self.location.href = gourl;
}


function ajax_connect()
{
	if (window.XMLHttpRequest) 
	{ 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
			http_request.overrideMimeType('text/plain');
	} 
	else 
		if (window.ActiveXObject)
		{
			try
			{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) 
			{
				try
				{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}
}


function ajax_check_status()
{
	if(http_request.readyState == 4 && http_request.status == 200)
		return true;
	else
		return false;
}


function ajax_login_check(login)
{
	var response;
	ajax_connect();
	
	http_request.onreadystatechange = function()
	{
		if (ajax_check_status())
		{
			switch (http_request.responseText)
			{
				case '0':
					response = '<img src="/gfx/no.png" />';
				break;
				
				case '1':
					response = '<img src="/gfx/yes.png" />';
				break;
				
				case '2':
					response = '<font style="color:red;"><img src="/gfx/no.png" /> login jest juz zajety!</font>';
				break;
			}
			document.getElementById('register_login').innerHTML = response;
		}
				
	}

	http_request.open('GET', 'http://fotowrzut.pl/func/ajax.php?mode=login_check&login=' + login, true);
	http_request.send(null);
}


function ajax_email_check(email)
{
	ajax_connect();
	
	http_request.onreadystatechange = function()
	{
		if (ajax_check_status())
			if (http_request.responseText == 0)
				document.getElementById('register_email').innerHTML = '<font style="color:red;"><img src="/gfx/no.png" /> adres email jest nieprawidlowy!</font>';
			else
				document.getElementById('register_email').innerHTML = '<img src="/gfx/yes.png" />';
	}

	http_request.open('GET', 'http://fotowrzut.pl/func/ajax.php?mode=email_check&email=' + email, true);
	http_request.send(null);
}


function ajax_passwd_check(passwd)
{
	ajax_connect();
	
	http_request.onreadystatechange = function()
	{
		if (ajax_check_status())
			if (http_request.responseText == 0)
				document.getElementById('passwd_status1').innerHTML = '<img src="/gfx/no.png" />';
			else
				document.getElementById('passwd_status1').innerHTML = '<img src="/gfx/yes.png" />';
	}

	http_request.open('GET', 'http://fotowrzut.pl/func/ajax.php?mode=passwd_check&passwd=' + passwd, true);
	http_request.send(null);
}


function ajax_image_rotate(hash, image, rotate, from)
{
	ajax_connect();
	
	tmp = document.getElementById(hash + image);
	x = tmp.width;
	y = tmp.height
	
	http_request.onreadystatechange = function()
	{
		if (ajax_check_status())
			if (http_request.responseText == 1)
			{
				img = document.getElementById(hash + image);
				
				if (from == 1)
					img.src = 'http://s1.fotowrzut.pl/' + hash + '/' + image + '.jpg?' + Math.random();
				else
					img.src = '/tmp/upload/' + hash + '/' + image + '.jpg?' + Math.random();
					
				img.width = y;
				img.height = x;
			}
	}

	http_request.open('GET', 'http://fotowrzut.pl/func/ajax.php?mode=image_rotate&hash=' + hash + '&image=' + image + '&rotate= ' + rotate + '&from=' + from, true);
	http_request.send(null);
}


function show(id)
{
	document.getElementById(id).style.display = 'block';
	return 1;
}


function hide(id)
{
	document.getElementById(id).style.display = 'none';
	return 1;
}


function show_hide(id)
{
	obj = document.getElementById(id);
	
	if (obj.style.display == 'none')
		document.getElementById(id).style.display = 'block';
	else
		document.getElementById(id).style.display = 'none';
		
	return 1;
}


function check_adult(check)
{
	if(check != 1)
	{
document.getElementById('container').innerHTML = '<div style="margin:100px auto 0 auto; width:500px; border:2px solid #F90304; overflow:hidden; height:240px; font-size:13px; padding:15px;"><div style="background-image:url(/gfx/adult.jpg); width:154px; height:28px; margin:0px auto 10px auto;"></div><div style="font-size:14px; text-align:center;"><span style="font-size:16px; font-weight:bold;">UWAGA!</span> Wybrana podstrona (oraz dalsze) serwisu <strong>Foto<span style="color:#F90304;">Wrzut</span>.pl </strong>zawiera tre&#347;ci o tematyce erotycznej, drastycznej lub innej przeznaczonej <u>tylko i wy&#322;&#261;cznie</u> dla <strong>os&oacute;b pe&#322;noletnich </strong>(powy&#380;ej 18 roku &#380;ycia). Je&#380;li jeste&#347; osob&#261; <strong>niepelnoletnia</strong> (nie uko&#324;czy&#322;e&#347; 18 roku &#380;ycia), nie chcesz ogl&#261;da&#263; tre&#347;ci tego typu lub jest to niezgodne z prawem Twojego kraju, nie wolno Ci wchodzi&#263; dalej!<p style="font-weight:bold;">Wchodz&#261;c dalej robisz to na w&#322;asn&#261; odpowiedzialno&#347;&#263;, a tak&#380;e <u>o&#347;wiadczasz</u>, &#380;e jeste&#347; osob&#261; pe&#322;noletni&#261;, chcesz ogl&#261;da&#263; tre&#347;ci tego typu z w&#322;asnej, nie przymuszonej woli oraz odbi&oacute;r tych tre&#347;ci nie zosta&#322; Ci w &#380;aden spos&oacute;b narzucony.</p></div><div align="center" style="clear:both; margin-top:20px;"><a href="?enter" style="color:#fff; border:1px solid #504C78; padding:2px 30px; background-color:#F90304; margin-right:10px; font-size:16px; text-decoration:none; font-weight:bold;">WCHODZ&#280;</a><a href="http://fotowrzut.pl" style="color:#ffffff; border:1px solid #504C78; padding:2px 30px; background-color:#000; margin-left:10px;  font-size:16px; text-decoration:none; font-weight:bold;">NIE WCHODZ&#280;</a></div></div>';
	}
}

var rollovers_count = 2;
var filenames_on = new Array;

filenames_on[0] = "/gfx/lefton.jpg";
filenames_on[1] = "/gfx/righton.jpg";

var images_on  = new Array;
var images_loaded = false;

function preload()
{
    for (i = 0; i < rollovers_count; i++) 
	{
        images_on[i] = new Image();
        images_on[i].src = filenames_on[i];
    }
    images_loaded = true;
}

function image_options (mode, id)
{
	if (mode == 1)
	{
		show('options' + id);
		show('more' + id);
		show('expand' + id);
	}
	else
	{
		hide('options' + id);
		hide('more' + id);
		hide('expand' + id);	
	}
}
