// JavaScript Document
//<!--

// helpfull debug func
function alertObject(obj)
{
	var s = '';
	var i = 0;
	for(var key in obj)
	{
		i++;
		s += key+'='+obj[key]+'; ';
		if ((i % 3) == 0) s += '\n';
	}
	alert(s);
}

function FindObjOld(n,d)
{
	var p,i,x;
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
    	d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function FindObj(Id)
{
	return document.getElementById(Id);
}


//*************************************************************************************************
function ActivateForm(El,DefValue) { if((Obj=FindObj(El))!=null)if(Obj.value==DefValue)Obj.value=''; }
//*************************************************************************************************
function BlurForm(El,DefValue) { if((Obj=FindObj(El))!=null)if(Obj.value=='')Obj.value=DefValue; }
//*************************************************************************************************
function SetIdClass(Id,ClassName) { if((Obj=FindObj(Id))!=null) Obj.className=ClassName; }
//*************************************************************************************************

function Remove() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.parentNode.removeChild(Obj);}
	}
}

function Hide() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.style.display='none'}
	}
}

function Show() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.style.display=''}
	}
}

function Disable() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.disabled = true;}
	}
}

function Enable() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.disabled = false;}
	}
}

function ClearValue() {
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {Obj.value = '';}
	}
}

function ToggleVisibility()
{
	for (i=0; i<arguments.length; i++) {
		if ((Obj = FindObj(arguments[i])) != null) {
			if (Obj.style.display=='none') Obj.style.display = '';
			else Obj.style.display='none';
		}
	}
}

function GoTo(URL) {
	document.location = URL;
}

function GetElementPosition(elemId)
{
    var elem = FindObj(elemId);//document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}


//('e1','contact','alfa-group.biz');
function SetEMail(Id,prefix,postfix) {
	if ((Obj = FindObj(Id)) != null) Obj.innerHTML = '<a href = "'+'mailto:'+prefix+'@'+postfix+'">'+prefix+'@'+postfix+'</a>';
}

function SetBG(Id, Src) {
	if ((Obj = FindObj(Id)) != null) {Obj.style.backgroundImage = "url("+Src+")"; Obj.style.backgroundRepeat = "repeat-x"}
}

function GetClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function GetClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

// вспомогательная ф-я устанавливает value элемента, найденного по Id в значение Val
function SetIdVal(Id, Val) { if ((Obj = FindObj(Id)) != null) Obj.value = Val; }
function GetIdVal(Id) { if ((Obj = FindObj(Id)) != null) return Obj.value; }
function TrimAll(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); }
function LeftTrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); }
function RightTrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); }



// "индивидуальные" функции

function MenuPlusMinus(Id)
{
	if ((Obj = FindObj(Id)) != null)
	{
		if(Obj.src.indexOf('minus.gif')>=0) Obj.src = Obj.src.replace(/minus.gif$/,'plus.gif');
		else Obj.src = Obj.src.replace(/plus.gif$/,'minus.gif');
	}
}





//-->
