function checkSubmitWay () {
	var theform = null ;

	if (window.navigator.appName.toLowerCase ().indexOf ("microsoft") > -1) {
		theform = document.aspnetForm ;
	}
	else {
		theform = document.forms ["aspnetForm"] ;
	}
	theform.action = location.pathname;

	return theform.submitWay.value != "0" ;
}

function setSubmitWay (_value) {
	var theform = null ;

	if (window.navigator.appName.toLowerCase ().indexOf ("microsoft") > -1) {
		theform = document.aspnetForm ;
	}
	else {
		theform = document.forms ["aspnetForm"] ;
	}

	theform.submitWay.value = _value ;
}

var agt = navigator.userAgent.toLowerCase () ;

function enterEventSubmit(event, controlID) {

    var characterCode;

    if(event && event.which) {
        e = event;
        characterCode = e.which;
    }
    else {
        e = event;
        characterCode = e.keyCode;
    }
    
    if(characterCode == 13) {
        document.getElementById(controlID).focus();
        if ((agt.indexOf ("opera") != -1)&&(parseInt(agt.substr(agt.indexOf("opera/9.")+8,1))<5)) 
        {
            document.getElementById(controlID).click();
        }
    }
}


var a = new Array();
a["wbmstr"] = "webmaster2008";
a["wbmstr_site"] = "epam.com";
a["prss"] = "press";
a["prss_site"] = "epam.com";
a["pmcms"] = "cms";
a["pmcms_site"] = "epam.com";

function writeML(id, text, cssClass)
{
    if (text == "")
    {
        text = a[id];
    }
    if (cssClass != "")
    {
        cssClass = "class=\"" + cssClass + "\"";
    } 
    document.write("<a href=\"mailto:" + a[id] + "@" + a[id + "_site"] + "\""+ cssClass +">" + text + "</a>");
}

var BAD_STR_SEARCH  = "\\`~!@^*_{}[]=<>" ;
var BAD_SEARCH  = 11 ;

function is_symbols_correct (str, what_case) {
	var BAD = "" ;
	
	if (what_case == BAD_SEARCH) {
		BAD = BAD_STR_SEARCH ;
	}	
	
	var symbol ;
	var l = str.length ;
	for (var i = 0 ; i < l ; i++) {
		symbol = str.substr(0, 1) ;
		if (BAD.indexOf (symbol) > 0) return false ;
		if ((escape (symbol) == "%5C") && (BAD != BAD_STR_URL)) return false ;
		str = str.substr (1) ;
	}
	return true;
}

function trim_value(value) 
{
	return value.replace(/^\s*/,'').replace(/\s*$/,'');
}

function search_submit (caller) {
	
	var sTemp;
	
	if (document.forms["NewQuery"]) {
	    sTemp = new String (document.forms["NewQuery"].keyword.value);
	}
	else if (document.forms["aspnetForm"]) {
	    sTemp = new String (document.forms["aspnetForm"].ctl00_ctl00_RootContent_Content_keyword.value);
	}
	
	sTemp = trim_value(sTemp);
	var sRes = -1 ;
	if ((sTemp.length == 0) || (sTemp == " ") || (sTemp.substr(0, 1) == " ")) {
		alert ("The field '" + 'Search' + "' cannot be empty.") ;
		sRes = 0 ;
	}
	
	if (!is_symbols_correct (sTemp, BAD_SEARCH)) {
		alert ("The field '" + 'Search' + "' should not contain special symbols.") ;
		sRes = 0 ;
	}
	
	if (sRes == 0) {
	    if (document.forms["NewQuery"]) {
	        sTemp = new String (document.forms["NewQuery"].keyword.focus());
	    }
	    else if (document.forms["aspnetForm"]) {
	        sTemp = new String (document.forms["aspnetForm"].ctl00_ctl00_RootContent_Content_keyword.focus());
	    }
		if (caller != "button")	return false ;
	}
	else {
	    return true;
	}
	return void (false) ;
}