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 fl = new SWFObject(url, "", width, height, "10");
	fl.addParam("flashVars", "swffull=1");
	fl.addParam("menu", "false");
	if(!window.opera){ fl.addParam("wmode", "opaque"); }
	fl.write("imaga");
	if(arguments[3]){ document.getElementById("imaga").innerHTML += "<img src='i/pv.php?id="+(arguments[3]*1).toString()+"&"+Math.random()+"' style='display:none;'>"; }
	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';
		}
	}
}

