function check_loginform(){
if ((document.loginform.user.value.length == 0)||(document.loginform.pass.value.length == 0)){
	alert('Вы заполнили не все поля! Укажите своё имя и пароль!')
	return false;
 }
return true;
}

function submit_once(theform){
if (document.all||document.getElementById){
	for (i=0; i<theform.length; i++){
		var tempobj=theform.elements[i]
		if (tempobj.type.toLowerCase()=="submit" || tempobj.type.toLowerCase()=="reset") {tempobj.disabled=true}
	}
}
}

function getCookie(name) {
var prefix = name + "="
var StartIndex = document.cookie.indexOf(prefix)
if (StartIndex == -1)
return null
var EndIndex = document.cookie.indexOf(";", StartIndex + prefix.length)
if (EndIndex == -1)
EndIndex = document.cookie.length
return unescape(document.cookie.substring(StartIndex + prefix.length, EndIndex))
}

function set_albumform_view(param){
v1 = document.getElementById('view1').style;
v2 = document.getElementById('view2').style;
v1.display = v2.display = 'none';
if (param==5) v1.display = '';
if (param==6) v2.display = '';
}

function check_albumform(){
if (document.album.albumdelete.checked){
	return confirm('Вы действительно хотите удалить альбом со всеми фотографиями?');
}
if (document.album.name.value.length == 0){
	alert('Вы не указали имя альбома!');
	document.album.name.focus();
	return false;
}
if ((document.album.access.selectedIndex==4) && (document.album.password.value.length == 0)){
	alert('Вы не указали пароль доступа к альбому!');
	document.album.password.focus();
	return false;
}
if ((document.album.access.selectedIndex==5) && (document.album.users.value.length == 0)){
	alert('Вы не указали имена посетителей, допущенных к просмотру альбома!');
	document.album.users.focus();
	return false;
}
return true;
}

function check_deletephoto(){
return confirm('Вы действительно хотите удалить фотографию?');
}

function check_editphotoform(){
if (document.photo.delete_photo.checked){
	return confirm('Вы действительно хотите удалить фотографию?');
}
}

function hex_color(v){
var hex="0123456789abcdef";
color=hex.charAt(v/16)+hex.charAt(v%16);
return '#'+color+color+color;
}

function fullscreen_image(url) {
var win = window.open('','','fullscreen=yes,menubar=0,location=0,scrollbars=0,directories=0,resizable=0,status=0');
var doc = win.document;
var td_text = '';
for (i=0; i<=255; i++) {
	color=hex_color(i);
	td_text+='<td width=2 class="s" bgcolor="'+color+'" onMouseOver="document.bgColor=\''+color+'\'"><br>&nbsp;</td>\n';
}
doc.writeln('<html><head><style type="text/css">.s {font-family: Small Fonts, Verdana, Arial; font-size: 5pt}</style></head><body bgcolor="#808080"><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" onClick="window.close()"><a href="#" onClick="window.close()"><img border=0 src="'+url+'"></a></td></tr><tr><td height="2%">\n');
doc.writeln('<table align="center" cellpadding="0" cellspacing="0" border="0"><tr style="cursor: crosshair">'+td_text+'</tr></table></td></tr></table></body></html>');
}

function expand_menu(expand_id) {
var e = document.getElementById(expand_id).style;
var i = document.getElementById(expand_id+'-img');
if (e.display=="none") {
	e.display=""
	if (i) i.src = 'img/menu-array-up.gif';
} else {
	e.display="none"
	if (i) i.src = 'img/menu-array-down.gif';
}; 
}

function print_size(size){
return (size>1024*1024) ? Math.round(size*100/1024/1024)/100+" Мб" : Math.round(size*100/1024)/100+" Кб";
}

function print_thumbs_table(){
table_width = (document&&document.body && document.body.clientWidth) ? document.body.clientWidth : window.innerWidth;
table_width = Math.round(table_width*0.8);
columns =  Math.round(table_width/200);
if (columns<3) columns = 3;
if (columns!=old_columns){
	old_columns=columns;
	cell_width=Math.ceil(100/columns);
	text='<table class="viewalbumpreview">'
	i=columns; tr1=''; tr2=''; tr3='';
	for (j=0; j<data.length; j++) {
		i++;
		if (i>columns){
			if (j>0) text+='<tr>'+tr1+'</tr><tr>'+tr2+'</tr><tr>'+tr3+'</tr>';
			i=1; 	tr1=''; tr2=''; tr3='';
		}
		tr1+='<td align=center valign=top width="'+cell_width+'%">'+data[j][0]+'</td>';
		tr2+='<td align=center valign=center class="d" width="'+cell_width+'%">'+data[j][1]+'</td>';
		tr3+='<td align=center valign=top class="d2" width="'+cell_width+'%">'+data[j][2]+'</td>';
	}
	if (data.length>0) text+='<tr>'+tr1+'</tr><tr>'+tr2+'</tr><tr>'+tr3+'</tr>';
	text+='</table>'
	document.getElementById('thumbs_table').innerHTML=text;
}
}
