String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
} // -------------------------------------------------------------------------------------------


function truncateForm( form ) {
	for( i = 0 ; i < form.length ; i++ )
	{
	    if( form.elements[i].type == 'text' || form.elements[i].type == 'textarea' )
			form.elements[i].value = form.elements[i].value.trim();
	};
}


function searchFormSubmit() {

 	var form = document.searchform;
	truncateForm(form);	

	if (form.keyword.value=="") {
		alert("Укажите, пожалуйста, слово для поиска!");
		form.keyword.focus();
		return false;
	}

	return true;
	//document.searchform.submit();
}

function openWinnn(x,title,wid,hei) {
  myWin= open("", "_blank", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+wid+",height="+hei);
  myWin.document.open();
  myWin.document.write("<html><head><title>"+title+"</title></head>");
  myWin.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
  myWin.document.write("<img src='"+x+"' width='"+wid+"' height='"+hei+"'>");
  myWin.document.write("</body></html>");
  myWin.document.close();  
}

function isNumber( value ) {
    return !isNaN(value);
}


function isEmail( str ) {
    var supported = 0;

    if (window.RegExp) 
    {
        var tempStr = "a";
        var tempReg = new RegExp(tempStr);
        if (tempReg.test(tempStr)) supported = 1;
    }
    if (!supported) 
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
    str = str.replace(/ /,'');
    return (!r1.test(str) && r2.test(str));
}



function checkFeedForm() {	
	
	truncateForm(document.sendform);
	
	/*if (document.sendform.name.value=="") {
		alert('Пожалуйста, укажите свое имя!');
		document.sendform.name.focus();
		return false;
	}*/
	
	if (document.sendform.email.value!="" && !isEmail(document.sendform.email.value)) {
		alert('Пожалуйста, укажите свой E-Mail!');
		document.sendform.email.focus();
		return false;
	}
    

	if (document.sendform.message.value=="") {
		alert('Извините, Вы не можете отослать пустое сообщение!');
		document.sendform.message.focus();
		return false;
	}

}



