isDOM=document.getElementById?true:false
isOpera=isOpera5=isOpera6=isOpera7=window.opera&&isDOM?true:false
if(isOpera) {
	s=navigator.userAgent.indexOf("Opera")
	s=parseInt(navigator.userAgent.charAt(s+6))
	isOpera7=(s>=7)
	isOpera6=(s>=6)
	isOpera5=(s==5||s==6)
}
isNN=navigator.appName=='Netscape'
isIE=document.all&&document.all.item&&!window.opera
isIEF=isDOM&&isIE&&/MSIE ((5\.5)|[6789])/.test(navigator.userAgent)
isIE4=isIE&&!isDOM
isNN4=isNN&&!isDOM
isMozilla=isNN&&isDOM
isPNG=(isDOM&&!isIE&&!isOpera5)||isOpera6

function val(_var,_def) {return(_var==null?_def:_var)}

function getobj(id,parent) {
	var i,o
	if(isDOM) return(document.getElementById(id))
	if(isIE) return(document.all[id])
	if(isNN4) {
		if(!parent) parent=document.layers
		if(parent[id]) return(parent[id])
		for(i=0;i< parent.length;i++) {
			if(parent[i].document.layers.length) {
				o=getobj(id,parent[i].document.layers)
				if(o) return(o)
			}
		}
	}
}

function object(v) {
	this.object=typeof(v)=='string'?getobj(v):v
	if(!this.object) return
	this.css=this.object.style?this.object.style:this.object
}

MSOP=object.prototype

MSOP.zindex=function(v) {this.css.zIndex=v}

MSOP.forecolor=function(v) {
	with(this.css) {
		if(isNN4) document.fgColor=v
		else color=v
	}
}

MSOP.backcolor=function(v) {
	with(this.css) {
		if(isNN4) document.bgColor=v
		if(isOpera5) background=v
		else backgroundColor=v
	}
}

MSOP.visible=function(v) {
	this.css.visibility=v?(isNN4?'show':'visible'):(isNN4?'hide':'hidden')
}

MSOP.abs=function(v) {
	if(isIE4||isNN4) return
	this.css.position=v?'absolute':'relative'
}

MSOP.move=function(l,t) {
	with(this.css) {
		if(l!=null) {
			if(isOpera7) pixelLeft=l
			else if(isNN4) x=l
			else left=l
		}
		if(t!=null)
			if(isOpera7) pixelTop=t
			else if(isNN4) y=t
			else top=t
	}
}

MSOP.pos=function() {
	var o=this.object,x=0,y=0
	if(isNN4) {
		x=o.pageX
		y=o.pageY
	} else {
		do {
			x+=o.offsetLeft
			y+=o.offsetTop
		} while (o=o.offsetParent)
	}
	return{left:x,top:y}
}

MSOP.size=function() {
	var o=this.object,arg=arguments
	if(!arg.length)
		return {
			width:isNN4?o.clip.width:isOpera5?this.css.pixelWidth:o.offsetWidth,
			height:isNN4?o.clip.height:isOpera5?this.css.pixelHeight:o.offsetHeight
		}
	if(arg.length>0) {
		if(isNN4) o.clip.width=arg[0]
		else this.css.width=arg[0]
	}
	if(arg.length>1) {
		if(isNN4) o.clip.height=arg[1]
		else this.css.height=arg[1]
	}
}

MSOP.write=function(text) {
	if(!isNN4)
		this.object.innerHTML=text
	else
		with(this.object.document) {
			open()
			write(text)
			close()
		}
}

MSOP.temp=function() {
	this.visible(false)
	this.abs(true)
	this.move(-10000,-10000)
}

function trim(str) {return str.replace(/(^\s*)|(\s*$)/g,'')}
function vword(str, name) {if(str.match(/\W/)!=null) {alert("Недопустимые символы в поле ''"+name+"''\n\nдопускаются:\n    - латинские символы\n    - цифры\n    - нижнее подчеркивание");return false}else{return true}}
function vmail(str) {return (str.search(/[^A-Za-z0-9_@.-]/)==-1&&str.search(/@(.*)@/)==-1&&str.search(/@(.*)\./)!=-1&&str.indexOf('@')!=0&&str.lastIndexOf('.')!=str.length-1)}


function GoToPage(pageURL) { document.location=pageURL; }
function setHomepage(f) { f.style.behavior='url(#default#homepage)'; f.setHomePage('{/literal}{$page.domain}{literal}') }
function addBookmark() { window.external.addFavorite('{/literal}{$page.domain}{literal}', '{/literal}{$page.description|strip}{literal}') }
function look(url, winame, ww, wh, ws, wr) { popwin = self.open(url, winame, 'toolbar=no, location=no, status=no, menubar=no, scrollbars='+ws+', width='+ww+', height='+wh+', resizable='+wr); popwin.focus(); }
$(function(){
	var width = $(window).width(),
		height = $(window).height(),
		width_oc = $('#oc').width(),
		height_oc = $('#oc').height();
	$('#oc').css({left: width-width_oc, top: height-height_oc-10, display: 'block'});
});
