var MaxFrameHeight = 470;

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(obgName, text, state) {
	if(text=="") return false;
	var obj = ((obgName.value!=null) ? obgName : document.getElementById(obgName));
	if(state==1) {
		if(obj.value==text) obj.value='';
	} else {
		if(obj.value=='') obj.value=text;
	}
}
function getGlobalPosition(obj, type) {
	pos = 0;
	if(obj.parentElement) {
		pos = getGlobalPosition(obj.parentElement, type);
	}
	if(type=="l")
		pos = pos + obj.offsetLeft;
	else
		pos = pos + obj.offsetTop;
	return pos;
}
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 changeInfo(objInfo, block) {
	$("SPAN", "#"+objInfo).hide();
	$("#"+block, "#"+objInfo).show();
}
function shopAvtoPopup(page) {
	$("#popupPage H3").attr('innerHTML','');
	var objPop = document.getElementById("popupPage");
	$("IFRAME",objPop).attr('Height',MaxFrameHeight);
	objPop.style.left = (parseInt(document.body.clientWidth)-650)/2 + "px";
	objPop.style.top = (document.body.offsetHeight - MaxFrameHeight-10)/2+Math.max(document.body.scrollTop,document.documentElement.scrollTop)+"px";
	if(page!="") $("IFRAME",objPop).attr('src',page);
	$("#popContent").hide();
	$("#popLoader").show();
	$(objPop).show("fast");
}
function hideAvtoFrame() {
	$('#popupPage').hide('fast');
}
function setPopLoaded(Title, Height) {
	$("#popupPage H3").attr('innerHTML',Title);
	$("#popContent").show();
	$("#popLoader").hide();
	if(Height+20<MaxFrameHeight && Height>0) {
		$("IFRAME","#popupPage").attr('Height',Height+20+"px");
	} else {
		$("IFRAME","#popupPage").attr('Height',MaxFrameHeight+"px");
	}
}
