sfHover = function() {
	var sfEls = document.getElementById("navigation").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);


//disable auto enter event for IE and firefox
function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
    
 
    
     if(key == 13)
          return false;
     else
          return true;
}

// trim all leading and trailing spaces from a string
// 2008 Nov 5 added 
function allTrim(string) {
	while (string.charAt(0) == " ") {
		string = string.substr(1);
	}
	while (string.charAt(string.length - 1) == " ") {
		string = string.slice(0,string.length - 1);
	}
	return string;
}

// trim all leading spaces from a string
function leftTrim(string) {
	while (string.charAt(0) == " ") {
		string = string.substr(1);
	}
	return string;
}

// trim all trailing spaces from a string
function rightTrim(string) {
	while (string.charAt(string.length - 1) == " ") {
		string = string.slice(0,string.length - 1);
	}
	return string;
}

// check if a string variable is empty, i.e. a blank string
function isEmpty(string) {
	string = allTrim(string);
	if (string == "") {
		return true;
	}
	return false;
}


//ajax auto-check contact name is valid or not in webnames
function validateContactName(myele ,rootURL) {
 
    var parameter = { 'name': $(myele).val(), 'format': '' }
    var pmtid = "ctc_prompt_" + myele.name.replace(/\$/gi,"_");    
    parameter = "{'name':'" + $(myele).val().replace(/'/gi, "\\'") + "','format':''}"

    $.ajax({
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        url: rootURL + 'myaccount/ajaxhelper.aspx/validateConactName',
        data: parameter,
        dataType: "json",
        timeout: 1000 * 60 * 10,
        error: function() { },

        success: function(jsondata) {
            var xml = jsondata.d
            var isDone = true;
            var doc;

            if (window.ActiveXObject) {
                doc = new ActiveXObject('Microsoft.XMLDOM');
                doc.async = 'false';
                doc.loadXML(xml);
            } else doc = xml;

            var spantag = $('#' + pmtid);
            spantag.empty();
            if ($(doc).find('status').text() != 'OK') {
                if (!spantag.length)
                    $("<span class='ajax_alert_msg' id='" + pmtid + "'> " + $(doc).find('msg').text() + "</span>").insertAfter($(myele));
                else
                    spantag.html($(doc).find('msg').text())
            }
        }
    });
}
function openlimitedword() {
    window.open(window._SmartURL + 'ciralimitedword.aspx', 'Limited Words', 'scrollbars=yes,width=600,height=400')
}
