function winClose(){window.close();}

function openNewWindowForLoad(url,name,width,height)
{
	window.open(url,name,"width="+width+",height="+height+",left=0,top=0,status=no,toolbar=no,menubar=no,scrollbars=no").focus();
}


//-------GET VARIABLES------------------------
function getParam(sParamName)
{
    var Params = location.search.substring(1).split("&");
    var variable = "";
    for (var i = 0; i < Params.length; i++)
    {
        if (Params[i].split("=")[0] == sParamName)
        {
            if (Params[i].split("=").length > 1) variable = Params[i].split("=")[1];
            	return variable;
        }
    }
    return "";
}

function changeImg(id,newSrc)
{
	var img = document.getElementById(id);
	img.src = newSrc;
}

function changeSelfImg(id)
{
	var img = document.getElementById(id);
	var path = img.src;
	img.src = path;
}


function HideMail(s)
{
	var p = new String("");
	p="mailto:"+s+"@fx-plus.ru";
	window.open(p);
}

function clearHistory()
{
	h = window.history; 
	if ( h.length ) {
    	h.back();
	}
}


function clearValue(id){id.value="";}
function setValue(id,value){id.value=value;}


function validateRequired(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}


function validateEmail(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function sendForm(formId)
{
	document.getElementById(formId).submit();
}

function clearValue(id)
{
	document.getElementById(id).value='';
}

function setValue(id,value)
{
	document.getElementById(id).value=value;
}

function clickOutside(value,setvalue,id)
{
	if(document.getElementById(id).value==value)setValue(id,setvalue);
}


var actionHandlerScriptUrl;
function sendOnlyNewsIdF(id)
{
	var newsId=document.getElementById(id).innerHTML;
	document.getElementById('doculoaderSender').src=actionHandlerScriptUrl+'action=sendOnlyNewsId'+'?newsId='+newsId;
	alert(txt);
}

function aaa(){
	if(document.getElementById('out1').readOnly)
	{
	alert('aaa');	
	}
}

function xz(obj)
{
	if(document.getElementById)
	{
		var x = document.getElementById(obj)
		if(x.style.display != "block")
			x.style.display = "block";
		else
			x.style.display = "none";
	}
}

function dropFile(btn,todrop){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast(todrop);
	}
}
function addFile(btn,toadd){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');
		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
			if (thisChilds[i].className == 'files') thisChilds[i].innerHTML = '<input size="32" name="att[]" class="wideFile" type="file">';
		}
		checkForLast(toadd);
	}
}
function checkForLast(todrop){
	btns = document.getElementsByName(todrop);
	for (i = 0; i < btns.length; i++){
		btns[i].disabled = (btns.length == 1) ? true : false;
	}
}
function up(btn)
{
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');
		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
			if (thisChilds[i].className == 'files') thisChilds[i].innerHTML = '<input size="32" name="att[]" class="wideFile" type="file">';
		}
		checkForLast();
	}
}


var DH = 0;var an = 0;var al = 0;var ai = 0;
if (document.getElementById) 
{
	ai = 1; 
	DH = 1;
}
else 
{
	if (document.all) 
	{
		al = 1; 
		DH = 1;
	} 
	else 
	{ 
		browserVersion = parseInt(navigator.appVersion); 
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) 
		{
			an = 1; 
			DH = 1;
		}
	}
} 

function fd(oi, wS) 
{
	if (ai) 
		return wS ? document.getElementById(oi).style:document.getElementById(oi); 
	if (al) 
		return wS ? document.all[oi].style: document.all[oi]; 
	if (an) return document.layers[oi];
}
function pw() 
{
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}
function mouseX(evt) 
{
	if (evt.pageX) 
		return evt.pageX; 
	else 
		if (evt.clientX)
			return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
		else 
			return null;
}
function mouseY(evt) 
{
	if (evt.pageY) 
		return evt.pageY; 
	else 
		if (evt.clientY)
			return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
		else 
			return null;
}
function popUp(evt,oi) 
{
	if (DH) 
	{
		var wp = pw(); 
		ds = fd(oi,1); 
		dm = fd(oi,0); 
		st = ds.visibility; 
		if (dm.offsetWidth) 
			ew = dm.offsetWidth; 
		else 
			if (dm.clip.width) 
				ew = dm.clip.width; 
		if (st == "visible" || st == "show") 
		{ 
			ds.visibility = "hidden"; 
		} 
		else 
		{
			tv = mouseY(evt) + 5; 
			lv = mouseX(evt) - (0); 
			if (lv < 2) lv = 2; 
			else 
				if (lv + ew > wp) lv -= ew/2; 
					if (!an) 
						{lv += 'px';tv += 'px';} 
			ds.left = lv; 
			ds.top = tv; 
			ds.visibility = "visible";
		}
	}
}

