var jezyk = 'pl';
var on = new Array;
var pop = '';

$(document).ready( function() {
	// obsluga menu
	jQuery.each($('.submenu'), function() {
		var tmp = this.id.replace(/on/g, "");
		$("#on" + this.id).mouseover(function() {
			if(pop != '') {
				$("#on" + pop).find('.submenu').css('display', 'none');
			}
			$(this).find('.submenu').css('width', $(this)[0].clientWidth).css('display', 'block');
			on[tmp] = 1;
			pop = tmp;
		});
		$("#on" + this.id).mouseout(function() {
			on[tmp] = 0;
			setTimeout('hidesubmenu(this,"' + tmp + '")',200);
		});
		$(this).mouseover(function() {
			on[tmp] = 2;
		});
		$(this).mouseout(function() {
			on[tmp] = 0;
			hidesubmenu(this,tmp);
		});
	});
	
	$(document).pngFix();
	
	$('.smallimage').click(function() {
		$('#mainimage').attr('src', $(this).attr('href'));
		var tmphref = $('#mainimage').parent().attr('href');
		$('#mainimage').parent().attr('href', $(this).attr('rel'));
		if($('#mainimage').parent().next()) {
			if($(this).attr('rel') == $('#mainimage').parent().next().attr('href')) {
				$('#mainimage').parent().next().attr('href', tmphref);
			}
		}
		if($('#mainimage').parent().next().next()) {
			if($(this).attr('rel') == $('#mainimage').parent().next().next().attr('href')) {
				$('#mainimage').parent().next().next().attr('href', tmphref);
			}
		}
		return false;
	});
});

function hidesubmenu(th, ids) {
	if(on[ids] == 0)
		$(th).find('#'+ids).css('display', 'none');
}

function CheckEmail(y) {
	if (y == "") { return false; }

	var x= new String(y);
	x.toLowerCase();
	var ret= new String();
	var znaki1= ".-+_@";
	var znaki= "0123456789zxcvbnmasdfghjklqwertyuiop" + znaki1;

	if ( x.length < 1 ) return false;
	if ( x.indexOf("@") == -1 ) { ok= 0; return false; }
	if ( x.indexOf("@") != x.lastIndexOf("@") ) { ok= 0; return false; }
	for ( i=0; i < x.length; ++i) 
		if ( znaki.indexOf(""+x.charAt(i)) == -1 ) { ok= 0; return false; }
	if ( znaki1.indexOf(x.charAt(x.length-1)) != -1 ) { ok= 0; return false; }

	return true;
}
