var ua = navigator.userAgent;

var os_win = ( navigator.appVersion.indexOf( 'Win' ) != -1 );
var os_mac = ( navigator.appVersion.indexOf( 'Mac' ) != -1 );
var os_lin = ( ua.indexOf( 'Linux' ) != -1 );

var is_opera = ( ua.indexOf( 'Opera' ) != -1 );
var is_konq  = ( ua.indexOf( 'Konqueror' ) != -1 );
var is_saf   = ( ua.indexOf( 'Safari' ) != -1 );
var is_moz   = ( ua.indexOf( 'Gecko' ) != -1 && !is_saf && !is_konq);
var is_ie    = ( document.all && !is_opera );
var is_ie4   = ( is_ie && !document.getElementById );

var is_ie5x    = ( document.all && document.getElementById );
var os_ie5mac  = ( os_mac && is_ie5x );
var os_ie5xwin = ( os_win && is_ie5x );

function showPictureFrame() {
	objFrame = document.getElementById("popupFrame").style.display = '';
}
function showPicture(Path, w, h) {
	objFrame = document.getElementById("popupFrame");
	objFrame.style.left = parseInt((document.body.clientWidth-(w+20))/2);
	objFrame.style.top = parseInt((screen.height-(h+20))/2);
	objFrame.style.width = w;
	objFrame.style.height = h;
	document.getElementById("popupImage").src = Path;
	setTimeout("showPictureFrame()",200);
}
function changeText(obj, text, state) {
	if(state==1) {
		if(obj.value==text) obj.value='';
	} else {
		if(obj.value=='') obj.value=text;
	}
}
function absolutePosition(el) {
	if(el.style.position=='absolute') {
		var r = { x: parseInt(el.style.left), y: parseInt(el.style.top) };
	} else {
		var r = { x: el.offsetLeft, y: el.offsetTop };
		if (el.offsetParent) {
		  var tmp = absolutePosition(el.offsetParent);
		  r.x += tmp.x;
		  r.y += tmp.y;
		}
	}
	return r;
};
function ckeckAlias(objText, objImage, objLabel, blankText, findText, root) {
	if((AliasString.indexOf(objText.value+',')>0) || (objText.value=='' && blankText!='')) {
		objImage.src = root+"images/off.jpg";
		if(objText.value=='')
			objLabel.innerHTML = blankText;
		else
			objLabel.innerHTML = findText;
		return false;
	} else {
		objImage.src = root+"images/on.jpg";
		objLabel.innerHTML = "";
		return true;
	}
}
function showPopup(page,target,w,h,c,s,m,tol,r,loc) {
	if(c=='yes') {
		l = parseInt(screen.width/2-w/2);
		t = parseInt(screen.height/2-h/2);
		window.open(page, target, 'width='+w+'px,height='+h+'px,status='+s+',menubar='+m+',toolbar='+tol+',resizable='+r+',location='+loc+',help=no,left='+l+',top='+t);
	} else {
		window.open(page, target, 'width='+w+'px,height='+h+'px,status='+s+',menubar='+m+',toolbar='+tol+',resizable='+r+',location='+loc+',help=no');
	}
}
function validate(Form) {
    dnotpass = false;
    $(".important","#" + Form).blur();
    if($(".error","#" + Form).length>0) dnotpass = true;
    if(RootVersion=='rus') {
    	if(dnotpass) alert("Заполните все обязательные поля");
    } else {
    	if(dnotpass) alert("Fill in all the necessary fields");
    }
    return !dnotpass;
}
function clearForm(Form) {
    $("INPUT[type=password]", "#" + Form).attr("value", "");
    $("INPUT[type=text]", "#" + Form).attr("value", "");
    $("TEXTAREA", "#" + Form).attr("value", "");
}
function changeInfo(objInfo, block) {
	$("SPAN", "#"+objInfo).hide();
	$("#"+block, "#"+objInfo).show();
}