document.onclick = function(e) {
	e = e || event;
	var t = e.target || e.srcElement;
	while (t && t.nodeType == 1 && t.tagName.toLowerCase() != 'a')
		t = t.parentNode;
	if (t && t.nodeType == 1) {
		var myrel = t.rel;
		var str = 'external';
		var str_len = str.length;
		if (myrel == str || myrel.indexOf(' ' + str) == myrel.length - (str_len + 1) || myrel.indexOf(str + ' ') == 0 || myrel.indexOf(' ' + str + ' ') != -1) {
			t.target = '_blank';
		}
	}
}


// открываем окно для выбора параметров поиска
function showSearchOptions (param, paramid, defcheck) {
	var width = 350;
	var height = 450;
	var wnd = window.open('/getparamlist.mhtml?param='+param+'&paramid='+paramid+'&defcheck='+defcheck+'&SessionID='+ses,'searchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
}

function showCountryOptions (param, paramid, defcheck) {
	var width = 350;
	var height = 450;
	var wnd = window.open('/getcountrylist.mhtml?param='+param+'&paramid='+paramid+'&defcheck='+defcheck+'&SessionID='+ses,'searchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
}

function showProducerOptions (param, paramid, defcheck) {
	var width = 350;
	var height = 450;
	var wnd = window.open('/getproducerlist.mhtml?param='+param+'&paramid='+paramid+'&defcheck='+defcheck+'&SessionID='+ses,'searchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
}

function showModelOptions (param, paramid, defcheck) {
	var width = 350;
	var height = 450;
	var wnd = window.open('/getmodellist.mhtml?param='+param+'&paramid='+paramid+'&defcheck='+defcheck+'&SessionID='+ses,'searchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
}

function getHelpFile (param) {
	var width = 550;
	var height = 550;
	var wnd = window.open('/gethelpfile.mhtml?paramid='+param,'helpchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
}

function showInfo(myhref) {
	var width = 550;
	var height = 550;
	var wnd = window.open(myhref,'helpchOptions','toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=' + width + ',height=' + height);
	var left = (screen.availWidth - width) / 2;
	var top = (screen.availHeight - height) / 2;
	wnd.window.moveTo(left,top);
	return false;
}

function isNotEmpty(elem) {
    var str = elem.value;
    if(str == null || str.length == 0) {
        return false;
    } else {
        return true;
    }
}

function isNumber(elem) {
    var str = elem.value;
    // make sure value hasn't cast to a number data type
    str = str.toString( );
    for (var i = 0; i < str.length; i++) {
        oneChar = str.charAt(i).charCodeAt(0);
        // characters outside of 0 through 9 not OK
        if (oneChar < 48 || oneChar > 57) {
            return false;
        }
    }
    return true;
}

function showhide(elemName, headerElem) {
	var elem = document.getElementById(elemName);
	if (elem.className=='hidden') {
		elem.className='visible';
		headerElem.className = "visible";
		// alert(document.getElementById(elemName + '_hidden').value);
		document.getElementById(elemName + '_hidden').value = "visible";
		// alert(document.getElementById(elemName + '_hidden').value);
	} else {
		elem.className='hidden';
		headerElem.className = "hidden";
		// alert(document.getElementById(elemName + '_hidden').value);
		document.getElementById(elemName + '_hidden').value = "hidden";
		// alert(document.getElementById(elemName + '_hidden').value);
	}
}