top.stats = 14;

var BAD_STR_SEARCH  = "%\\`~!@#$^&*()_+|{}[];=:'<>,./?" ;
var BAD_SEARCH  = 11 ;

var BAD_STR_URL = "%`~^|{}'<>?;&+[!@#*=$%]\"" ;
var BAD_URL = 8 ;

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") || (escape (symbol) == "%25")) return false ;
		str = str.substr (1) ;
	}
	return true;
}

function search_submit (caller) {
	var sTemp = new String (document.forms ["SearchForm"].keyword.value) ;
	var sRes = -1 ;
	if ((sTemp.length == 0) || (sTemp == " ") || (sTemp.substr(0, 1) == " ")) {
		alert ("The field `" + 'Search' + "` cannot be empty or contain the first symbol as a space.") ;
		sRes = 0 ;
	}		
	
	if (!is_symbols_correct (sTemp, BAD_SEARCH)) {
		alert ("The field `" + 'Search' + "` should not contain special symbols.") ;
		sRes = 0 ;
	}		

	if (sRes == 0) {
		document.forms ["SearchForm"].keyword.focus () ;
		if (caller != "button")	return false ;
	}
	else {
		document.forms ["SearchForm"].submit () ;
	}
	return void (false) ;
}

var a = new Array();
a["wbmstr"] = "webmaster2008";
a["wbmstr_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>");
}

function ShowBigImageOut(imagePath, imageWidth, imageHeight)
{
//	var strParams = "height="+ imageHeight +", width="+ imageHeight +"";
	window.open(imagePath, "", "height="+ imageHeight +", width="+ imageWidth);
}
function ShowBigImageIn(imagePath, windowTitle, imageWidth, imageHeight)
{
	var win = window.open("", "","height="+ imageHeight +", width="+ imageWidth);
	var htmStr = "<html><head><title>"+ windowTitle +"</title></head><body style='margin:0px;'><img src="+ imagePath +"></body></html>";
	
	win.document.write(htmStr);
}

function fieldLengthIsMore(_field, _fieldRealName, symbolLimit)
{
	var field = document.getElementById(_field);
	var err = "The field '" + _fieldRealName + "' cannot contain more than " + symbolLimit + " symbols!";
	
	//debugger;
	var str = field.value;
		
    	if (str.match(/[^\r]\n/)) str = str.split("\n").join("\r\n"); // FF, Safari, any Unix/MaxOS X browser
    	else
		if (str.match(/\r[^\n]/)) str = str.split("\r").join("\r\n"); // legacy MacOS 9 and lower
    
        //alert("The length is " + str.length);	
	if (str.length > symbolLimit)
	{
		alert(err);
		field.focus();
		return true;
	}
	else
		return false;
}