function DoConfirm(message, url) {
	if(confirm(message)) location.href = url;
}

function WhichClicked(ww) {
	window.document.writeform.waction.value = ww;
}

function submitonce(theform) {
	// if IE 4+ or NS 6+
	if (document.all || document.getElementById) {
		// hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++) {
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
				//disable it
				tempobj.disabled=true;
			}
		}
	}
}

function storeCaret(text) {
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

function replaceText(text)
{

	if (document.writeform.text.createTextRange && document.writeform.text.caretPos) {
		var caretPos = document.writeform.text.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else document.writeform.text.value += text;
	document.writeform.text.focus(caretPos)
}

function surroundText(text1,text2)
{
	if (document.writeform.text.createTextRange && document.writeform.text.caretPos) {
		var caretPos = document.writeform.text.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
	}
	else document.writeform.text.value += text1 + text2;
	document.writeform.text.focus(caretPos)
}

function isEmptyText(theField)
{
	while (theField.value.length > 0 && (theField.value.charAt(0)==' ' || theField.value.charAt(0)=='\t'))
		theField.value = theField.value.substring(1,theField.value.length);
	while (theField.value.length > 0 && (theField.value.charAt(theField.value.length-1)==' ' || theField.value.charAt(theField.value.length-1)=='\t'))
		theField.value = theField.value.substring(0,theField.value.length-1);

	if (theField.value=='')
		return true;
	else
		return false;
}

function check(vars)
{

   if(vars == 1)
   {
        if(document.all.email.value=='')
        	{	alert("Не введен email."); return false; }

        if(document.all.name.value=='')
        	{	alert("Не введено имя."); return false; }

        if(document.all.text.value=='')
             {   alert("Не введен текст сообщения."); return false;}

        else
        	{
                	return true;
        	}
   }

   if(vars == 2)
   {
        if(document.all.group.value==0)
        	{	alert("Не выбрана категория ссылки."); return false; }

        if(document.all.name.value=='')
        	{	alert("Не введено наименование ссылки."); return false; }

        if(document.all.url.value=='http://' || document.all.url.value=='')
             {   alert("Не введен URL ссылки."); return false;}

        if(document.all.descr.value=='')
             {   alert("Не введено описание ссылки."); return false;}

        else
        	{
                	return true;
        	}
   }

   if(vars == 3)
   {

        if(document.all.name.value=='')
        	{	alert("Не введено имя."); return false; }

        if(document.all.email.value=='http://' || document.all.email.value=='')
             {   alert("Не введен E-Mail."); return false;}

        if(document.all.text.value=='')
             {   alert("Не введен текст сообщения."); return false;}

        else
        	{
                	return true;
        	}
   }



}


function cOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#B9C3D9";
window.status = '';
return true;
}
}
function cOut(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="";
window.status = '';
return true;
}
}