var max_width = 800;


function darkn(){	document.getElementById("darkness").style.display = 'block';
	document.getElementById("darkness").style.width = offw+"px";
	document.getElementById("darkness").style.height = offh+"px";
	setOpacity(document.getElementById("darkness"),9);
	document.getElementById("imaga").style.display = 'block';
	document.getElementById("dark_txt").style.display = 'block';
	document.getElementById("dark_txt").style.position = 'absolute';
	document.getElementById("dark_txt").style.left = '0px';
	document.getElementById("dark_txt").style.top = scrlT+'px';
}

function imaging(url,width,height){	var resize;
	var title="";
	var image = "<img src='"+url+"' width="+width+" height="+height+title+">";
	updScreen(); darkn();
	if(arguments[3]){ title = " title='"+arguments[3]+"'"; }
	if(arguments[4]){ image = "<img src='i/pv.php?id="+(arguments[4]*1).toString()+"&"+Math.random()+"' style='display:none;'>"+image; }
	document.getElementById("imaga").innerHTML = image;
	if(width>max_width){ height = max_width/(width/height); width = max_width; resize=1; }
	if(width>sw-40){ height = (sw-40)/(width/height); width = sw-40; resize=1; }
	if(height>sh-40){ width = (sh-40)*(width/height); height = sh-40; resize=1; }
	if(resize>0){ document.getElementById("imaga").innerHTML = "<a href='"+url+"' target=_blank><img src='"+url+"' width="+width+" height="+height+" style='cursor:move;' title='Оригинальный размер'></a>"; }
	t = scrlT + sh/2 - height/2;
	document.getElementById("imaga").style.top = t+'px';
	document.getElementById("imaga").style.left = scrlL + sw/2 - width/2 - 8 +'px';
}

function flashing(url,width,height){	updScreen(); darkn();
	if(width> max_width){ height =  max_width/(width/height); width= max_width; }
	if(width>sw-40){ height = (sw-40)/(width/height); width = sw-40; }
	if(height>sh-40){ width = (sh-40)*(width/height); height = sh-40; }
	var flash = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width="+width+" height="+height+" align=middle><param name=menu value=false><param name=allowScriptAccess value=sameDomain><param name=movie value='"+url+"'><param name=quality value=high><param name=flashVars value='swffull=1'><param name=wmode value=opaque><embed wmode=opaque menu=false width="+width+" height="+height+" src='"+url+"' quality=high flashVars='swffull=1' align=middle allowScriptAccess=sameDomain type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></object>";
	if(arguments[3]){ flash = "<img src='i/pv.php?id="+(arguments[3]*1).toString()+"&"+Math.random()+"' style='display:none;'>"+flash; }
	document.getElementById("imaga").innerHTML = flash;
	t = scrlT + sh/2 - height/2;
	document.getElementById("imaga").style.top = t+'px';
	document.getElementById("imaga").style.left = scrlL + sw/2 - width/2 - 8 +'px';
}

function hitEvent(s){	if(s!=1){ setTimeout('hitEvent(1)',1); } else {		if(document.getElementById("imaga").style.display!='none'){
		    document.getElementById("imaga").style.display='none';
		    document.getElementById("darkness").style.display = 'none';
		}
	}
}
