var id_row;
var clas;

function mklight(id){
	if(!document.getElementById(id)) return false;
	id_row=id;
	clas=document.getElementById(id).className;
	document.getElementById(id).className="table_row_lights";
}

function mkback(){
	if(!document.getElementById(id_row)) return false;
	document.getElementById(id_row).className=clas;
}

function onBlurSearch()
{
	if(document.getElementById('word_field').value==''){
		document.getElementById('word_field').value='Поиск...';
	}
}
function onBlurSearch()
{
	if(document.getElementById('word_field').value==''){
		document.getElementById('word_field').value='Поиск...';
	}
}
function onFocusSearch()
{
	if(document.getElementById('word_field').value=='Поиск...'){
		document.getElementById('word_field').value='';
	}
}

function handleSel(param, tagName){
    if (document.getElementById(tagName).setSelectionRange) {
        el = document.getElementById(tagName);
        el.value = el.value.substring(0,el.selectionStart) + '['+ param +']'+ el.value.substring(el.selectionStart,el.selectionEnd) + '[/'+ param +']' + el.value.substring(el.selectionEnd,el.value.length);
    } else if(document.selection.type == 'Text'){
        var TR = document.selection.createRange();
        TR.text = '[' + param +']'+ TR.text + '[/' + param + ']';
        document.selection.createRange().select();
    }
}


function onDelete(url){
    if (confirm('Вы уверены, что хотите удалить?')){
        document.location = url;
    }
}

function onWindowOpen(url,width,height){
    window.open( url,'','left='+(screen.availWidth/2-width/2)+',top='+(screen.availHeight/2-height/2)+',width='+width+',height='+height+',scrollbars=1');
}

function onChangeSelect(){
	var action = document.newslist.action.value;
	if (action=='move'){
		document.newslist.cat_id.style.display = 'block';
	}else{
		document.newslist.cat_id.style.display = 'none';
	}	
}

function makeAction(){
	var action = document.newslist.action.value;
	if (action.length>0){
		document.newslist.submit();
	}
}

function checkAll(elem, groupName) {
    var chkAll = document.getElementById(elem);
    var checks = document.getElementsByName(groupName);
    var boxLength = checks.length;
    var allChecked = false;
    if ( chkAll.checked == true ) {
        for ( i=0; i < boxLength; i++ ) {
            checks[i].checked = true;
        }
    }
    else {
        for ( i=0; i < boxLength; i++ ) {
            checks[i].checked = false;
        }
    }
}
