$(document).ready(function(){

$(".accordion2 h3").click(function(){
$(this).next("p").slideToggle("normal")
.siblings("p:visible").slideUp("normal");
$(this).toggleClass("active");
$(this).siblings("h3").removeClass("active");
});

});

$(function() {
$('.gallery').lightBox({
	imageLoading: '/images/lightbox-ico-loading.gif',
	imageBtnClose: '/images/lightbox-btn-close.gif',
	imageBtnPrev: '/images/lightbox-btn-prev.gif',
	imageBtnNext: '/images/lightbox-btn-next.gif'
	});
});



function hi_window(page)
        {
        var url=page;
        var settt=window.open( url, "his" ,"toolbar=no,directories=no,scrollbars=yes,status=yes,resizable=yes,width=500,height=400");
        }


function hiza()
        {
        window.open( "/new.htm", "ahis" ,"toolbar=no,directories=no,scrollbars=no,status=no,resizable=no,width=400,height=200");
        }


function tumbpre(ids,met)
        {
if (met==500)
{        
var siz=(ids.src.substring(ids.src.length-7,ids.src.length-4)==200 ? '200':'0');
ids.outerHTML='<IMG vspace=6 vspace=6 ALIGN=TOP ALT=\"Уменьшить\" class=hlan SRC=/tumb/icons/'+ids.id+'500.jpg id=\"'+ids.id+'\" OnClick=\"tumbpre(this,'+siz+');\">';
}
else
{        
var siz=(met==0 ? '':'200');
ids.outerHTML='<IMG vspace=6 vspace=6 ALIGN=absmiddle ALT=\"Увеличить\" class=hlan SRC=/tumb/icons/'+ids.id+siz+'.jpg id=\"'+ids.id+'\" OnClick=\"tumbpre(this,500);\">';}
       }

function nxtl(elm,nexta,cods)
{
	if (navigator.appName=="Microsoft Internet Explorer" || navigator.appName=='Opera')
		{
		if (elm.value.length>=elm.maxLength && cods!=8 && cods!=46 && cods!=9 && cods!=16)
			{
			var oForm=elm.form;
			oForm[nexta].focus();
			return false;
			}
		}
}

function disp(id_obj)
{
var dsp =document.getElementById(id_obj).style;
var himg =document.getElementById('himg'+id_obj);
dsp.display = (dsp.display != 'block' ? 'block' : 'none');
if (himg!=null){
himg.src = (himg.src.indexOf('gr_pl') != -1 ? himg.src.replace('gr_pl','gr_mn') : himg.src.replace('gr_mn','gr_pl'));
}
}



function makeRequest(url) 
	{
	var http_request = false;
	if (window.XMLHttpRequest) 
		{ // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
			{
			http_request.overrideMimeType('text/html; charset=windows-1251');
			}
		} else if (window.ActiveXObject) 
		{ // IE
		try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch (e) 
			{
			try 
				{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}

		if (!http_request) 
		{
		// alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}
		http_request.onreadystatechange = function() { alertContents(http_request); };
		http_request.open('GET', url, true);
		http_request.send(null);
	}

function alertContents(http_request) 
	{
	if (http_request.readyState == 4) 
		{
		if (http_request.status == 200) 
			{
			sel_reg(http_request.responseText);
			} else 
			{
			return;
			}
		}
	}


function get_cook(id_obj)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (id_obj == aCrumb[0]) 
		{
		return aCrumb[1];
		}
	}
	return;
}


function sel_reg(toreg)
	{
	for(i=0;i<document.getElementById('select_region').length;i++)
		{ 
		if (toreg.indexOf(document.getElementById('select_region').options[i].text)>-1 && toreg.indexOf(document.getElementById('select_region').options[document.getElementById('select_region').selectedIndex].text)<0) 
			{
//			alert(get_cook('chk_reg'));
			if (get_cook('chk_reg')!='true') disp('region');
			disp('btn_reg');
			disp('span_chk_reg');
			document.getElementById('chk_reg').checked=get_cook('chk_reg');
			document.getElementById('select_region').options[i].selected = true;
			}
		}

	}


function set_cook(id_obj,val)
{
var to = 5*365*24*60*60*1000; 
var expDate = new Date(); 
expDate.setTime(expDate.getTime() +to); 
document.cookie = id_obj + "=" + val + "; path=/; expires=" + expDate.toGMTString() ; 
}

function re3play()
{
if(document.getElementById('tar_z')!=null) document.getElementById('tar_z').disabled=(document.getElementById('u_int').checked!=true?true:false);
if(document.getElementById('fixip_yn')!=null) document.getElementById('fixip_yn').disabled=(document.getElementById('u_int').checked!=true?true:false);

if(document.getElementById('iptv')!=null) document.getElementById('iptv').disabled=(document.getElementById('u_iptv').checked!=true?true:false);
if(document.getElementById('iptv1')!=null) document.getElementById('iptv1').disabled=(document.getElementById('u_iptv').checked!=true?true:false);
if(document.getElementById('iptv2')!=null) document.getElementById('iptv2').disabled=(document.getElementById('u_iptv').checked!=true?true:false);
if(document.getElementById('iptv3')!=null) document.getElementById('iptv3').disabled=(document.getElementById('u_iptv').checked!=true?true:false);
if(document.getElementById('iptv4')!=null) document.getElementById('iptv4').disabled=(document.getElementById('u_iptv').checked!=true?true:false);

if(document.getElementById('pdb')!=null) document.getElementById('pdb').disabled=(document.getElementById('u_sip').checked!=true?true:false);
if(document.getElementById('id_Sip')!=null) document.getElementById('id_Sip').disabled=(document.getElementById('u_sip').checked!=true?true:false);
if(document.getElementById('Loc_sip_yn')!=null) document.getElementById('Loc_sip_yn').disabled=(document.getElementById('u_sip').checked!=true?true:false);
if(document.getElementById('Mgmn_sip_yn')!=null) document.getElementById('Mgmn_sip_yn').disabled=(document.getElementById('u_sip').checked!=true?true:false);
if(document.getElementById('Oper_sip')!=null) document.getElementById('Oper_sip').disabled=(document.getElementById('u_sip').checked!=true?true:false);
}

function testf(idd)
{
for (var i= 0; i< idd.length; i++) {

if (document.getElementById(idd[i]).value == "" ) 
{document.getElementById(idd[i]).style.backgroundColor = '#FFCCCC'; alert ('Не заполнено обязательное поле: '+document.getElementById(idd[i]).title); document.getElementById(idd[i]).focus(); return false;}
else 
{document.getElementById(idd[i]).style.backgroundColor = ''; }

}
return true;
}
