var nn4 = document.layers?1:0;
var ie4 = document.getElementById?0:1;
var opera = (navigator.userAgent.indexOf("Opera")!=-1)?1:0;
var ieAll = (document.all&&!opera?1:0);
var ns6 = (document.getElementById && !document.all && !opera)?1:0;

var lastMilisecs=0;
var strToPrint="START";

function getFormElementByName(forma,nam) {
	var wanted=null;
	for (var i=0; i<forma.elements.length; i++) {
		if (nam==forma.elements[i].name) {
			wanted=forma.elements[i];
			break;
		}
	}
	return wanted;
}

function setTimePoint(where) {
	var now=(new Date().getTime()/1000);
	if (lastMilisecs!=0) strToPrint+=" - "+where+" - "+(((now-lastMilisecs)+"").substring(0,5));
	lastMilisecs=now;
}

function blendimage(bd_ob,image_ob,imagefile,millisec,origw,origh) { 
    var speed = Math.round(millisec / 100);
    var timer = 1;
	image_ob.style.width='1px'; image_ob.style.height='1px';
    bd_ob.style.backgroundImage = "url(" + image_ob.src + ")";
	setTimeout(function() {
		changeOpacInsta(0, image_ob);
		image_ob.src = imagefile;
		image_ob.style.width=origw+'px'; image_ob.style.height=origh+'px';
		setTimeout(function() {
			changeOpacSmooth(timer,image_ob,speed);
		},speed);
	},100);
} 

function changeOpacInsta(opacity,o) {
    o.style.opacity = (opacity / 100);
    o.style.filter = "alpha(opacity=" + opacity + ")";
}

function changeOpacSmooth(opacity,o,speed) {
	o.style.opacity = (opacity / 100);
	o.style.filter = "alpha(opacity=" + opacity + ")";
	setTimeout(function() {
		if (opacity < 100) {
			changeOpacSmooth((opacity+Math.ceil(opacity/8)),o,speed);
		}
		else {
			o.style.opacity = 1;
    		o.style.filter = "alpha(opacity=100)";
		}
	},speed);
} 

//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("BeforeEnd", 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 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};
}


function repeatSymbol(symbol,times) {
	var str="";
	for (var i=0; i<times; i++) str+=symbol;
	return str;
}

function isFoundSameObj(obj,obj_arr) {
	for (var i=0; i<obj_arr.length; i++) if (obj==obj_arr[i]) return true;
	return false;
}

function copy_clip(meintext){
 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   // you have to sign the code to enable this, or see notes below 
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1']
                 .createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1']
                  .createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten 
   // nodig om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   var str = Components.classes["@mozilla.org/supports-string;1"]
                .createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
   clip.setData(trans,null,clipid.kGlobalClipboard);
   
   }
   alert("Following info was copied to your clipboard:\n\n" + meintext);
   return false;
}

//prints human readable array in JavaScript, enjoy ;-)
function print_array(array_a,elem,max_level,level,passed_objs,current_name) {
	if (current_name==null) current_name="array_a";
	if (max_level==null) max_level=2;
	if (passed_objs==null) passed_objs=new Array();
	if (level==null) level=0;
	var str="";
	if (level<max_level) {
		if (elem==null) {
			for (var i in array_a) {
				var typ=typeof(array_a[i]);
				if (typ=="array" || typ=="object") {
					if (!isFoundSameObj(array_a[i],passed_objs)) {
						passed_objs[passed_objs.length]=array_a[i];
						str+=repeatSymbol("\t",level)+current_name+(typ=="array"?"["+i+"]":"."+i)+"=["+typ+"] "
						+((level+1)<max_level
						  ?"(\n"+print_array(array_a[i],null,max_level,level+1,passed_objs,current_name+(typ=="array"?"["+i+"]":"."+i))+"\n"+repeatSymbol("\t",level)+")\n"
						  :"(-<[MAX_LEVEL_REACHED]>-)\n"
						);
					}
					else {
						str+=repeatSymbol("\t",level)+current_name+(typ=="array"?"["+i+"]":"."+i)+"=["+typ+"] "+"(-<[RECOURSION]>-)\n";
					}
				}
				else {
					str+=repeatSymbol("\t",level)+current_name+(typ=="array"?"["+i+"]":"."+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].id+"\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";
				}
			}
		}
	}
	else {
		str+=repeatSymbol("\t",level)+"-<[MAX_LEVEL_REACHED]>-";
	}
	
	if (level==0) {
		//copy_clip(str);
		//else strToPrint+=str+"\n";
		alert("here's the Array:\n"+str);
	}
	else return 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;
}

//This function is being called to initialize the menu, onLoad, onTableRederReady i onResize
function startMenu() {
	var left,top;
	left=getLeft('menuContainer'); top=getTop('menuContainer');
	if (left>0||top>0) {
		showPermPanel('Special', left, top); menusGo();
		document.getElementById('menuContainer').style.height = menuHeight;
	}
	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=el
	if (typeof(el)!='object') element = document.getElementById(el);
	var top = element.offsetTop;
	while ((element = element.offsetParent) != null)
	top += element.offsetTop; return top;
}

function getLeft(el) {
	var element=el
	if (typeof(el)!='object') element = document.getElementById(el);
	var left = element.offsetLeft;
	while ((element = element.offsetParent) != null)
	left += element.offsetLeft; return left;
}

function getWidth(layerid) { //Gets layer width crossbrowser
	var width=null;
	if (document.layers) width=document.layers[layerid].document.width;
	if (document.all) width=document.all[layerid].offsetWidth;
	else if (document.getElementById) width=document.getElementById(layerid).offsetWidth;
	return width;
}

function getHeight(layerid) { //Gets layer height crossbrowser
	var height=null;
	if (document.layers) height=document.layers[layerid].document.height;
	if (document.all) height=document.all[layerid].offsetHeight;
	else if (document.getElementById) height=document.getElementById(layerid).offsetHeight;
	return height;
}

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);
                	 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;
		newwin.document.location.href=url;
		newwin.focus();
	}
	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();
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];
	
	//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);
}
// 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 - this.offsetX + aDocScroll.x + "px"
	}
	else
	{
		nLeft = nLeft + this.offsetX + aDocScroll.x + "px"
	}
	
	nTop = nTop + 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 - cToolTip.offsetX + aDocScroll.x + "px"
	}
	else
	{
		nLeft = nLeft + cToolTip.offsetX + aDocScroll.x + "px"
	}

	nTop = nTop + cToolTip.offsetY + aDocScroll.y + "px"

	hTarget.hToolTip.style.left = nLeft
	hTarget.hToolTip.style.top = nTop
}

cToolTip.hideTip = function( hTarget )
{
	if( hTarget.hToolTip != 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,level) {
	if (level==null) level=0;
	level++;
	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],level);
				}
				if (typeof(childNodes[i][myFunc])!='undefined'&&childNodes[i][myFunc]!=null) {
					childNodes[i][myFunc]();
				}
			}
		}
	}
	if (myFunc=="onmouseover") execMouseOverChilds(startElem,level);
}

function execMouseOutChilds(startElem,level) {
	if (level==null) level=0;
	level++;
	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],level);
				}
				if (typeof(childNodes[i][myFunc])!='undefined'&&childNodes[i][myFunc]!=null) {
					childNodes[i][myFunc]();
				}
			}
		}
	}
	if (myFunc=="onmouseout") execMouseOutChilds(startElem,level);
}
// End Script -->

