
function getBrowserType(){
	if( navigator.userAgent.indexOf("Opera")!=-1 )		return "opera";
	if( navigator.userAgent.indexOf("MSIE")!=-1 )		return "ie";
	if( navigator.userAgent.indexOf("Netscape")!=-1 )	return "netscape";
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


var stateImgCount = 0;
function outputStateImg(outSrc, overSrc, downSrc){
	stateImgCount++;
	var States		=	new Array();
	States.out		=	new Image();
	States.out.src	=	outSrc;
	if(overSrc)	{
		States.over		=	new Image();
		States.over.src	=	overSrc;
	}
	if(downSrc)	{
		States.down		=	new Image();
		States.down.src	=	downSrc;
	}
	
	document.write( '<img id="StateImg'+stateImgCount+'"' );
	document.write( ' src="'+States.out.src+'"' );
	document.write( ' onMouseOut="this.src=this.States.out.src"' );
	if(overSrc)		document.write( ' onMouseOver="this.src=this.States.over.src"' );
	if(downSrc)		document.write( ' onMouseDown="this.src=this.States.down.src"' );
		else		document.write( ' onMouseDown="this.src=this.States.out.src"' );
	if(overSrc)		document.write( ' onMouseUp="this.src=this.States.over.src"' );
		else		document.write( ' onMouseUp="this.src=this.States.out.src"' );
	document.write( '">' );
	var Img		=	findObj("StateImg"+stateImgCount);
	Img.States	=	States;
}



function outputPngImg(src, width, height, alt){
	if( getBrowserType()=='ie' ) 	document.write("<img width=\""+width+"\" height=\""+height+"\" src=\""+ROOT+"assets/empty.gif\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='scale')\">");
	else 	document.write("<img width=\""+width+"\" height=\""+height+"\" src=\""+src+"\">");
}


function openExtraWindow( url , name , width , height , scrollbars ){
	
	var options = 'width='+width+',height='+height+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+Number(scrollbars)+',status=0,titlebar=0,toolbar=0';
	
	var win = window.open(url, name, options);
	win.window.focus();
	
	return win;
}




function openImgGalleryWindow(type, category, key, sessionOffset, imgOffset){
	openExtraWindow(  ROOT+'imagegallery.php?lng='+LNG+'&type='+type+'&category='+category+'&key='+key+'&sessionOffset='+sessionOffset+'&imgOffset='+imgOffset );
}


function viewImg( fURL, title, info, date, credits ){
	var ExtraWindow = openExtraWindow('', 'image', 560, 540);
	
	ExtraWindow.document.write('<html><head><title>'+title+'</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link href="'+ROOT+'css/_base.css" rel="stylesheet" type="text/css"><link href="'+ROOT+'css/imgGallery.css" rel="stylesheet" type="text/css"></head><body class="black"><table width="540" height="540" align="center" cellpadding="0" cellspacing="0" style="table-layout:fixed;"><col width="40"><col><col width="40"><tr align="center" valign="middle"><td colspan="3"><img src="'+fURL+'" /></td></tr><tr align="center" valign="middle"><td height="20"></td><td><table width="100%" style="table-layout:auto "><tr align="center"><td width="50%"><hr class="white" noshade></td><td nowrap id="title">'+title+'</td><td width="50%"><hr class="white" noshade></td></tr></table></td><td></td></tr><tr align="center" valign="top"><td colspan="3" height="20" id="info"></td></tr><tr align="right" valign="top"><td height="15" colspan="3" id="credits"></td></tr></table></body></html>');
	ExtraWindow.document.close();
	ExtraWindow.focus();
}



function openHelpWindow( content ) {
	var HW=window.open('','HW','width=300,height=200'); 
	HW.focus();
	HW.document.open();
	HW.document.write('<body style="font-family: Verdana, Arial, Helvetica, sans-serif;">');
	HW.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="left" valign="top">');
	HW.document.write('<div style="font-size:12px">');
	HW.document.write(content);
	HW.document.write('</div>');
	HW.document.write('</td></tr><tr><td align="right" valign="bottom"><span style="font-size:12px; cursor:pointer;" onClick="window.close()"><b>'+(LNG=='ru'?'закрыть':'close')+'</b></span></td></tr></table>');
	HW.document.write('');
	HW.document.write('</body>');
	HW.document.close();
}

function linkOnConfirm( link ){
	if( confirm( LNG=='ru'?'Вы уверены?':'Are You sure?' ) ){
		document.location=link;
	}
}

