function checkEMail(formName, fieldName, message){
	var str = eval("document.forms."+formName+"."+fieldName+".value");
	re = new RegExp("","i");
	str=str.replace(/^\s*/,"");
	str=str.replace(/\s*$/,"");
	re=/^([\w.\-]+)@(([\w\-]+\.)+)([a-zA-Z]{2,4})$/;
	if (re.test(str)){
		return true;
	}else{
		alert(message);
		eval("document.forms."+formName+"."+fieldName+".focus()");
		return false;
	}
}

function _hasValue(formName, fieldName, field_type){
    if (field_type == "TEXT" || field_type == "PASSWORD"){
		if (eval("document.forms."+formName+"."+fieldName+".value.length") == 0){
			eval("document.forms."+formName+"."+fieldName+".focus()");
   	  		return false;
		}else 
   			return true;
   	}
    else if (field_type == "SELECT"){
        for (i=0; i < obj.length; i++){
			if (obj.options[i].selected)
				return true;
		}
       	return false;	
	}
}
function _compareValue(formName, fieldName1, fieldName2){
	if (eval("document.forms."+formName+"."+fieldName1+".value") != eval("document.forms."+formName+"."+fieldName2+".value")){
		eval("document.forms."+formName+"."+fieldName2+".focus()");
  	  		return false;
	}else 
  			return true;
}

// new window engine 
var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=350,height=300,resizable=Yes,scrollbars=Yes';

function isUndefined(v) {
    var undef;
    return v===undef;
}

function raw_popup(url, target, features) {
  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  var theWindow = window.open(url, target, features);
  theWindow.focus();
  return theWindow;
}

function link_popup(src, features) {
	return raw_popup(src.getAttribute('href'),src.getAttribute('target') || '_blank', features);
}

function Quote(aId) {
	/*var SpawPage = edtComment_obj.getActivePage();
	var tmpValue = edtComment_obj.getPageHtml(SpawPage);*/
	//var tmpValue = CKEDITOR.instances.edtComment.getData();
	/*if (tmpValue.length > 0){
		tmpValue = tmpValue + '<br>';
	}
	tmpValue = tmpValue + '<div class="quoteAuthor">Цитата: '+document.getElementById("author"+aId).innerHTML+'</div><div class="quoteText">'+document.getElementById("comm"+aId).innerHTML+'</div><br />';
	document.getElementById('edtComment').value = tmpValue;
	edtComment_obj.updatePageDoc(edtComment_obj.getActivePage());*/
	//CKEDITOR.instances.edtComment.setData( tmpValue );
	tmpValue = '<div><div class="quoteAuthor">Цитата: '+document.getElementById("author"+aId).innerHTML+'</div><div class="quoteText">'+document.getElementById("comm"+aId).innerHTML+'</div></div><p> </p>';
	CKEDITOR.instances.edtComment.insertHtml( tmpValue );
	return true;
}

sfHover = function() {
	if (document.getElementById("navtop")){
		var sfEls = document.getElementById("navtop").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {this.className+=" sfhover";}
			sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" sfhover\\b"), "");}
		};
	};
	if (document.getElementById("navright")){
		var sfEls = document.getElementById("navright").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {this.className+=" sfhover";}
			sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" sfhover\\b"), "");}
		};
	};
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(function(){
	$("#usermenu-link").click(function (){
		if ($("#usermenu").css("display") == "none")
			$("#usermenu").show()
		else 
			$("#usermenu").hide();
	});
	$("#usermenu-link2").click(function (){
		if ($("#usermenu2").css("display") == "none")
			$("#usermenu2").show()
		else 
			$("#usermenu2").hide();
	});
});
$(document).click(function(e){
	if ($(e.target).attr("Id")!="usermenu-link" && $("#usermenu").css("display") == "block") $("#usermenu").hide();
});
