var opened_id;
function DivDisplay(IDElement,display){
	var el = document.getElementById(IDElement);
	if (!el) return false;
	el.style.display = display?'block':'none';
}

function DivCheckScroll(IDElement,display) {
DivCheck(IDElement,display);
StartScroller(false);
}
function DivCheck(IDElement){
	var el = document.getElementById(IDElement);
	if (!el) return false;
	if (el.style.display != 'block') {
	  if (opened_id) {
	  	document.getElementById(opened_id).style.display = 'none';
	  }
	  opened_id=IDElement;
	  el.style.display = 'block';
	} else {
	  opened_id='';
	  el.style.display = 'none';
	}  
}
function DivWrite(IDElement,city, write_id){
	var citywrite = document.getElementById(write_id);
	citywrite.value = city;
	var el = document.getElementById(IDElement);
	if (!el) return false;
	el.style.display = 'none';
}

function popup(path, width, height) {
    window.open(path, "_blank", "toolbar=no, location=no, directories=no, status=yes, menubar=no, resizable=no, copyhistory=no, scrollbars=no, width=" + width + ", height=" + height + "");
    return false;
}

function OpenMiniWin(url,x,y) {
	if(y < (screen.availHeight - 20) )
		str3="scrollbars=no,status=no,resizable=no,width="+x+",height="+y+",left="+(screen.availWidth-x)/2+",top="+(screen.availHeight-y)/2;
	else
		str3="scrollbars= yes,width="+ (x + 20) +",height="+ (screen.availHeight - 50)  +",left="+(screen.availWidth-x)/2+",top= 10";

	newWindow = window.open("","newWindow",str3);
	newWindow.document.open();
	newWindow.document.write('<html><title>Glamour</title> <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">');  
	newWindow.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="100%"><tr><td>');
	newWindow.document.write('<img src="'+url+'" width="'+x+'" height="'+y+'">'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}

function changeDiv(open,close) {
	if (close != '') {
		document.getElementById(close).style.display='none';
	}
	document.getElementById(open).style.display='block';
}

var forClose = 'lab_main';
function changeLabDiv(curdiv) {
	changeDiv(curdiv, forClose);
	forClose = curdiv;
	StartScroller(true);
}

function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	
    if (element.tagName=='IMG')
    {
      if (/\.png$/.test(element.src))
      {
        src = element.src;
        element.src = "/theme/site/img/blank.gif";
      }
    }
    else 
    {
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1];
        element.runtimeStyle.backgroundImage="none"; //убираем фоновое изображение
      }
    }
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + ")";
  }
}

function tryToClear(el, def_value) {
	if (el.value == def_value)
		el.value = '';
}