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;

//// MENU FUNCTION
function getSubMenu(menu,num,sel,level,subparent) {
	var subMenu='';
	if (typeof subparent != "undefined") var subparent='';
	for (var i = 0; i < menu.length; i++) {
		if (menu[i].length > 1 && menu[i][0].length >= 0) {
			if (menu[i][1].length > 0)	subMenu = subMenu + '<div onClick="show_hide(\'sub_menu_' + num + '_' + i +'\')" style=" display:block; padding:0px 0px 0px 4px; cursor:pointer;">' + menu[i][0] + '</div> <div id="sub_menu_' + num + '_' + i + '" style="'+ sel +'padding:0px 0px 0px 5px;">' + getSubMenu(menu[i][1],i,(subparent==i&&selectedParent==num),level+1)  + '</div>';
				else subMenu = subMenu + '<div style="padding : 0px 0px 0px 4px;vertical-align:middle;cursor:pointer;display:block;">' + menu[i][0] + '</div>';
		} else subMenu = subMenu + menu[i] ;
	}	
	return subMenu ;
}

function show_hide(name) {
	var elem = document.getElementById(name);
	
	if (elem.style.display == 'none') {
		elem.style.display = 'block';
		elem.style.visibility = 'visible';
	} else {
		elem.style.display = 'none';
		elem.style.visibility = 'hidden';
	}
}

function print_menu_pane_split(selectedParent,subparent) {
	var menu_all = document.getElementById('menuContainer'),
		sub_menu = document.getElementById('menuContainer_sub'),
		sub_menu_div = '',
		submenu='',
		menu='';
	
	if (typeof(selectedParent) == "undefined") var selectedParent=-1;
	for (var i = 0; i<p_Menu.length; i++) {
		if (p_Menu[i].length > 0) {
			if (selectedParent == i) sel = 'display:block;';
				else sel = 'display:none;visibility:hidden;';
			submenu = getSubMenu(p_Menu[i][1],i,sel,0,subparent);
			if (submenu.length > 0) {
				menu += '<span onMouseOver="this.style.cursor=\'pointer\'" onClick="show_hide(\'sub_menu_' + i +'\')">' + p_Menu[i][0] + '</span>';
			} else {
				menu += '<span onMouseOver="this.style.cursor=\'pointer\'">' + p_Menu[i][0]  + '</span>';
			}
			sub_menu_div += '<div id="sub_menu_' + i + '" style="'+sel+'padding:0px 0px 0px 0px;">' + submenu + '</div>';
		} else menu = menu + p_Menu[i];
	}
	menu_all.innerHTML = menu;
	sub_menu.innerHTML = sub_menu_div;
}

function print_menu_pane() {
	var menu_all = document.getElementById('menuContainer_new');
	var menu='';
	
	if (typeof(selectedParent) != "undefined") var selectedParent=-1;
	for (var i = 0; i<p_Menu.length; i++) {
		if (p_Menu[i].length > 0) {
			submenu = getSubMenu(p_Menu[i][1],i,selectedParent == i,0,subparent);
			if (selectedParent == i) sel = 'display:block;';
				else sel = 'display:none;';
			if (submenu.length > 0) {
				menu += '<span onMouseOver="this.style.cursor=\'pointer\'" onClick="show_hide(\'sub_menu_' + i +'\')">' + p_Menu[i][0] + '</span> <div id="sub_menu_' + i + '" style="'+sel+'padding:0px 0px 0px 0px;">' + submenu + '</div>';
			} else {
				menu += '<span onMouseOver="this.style.cursor=\'pointer\'">' + p_Menu[i][0]  + '</span>';
			}
		} else menu = menu + p_Menu[i];
	}	
	menu_all.innerHTML=menu;
}
/// FUNCTION MENU


function urlCleanup(url,arr) {
	var params;
	if (url.indexOf("?")!=-1) params=url.split("?")[1];
	else params=url;
	if (params.indexOf("#")!=-1) params=params.split("#")[0];
	var paramz=params.split("&");
	var new_url=""; new_paramz=new Array();
	for (var i in paramz) if (!in_array((paramz[i].split("=")[0]),arr)) new_paramz[new_paramz.length]=paramz[i];
	var new_url=new_paramz.join("&");
	return new_url;
}

function in_array(val,arrayIn) {
	for (var i in arrayIn) {
		if (arrayIn[i]==val) {
			return true;
		}
	}
	return false;
}

//Gets the selected radio option.. of a radio group !!!
function getRadioSelOpt(radio_o) {
	if (typeof(radio_o.length)!='undefined'&&radio_o.length) {
		for (var i=0; i<radio_o.length; i++) {
			if (radio_o[i].checked) return radio_o[i];
		}
	}
	else {
		if (radio_o.checked) return radio_o;
	}
	return null;
}

/* --[ timeout ID operating, za izchistwane na timeout id, ako go ima]-- */
function freeID(timeoutid) {
	if (eval('typeof('+timeoutid+')') != 'undefined') { if (eval(timeoutid)) eval('clearTimeout('+timeoutid+')') ; }
	return timeoutid ;
}	

/* --[Wzima koordinatite na skriptowoto sybitie spriamo documenta]-- */
var leftPoint,topPoint;
function mapCoords(e) {
	if (document.all) {
			leftPoint = event.clientX+document.body.scrollLeft ;
			topPoint = event.clientY+document.body.scrollTop ;
	}
	else if (document.layers) {
			leftPoint = e.pageX ;
			topPoint = e.pageY ;
	}
	else if (document.getElementById) {
			leftPoint = e.pageX+2;
			topPoint = e.pageY+2;
	}
}

/* --[Cross-browser layer action functions writen by Nikolai Tokludjanov v.3.0 - BEGIN]-- */

function crossBrowserLayerDelete(id) {
		var lyr=document.getElementById(id);
		lyr.parentNode.removeChild(lyr);
}

function crossBrowserLayerCreate(id, L, T, visible,zIndex) {
	var myLayer;
	if (document.layers) {
		/*if (document.layers[id]) {
			alert ('Layer with this ID already exists!');
			return ;
		}*/
		var LR = document.layers[id] = new Layer(0) ;
		LR.name = id ;
		LR.left = L ;
		LR.top = T ;
		LR.visibility = (null == visible || 1 == visible ? 'show' : 'hide')
		myLayer=LR;
	}
	else if (document.all) {
		/*if (document.all[id]) {
			alert('Layer with this ID already exists!') ;
			return ;
		}*/
		var LR = '\n<div id=' + id + ' style="position:absolute'
		+ '; z-index:' + zIndex
		+ '; left:' + L
		+ '; top:' + T
		+ '; visibility:' + (null==visible || 1==visible ? 'visible':'hidden')
		+ '"></div>' ;
		document.body.insertAdjacentHTML("AfterBegin",LR) ;
		myLayer=document.getElementById(id);
	}
	else if (document.getElementById) { // Nimashe kak da go znam towa opredeleno Netscape 6 rulzz
		/*if (document.getElementById(id)) {
			alert('Layer with this ID already exists!') ;
			return ;
		}*/
		this.lyr = document.createElement("DIV") ;
		this.lyr.style.position = "absolute" ;
		this.lyr.style.zIndex = zIndex ;
		this.lyr.style.visibility = (null==visible || 1==visible ? 'visible':'hidden') ;
		this.lyr.id = id ;
		document.body.appendChild(this.lyr) ;
		var t = document.getElementById(id) ;
		t.style.left = L ;
  		t.style.top = T ;
		myLayer=t;
	}
	return myLayer;
}

function createLayer(L,T,id) {
		var lyr = document.createElement("DIV") ;
		lyr.style.position="absolute";
		if  (id!=null) lyr.id=id;
		lyr.style.left=L;
  		lyr.style.top=T;
		document.body.appendChild(lyr);
		return lyr;
}


function crossBrowserLayerMove(layerid, newLEFT, newTOP) {
	if (document.layers) {
		document.layers[layerid].moveTo(newLEFT, newTOP);
	}
	if (document.all) {
  		document.all[layerid].style.pixelLeft = newLEFT ;
  		document.all[layerid].style.pixelTop = newTOP ;
  	}
  	else if (document.getElementById) {
  		document.getElementById(layerid).style.left = newLEFT ;
  		document.getElementById(layerid).style.top = newTOP ;
  	}
}

function crossBrowserLayerHide(layerid) {
	if (document.layers) document.layers[layerid].visibility = 'hide' ;
	if (document.all) document.all[layerid].style.visibility = 'hidden' ;
  	else if (document.getElementById) document.getElementById(layerid).style.visibility = 'hidden' ;
}

function crossBrowserLayerShow(layerid) {
	// if (!document[layerid] && !document.all[layerid] && document.getElementById(layerid)) return false ;
	if (document.layers) document.layers[layerid].visibility = 'show' ;
	if (document.all) document.all[layerid].style.visibility = 'visible' ;
  	else if (document.getElementById) document.getElementById(layerid).style.visibility = 'visible' ;
}

//#######################################################################################################################################

function getDocSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return {w:myWidth,h:myHeight};
}

//prints human readable array in JavaScript, enjoy ;-)
function print_array(array_a,elem) {
	var str="";
	if (elem==null) for (var i in array_a) str+="array_a["+i+"]="+array_a[i]+"\n";
	else {
		var re=new RegExp(elem,"i");
		for (var i in array_a) {
			if (typeof(array_a[i])=='object' && array_a[i]!=null && typeof(array_a[i].tagName)!='undefined' && array_a[i].tagName!=null && re.exec(array_a[i].tagName)) {
				str+="matched tagName:"+array_a[i].tagName+" --- array_a["+i+"]="+array_a[i]+"\n";
			}
			if (typeof(array_a[i])=='object' && array_a[i]!=null && typeof(array_a[i].name)!='undefined' && array_a[i].name!=null && re.exec(array_a[i].name)) {
				str+="matched name:"+array_a[i].name+" --- array_a["+i+"]="+array_a[i]+"\n";
			}
		}
	}
	alert("here's the Array:\n"+str);
}

function getElementHeight(Elem) {
	var elem;
	if (typeof(Elem.tagName)=="undefined") {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
	}
	else elem=Elem;
	if (opera) { 
		xPos = elem.style.pixelHeight;
	} else {
		xPos = elem.offsetHeight;
	}
	return xPos;
}

function getElementWidth(Elem) {
	var elem;
	if (typeof(Elem.tagName)=="undefined") {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
	}
	else elem=Elem;
	if (opera) {
		xPos = elem.style.pixelWidth;
	} else {
		xPos = elem.offsetWidth;
	}
	return xPos;
}



function moveImgs(imsObj,frObj,direction) {
	switch(direction) {
		case 'forward':
			imsObj.curr++;
			if (typeof(imsObj.values[imsObj.curr])=='undefined') imsObj.curr=0;
			break;
		case 'backward':
			imsObj.curr--;
			if (typeof(imsObj.values[imsObj.curr])=='undefined') imsObj.curr=imsObj.values.length-1;
			break;
	}
	frObj.document.location.href='image_show.php?im='+escape(imsObj.values[imsObj.curr]);
}

//This function is being called to initialize the menu, onLoad, onTableRederReady i onResize
function startMenu() {
	var left,top;
	left=getLeft('menuContainer'); top=getTop('menuContainer');
//	alert("top="+top+"\nleft="+left);
	if (left>0||top>0) {
		showPermPanel('Special',left,top); menusGo();
		document.getElementById('menuContainer').style.height = menuHeight;
//		alert(document.getElementById('menuContainer').style.height);
	}
	else {
		setTimeout("startMenu()",1000);
	}
}


//This function is being called to initialize the menu, onLoad, onTableRenderReady i onResize
function startMenuRight() {
	var left,top,theObj=document.getElementById('menuContainer');
	left=getLeft('menuContainer'); top=getTop('menuContainer');
	if (left!=0||top!=0) {
		left+=getElementWidth('menuContainer')+5;
		top+=getElementHeight('menuContainer')-20;
		showPermPanel('Special', left+1, top); menusGo();
		theObj.style.height = menuHeight;
	}
	else {
		setTimeout("startMenuRight()",1000);
	}
}


function getTop(el) {
	var element;
	if (typeof(el.tagName)=="undefined") {
		if (document.getElementById) {
			element=document.getElementById(el);
		} else if (document.all) {
			element=document.all[el];
		}
	}
	else element=el;
	var top = element.offsetTop;
	while ((element = element.offsetParent) != null)
		top += element.offsetTop; 
	return top;
}

function getLeft(el) {
	var element;
	if (typeof(el.tagName)=="undefined") {
		if(document.getElementById) {
			element = document.getElementById(el);
		} else if (document.all) {
			element = document.all[el];
		}
	}
	else element=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;
}



//##############################
//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);
                	 if (this.cont_lyr.filters) this.cont_lyr.filters[0].Apply();
		         	 this.overflowref.style.visibility='visible';
		         	 if (this.cont_lyr.filters) 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;
		newwin.document.location.href=url;
		newwin.focus();
	}
	return newwindow;
}

function izpukvane(o) {
	
}

function vdlubvane(o) {
	
}

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();
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);
}
function sp(pointer) {
	var data=rotPic[pointer];
//	var detect = navigator.userAgent.toLowerCase();
//	var ie = false;
	//alert('pointer:'+pointer+' src:'+data.srcs+' duration:'+data.duration+' imgId:'+data.imgId+' num:'+data.num+' pix:'+data.pix+'');
	//alert(data.srcs.length);
//	if (detect.indexOf('msie')) ie = true;
	
	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)"
		if (document[data.imgId].filters) document[data.imgId].filters.blendTrans.Apply();
		document[data.imgId].src = data.pix[data.num=n].src;
		if (document[data.imgId].filters) 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);
}
// TOOLTIP ZA SHOPPING BASKET-A
cToolTip = {
	offsetX			: 20,
	offsetY			: 3,
	nTimeout 		: 1000,
	bShowDelayed	: true,
	nSteps			: 5,
	nSpeed			: 35
}

var hTarget = null
var hToolTop = null

cToolTip.showTip = function( nLeft, nTop, hTarget, sText )
{
	if( typeof sText == "undefined" )
	{
		sText = hTarget.getAttribute( "tooltip" )
		if( sText )
		{
			if( ( typeof sText == "undefined" ) || ( sText.length = 0 ) ) return
			if( sText.substr( 0, 5 ) == "data:" )
			{
				sText = eval( sText.substr( 5 ) )
			}
		}
		else
		{
			return
		}
	}
	
	if( hTarget.hToolTip )
	{
		this.hideTip( hTarget )
		return
	}
	
	hTarget.bStay = false
	
	hToolTip = document.createElement( "DIV" )
	hToolTip.className = "motooltip"
	
	if( this.bShowDelayed )
	{
		hToolTip.style.visibility = "hidden"
	}

	document.body.appendChild( hToolTip )
	hToolTip.innerHTML = sText

	hTarget.hToolTip = hToolTip
	
	hToolTip.onmousedown = function()
	{
		hTarget._onblur = hTarget.onblur
		hTarget.onblur = null
		hTarget.bStay = true
	}

	hToolTip.onmouseup = function()
	{
		hTarget.onblur = hTarget._onblur
		hTarget._onblur = null
		hTarget.bStay = false
		hTarget.focus()
	}
	
	hTarget.onblur = function()
	{
		if( ( hTarget.bStay ) || ( typeof hTarget.hToolTip == "undefined" ) ) return
		document.body.removeChild( hTarget.hToolTip )
		hTarget.hToolTip = null
		hTarget.onblur = null
		hTarget.onmouseout = null
	}

	/* just a quick hack better use cMoDomEvent */
	function mo()
	{
		hTarget.onmousemove = new Function('')
	}
	
	if( document.attachEvent ) 
	{
		hTarget.attachEvent( 'onmouseout', mo )
	}
	else if( document.addEventListener )
	{
		hTarget.addEventListener( 'mouseout', mo, false )
	}
	else if( document.all )
	{
		hTarget.onmouseout = mo
	}
	
	hTarget.onmousemove = function(hEvent)
	{
		if( hEvent == null ) hEvent = window.event
		if( ( hTarget.bStay ) || ( typeof hTarget.hToolTip == "undefined" ) ) return

		nLeft = hEvent.clientX
		nTop = hEvent.clientY
		cToolTip.setPos( hTarget, nLeft, nTop )
	}
	

	//correct position
	var nDocWidth = document.width ? document.width : document.documentElement.offsetWidth - 25	
	var aDocScroll = getScroll()

	if( nLeft > nDocWidth - hToolTip.offsetWidth )
	{
		nLeft = nLeft - hToolTip.offsetWidth - (typeof(globalOX)!="undefined" && globalOX?globalOX:this.offsetX) + aDocScroll.x + "px"
	}
	else
	{
		nLeft = nLeft + (typeof(globalOX)!="undefined" && globalOX?globalOX:this.offsetX) + aDocScroll.x + "px"
	}
	
	nTop = nTop + (typeof(globalOY)!="undefined" && globalOY?globalOY:this.offsetY) + aDocScroll.y + "px"

	hToolTip.style.left = nLeft
	hToolTip.style.top = nTop
	
	hToolTip.style.visibility = "visible"

	if( this.bShowDelayed )
	{
		this.showDelayed( 1 )
	}
}
cToolTip.setPos = function( hTarget, nLeft, nTop )
{
	var nDocWidth = document.width ? document.width : document.documentElement.offsetWidth - 25	
	var aDocScroll = getScroll()
	
	if( nLeft > nDocWidth - hTarget.hToolTip.offsetWidth )
	{
		nLeft = nLeft - hTarget.hToolTip.offsetWidth - (typeof(globalOX)!="undefined" && globalOX?globalOX:cToolTip.offsetX) + aDocScroll.x + "px"
	}
	else
	{
		nLeft = nLeft + (typeof(globalOX)!="undefined" && globalOX?globalOX:cToolTip.offsetX) + aDocScroll.x + "px"
	}

	nTop = nTop + (typeof(globalOY)!="undefined" && globalOY?globalOY:cToolTip.offsetY) + aDocScroll.y + "px"

	hTarget.hToolTip.style.left = nLeft
	hTarget.hToolTip.style.top = nTop
}

cToolTip.hideTip = function( hTarget )
{
	if( hTarget.hToolTip != null )
	{	
		globalOX=null; globalOY=null;
		document.body.removeChild( hTarget.hToolTip )
		hTarget.hToolTip = null
		hTarget.onblur = null
		hToolTip = null
	}
}

cToolTip.getTarget = function( hEvent )
{
	hElm =  ( hEvent.srcElement ) ? hEvent.srcElement : (hEvent.originalTarget&&hEvent.originalTarget.parentNode?hEvent.originalTarget.parentNode:new Object());
	if( typeof hElm.tagName == "undefined" ) return null
	//if( hElm.tagName.toUpperCase() == "A" )
	while( ( hElm.tagName ) && !( /body/i.test( hElm.tagName ) ) )
	{
		if ( hElm.getAttribute( 'tooltip' ) != null )
		{
			return hElm
		}
		
		hElm = hElm.parentNode
	}
	return null
}

cToolTip.showDelayed = function( nStep )
{
	if( hToolTip == null ||  nStep>this.nSteps ) return
	if( ( bw.ie55 || bw.ie6 ) && ( hToolTip.filters == null || hToolTip.filters.alpha == null ) ) return
	nOpacity = nStep*1/this.nSteps
	nOpacity = Math.floor( nOpacity * 100 )
	cToolTip.setTipOpacity(nOpacity)
	nStep++
	this.hDelayedTimeout = setTimeout( 'cToolTip.showDelayed('+nStep+')' , this.nSpeed )
}

cToolTip.setTipOpacity = function( nValue )
{
	if( hToolTip == null ) return
	if( bw.ie )
	{
		hToolTip.filters.alpha.opacity = nValue
	}
	else if( bw.ns5 )
	{
		hToolTip.style.MozOpacity = nValue+'%'
	}
}

cToolTip.show = function( hEvent, sText )
{
	if( !hEvent )
	{
		hEvent = window.event
		hEvent.returnValue = true
		hEvent.cancelBubble = false
	}
	hTarget = cToolTip.getTarget( hEvent )
	
	if( !hTarget )
	{
		return
	}
	else
	{
		cToolTip.showTip( hEvent.clientX, hEvent.clientY, hTarget, sText )
	}
}

cToolTip.hide = function( hEvent )
{
	if( !hEvent )
	{
		hEvent = window.event
		hEvent.returnValue = true
		hEvent.cancelBubble = false
	}
	hTarget = cToolTip.getTarget( hEvent )
	
	if( this.bShowDelayed )
	{
		clearTimeout( this.hDelayedTimeout )
	}

	if( !hTarget )
	{
		return
	}
	else
	{
		cToolTip.hideTip( hTarget )
	}
}


cToolTip.initAutoTips = function( )
{
	if( document.attachEvent ) 
	{
		document.attachEvent( 'onmouseover', cToolTip.show )
		document.attachEvent( 'onmouseout', cToolTip.hide )
	}
	else if( document.addEventListener )
	{
		document.addEventListener( 'mouseover', cToolTip.show, true )
		document.addEventListener( 'mouseout', cToolTip.hide, false )
	}
	else if( document.all )
	{
		document.onmouseover = cToolTip.show
		document.onmouseout = cToolTip.hide
	}
}

cToolTip.init = function()
{
	this.bShowDelayed = bw.ie55 || bw.ie6 || bw.ns5
}

cToolTip.init()

//helper functions
function getScroll()
{
	if ( typeof document.body.scrollTop != "undefined") 
	{
		var ieBox = document.compatMode != "CSS1Compat"
		var cont = ieBox ? document.body : document.documentElement
		return {x : cont.scrollLeft, y : cont.scrollTop}
	}
	else 
	{
		return {x : window.pageXOffset, y : window.pageYOffset}
	}
}



function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
	endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
}

//DeleteCookie('favorites'); 

function AddFavorites(item_id){
	
	var expire = new Date(); 
	expire.setTime(expire.getTime() + (24 * 60 * 60 * 1000 * 700));
	
	var favs = GetCookie('favorites');
	if(favs != null && favs != '') {
		var myRe= new RegExp("(?:^|\\|)"+item_id+"(?:\\||$)");
		if (!myRe.exec(favs)) {
			SetCookie('favorites',favs+item_id+'|', expire);
		}
	}
	else{
		SetCookie('favorites',item_id+'|', expire);
	}
	//alert(GetCookie('favorites'));
}

function DelFavorites(item_id){
	var arr = GetCookie('favorites').split("|");
	var nov=[];
	for(var i=0; i<arr.length; i++){
		if(item_id != arr[i]){
			nov[nov.length] = arr[i];
		}
	}
	SetCookie('favorites',nov.join("|"));
	//alert(GetCookie('favorites'));
}

/// COOKIES ###
function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
	return null;
}

function SetCookie (name, value) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) + 
	((domain == null) ? "" : ("; domain=" + domain)) + 
	((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) { 
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	// This cookie is history 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function execMouseOverChilds(startElem) {
	var myFunc;
	if (typeof(startElem.mouseOverExecuted)=='undefined'||!startElem.mouseOverExecuted) {
		myFunc="onmouseover";
		startElem.mouseOverExecuted=true;
	}
	else myFunc="neshtosiON";
	with (startElem) {
		if (typeof(childNodes)!='undefined'&&childNodes!=null&&childNodes.length>0) {
			for (var i=0; i<childNodes.length; i++) {
				if (typeof(childNodes[i].childNodes)!='undefined'&&childNodes[i].childNodes!=null&&childNodes[i].childNodes.length>0) {
					execMouseOverChilds(childNodes[i]);
				}
				if (typeof(childNodes[i][myFunc])!='undefined'&&childNodes[i][myFunc]!=null) {
					childNodes[i][myFunc]();
				}
			}
		}
	}
	if (myFunc=="onmouseover") execMouseOverChilds(startElem);
}

function execMouseOutChilds(startElem) {
	var myFunc;
	if (typeof(startElem.mouseOutExecuted)=='undefined'||!startElem.mouseOutExecuted) {
		myFunc="onmouseout";
		startElem.mouseOutExecuted=true;
	}
	else myFunc="neshtosiOFF";
	with (startElem) {
		if (typeof(childNodes)!='undefined'&&childNodes!=null&&childNodes.length>0) {
			for (var i=0; i<childNodes.length; i++) {
				if (typeof(childNodes[i].childNodes)!='undefined'&&childNodes[i].childNodes!=null&&childNodes[i].childNodes.length>0) {
					execMouseOutChilds(childNodes[i]);
				}
				if (typeof(childNodes[i][myFunc])!='undefined'&&childNodes[i][myFunc]!=null) {
					childNodes[i][myFunc]();
				}
			}
		}
	}
	if (myFunc=="onmouseout") execMouseOutChilds(startElem);
}
// End Script -->
