if(window.attachEvent){
	window.attachEvent('onload', mmwidth);
	window.attachEvent('onresize', mmwidth); 
} else {  
	window.addEventListener('onload', mmwidth, false);
	window.addEventListener('onresize', mmwidth, false);
} 
function mmwidth(){
	document.getElementById('wrap').style.width = ((document.documentElement.clientWidth || document.body.clientWidth) < 1000) ? '1000px' : ((document.body.clientWidth > 1600) ? '1600px' : '100%');
};

function OpenPic(node, width, height) {
	ur = node.href;
	str = '';
	title = node.title;
	if (!title)
		title = node.firstChild.title;

	if (width) {
		str += ',width=' + (width + 53);
		str += ',left=' + parseInt((screen.availWidth - (width + 53)) / 2)
	}
	if (height) {
		str += ',height=' + (height + 66);
		str += ',top=' + parseInt((screen.availHeight - (height + 66)) / 2)
	}

	resWidth = 61;
	resHeight = 115;
	if (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1) {
		resWidth = 65;
		resHeight = 117;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 7.") != -1) {
		resWidth = 67;
		resHeight = 130;
	}

	opts = 'resizable=yes,location=no,menubar=no,titlebar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=yes'+str;
	var a = window.open('about:blank','imagDetail',opts);
	var html = "<html><head><title>Просмотр фотографий</title><\/head>";
	html += "<body style='margin:0px; text-align: center; vertical-align: middle'><div style='padding: 10px'>";
	html += "<img onclick='window.close()' ";
	html += "onload=\"window.resizeTo(Math.min(screen.availWidth+"+resWidth+",this.width+"+resWidth+"),Math.min(screen.availHeight+"+resHeight+",this.height+"+resHeight+"))\" ";
	html += "style='cursor:pointer; padding-bottom:10px' src='"+ur+"' alt='Закрыть' title='Закрыть' \/>";
	html += "<div>"+title+"<\/div>";
	html += "<\/div><\/body><\/html>";
	a.document.write(html);
	a.document.close();
	return false;
}

function SetOpenPic_item() {
	return OpenPic(this, 800, 600);
}
function SetOpenPic(id) {
	col = document.getElementById(id).getElementsByTagName('img');
	for (i = 0, len = col.length; i < len; i++) {
		var ch = new RegExp('\.(jpe?g|gif|png|bmp)$', 'i');
		if (col[i].parentNode.nodeName == 'A' && col[i].parentNode.href.match(ch) && !col[i].parentNode.onclick)
			col[i].parentNode.onclick = SetOpenPic_item;
	}

}

