function AddBookmark($url, $caption){
	window.external.AddFavorite($url, $caption);
}

function MyAlert(str){
	alert(str);
}

function CheckIfEmpty(field, message)
{
	//alert("field="+field);
	//alert("CheckIfEmpty, value="+field.value);
	if(field.value == '')
	{
		MyAlert(message);
		field.focus();
		return false; 
	}
	return true;
}

function confirmChecked(frm)
{
	var isChecked = false;
	var msg;
	
	radioGrp = frm.art;
	
	if(frm.art == null)
	{
		msg= "Выберите хотя бы один из вариантов ответа.";
		//Это не радиокнопки, а чекбоксы
		for(var i=0; i<frm.length; i++)
		{
			if(frm.elements[i].type == "checkbox")
			if(frm.elements[i].checked)
			isChecked = true;
		}     
	}
	else
	{
		msg= "Выберите один из вариантов ответа.";
		//РАДИОкнопки
		for(var i=0; i<radioGrp.length; i++)
			if(radioGrp[i].checked)
				isChecked = true;
	}
	
	if(isChecked)
		return true;
	else
		alert(msg);
	
	return false;
}

function openWnd(t_url, width, height)
{
    var windowProperties = "";
    var windowWidth;
    var windowHeight;
   	maxWindowWidth = 800;
    maxWindowHeight = 600;
    if(width < maxWindowWidth && width > 0)
    	windowWidth= width + 10;
    if(height < maxWindowHeight && height > 0)
    	windowHeight= height + 30;

    left= (screen.availWidth/2 - windowWidth/2);
    right= (screen.availHeight/2 - windowHeight/2);

    windowProperties += 'width='+windowWidth+',height='+windowHeight;
    windowProperties += ',left=' + left;
    windowProperties += ',top='+ right;
    windowProperties += ',status=no, scrollbars=auto, resizable=yes';
    window.open(t_url, "", windowProperties);

    //window.document.write(',left=' + left + "; right="+ right);

    return false;
}

function clearFakeInput(input, fake)
{
	//alert('clearFakeInput');
	if(input.value == fake)
		input.value= "";
}

function checkSearchForm(form)
{
	if(form.like.value == "")
	{
	    alert("Введите строку поиска!");
		form.like.focus();
		return false;
	}
	return true;
}


