

function Write(str) {
    document.write(str);
}


function toggle_src(obj, val) {
	obj.src=val;
}

function toggle(obj, overimg) {
	if(obj.className != "selected")
	    obj.className=overimg;
}

// Class ErrorMessage //

function ErrorMessage()
{
	this.messages = new ActiveXObject("Scripting.Dictionary");
	this.add = _add;
	this.isOk = _isOk;
	this.message = _message;
	this.display = _display;
	this.header = "";
}

function _add(message)
{
	var key;
	key = "msg_" + this.messages.count;
	this.messages.add (key,message);
}

function _isOk()
{
	if (this.messages.count==0)
	{
		return true;
	}else{
		return false;
	}
}

function _display()
{
	if (!this.isOk())
	{
		alert(this.message());
	}
}

function _message()
{
	var msg;
	var j;
	
	msg = "";
	if (!(this.header==""))
	{
		msg = this.header + "\n";
	}
	for (j=0; j<this.messages.count; j++)
	{
		key = "msg_" + j;
		msg += " - " + this.messages.item(key) + "." + "     " + "\n";
	}
	return msg;
}

// End Class ErrorMessage //

function OpenWindow(url, width, height)
{
	window.open (url, '_blank', 'resizable=0,toolbar=0,directories=0,statusbar=0,width=" + width + ",height=" + height + "');
}

function IsNumeric(value) // == IsInteger
{
	var re1;
	var re2;
	re1 = new RegExp("[0-9]");
	re2 = new RegExp("[^0-9]");
	return re1.test(value)&&(!re2.test(value));
}

function IsEMail(value)
{
	var re;
	re = new RegExp(".@{1}[0-9A-Za-z\-]{1,}\.{1}[A-Za-z]{2,4}");
	return re.test(value);
}

function IsEmpty(value)
{
	var re;
	re = new RegExp(".+");
	return !re.test(value);
}

function IIf(condition, truepart, falsepart)
{
	if (condition)
	{
		return truepart;
	}else{
		return falsepart;
	}
}

function CancelEvent()
{
	window.event.cancelBubble = true;
	window.event.returnValue = false;
	return false;
}


	var tdToReset;
	var prevClickedSpan;
	
	function termin_click(id)
	{
		var span;
		var tId;
		tId = 'idTermin_' + id;
		span = document.getElementById(tId);
		if (!span.clicked)
		{
			resetClick(id);
			span.className = "termin_expanded";
			span.clicked = true;
			showDesc(id);
			prevClickedSpan = span;
		}else{
			resetClick(id);
		}
	}
	
	function showDesc(id)
	{
		var td;
		var strHTML;
		var tdId;
		tdId = 'idDesk_' + id;
		td = document.getElementById(tdId);
		td.style.display = "";
		tdToReset = td;
	}
	
	function hideDesk()
	{
		if (!(tdToReset==null))
		{
			tdToReset.style.display = "none";
			tdToReset = null;
		}
	}
	
	function resetClick(id)
	{
		if (!(prevClickedSpan==null))
		{
			hideDesk();
			prevClickedSpan.className = "termin";
			prevClickedSpan.clicked = false;
			prevClickedSpan = null;
		}
	}
	
    function _obj(id) {
        return document.getElementById(id);
    }

    function _print() {
        _obj("idc1").style.display = "none";
        _obj("idc2").style.display = "none";
        window.setTimeout("window.print();", 500);
        return false;
    }
    
 	    function _showImage(title, image, w, h) {
	        var f = "width=" + w + "px, height=" + h + "px, resizable=yes, location=no, scrollbars=yes";
	        var w = window.open("about:blank", "_blank", f);
	        var s = '';
	        s += "<html><head>";
	        s += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
	        s += "<title>" + title + "</title>";
	        s += "</head><body style='padding: 0px; margin: 0px;'>"
	        s += "<a href='#' onclick='window.close(); return false;'><img border='0' alt='Кликните чтобы закрыть' src='" + image + "' /></a>"
	        s += "<body></html>";
	        w.document.write(s);
	        return false;
	    }
