﻿<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
function GoToURL(sender)
{
	if(sender.value)
		document.location=sender.value;
}
function GetFavorite()
	{
	window.open('/favorite.ashx?path='+location.href+'&title='+document.title,'','','');
	}
function SetCookie (name,value,expires) 
{
  //alert(value);
  var dt = new Date();
  var dtt = "";
  dt.setTime(dt.getTime()+expires*24*60*60*1000);
  dtt = dt.toGMTString();
  document.cookie = name+"="+value+";expires="+dtt+";path=/";
}
function getCookie(name) {
        var prefix = name + "=";
        var cookieStartIndex = document.cookie.indexOf(prefix);
        if (cookieStartIndex == -1)
                return null;
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length;
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
        }
function deleteCookie(name) {
        if (getCookie(name)) 
        {
                document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT;path=/";
        }
}

function Expand_Or_CollapseDiv(sender,divForExpandID,lnkForExpandTextID, hideText, openText, change_sender)
{
    var divForExpand=document.getElementById(divForExpandID);
    var lnkForExpandText=document.getElementById(lnkForExpandTextID);
    
    if(divForExpand.style.display=='none')
    {
            divForExpand.style.display="block";
        divForExpand.style.visibility="visible";
        if(lnkForExpandTextID)
        {
        lnkForExpandText.innerHTML=hideText;
        lnkForExpandText.style.backgroundImage="url(/i/minus_blue.gif)";
        }
        else if(change_sender)
        {
            sender.style.backgroundImage="url(/i/minus_blue.gif)";
        }
    }
    else
    {
        divForExpand.style.display="none";
        divForExpand.style.visibility="hidden";
        if(lnkForExpandTextID)
        {
        lnkForExpandText.innerHTML=openText;
        lnkForExpandText.style.backgroundImage="url(/i/plus_blue.gif)";
        }
        else if(change_sender)
        {
            sender.style.backgroundImage="url(/i/plus_blue.gif)";
        }
    }
}

function Show_News_TabSheet(sender,NameForShow,NameForHide, tagNameForClassChange)
{
    var divForShow=document.getElementById("div"+NameForShow);
    var tagForShow=document.getElementById(tagNameForClassChange+NameForShow);
    var class_name=sender.className.replace("_active","");
    if(class_name==tagNameForClassChange)
        class_name="";
    if(divForShow)
    {
        if(NameForHide)
        {
            var divForHide=document.getElementById("div"+NameForHide);
            var tagForHide=document.getElementById(tagNameForClassChange+NameForHide);
            divForHide.style.display="none";
            divForShow.style.visibility="hidden";
            tagForHide.className=class_name;
        }
        if(divForShow.style.display=="none")
        {
            divForShow.style.display="block";
            divForShow.style.visibility="visible";
            if(class_name)
            tagForShow.className=class_name+"_active";
            else
            tagForShow.className=tagNameForClassChange+"_active";
        }
        else
        {
            divForShow.style.display="none";
            divForShow.style.visibility="hidden";
            tagForShow.className=class_name;
       }
    }
}

function Expand_Or_CollapseTabSheet(sender,otherSenderIDForHide,IDForShow,IDForHide, sndr_css_active, sndr_css_inactive,trgt_css_active, trgt_css_inactive,
    divAdditID, addit_css_inactive, addit_css_active)
{
    var divForExpand=document.getElementById(IDForShow);
    var divForClose=document.getElementById(IDForHide);
    var divAddit=document.getElementById(divAdditID);
     if(divForExpand.style.display=='none')
    {
            divForExpand.style.display="block";
        divForExpand.className=trgt_css_active;
        if(sender)
        {
            sender.className=sndr_css_active;
        }
        var divForClose=document.getElementById(IDForHide);
        var sndrForClose=document.getElementById(otherSenderIDForHide);
        if(divForClose)
        {
        divForClose.className=trgt_css_inactive;
        divForClose.style.display="none";
        }
        if(sndrForClose)
        {
        sndrForClose.className=sndr_css_inactive;
        }
        if(divAddit)
        {
            divAddit.className=addit_css_active;
        }
    }
    else
    {
        divForExpand.style.display="none";
        divForExpand.className=trgt_css_inactive;
        if(sender)
        {
            sender.className=sndr_css_inactive;
        }
        if(divAddit)
        {
            divAddit.className=addit_css_inactive;
        }
    }
}
function Switch_TabSheet(NameForShow,NameForHide, _btnForHide,_btnForShow,btnForHideCss,btnForShowCss,newscount)
{
    var divForShow=document.getElementById(NameForShow);
    var divForHide=document.getElementById(NameForHide);
    var btnForShow=document.getElementById(_btnForShow);
    var btnForHide=document.getElementById(_btnForHide);
    if(divForHide)
    {
        divForHide.style.display="none";    
        divForHide.style.visibility="hidden";
        btnForHide.className=btnForHideCss;
    }
    
    divForShow.style.display="block";
    divForShow.style.visibility="visible";
    btnForShow.className=btnForShowCss;    
}
function Switch_TabSheetX(NameForShow,NameForHide, _btnForHide,_btnForShow,btnForHideCss,btnForShowCss, spanCurr, aCurr, spanGo, aGo, newscount)
{
    var divForShow=document.getElementById(NameForShow);
    var divForHide=document.getElementById(NameForHide);
    var btnForShow=document.getElementById(_btnForShow);
    var btnForHide=document.getElementById(_btnForHide);
    var divSpanCurr = document.getElementById(spanCurr);
    var divACurr = document.getElementById(aCurr);
    var divSpanGo = document.getElementById(spanGo);
    var divAGo = document.getElementById(aGo);    
    if(divForHide)
    {
        divForHide.style.display="none";    
        divForHide.style.visibility="hidden";
        btnForHide.className=btnForHideCss;
        divSpanCurr.style.display="none";
        divSpanCurr.style.visibility="hidden";
        divAGo.style.display="none";   
        divAGo.style.visibility="hidden";          
    }
    
    divForShow.style.display="block";
    divForShow.style.visibility="visible";
    btnForShow.className=btnForShowCss; 
    divACurr.style.display="block";
    divACurr.style.visibility="visible";  
    divSpanGo.style.display="block";
    divSpanGo.style.visibility="visible";          
}
//Показ всплывающего div-а
<!--
function ShowDiv(divID)
{
    var div=document.getElementById(divID);
    if(div)
    {
             var x1 = (document.all) ? window.event.x + document.body.scrollLeft : undefined;
	        var y1 = (document.all) ? window.event.y + document.body.scrollTop : undefined;
    	
		    div.style.left = (x1 + 20) + "px";
		    div.style.top = (y1) + "px";
        div.style.display="block";
        div.style.visibility="visible";
    }
}
function ShowDivWithFocus(divID, inputID)
{
    var div=document.getElementById(divID);
    if(div)
    {
        div.style.display="block";
        div.style.visibility="visible";
        var inpt=document.getElementById(inputID);
        if(inpt)
        inpt.focus();
        
    }
}
function HideDiv(divID)
{
    var div=document.getElementById(divID);
    if(div)
    {
   		
        div.style.display="none";
        div.style.visibility="hidden";
    }
}//-->


var ajaxTargetCtrlID;
function Return_AjaxResult (){

	if(req.readyState == 4){
	
	document.getElementById(ajaxTargetCtrlID).innerHTML = req.responseText;
	//alert(req.responseText);
	delete req;
	}	
	
}
function Blank_AjaxResult (){

	if(req.readyState == 4){
	delete req;
	}	
	
}
var req;
function connect(url, u_function) 
{
if(req!=null&&req.readyState != 4)
{
    alert("Подождите. Обрабатывается предыдущий запрос.");
    return false;
}
if(!u_function)
    u_function='Return_AjaxResult';
	if(window.XMLHttpRequest)
	{  
		req = new XMLHttpRequest();
		req.onreadystatechange = eval (u_function);
		req.open("GET", url, true); 		
		req.send(null);
	}else if(window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if(req)
		{
			req.onreadystatechange = eval (u_function);
			req.open("GET", url, true);
			req.send();
		}else
		{
			alert('Не удалось создать экземпляр объекта: ActiveXObject.');
		}
	}
}
function GetAjaxDDL(div,url)
{
    if(req!=null&&req.readyState != 4)
    {
        alert("Подождите. Обрабатывается предыдущий запрос.");
        return false;
    }
    ajaxTargetCtrlID=div;
    connect(url);
}


function SetImgToControl(sender,imgID,path, width,height)
	{
	var img=document.getElementById(imgID);
	if(img)
	{
	img.src='/img.ashx?Img='+path+sender.value+'.jpg'+'&width='+width+'&height='+height;
	}
	}
function CheckDDLSelection(divID, ddlID)
	{
	    var div=document.getElementById(divID);
	    var ddl=document.getElementById(ddlID);
	    if(div&&ddl)
	    {	        
	        if(parseInt(ddl.value)==-1)
	        {
	            div.style.display="block";
	        }
	        else
	        div.style.display="none";
	    }
	}
	 function SelectAllCheckBoxes(sender, name)
        {
            var list=document.getElementsByName(name);
            for(var i=0;i<list.length;i++)
            {
                list[i].checked=sender.checked;
            }
        }
        
        
          function GoToSearch(id, path, paramName)
    {
        var tb = document.getElementById(id);
        //alert(path + '?search=' + tb.value);
        if(!paramName)
        window.location = path + '?search=' + tb.value;
        else
        window.location = path + '?'+paramName+'=' + escape(tb.value);
        return false;
    }
    
    function SetValToAjaxHidd(val, hiddID,str,spanID)
    {
        var hidd = document.getElementById(hiddID);
        if(hidd)
            hidd.value=val;
        var span = document.getElementById(spanID);
        if(span)
            span.innerHTML=str;
    }   
    
    
