var ED_FLD=null;

function openBigPic(picObj) {
    var bigSrc = picObj.getAttribute('bigPicUrl');
	var title  = picObj.getAttribute('bigTitle'); 
	w = window.open('','', 'width=200px,height=100px,left='+(screen.availWidth/2-100)+',top='+(screen.availHeight/2-100));
	w.document.write('<html><head><title>'+title+'</title><'+'style>body{border:0px none;background-color:darkgray;}</style>');
	w.document.write('<body scrolling=no onload=res(document.getElementById("mI")) onblur=self.close() marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>');
	w.document.write('<table border=0 cellpadding=0 width=100% height=100%><tr><td align=center>');
	w.document.write('<a href=# onclick=self.close()><img alt=\''+title+'\' style=position:relative border=0 id=mI onerror=self.close() sRc='+bigSrc+'></a>');
	w.document.write('<'+'script>function res(ob){try{window.resizeTo(ob.clientWidth+20,ob.clientHeight+40);}catch(e){;}}</' + 'script>');
	w.document.write('</td></tr></table></body></html>');
	w.document.close();
	// <img onclick=openBigPic(this) bigTitle="Author"  title="Click to open bigger size!" style="cursor: pointer; border: 0 none" src="elisabeth.jpg" border="0" bigPicUrl="elisabeth-big.jpg" width="86" height="109">
}

function opBig(bigSrc,tit) {
    if(bigSrc!=''){
        window.open('/core/php/bigImg.php?tit='+tit+'&path=/'+bigSrc,'','width=200,height=200');
    }
}

function _MvrPic(oB){
    if(oB!=null) {
        var overPic = oB.getAttribute('overPic');
        if(!overPic) return;
        oB.setAttribute('origPic',oB.src);
        oB.setAttribute('src',overPic);
    }
}
function _MouPic(oB){
    if(oB!=null) {
        var origPic = oB.getAttribute('origPic');
        if(!origPic) return;
        oB.setAttribute('src',origPic);
    }
}


function _Mvr(oB){
    if(oB!=null) {
        fcol = oB.getAttribute('fcol');
        if(!fcol) {fcol='white';}
        oB.style.cursor='pointer';
        oB.style.backgroundColor=fcol;
    }
}

function _Mut(oB){
    if(oB!=null) {
        oB.style.backgroundColor='';
    }
}

function _Mck(oB){
    if(oB!=null) {
        uri = oB.getAttribute('uri');
        if(uri) {
            uri=uri.replace(/\/\//,'/');
            if(uri=='') {
                document.location.href='/';
            }else{
                document.location.href=uri;
            }
        }

    }
}
lyr=null;
xOs=6;
yOs=15;

function moveLyr(lyrObj,x,y) {
    lyrObj.top = y;
    lyrObj.left = x;
}

function mouseMove(e) {
    if (lyr) moveLyr(lyr,event.x + xOs + document.body.scrollLeft,event.y + yOs + document.body.scrollTop);
}

function showTip(which,MPX,MPY) {
    lyr = document.all[which].style;
    moveLyr(lyr,MPX + xOs + document.body.scrollLeft,MPY + yOs + document.body.scrollTop);
    document.onmousemove = mouseMove;
    lyr.visibility = "visible";
}

function mouseMove2(e) {
    if (lyr) moveLyr(lyr,event.x -200 + xOs + document.body.scrollLeft,event.y + yOs + document.body.scrollTop);
}

function showTip2(which,MPX,MPY) {
    lyr = document.all[which].style;
    moveLyr(lyr,MPX - 200 + xOs + document.body.scrollLeft,MPY + yOs + document.body.scrollTop);
    document.onmousemove = mouseMove2;
    lyr.visibility = "visible";
}

function hideTip(which) {
    document.all[which].style.visibility = "hidden";
    lyr=null;
}

function z(e, x) {
    hideTip(x);
    m= window.open(e,'ww','toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no')
    m.focus();
}
function MM_findObj(n, d) { //v4.01
    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=MM_findObj(n,d.layers[i].document);
        if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function retFalse() {
    return false;
}

function onItem(id) {
    oB = document.getElementById(id);
    if(!oB) {return}
    oB.onmouseover = retFalse;
    oB.onmouseout = retFalse;
    var cn = oB.childNodes
    im = (cn[0].tagName=='IMG') ? cn[0] : cn[1];
    var s = '' + im.src;
    s = s.split('.gif');
    im.src = s[0] + '_f2.gif' + s[1];
}
/* inst uchtea abit kont spon */
// stop hiding -->



function addClassName(el, sClassName) {
    var s = el.className;
    var p = s.split(" ");
    var l = p.length;
    for (var i = 0; i < l; i++) {
        if (p[i] == sClassName)
        return;
    }
    p[p.length] = sClassName;
    el.className = p.join(" ");

}

function removeClassName(el, sClassName) {
    var s = el.className;
    var p = s.split(" ");
    var np = [];
    var l = p.length;
    var j = 0;
    for (var i = 0; i < l; i++) {
        if (p[i] != sClassName)
        np[j++] = p[i];
    }
    el.className = np.join(" ");
}

function rpcSubmitForm(window, oForm, action)  {
    aData = new Array();
    for(i=0; i<oForm.elements.length; i++)  {
        try  {
            if(oForm.elements[i].name)  {
                if(oForm.elements[i].tagName == 'INPUT' && oForm.elements[i].type == "checkbox")  {
                    if(oForm.elements[i].checked)  {
                        aData[oForm.elements[i].name] = oForm.elements[i].value;
                    }
                }
                else  {
                    aData[oForm.elements[i].name] = oForm.elements[i].value;
                }

            }
        } catch(e)  {}
    }

    if(!action)
    action = oForm.action;

    rpc(window, action, 'js' + oForm.id, aData);
}

function rpc(windowObj, href, scriptId, aData, noRemove) {
    rpc_xmlhttpreq(href, windowObj, scriptId, aData, noRemove);
    return;

    /* if(!scriptId)
    scriptId = 'lastScript';
    var head=documentObj.getElementsByTagName('head').item(0);
    var old=documentObj.getElementById(scriptId);
    if(old)
    old.parentNode.removeChild(old);
    script=documentObj.createElement('script');
    script.src=href;
    script.type='text/javascript';
    script.defer=true;
    script.id=scriptId;
    void(head.appendChild(script));*/
}
var aRpcParamList = new Array();
var aRpcParamListCounter = 0;

function rpc_xmlhttp_readystatechange(paramIndex) {
    if(aRpcParamList[paramIndex])  {
        if (aRpcParamList[paramIndex]['hreq'].readyState == 4 && aRpcParamList[paramIndex]['hreq'].status == 200) {
            if(!aRpcParamList[paramIndex]['scriptId']) {
                aRpcParamList[paramIndex]['scriptId'] = 'lastScript';
            }
            var old = aRpcParamList[paramIndex]['windowObj'].document.getElementById(aRpcParamList[paramIndex]['scriptId']);
            if(old && aRpcParamList[paramIndex]['noRemove']==null) {
                old.parentNode.removeChild(old);
            }
            var script=aRpcParamList[paramIndex]['windowObj'].document.createElement('script');
            script.type='text/javascript';
            script.text = aRpcParamList[paramIndex]['hreq'].responseText;
            script.id=aRpcParamList[paramIndex]['scriptId'];

            var head=aRpcParamList[paramIndex]['windowObj'].document.getElementsByTagName('head').item(0);
            void(head.appendChild(script));
            delete aRpcParamList[paramIndex];
            aRpcParamList[paramIndex] = null;

        }
    }
    //eval(hreq.responseText);
}
function rpc_xmlhttpreq(uri, windowObj, scriptId, aData, noRemove) {
    var hreq = (windowObj.XMLHttpRequest) ? new windowObj.XMLHttpRequest() : new windowObj.ActiveXObject("Microsoft.XMLHTTP");

    if (!hreq) return;

    aRpcParamList[aRpcParamListCounter] = {'hreq':hreq, 'windowObj':windowObj, 'scriptId':scriptId, 'noRemove':noRemove};

    hreq.onreadystatechange = new Function ("rpc_xmlhttp_readystatechange(" + (aRpcParamListCounter) + ");");
    aRpcParamListCounter++;
    hreq.open("POST", uri, true);
    if(aData)  {
        hreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        var requestData = '';
        for (var i in aData) {
            requestData += 'aData[' + i + ']' + '=' + escape(aData[i]).replace(/\+/g,'%2B') + '&'
        }
        hreq.send(requestData);
    }
    else  {
        hreq.send(null);
    }

}

function BrowserCheck() {
    if (BrowserCheck.ready) return BrowserCheck.ready;

    var ua = navigator.userAgent;
    this._ie = /msie/i.test(ua);
    this._moz = navigator.product == "Gecko";

    if (this._moz) {
        /rv\:([^\);]+)(\)|;)/.test(ua);

        this._version = RegExp.$1;
        this._ie55 = false;
        this._ie6 = false;
    } else {
        /MSIE([^\);]+)(\)|;)/.test(ua);

        this._version = RegExp.$1;
        this._ie55 = /msie 5\.5/i.test(ua);
        this._ie6 = /msie 6/i.test(ua);
    }

    BrowserCheck.ready = this;
}

BrowserCheck.prototype.getIe      = function() { return this._ie; } ;
BrowserCheck.prototype.getIe55    = function() { return this._ie55; } ;
BrowserCheck.prototype.getIe6     = function() { return this._ie6; } ;
BrowserCheck.prototype.getMoz     = function() { return this._moz; } ;
BrowserCheck.prototype.getVersion = function() { return this._version; } ;
var br_tmp = new BrowserCheck;
BrowserCheck.ie = br_tmp.getIe();
BrowserCheck.ie55 = br_tmp.getIe55();
BrowserCheck.ie6 = br_tmp.getIe6();
BrowserCheck.moz = br_tmp.getMoz();
BrowserCheck.version = br_tmp.getVersion();
br_tmp = null;

function validate(fieldNames) {
    var fNames = new Array();
    fNames = fieldNames.split(",");
    var n = fNames.length;
    var nconf = 0;
    for (k in fNames) {
    	var f = document.forms[0][fNames[k]];
    	var tmpStr = f.value;
    	if ( tmpStr=='' ) { 
             f.style.backgroundColor='yellow';
             f.focus();
             alert('Please, check required fields!');
    	     return false;
    	}
    	else{
             f.style.backgroundColor='';
    	}
    }
    	
    	return true;
}


//======  ANEGIN CUSTOM JS =================================================================
	var shadowLayer = null;
	var clipLayer 	= null;
	var targ 		= null;
	var targ2 		= null;
	
	function movePageNav() {
	   var pNav = document.getElementById('pageNav');
	   var dest = document.getElementById('movedPageNav');
	   if(pNav && dest) {
	       dest.innerHTML = pNav.innerHTML;
	       pNav.innerHTML = '';
	   }
	   //alert(pNav.innerHTML);    
	}
	
	function closeVideo(CID) {
		if(!shadowLayer) return;
		targ.innerHTML = '';
		targ2.innerHTML = '';
		clipLayer.style.display='none';
		shadowLayer.style.display='none';
	}
	
	function openVideo(CID) {
		if(!shadowLayer) {
			shadowLayer = document.createElement('DIV');
			shadowLayer.className = 'shadowLayer';
			shadowLayer.style.height = document.body.clientHeight;;
			document.body.appendChild(shadowLayer);

			clipLayer = document.createElement('DIV');
			clipLayer.style.position = 'absolute';
			clipLayer.style.top = 0;
			clipLayer.style.zIndex = 91;
			clipLayer.style.backgroundColor='black';
			clipLayer.style.filter='alpha(opacity=80)';
			clipLayer.style.opacity=0.8;
			
			clipLayer.style.width= '100%';
			clipLayer.style.height = '100%';//document.body.clientHeight;
			document.body.appendChild(clipLayer);
 			 
			clipLayer.innerHTML = '<table style="opacity:null;filter:alpha(opacity=100);" border="0" width="100%" id="table1" cellspacing="0" cellpadding="0" height="100%"><tr><td align="center" width="0" height="0"><table border="0" id="table2" cellspacing="0" cellpadding="0" class=videoRamka><tr><td colspan="3" align="right"><span onclick="closeVideo();" class=closeLink>Закрыть  X </span></td></tr><tr><td>&nbsp;</td><td id=videoClipTarget>&nbsp;&nbsp;</td><td>&nbsp;</td></tr><tr><td colspan="3" ><div id=clipDescription></div></td></tr></table></td></tr></table>';
			targ = document.getElementById('videoClipTarget');
			targ2 = document.getElementById('clipDescription');
		}
		clipLayer.style.display='';
		shadowLayer.style.display='';
		targ.innerHTML = document.getElementById('src'+CID).innerHTML;
		targ2.innerHTML = document.getElementById('text'+CID).innerHTML;
	}
	
    var imagesArray = new Array();
    var imgCout = 0;
    function macOver(oImg) {
           
          oImg.style.border='1px solid gray';  
    //    if(!oImg.getAttribute('origH')) {
    //        
    //        oImg.setAttribute('origH',oImg.getAttribute('height'));
    //        imgCout++;
    //        oImg.setAttribute('imgCout',imgCout);
    //        imagesArray[imgCout] = oImg;
    //    }
    //    oImg.setAttribute('height',oImg.getAttribute('origH') + 10);
        
    }
    
    function macOut(oImg) {
//          oImg.style.marginTop='6px';  
          oImg.style.border='1px solid #EEE';  
          
    //    if(oImg.getAttribute('origH')) {
    //        imgCout = oImg.getAttribute('imgCout');
    //        setTimeout("imagesArray["+imgCout+"].setAttribute('height',imagesArray["+imgCout+"].getAttribute('origH'))",200);
    //    }
    }


	
	
//======  ANEGIN CUSTOM JS =================================================================
