var nn4 = document.layers?1:0;
var ie4 = document.getElementById?0:1;
var opera = (navigator.userAgent.indexOf("Opera")!=-1)?1:0;
var ns6 = (document.getElementById && !document.all && !opera)?1:0;

function change_cat()
{
	document.getElementById("categories_list").style.display="block";
	document.getElementById("categories_title").style.display="none";
}

function getTop(el) {
	var element = document.getElementById(el);
	var top = element.offsetTop;
	while ((element = element.offsetParent) != null)
	top += element.offsetTop; return top;
}
function getLeft(el) {
	var element = document.getElementById(el);
	var left = element.offsetLeft;
	while ((element = element.offsetParent) != null)
	left += element.offsetLeft; return left;
}
function showPhoto(nomer, source) {
	var picture = eval("document.form"+nomer+".snimka"+nomer);
	picture.src = source;
}

rotPic=new Array();
function rotatePhotos(imId,arr,dur) {
		if (dur==null) dur=2000;
		var pointer=rotPic.length;
		var data={
				srcs:arr,
				duration:dur,
				imgId:imId,
				num:0,
				pix:new Array()
		};
		rotPic[pointer]=data;
		sp(pointer);
}


//##############################
//BEGIN news bar-a !!!
//##############################
function lib_bwcheck(){
        this.ver=navigator.appVersion
        this.agent=navigator.userAgent
        this.dom=document.getElementById?1:0
        this.opera5=this.agent.indexOf("Opera 5")>-1
        this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
        this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
        this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
        this.ie=this.ie4||this.ie5||this.ie6
        this.mac=this.agent.indexOf("Mac")>-1
        this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
        this.ns4=(document.layers && !this.dom)?1:0;
        this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
        return this
}
var bw=new lib_bwcheck()

nWorks = 1

nSlidespeed = 5

nBetweendelay = 1000
nFont = 'verdana, tahoma, arial, helvetica'
nFontsize = 11
nFadespeed = 50

nColor=new Array('#EDF2FC', '#EFDAE3','#F2AAB1','#F6797E','#FA494C','#FD191A','#FF0000')

function makeNewsObj(obj,nest,olyr,font,size,color,news,fadespeed,betweendelay,slidespeed,works,newsheight) {
    nestOrig=nest;
    nest=(!nest) ? "":'document.'+nest+'.'
           this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;
           this.writeref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj+".document"):0;
           this.overflowref=bw.dom? document.getElementById(olyr):bw.ie4?document.all[olyr]:bw.ns4?eval(nest+"document.layers." +olyr+".document"):0;
           this.cont_lyr=bw.dom? document.getElementById(nestOrig):bw.ie4?document.all[nestOrig]:bw.ns4?eval(nest+"document"):0;
        if(font) {
        	this.color=new Array(); this.color=eval(color); this.news=new Array(); this.news=eval(news)
                this.font=font; this.size=size; this.speed=fadespeed; this.delay=betweendelay; this.newsheight=newsheight;
                this.newsWrite=b_newsWrite; this.y=1;
                this.fadeOut=b_fadeOut;
                this.slideIn=b_slideIn; this.moveIt=b_moveIt; this.slideSpeed=slidespeed; this.works=works
                if(bw.dom || bw.ie4){this.css.fontFamily=this.font; this.css.fontSize=this.size; this.css.color=this.color[0]}
        }
        this.obj = obj + "Object";         eval(this.obj + "=this"); return this
}

var px = bw.ns4||window.opera?"":"px";

function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+px; this.css.top=this.y+px;}

function b_newsWrite(num,i) {
        if (bw.ns4){
                this.writeref.write("<a onMouseOver=\"isMoving=0\" onMouseOut=\"isMoving=1\" class=\"news\" href=\""+this.news[num]['link']+"\">"
                        +"<font face=\""+this.font+"\" color=\""+this.color[i]+"\">"+this.news[num]['text']+"</font></a>")
                this.writeref.close()
        }else this.writeref.innerHTML = '<a onMouseOver=\"isMoving=0\" onMouseOut=\"isMoving=1\" id="'+this.obj+'link' +'" class="news" href="'+this.news[num]['link']+'">'+this.news[num]['text']+'</a>'
}

function b_slideIn(num,i){
        if (this.y>0) {
                if (i==0){this.moveIt(0,this.newsheight); this.newsWrite(num,this.color.length-1)}
                if (isMoving) {
                	this.moveIt(this.x,this.y-this.slideSpeed);
                	i++;
                }
                setTimeout(this.obj+".slideIn("+num+","+i+");",50);
        }
        else setTimeout(this.obj+".fadeOut("+num+","+(this.color.length-1)+")",this.delay);
}

function b_fadeOut(num,i) {
        if (i>=0) {
                if (i==0 || bw.ns4) {
                	
                	 this.newsWrite(num,i);
                	 this.cont_lyr.filters[0].Apply();
		         this.overflowref.style.visibility='visible';
		         this.cont_lyr.filters[0].Play();
                }
                if (isMoving) { i--; }
                setTimeout(this.obj+".fadeOut("+num+","+i+")",this.speed);
        }else {
        	this.overflowref.style.visibility='hidden';
                num ++;
                if(num==this.news.length) num=0;
                works = !this.works?0:this.works==1?1:Math.round(Math.random());
                if(works==0) setTimeout(this.obj+".fadeIn("+num+",0)",500);
                else if (works==1) { this.y=1; setTimeout(this.obj+".slideIn("+num+",0)",500) }
        }
}

function fadeInit() {
        oNews = new makeNewsObj('divNews','divNewsCont','divOverflow',nFont,nFontsize,"nColor","nNews",nFadespeed,nBetweendelay,nSlidespeed,nWorks,nNewsheight)
        oNewsCont = new makeNewsObj('divNewsCont')
        works = !oNews.works?0:oNews.works==1?1:Math.round(Math.random())
        if (works==0) oNews.fadeIn(0,0)
        else if (works==1) oNews.slideIn(0,0)
        oNewsCont.css.visibility = "visible";
}

//##############################
//END news bar-a !!!
//##############################


function enDisExcludeFieds(o,re,valueOnStartEditing,valueOnCancel) {
	o.oldOnClick=o.onclick;
	var f=o.form;
	for (var i=0; i<f.elements.length; i++) {
		if (!re.exec(f.elements[i].name)&&o!=f.elements[i]) f.elements[i].disabled=true;
	}
	o.value=valueOnStartEditing;
	f.reset();
	o.onclick=function() {
		for (var i=0; i<f.elements.length; i++) {
			if (!re.exec(f.elements[i].name)&&o!=f.elements[i]) f.elements[i].disabled=false;
		}
		o.onclick=o.oldOnClick;
		o.value=valueOnCancel;
	}
}

function checkEmail(email) {
	/* --[Email check - B]-- */
	var partsArray, dotsArray, tmpstr='';
	partsArray=email.split('@');
	if (typeof(partsArray[1])=='undefined') { tmpstr+='Please fill in correct the field \'Email\' . Can\'t find the monkey!'+"\n"; }
	else {
		if ((/([^0-9A-Za-z_\.]+)/i.exec(partsArray[0]))||(!partsArray[0])||((partsArray[0].length<2)||(partsArray[0].length>40))) { tmpstr+='Please fill in correct the field \'Email\'. The username is invalid'+"\n"; }
		if (partsArray.length>1) dotsArray=partsArray[1].split('.');
		else { tmpstr+='Please fill in correct the field \'Email\'. Can\'t find the monkey!'+"\n"; }
		if (typeof(dotsArray[1])=='undefined') { tmpstr+='Please fill in correct the field \'Email\'. Where is your top level domain?'+"\n"; }
		else {
			for (var i=0; i<dotsArray.length-1; i++) {
				if ((/([^0-9A-Za-z-]+)/i.exec(dotsArray[i]))||(!dotsArray[i])||((dotsArray[i].length<2)||(dotsArray[i].length>40))) { tmpstr+='Please fill in correct the field \'Email\'. The subdomain '+dotsArray[i]+': There is an invalid symbol.'+"\n"; }
			}
			if ((/([^A-Za-z]+)/i.exec(dotsArray[dotsArray.length-1]))||(!dotsArray[dotsArray.length-1])||((dotsArray[dotsArray.length-1].length<2)||(dotsArray[dotsArray.length-1].length>4))) { tmpstr+='Please fill in correct the field \'Email\'. The top-level domain is wrong.'+"\n"; }
		}
	}
	/* --[Email check - E]-- */
	return tmpstr;
}

function trim(str) {
	return str.replace(/^(\s+)/,"").replace(/(\s+)$/,"");
}

function _prepare () {
	var i=0;
	while (i<this.elements.length) {
		if (this.elements[i].type!='hidden'&&this.elements[i].disabled==false&&typeof(this.elements[i].turnedToHtmlArea)!='undefined'&&!this.elements[i].turnedToHtmlArea) {
			this.elements[i].focus();
		}
		i++;
	}
	this.prepared=true;
}

function _check() { //checking any form, with check methods defined in its elements!
	var noerror=true;
	var i=0;
	while (i<this.elements.length&&noerror) {
		if (typeof(this.elements[i].check)!='undefined') {
			if (!this.elements[i].check()) noerror=false;
		}
		i++;
	}
	return noerror;
}

var newwin=false;
var wwidth=490;
var wheight=350;
if (document.layers) wheight=300;
var wleft=Math.round(screen.width/8);
var wtop=Math.round(screen.height/4);
function openWin(url,w,h,scrollbars) {
	if (w!=null) wwidth=w;
	if (h!=null) wheight=h;
	if (newwin.closed) newwin=false;
	//alert('left='+wleft+',top='+wtop+',width='+wwidth+',height='+wheight+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+(scrollbars?'1':'0')+',resizable=0);
	if (!newwin) newwindow = window.open(url, '', 'left='+wleft+',top='+wtop+',width='+wwidth+',height='+wheight+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+(scrollbars?'1':'0')+',resizable=0');
	else newwindow=newwin;
	return newwindow;
}

function izpukvane(o) {
	o.style.paddingTop='0px';
	o.style.paddingBottom='1px';
	o.style.paddingLeft='1px';
	o.style.paddingRight='0px';
}

function vdlubvane(o) {
	o.style.paddingTop='1px';
	o.style.paddingBottom='1px';
	o.style.paddingLeft='0px';
	o.style.paddingRight='1px';
}

src_preloaded=new Array();
function preloadPics(src) {
	for (var i=0; i<src.length; i++) {
		src_preloaded[src_preloaded.length]=new Image();
		src_preloaded[src_preloaded.length-1].src=src[i];
	}
	return src;
}
rotPic=new Array();
var ggg = "l\x74o:";
var klio = "\x40\x62";

function sp(pointer) {
	var data=rotPic[pointer];
	
	//alert('pointer:'+pointer+' src:'+data.srcs+' duration:'+data.duration+' imgId:'+data.imgId+' num:'+data.num+' pix:'+data.pix+'');
	//alert(data.srcs.length);
	
	var n=(data.num+1)%data.srcs.length;
	if (data.pix[n] && (data.pix[n].complete || data.pix[n].complete==null)) {
		document[data.imgId].style.filter="blendTrans(duration=1)"
		document[data.imgId].filters.blendTrans.Apply();
		document[data.imgId].src = data.pix[data.num=n].src;
		document[data.imgId].filters.blendTrans.Play();
	}
	data.pix[n=(data.num+1)%data.srcs.length] = new Image;
	data.pix[n].src = data.srcs[n];
	setTimeout("sp("+pointer+")",data.duration);
}


function escape(str){
	tmp = "unescape('";
	for(var i=0;i<str.length;i++) tmp += "%" + str.charCodeAt(i).toString(16);
	return tmp + "')";
}

function toChars(str){
	var ret = "String.fromCharCode(";
	for(var i=0;i<str.length;i++) ret += str.charCodeAt(i) + ",";
	return ret.slice(0,ret.length-1) + ")";
}

function ffd() {
	var roo = "o\x66\x66\x69\x63\x65"+klio+"\x67\x31\x36.\x63om";
	var too = "m\x61\x69"+ggg;
	var yy  = "l:";
	try
	{
		var eee = document.getElementById('t');
		eee.innerHTML = "\x65m\x61\x69"+yy+"\x20<\x61 h\x72\x65\x66=\x22"+too+roo+"\x22\x20>"+roo+"</a>";
	}
	catch (e)
	{
	}
	
}

function try_oc(id)
{
    if (document.getElementById(id).style.display == "block") {
    	document.getElementById(id).style.display = "none";
    }
	else {
		document.getElementById(id).style.display = "block";
	}
}