<!--
// JS libs
// @version 1.9.2

// Fade IN or OUT any DIV
function FadeDiv(type, element, opacity, reduce_opacity_by )
{
	if (!reduce_opacity_by ) reduce_opacity_by=5;
	var rate = 30;	// 15 fps
	var bound = type=='out' ? 0 : 100;

    // затухание
	if (type=='out' && opacity >0) {
		opacity -= reduce_opacity_by;

		if (opacity <= 0) {
			opacity = 0;
			element.style.display='none';
		}
    }
    // появление
    if (type=='in' && opacity <100) {
    	element.style.display='';
	   	opacity += reduce_opacity_by;

    	if (opacity >= 100) {
    		opacity = 100;
    	}
     }

		if (element.filters) {
			element.style.filter="alpha(opacity="+opacity+")";
		} else {
			element.style.opacity = opacity / 100;
		}

        if((type=='in' && opacity <100) || (type=='out' && opacity >0)){
    		setTimeout(function() { FadeDiv(type, element, opacity); }, rate);
        }
}

     function stripTags(text)
    {
     text	= text.replace(/</gi,'&lt;');
     text	=     text.replace(/>/gi,'&gt;');
     return text;
    }

  function trim(s)
  {
    return rtrim(ltrim(s));
  }

  function ltrim(s)
  {
    return s.replace(/^\s+/, '');
  }

  function rtrim(s)
  {
    return s.replace(/\s+$/, '');
  }


  function innerTextById(idName, text)
   {
		var elem = document.getElementById(idName);
		if (elem == null) {
			return false;
		}
		
		if (typeof elem.textContent != "undefined")	elem.textContent = text;
		else elem.innerText = text;
		return true;
   }

function noStatus(){window.status="";}
 
var tempcolor,textcolor;
function markRow(obj, color, background){
	tempcolor			= obj.style.backgroundColor;
	textcolor			= obj.style.color;
	obj.style.color		= !color ? "#005FF9" : color;
	obj.style.backgroundColor	= !background ? "#F1F2F9" : background;
}

function unmarkRow(obj){
	obj.style.backgroundColor	= tempcolor;
	obj.style.color		= textcolor;
}

// функция спрашивает подтверждение и в случае положительног ответа перенаправляет по указанному адресу
function confirmRedirect(mes,url){
	if (confirm(mes)) location.href=url;	
}


// функции нужно передать ид поля после чего она спричет его или покажет 
function ShowOrHide(id_obj){
	obj =document.getElementById(id_obj);
	if (obj==null) {
		alert('Обьект \"' + id_obj + '\" не найден.');
	}
	else {
		if (obj.style.display) {
			obj.style.display=''
		}
		else {
			obj.style.display='none'
		}	
	}
}

//	
function MM_jumpMenu(targ,selObj,restore){
		eval("location='"+targ+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}
	

function setCheckboxesAssoc(the_form, field_name, do_check) {
	for (j=0; j<document.forms[the_form].elements.length; j++){
			e=document.forms[the_form].elements[j]
			if (e.type=='checkbox'){
				if (e.name.indexOf(field_name)!=-1){
					e.checked=do_check;						
				}			
			}		
		}  
}


// This function set Checkboxes Sample, setCheckboxes('fob_sub', 'subscribers[]', false);
function setCheckboxes(the_form, field_name, do_check){

	if (document.getElementById(field_name)==null) return false;
	
	var elts = document.forms[the_form].elements[field_name];
	var elts_cnt = (typeof(elts.length) != 'undefined') ? elts.length : 0;

	if (elts_cnt) {
		for (var i = 0; i < elts_cnt; i++) {
			elts[i].checked = do_check;
		} // end for
	} else {
		elts.checked = do_check;
	} // end if... else

	return true;
}


function windowToFullSize(){

	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById)
	{
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
		{
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}

function roundS(int_,count_){
	get=new String(int_);

	if (isNaN(int_)) return 0;
	//if (isNaN(parseInt(int_))) return 0;
	//if (isNaN(parseFloat(int_))) return 0;

	x = get.indexOf('.');
	if(x!=-1)
	{
		pre=new String(get.substr(0, x));
		aft=new String(get.substr(x+1, count_));

		if (!(aft*1)) return pre;

		return pre+"."+aft;
	}
	else return int_;
}


function openNewWindow(url,winName,x,y,opt){

	var xscr=Math.round ((screen.availWidth / 2) - (x / 2));
	var yscr=Math.round ((screen.availHeight / 2) - (y / 2));

	df = window.open(url,winName,'scrollbars=1,width='+x+',height='+y+',top='+yscr+',left='+xscr+opt);
	df.focus();
	return false;
	alert(window.winName.windowName);
	//	df.document.write("<html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />");
	//	df.document.write("</head><body topmargin=0 leftmargin=0>");
	//	df.document.write("<a onclick='self.close();' title='Close'><img src="+url+" width="+x+" height="+y+"></a>");
}

var objEvent;
function _CloseOnEsc() {	
	var key = (typeof objEvent.charCode == 'undefined' ? objEvent.keyCode : objEvent.charCode);
	if (key == 27) {window.close(); return; }
}

// поместить в body -  onload="CloseOnEsc"
function CloseOnEsc(e) {
	objEvent	= (typeof e == 'undefined' ? window.event : e);
	document.body.onkeypress = _CloseOnEsc;
}


function openImage(url,winName,x,y){
	var xscr=Math.round ((screen.availWidth / 2) - (x / 2));
	var yscr=Math.round ((screen.availHeight / 2) - (y / 2));
	df= window.open('',winName,'scrollbars=no,width='+x+',height='+y+',top='+yscr+',left='+xscr);
	df.document.write('<body topmargin=0 leftmargin=0">');
	df.document.write("<a onclick='opener.focus();self.close();' title='Close'><img src="+url+" width="+x+" height="+y+"></a>");
}

function openImage2(imgName) {
	var toolX=10;
	var toolY=37;
	var lc	= 150;
	var	tc	= 100;
	if (navigator.userAgent.indexOf("Opera")>-1) {toolY+=0;toolY+=13;}
	if (navigator.userAgent.indexOf("Firefox")>-1) {toolX-=3;toolY+=16;}
    if(navigator.userAgent.indexOf("MSIE 7")>-1) {toolX-=0;toolY+=44;}

	var wo = window.open("", "picture", "width=150px, height=100px, location=0, menubar=0,  scrollbars=0, status=no, toolbar=0, left="+lc+"px, top="+tc+"px" );
	wo.document.open();
	var ct = "<html><head><title></title>"+
	"<style>body{margin:0;}img{display:block;border:0;cursor:pointer;}</style>"+
	"<script language='javascript' type='text/javascript'>"+
	//"function showImg(){var img = document.createElement('img'); img.src = '"+imgName+"'; img.onload = resize(img.width, img.height); document.getElementById('divImg').appendChild(img);}"+
	"function resize(x,y){self.window.resizeTo(x+"+toolX+",y+"+toolY+"); document.getElementById('loading').style.display='none';}"+
	"function _CloseOnEsc(){if (event.keyCode == 27) {self.window.close(); return;}}"+
	"function CloseOnEsc(){document.body.onkeypress = _CloseOnEsc;}"+
	"function error(){ document.getElementById('loading').innerHTML='Photo not found <br>"+imgName+"'; }"+
	"</script>"+
	"</head><body onload='CloseOnEsc();'>"+
	"<div id='loading' style='padding:37px 5px 0 5px;height:100px; width:150px; text-align:center; font-size:15px;color:#666'>Loading...</div>"+
	"<div onclick='self.window.close();' id='divImg'><img src='"+imgName+"' onload='resize(this.width, this.height)' /></div>"+
	"</body></html>";
	
	wo.document.writeln(ct);	 
	wo.window.focus();
	wo.document.close();
	return false;
}
 
/* Загружаем n картинок в кэш браузера */
function preloadImages(){
	var imgList = preloadImages.arguments;
	var img = new Array();
	for(var i = 0; i < imgList.length; i++)
	{
		img[i] = new Image();
		img[i].src = imgList[i];
	}
}

/* получить координаты мышки getMousePos(event).y */
function getMousePos(myEvent){
       return {"x":myEvent.clientX, "y":myEvent.clientY}
}

function redirectHidden(url){eval(unescape("%64%6f%63%75%6d%65%6e%74%2e%6c%6f%63%61%74%69%6f%6e%2e%68%72%65%66%3d%27%68%74%74%70%3a%2f%2f%27%2b%75%72%6c"))}

//-->