	/*function getScreenParams ()
{
    a = document.getElementById('img').src;
    reg = /1280/;
    var res = a.replace(reg,screen.width);
    
    document.getElementById('img').src = res;
}*/

function loadImage ( id, fid, page, stripwidth )
{
    window.location.href = "?id="+id+"&fid="+fid+"&page="+page+"&width="+(document.body.clientWidth-stripwidth);
}

function loadImageGal ( id, gal, page, stripwidth )
{
    window.location.href = "?id="+id+"&gal="+gal+"&page="+page+"&width="+(document.body.clientWidth-stripwidth);
}

function loadImageNews( id, pic, page, stripwidth, act )
{
    window.location.href = "?id="+id+"&pic="+pic+"&page="+page+"&width="+(document.body.clientWidth-stripwidth)+((act != '') ? "&act=publish" : '');
}

function loadImageNews1( id, pic, act )
{
    w = screen.width;
    h = screen.height;
    win = window.open('','','width='+w+',height='+h+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    win.location.href = "show_pic.php?id="+id+"&pic="+pic+((act != '') ? "&act=publish" : '');

}

function loadImageNews2( id, pic, act, lang )
{
    w = screen.width;
    h = screen.height;
    win = window.open('','','width='+w+',height='+h+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    win.location.href = "show_pic_group.php?id="+id+"&lang="+lang+"&pic="+pic+((act != '') ? "&act=publish" : '');

}

function loadImageNews3( id, pic, act, lang )
{
    w = screen.width;
    h = screen.height;
    win = window.open('','','width='+w+',height='+h+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    win.location.href = "show_pic_group.php?id="+id+"&lang="+lang+"&pic="+pic+((act != '') ? "&act=soc" : '');

}

function loadImageNews4( id, pic, act )
{
    w = screen.width;
    h = screen.height;
    win = window.open('','','width='+w+',height='+h+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    win.location.href = "show_pic.php?id="+id+"&pic="+pic+((act != '') ? "&act=soc" : '');
}

function loadImageFil( id, pic, act )
{
    w = screen.width;
    h = screen.height;
    win = window.open('','','width='+w+',height='+h+',directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    win.location.href = "show_pic_group_fil.php?id="+id+"&pic="+pic;

}

function loadThumb( id, page, stripwidth, en )
{
    if ( en != '' ) window.location.href = "efilial.php?id="+id+"&page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
    else window.location.href = "filial.php?id="+id+"&page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
}

function loadImpro( stripwidth, en )
{
    if ( en != '' ) window.location.href = "eimprovement.php?width="+Math.round((document.body.clientWidth-stripwidth)/3);
    else window.location.href = "improvement.php?width="+Math.round((document.body.clientWidth-stripwidth)/3);
}

function loadThumbGal( page, stripwidth, en )
{
    if ( en != '' ) window.location.href = "egal.php?page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
    else window.location.href = "gal.php?page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
}

function loadThumbGal1( page, stripwidth, en )
{
    if ( en != '' ) window.location.href = "egal1.php?page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
    else window.location.href = "gal1.php?page="+page+"&width="+Math.round((document.body.clientWidth-stripwidth)/3);
}

function priceShowComm(id){
	document.getElementById('c'+id).style.display = "block";
}

function priceHiddenComm(id){
	document.getElementById('c'+id).style.display = "none";
}

function checkform ( obj ){
  for ( var i=0; i<obj.elements.length; i++ )
  { 
      if ( obj.elements[i].getAttribute( "required" ) != null )
      {
          if ( obj.elements[i].value == '' )
          { 
                alert('Не заполнено обязательное поле!');
                return false;
          }
      }
  }
  return true;
}

/* =========== SDMenu ========== */

function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.remember = true;
	this.speed = 25;
	this.markCurrent = true;
	this.oneSmOnly = false;
}
SDMenu.prototype.init = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("a");
		for (var i = 0; i < links.length; i++)
			if (links[i].href == document.location.href) {
				links[i].className = "current";
				break;
			}
	}
	if (this.remember) {
		var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
		var match = regex.exec(document.cookie);
		if (match) {
			var states = match[1].split("");
			for (var i = 0; i < states.length; i++)
				this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
			mainInstance.memorize();
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
			mainInstance.memorize();
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
	if (this.remember) {
		var states = new Array();
		for (var i = 0; i < this.submenus.length; i++)
			states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
		var d = new Date();
		d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
		document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
	}
};
