function createPopupBg(){	if (getID('alphaBg')) {
		showID('alphaBg');
		return false;
	}
	brVer=7;
	if (navigator.userAgent.indexOf('MSIE 6.')!=-1) {		brVer=6;
	}
	else if (navigator.userAgent.indexOf('MSIE 5.')!=-1) {		brVer=5;
	}
	if (brVer!=6) {		bgContent = "<div style='width:100%;height:100%;background-image:url(/framework/themes/core/"+(brVer<6 ? 'grid.gif' : 'alphaBg.png')+");'></div>";
	}
	else {		bgContent = "<img src='/framework/themes/core/spacer.png' style=\"width: 100%; height: 100%; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/alphaBg.png', sizingMethod=scale);\"/>";
	}
	br = getBrawserSize();
	newDiv = document.createElement('div');
	newDiv.style.position = 'absolute';
	newDiv.style.width = br.pageWidth+'px';
	newDiv.style.height = br.pageHeight+'px';
	newDiv.style.zIndex = 1;
	newDiv.id = 'alphaBg';
	newDiv.innerHTML = bgContent;
	document.body.insertAdjacentElement('afterBegin', newDiv);
}

function createPopupWnd(width, height, closeBtn){	wnd=getBrawserSize();
	if(closeBtn == undefined){		closeBtn = true;
	}
	newDiv = getID('popupWnd') ? getID('popupWnd') : document.createElement('div');
	newDiv.style.position = 'fixed';
	newDiv.style.top = (wnd.height - height)/2.5+'px';
	newDiv.style.left = (wnd.width - width)/2+'px';
	newDiv.style.width = width+'px';
	newDiv.style.height = height+'px';
	newDiv.style.border = '1px solid #605F5F';	
  newDiv.style.background = 'url(/framework/themes/core/popup_bg.gif) repeat-x scroll 0% 0% rgb(186,186,186)';
	newDiv.style.zIndex=2;
	newDiv.id='popupWnd';
	newDiv.innerHTML = (closeBtn ? "<div style='position:absolute;top:0px;right:0px;'><a href='#' onClick='closePopup();return false;'><img src='/framework/themes/core/close.gif'></a></div>":"")+"<center><div id='popupContent' ><img src='/framework/themes/core/wait.gif' style='margin-top:"+(height/2.5)+"px' alt=''></div></center>";
	 	
	if (getID('popupWnd')) {
		showID('popupWnd');
		return false;
	}
	newDiv.style.padding='0px';
	document.body.insertAdjacentElement('afterBegin', newDiv);
	newDiv.onkeypress = function (e){		keyCode=(window.event ? window.event.keyCode : e.which);
		if(keyCode == 13){			submitDiv('divForm');
			return false;
		}
	}
}
var needReload=false;
function closePopup(){	hideID('alphaBg');
	hideID('popupWnd');
	if(needReload){		document.location.reload(true);
	}
}

function makePopup(width, height){	createPopupBg();
	createPopupWnd(width, height);
}

function showPhoto(file){
	br = getBrawserSize();
	for(i in p){
		if(p[i].file==file){
			h = Number(p[i].h);
			w = Number(p[i].w);
			overFlow = "visible";
			if(h>br.height){
				h = br.height-20;
				w +=20;
				overFlow = "auto";
			}
			makePopup(w,h);
			getID('popupContent').style.height=h+"px";
			getID('popupContent').style.overflow = overFlow;
			getID('popupContent').style.backgroundColor = '#C0C0C0';
		  getID('popupContent').innerHTML="<img src='"+p[i].path+"/"+file+"'>";
		  break;
		}
	}
}