var abc=" !\"#$%_'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~_?__";
function decodeurl(str){
	var res="";
	var n;
	for(var i=0;i<str.length;i++){
		var c=str.substr(i,1);
		if(c=="+"){
			res+=" ";
		}else if(c=="%"){
			var asc=parseInt(str.substr(i+1,2),16);
			if(asc>=32)res+=abc.substr(asc-32,1);
			i+=2;
		}else{
			res+=c;
		}
	}
	return res;
}
function encodeurl(str){
	var res="";
	var iii=0;
	for(var i=0;i<str.length;i++){
		var c=str.substr(i,1);
		if(c==" "){
			res+="+";
		}else if((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||("-_.~/?=&:".indexOf(c)>=0)){
			res+=c;
		}else{
			var n=abc.indexOf(c);
			if(n>=0){
				res+="%"+(n+32).toString(16);
			}
		}
	}
	return res;
}
function getCookieI(n){
	var s=getCookie(n);
	if(s==null) return 0;
	if(isNaN(s)) return 0;
	return parseInt(s);
}
function getCookie(n){
	var s=document.cookie.indexOf(n+'=');
	var l=s+n.length+1;
	if((!s)&&(n!=document.cookie.substring(0,n.length))) return null;
	if(s==-1){return null;}
	var e=document.cookie.indexOf(';',l);
	if(e==-1){e=document.cookie.length;}
	return unescape(document.cookie.substring(l,e));
}
function setCookie(n, v, d){
	var t=new Date();
	t.setTime(t.getTime());
	var e=new Date(t.getTime()+(d*86400000));
	document.cookie=n+'='+escape(v)+';expires='+e.toGMTString();
}
function addEventHandler(obj,event,handler){
	if(obj["addEventListener"]){
		obj.addEventListener(event, handler, false);
	}else if(obj["attachEvent"]){
		obj.attachEvent('on'+event, handler);
	}
}
function removeEventHandler(obj,event,handler){
	if(obj["removeEventListener"]){
		obj.removeEventListener(event, handler, false);
	}else if(obj["detachEvent"]){
		obj.detachEvent('on'+event, handler);
	}
}
function getElementOffset(elem){
	var x=0;
	var y=0;
	while(elem!=null){
		x+=elem.offsetLeft;
		y+=elem.offsetTop;
		elem=elem.offsetParent;
	}
	return{x:x,y:y};
}
function scrollToElement(elem){
	var ofs=getElementOffset(elem);
	window.scrollTo(ofs.x,ofs.y);
}
function getPageHeightWithScroll(w){
	var cn=w.document.body.childNodes;
	var h=35;
	for(var i=0;i<cn.length;i++){
		var c=cn[i];
		var d=c["style"]?c.style["display"]:"";
		if((!d||d=="block")&&(!c.id||(c.id!="shield"&&c.id.substr(0,3)!="mce"))){
			h+=c.scrollHeight||0;
		}
	}
	document.ifrHeigth=h;
	return h;
}
function changeCSSRule(w,selText,elem,val){
	if(!w.document["styleSheets"]){
		return;
	}
	var st=w.document.styleSheets[0];
	var rules=st["cssRules"]?st.cssRules:st.rules;
	for(var i=0;i<rules.length;i++){
		if(rules[i].selectorText==selText){
			rules[i].style[elem]=val;
			return true;
		}
	}
	return false;
}
function windowHeight(){
	var h=0;
	if(typeof(window['innerHeight'])=='number'){
		h=window.innerHeight;
	}else if(document['documentElement']&&(document.documentElement['clientHeight'])){
		h=document.documentElement.clientHeight;
	}else{
		h=document.body.clientHeight;
	}
	return h;
}
function getXmlHttp(){
  var xmlhttp;
  try {
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e){
	try {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E){
	  xmlhttp=false;
	}
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined'){
	xmlhttp=new XMLHttpRequest();
  }
  return xmlhttp;
}
function defMousePosition(event,w){
	var x=y=0;
	if(w){
		var fr=document.getElementsByTagName("iframe");
		if(fr){
			for(var i=0;i<fr.length;i++){
				if(fr[i].contentWindow==w){
					var ofs=getElementOffset(fr[i]);
					x=ofs.x;
					y=ofs.y;
					break;
				}
			}
		}
	}else{
		w=window;
	}
	if(w.event&&w.document.documentElement&&w.document.body){
		x+=w.event.clientX+w.document.documentElement.scrollLeft+w.document.body.scrollLeft;
		y+=w.event.clientY+w.document.documentElement.scrollTop+w.document.body.scrollTop;
	}else{
		x+=event.clientX+w.scrollX;
		y+=event.clientY+w.scrollY;
	}
	return{x:x,y:y};
}
function showMsgWnd(b,n){
	if(!document._userName)return;
	setShield(b);
	document.getElementById('usermailwnd').style.display=b?'':'none';
	if(b){
		document.getElementById('userinfo').style.display='none';
		info=false;
		initTinyMCE('umailtxtId',true);
		if(n){
			document.getElementById('mailForm').userName.value=n;
		}
	}
}
function addRow(cell1,cell2){
	var tr,td;
	var table=document.getElementById("infotable");
	tr=table.insertRow(table.rows.length);
	td=tr.insertCell(0);
	td.width='110px';
	td.innerHTML=cell1;
	td=tr.insertCell(1);
	td.innerHTML=cell2;
	return 1;
}
function setShield(b){
	document.getElementById("shield").style.display=b?"":"none";
}
function windowSize(){
	var w=0,h=0;
	if(typeof(window['innerWidth'])=='number'){
		w=window.innerWidth;
		h=window.innerHeight;
	}else if(document['documentElement']&&(document.documentElement['clientWidth'])){
		w=document.documentElement.clientWidth;
		h=document.documentElement.clientHeight;
	}else{
		w=document.body.clientWidth;
		h=document.body.clientHeight;
	}
	return{w:w,h:h};
}

function adjustImgSize(img,maxW,maxH,continuation){
	if(!img.complete){
		setTimeout(function(){adjustImgSize(img,maxW,maxH,continuation);},50);
		return;
	}
	if(!img.width||!img.height){
		return;
	}
	var w=maxW||150;
	var h=maxH||maxW||150;
	var dx=w/img.width;
	var dy=h/img.height;
	if((dx<1)||(dy<1)){
		if(dx>dy){
			w=img.width*dy;
		}else{
			h=img.height*dx;
		}
		img.width=w;
		img.height=h;
	}
	img.style.position="static";
	if(continuation){
		continuation();
	}
}
function replaceQuotes(s){
	return s.replace(/'/g,"\\'").replace(/&#39;/g,"\\'").replace(/"/g,"&quot;");
}
function stopPropagation(e){
	if(!e)e=window.event;
	e.cancelBubble=true;
	if(e.stopPropagation)e.stopPropagation();
}
function removeChildrenFromNode(node){
	while(node.childNodes.length>=1){
	   node.removeChild(node.firstChild);
	}
}
function getNumById(mas,id,n){
	if(!n){
		n=0;
	}
	for(var i=0;i<mas.length-1;i++){
		if(mas[i][n]==id){
			return i;
		}
	}
	return -1;
}
function trim(s){
	var l=0;
	var r=s.length-1;
	while(l<s.length&&s[l]==' '){
		l++;
	}
	while(r>l&&s[r]==' '){
		r--;
	}
	return s.substring(l,r+1);
}
function setRadioButtonValue(radioObj,newValue){
	for(var i=0;i<radioObj.length;i++){
		radioObj[i].checked=false;
		if(radioObj[i].value==newValue){
			radioObj[i].checked=true;
		}
	}
}
function setRadioButtonDisabled(radioObj,isDisabled){
	for(var i=0;i<radioObj.length;i++){
		radioObj[i].disabled=isDisabled;
	}
}
function isParentOf(parent,child){
	while(child){
		if(child==parent){
			return true;
		}
		child=child.parentNode;
	}
	return false;
}
function maxLength(field,maxChars){
	if(field.value.length>maxChars){
		field.value=field.value.substr(0,maxChars);
	}
}
function initCountryOptions(countryOptionsId,existingAlbumsOnly){
	var countryOptions=document.getElementById(countryOptionsId);
	var n=1;
	for(var i=0;i<document._allCountriesOrder.length-1;i++){
		var id=document._allCountriesOrder[i];
		var cntry=document._allCountries[id];
		if(!existingAlbumsOnly||cntry[1]){
			countryOptions.options[n]=new Option(cntry[0],id);
			n++;
		}
	}
}
function tinyMCEParams(id){
    return {
        mode:'exact',  
        elements:id,
        theme:'advanced',
        plugins:'inlinepopups,smiles',
        theme_advanced_buttons1:'bold,italic,underline,strikethrough,|,forecolor,backcolor,|,smiles',
        theme_advanced_buttons2:'',
        theme_advanced_buttons3:'',
        theme_advanced_toolbar_location:'top',
        theme_advanced_toolbar_align:'left',
        theme_advanced_resizing:false,
        strict_loading_mode:true,
        translate_mode:true,
        force_br_newlines:true,
        forced_root_block:'',
        handle_event_callback:'keyListener',
        language:document._lang
    };
}
function onContent(i){var u =navigator.userAgent;var e=/*@cc_on!@*/false; var st =
setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false); } else if(e){     (
function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}}
function oneSmile(mainURL,imgNo,imgTitle){
    return '<img border="0" src="'+mainURL+'images/tiny_mce/plugins/smiles/img/'+imgNo+'.gif" title="'+imgTitle+'">';
}
function replaceSmiles(s,mainURL){
    if(s.search(/O:-\)/)!=-1){
        var cont=s.replace(/O:-\)/gi,oneSmile(mainURL,'0301','O:-)'));
        return catSmiles(cont,mainURL);
    }
    var cont=s
        .replace(/\*JOKINGLY\*/gi,oneSmile(mainURL,'0126','*JOKINGLY*'))
        .replace(/\*KISSED\*/gi,oneSmile(mainURL,'0331','*KISSED*'))
        .replace(/\*TIRED\*/gi,oneSmile(mainURL,'0159','*TIRED*'))
        .replace(/\*STOP\*/gi,oneSmile(mainURL,'0515','*STOP*'))
        .replace(/\*KISSING\*/gi,oneSmile(mainURL,'0314','*KISSING*'))
        .replace(/\*THUMBS UP\*/gi,oneSmile(mainURL,'0134','*THUMBS UP*'))
        .replace(/\*DRINK\*/gi,oneSmile(mainURL,'0908','*DRINK*'))
        .replace(/\*IN LOVE\*/gi,oneSmile(mainURL,'0311','*IN LOVE*'))
        .replace(/\*HELP\*/gi,oneSmile(mainURL,'0927','*HELP*'))
        .replace(/\*OK\*/gi,oneSmile(mainURL,'0135','*OK*'))
        .replace(/\*WASSUP\*/gi,oneSmile(mainURL,'1812','*WASSUP*'))
        .replace(/\*SORRY\*/gi,oneSmile(mainURL,'0241','*SORRY*'))
        .replace(/\*BRAVO\*/gi,oneSmile(mainURL,'0131','*BRAVO*'))
        .replace(/\*ROLF\*/gi,oneSmile(mainURL,'0119','*ROLF*'))
        .replace(/\*PARDON\*/gi,oneSmile(mainURL,'0231','*PARDON*'))
        .replace(/\*NO\*/gi,oneSmile(mainURL,'0507','*NO*'))
        .replace(/\*CRAZY\*/gi,oneSmile(mainURL,'0204','*CRAZY*'))
        .replace(/\*DONT_KNOW\*/gi,oneSmile(mainURL,'0228','*DONT_KNOW*'))
        .replace(/\*DANCE\*/gi,oneSmile(mainURL,'0139','*DANCE*'))
        .replace(/\*YAHOO\*/gi,oneSmile(mainURL,'0133','*YAHOO*'))
        .replace(/\*HI\*/gi,oneSmile(mainURL,'0612','*HI*'))
        .replace(/\*BYE\*/gi,oneSmile(mainURL,'0103','*BYE*'))
        .replace(/\*YES\*/gi,oneSmile(mainURL,'0114','*YES*'))
        .replace(/\*WALL\*/gi,oneSmile(mainURL,'1243','*WALL*'))
        .replace(/\*WRITE\*/gi,oneSmile(mainURL,'1106','*WRITE*'))
        .replace(/\*SCRATCH\*/gi,oneSmile(mainURL,'0225','*SCRATCH*'))
        .replace(/@=/gi,oneSmile(mainURL,'0519','@='))
        .replace(/@}-&gt;--/gi,oneSmile(mainURL,'0323','@}-&gt;--'))
        .replace(/:-\*/gi,oneSmile(mainURL,'0332',':-\*'))
        .replace(/:-\(/gi,oneSmile(mainURL,'0235',':-('))
        .replace(/:\(/gi,oneSmile(mainURL,'0235',':('))
        .replace(/=\(/gi,oneSmile(mainURL,'0235','=('))
        .replace(/:\'\(/gi,oneSmile(mainURL,'0242',':\'('))
        .replace(/:-\)/gi,oneSmile(mainURL,'0101',':-)'))
        .replace(/:\)/gi,oneSmile(mainURL,'0101',':)'))
        .replace(/=\)/gi,oneSmile(mainURL,'0101','=)'))
        .replace(/;\)/gi,oneSmile(mainURL,'0129',';)'))
        .replace(/;-\)/gi,oneSmile(mainURL,'0129',';-)'))
        .replace(/%-\)/gi,oneSmile(mainURL,'0210','%-)'))
        .replace(/%\)/gi,oneSmile(mainURL,'0210','%)'))
        .replace(/8-\)/gi,oneSmile(mainURL,'0407','8-)'))
        .replace(/:-D/gi,oneSmile(mainURL,'0123',':-D'))
        .replace(/:D/gi,oneSmile(mainURL,'0123',':D'))
        .replace(/;D/gi,oneSmile(mainURL,'0128',';D'))
        .replace(/:-X/gi,oneSmile(mainURL,'0221',':-X'))
        .replace(/:-x/gi,oneSmile(mainURL,'0221',':-x'))
        .replace(/:-!/gi,oneSmile(mainURL,'0216',':-!'))
        .replace(/:!/gi,oneSmile(mainURL,'0216',':!'))
        .replace(/\[:-}/gi,oneSmile(mainURL,'0924','[:-}'))
        .replace(/:-\[/gi,oneSmile(mainURL,'0305',':-['))
        .replace(/:\[/gi,oneSmile(mainURL,'0305',':['))
        .replace(/&gt;:o/gi,oneSmile(mainURL,'0509','>:o'))
        .replace(/=-O/gi,oneSmile(mainURL,'0206','=-O'))
        .replace(/=O/gi,oneSmile(mainURL,'0206','=O'))
        .replace(/:-O/gi,oneSmile(mainURL,'0206',':-O'))
        .replace(/:O/gi,oneSmile(mainURL,'0206',':O'))
        .replace(/:-P/gi,oneSmile(mainURL,'0851',':-P'))
        .replace(/:-\|/gi,oneSmile(mainURL,'0516',':-|'))
        .replace(/:-\\/gi,oneSmile(mainURL,'0151',':-\\'))
        .replace(/\\m\//gi,oneSmile(mainURL,'0439','\\m/'))
        .replace(/:-\//gi,oneSmile(mainURL,'0151',':-/'))
        .replace(/]:-&gt;/gi,oneSmile(mainURL,'0520',']:->'));
    return cont;
}
function catSmiles(s,mainURL){
    var ret='',sb=s;
    var pos;
    do{
        pos=sb.search(/\</gi);
        if(pos==-1)pos=sb.length;
        ret+=replaceSmiles(sb.substr(0,pos),mainURL);
        sb=sb.substr(pos);
        pos=sb.search(/\>/gi)+1;
        ret+=sb.substr(0,pos);
        sb=sb.substr(pos);
    }while(sb!='');
    return ret;
}
function loadScript(src){
    document.write('<script src="'+src+'" type="text/JavaScript"></script>');
}
function initTinyMCE(id,now){
    /*if(((navigator.userAgent.indexOf('Chrome')>=0)&&(navigator.userAgent.indexOf('Windows')>=0)))*/
    if(!now&&!document._todoMCE)document._todoMCE=new Array();
    if(!id||(id==''))return;
    if(now){
        tinyMCE.init(tinyMCEParams(id,document._lang));
    }else{
        document._todoMCE.push(id);
    }
}
function loadTinyMCEScript(){
    if(document._todoMCE)loadScript('/images/tiny_mce/tiny_mce.js');
}
function delayedInitTinyMCE(){
    if(document._todoMCE){
        for(i=0;i<document._todoMCE.length;i++){
            initTinyMCE(document._todoMCE[i],true);
        }
    }
}
function findTokin(tok){
    var wl=window.location.search;
    var wp=wl.search(tok);
    var res='';
    if(wp!=-1){
        res=wl.substr(wp+(tok[tok.length-1]=='='?tok.length:0));
        wp=res.search(/&/gi);
        if(wp!=-1){
            res=res.substr(0,wp);
        }
    }
    return res;
}

/* move here from header_block.tpl
'{{sameURL}}','{{mainURL}}','{{imageURLn}}','{{lang}}'  
document._sameURL, document._mainURLn, document._imageURL, document._lang
.
*/

if(!parent.document["_allGenres"]&&document._sameURL=="http://"+window.location.host+"/"){
    var l=window.location;
    var uri=l.pathname.substr(1)+l.search+(l.hash=="#top"?"":l.hash);
    var hash=uri.replace(/\//g,"%2F").replace("?","%3F").replace("#","%23");
    parent.location.href=document._mainURL+"#"+hash;
}
document._allGenres=parent.document._allGenres;
document._allGenresOrder=parent.document._allGenresOrder;
document._karaokeGenreId=11;
document._clipsGenreId=13;
document._allCountries=parent.document._allCountries;
document._allCountriesOrder=parent.document._allCountriesOrder;
document._days=parent.document._days;
document._months=parent.document._months;
document._years=parent.document._years;
window.onmouseup=parent.playerStopMove;
document._awardData=parent.document._awardData;
document._epauletData=parent.document._epauletData;

document._userRatingStep=80;
document._newRatingStep=5;
document._rewiewRatingStep=25;
document._photoRatingStep=50;
document._userForumRatingStep=20;
document._cmpRatingStep=350;
document._topMonRatingStep=1500;
document._topWeekRatingStep=350;
document._topDayRatingStep=50;
function mainPageRef(txt,attr){
    if(parent&&parent!=window){
        return parent.mainPageRef(txt,attr);
    }else{
        return '<a href="'+document._mainURL+'"'+(attr||'')+'>'+txt+'</a>';
    }
}
function d2(n){
    return n<10?"0"+n:""+n;
}
document._getVars={};
var query=window.location.search.substr(1);
var vars=query.split("&");
if(!vars||!vars[0])vars=[];
for(var i=0;i<vars.length;i++){
    var pair=vars[i].split("=");
    document._getVars[pair[0]]=decodeurl(pair[1]);
}
function purePathname(pathname){
    if(pathname.substr(pathname.length-1)!="/")pathname+="/";
    return pathname.substr(3,1)=="/"?pathname.substr(3):pathname;
}
document._page=purePathname(window.location.pathname);
function keyListener(e){
    if(!e)e=window.event;
    if((e.keyCode==13||e.keyCode==10)&&e.ctrlKey){
        var f=document._ctrlEnterSubmitForm;
        if(f){
            var fr=document.getElementById(f);
            if((fr.mceText.value=="")&&document._fillMceText)
                document._fillMceText();
            fr.submit();
        }
    }
}
document.onkeypress=keyListener;
function mouseListener(e){
    if(!e)e=window.event;
    var m=document["_popupMenu"];
    var target=e.target||e.srcElement;
    if(m&&target!=document._popupTrigger&&!isParentOf(m,target)){
        m.className="";
        document._popupTrigger=null;
    }
}
function mouseX(evt) {
    if (evt.pageX)
        return evt.pageX;
    else {
        if (evt.clientX)
            return evt.clientX + (document.documentElement.scrollLeft ?
                        document.documentElement.scrollLeft :
                        document.body.scrollLeft);
        else {
            return null;
        }
    }
}
function mouseY(evt) {
    if (evt.pageY)
        return evt.pageY;
    else {
        if (evt.clientY)
            return evt.clientY + (document.documentElement.scrollTop ?
            document.documentElement.scrollTop :
            document.body.scrollTop);
        else {
            return null;
        }
    }
}
document.onmousedown=mouseListener;
var d=new Date();
document._curDay=d.getDate();
document._curMonth=d.getMonth()+1;
document._curYear=d.getFullYear();
d.setTime(d.getTime()-24*60*60*1000);
document._prevDay=d.getDate();
document._prevMonth=d.getMonth()+1;
document._prevYear=d.getFullYear();
document._filterPath=document._page;
if(document._filterPath!="/"&&document._filterPath!="/comp_list/"
        &&document._filterPath!="/prfm_list/"&&document._filterPath!="/main/"){
    document._filterPath="/comp_list/";
}
var info=false;
function showUserInfoWnd(b,indata,no,from,event,forum){
    if(!document._userName)return;
    if(b){
        if(!info){
            var ui=document.getElementById('userinfo');
            ui.style.display='';
            info=true;
            if(!no){
                return;
            }
            var item=indata[no-1];
            var cnt=0;
            removeChildrenFromNode(document.getElementById('infotable'));
            if(item[from]!=''){
                cnt+=addRow(document._name,item[from]);
                document.getElementById('userMail').href='javascript:showMsgWnd(true,\''+item[from]+'\')';
            }
            if(item[from+1]!=''){
                cnt+=addRow(document._sex,(item[from+1]=='M'?document._male:document._female));
            }
            if(item[from+2]!=''){
                cnt+=addRow(document._birth,item[from+2]);
            }
            if(item[from+3]!=''){
                cnt+=addRow(document._city,item[from+3]);
            }
            if(item[from+4] && (item[from+4]!=0)){
                cnt+=addRow(document._country,document._allCountries[item[from+4]][0]);
            }
            if(item[from+5]!=''){
                cnt+=addRow('ICQ',item[from+5]);
            }
            if(item[from+6]!=''){
                cnt+=addRow('E-mail',item[from+6]);
            }
            cnt+=(item[from+7]!=''?1:0);
            document.getElementById('pl_rating_id').innerHTML=
                ratingStars(item[from+7],document._userRatingStep,'white');
            document.getElementById('pl_regals_id').innerHTML=getRegals(item[from+8],item[from+9]);
            document.getElementById('pl_status').innerHTML=item[from+10];
            if(item[from+11]!=''){
                document.getElementById('userCmm').style.display='';
                document.getElementById('userCmmText').innerHTML=item[from+11];
            }else{
                document.getElementById('userCmm').style.display='none';
                document.getElementById('userCmmText').innerHTML='';
            }
            var IE=('\v'=='v');
            var tempX=mouseX(event);
            var tempY=mouseY(event);
            var ithi=(IE?25:30);
            if(tempX<0)tempX=0;
            if(tempY<0)tempY=0;
            if (forum) {
            	tempX += 330;
            	tempY += 370;
            }
            var wnd=ui.getElementsByTagName('div')[0];
            wnd.style.left=(tempX-300)+'px';
            wnd.style.top=(tempY-cnt*ithi-500)+'px';
        }
    }else{
        if(info){
            document.getElementById('userinfo').style.display='none';
            info=false;
        }
    }
}
function ratingStars(rating,step,bgcolor){
    if(rating<0){
        return '<img src="'+document._imageURL1+'images/stars/'+bgcolor+'0.gif" width="13" height="13" title="0">';
    }
    var r=(step?Math.floor(rating/step):0);
    var n=Math.floor(r/11);
    r=(r%11);
    if(n>5){
        n=5;
        r=10;
    }
    var res='';
    for(var i=0;i<n;i++){
        res=res+'<img src="'+document._imageURL1+'images/stars/'+bgcolor+'10.gif" width="13" height="13" title="'+rating+'">';
    }
    res=res+'<img src="'+document._imageURL1+'images/stars/'+bgcolor+r+'.gif" width="13" height="13" title="'+rating+'">';
    return res;
}
function getAvatar(a,m){
    return ('<img src="'+document._imageURL4+'image/avatar/'+(a?a:'blank50.png')+'" '+
            (a?'':'width="50" height="50" ')+'class="avatar" '+(m?m:'')+'/>');
}
function showEditCmpWnd(b,params,msg){
    setShield(b);
    var nm=document.getElementById("editmusic");
    nm.style.display=b?"":"none";
    var wnd=nm.getElementsByTagName("div")[0];
    var fr=wnd.getElementsByTagName("iframe");
    if(fr&&fr.length>0){
        var ifrm=fr[0];
        ifrm.contentWindow.close();
        wnd.removeChild(ifrm);
    }
    if(b){
        var ifrm=document.createElement("iframe");
        ifrm.allowTransparency=true;
        ifrm.frameBorder=0;
        ifrm.src=document._sameURL+document._lang+'/edit_comp/?'+params;
        ifrm.width=wnd.clientWidth-40;
        ifrm.height=wnd.clientHeight-60;
        ifrm.style.position='absolute';
        ifrm.style.top='50px';
        wnd.appendChild(ifrm);
    }else{
        if(msg){
            alert(msg);
        }
    }
}
function getRegals(epaulet,regals){
    var reg='';
    if(epaulet&&document._epauletData){
        for(var i=0;i<document._epauletData.length-1;i++){
            var ep=document._epauletData[i];
            if(ep[0]==epaulet){
                reg='<img src="'+document._imageURL2+'image/epaulet/'+ep[3]+'" title="'+ep[2]+'">';
            }
        }
    }
    if(regals&&document._awardData){
        for(var i=0;i<regals.length-1;i++){
            var rid=regals[i][0];
            var cnt=regals[i][1];
            for(var k=0;k<document._awardData.length-1;k++){
                var awd=document._awardData[k];
                if(awd[0]==rid){
                    for(var j=0;j<cnt;j++){
                        reg+='<img src="'+document._imageURL3+'image/award/'+awd[3]+'" title="'+awd[2]+'">';
                    }
                }
            }
        }
    }
    return reg;
}

function getLocation(getVars,pathname){
    var l=window.location;
    var query="";
    for(name in getVars){
        var value=getVars[name];
        if(value)query+="&"+name+"="+encodeurl(value);
    }
    query=query.substring(1);
    if(!pathname)pathname=l.pathname;
    return document._mainURL+document._lang+purePathname(pathname)+(query?"?"+query:"");
}
function getCaptcha(){
    var id=Math.floor(10000*Math.random());
    return '<img src="'+document._mainURL+'captcha/?id='+id+'"/>'+
            '<input type="hidden" name="captcha_id" value="'+id+'"/>';
}
function captcha(d){
    if(!d)d=document;
    d.write(getCaptcha());
}
function makeMailSubmit(){
    var f=document.forms.mailForm;
    f.mceText.value=catSmiles(tinyMCE.get('umailtxtId').getContent(),document._mainURL);
    f.submit();
}
function smallImg(img){
    var dot=img.lastIndexOf(".");
    return img.substr(0,dot)+"-small"+img.substr(dot);
}
var votesFrom='';
function showVotesWnd(b,f,i,v,u){
    if(votesFrom!='news')setShield(b);
    var nm=document.getElementById('votes');
    nm.style.display=b?'':'none';
    var wnd=nm.getElementsByTagName('div')[0];
    if(b){
        var ifrm=document.createElement('iframe');
        ifrm.allowTransparency=true;
        ifrm.frameBorder=0;
        votesFrom=f;
        ifrm.src=document._sameURL+document._lang+'/votes/?from='+f+'&id='+i+'&value='+v+(u?'&user='+u:'');
        ifrm.width=wnd.clientWidth-10;
        ifrm.height=wnd.clientHeight-40;
        ifrm.style.position='absolute';
        ifrm.style.left='10px';
        ifrm.style.top='40px';
        wnd.appendChild(ifrm);
    }else{
        var ifrm=wnd.getElementsByTagName('iframe')[0];
        ifrm.contentWindow.close();
        wnd.removeChild(ifrm);
    }
}
function showAddPictWnd(b,p){
    setShield(b);
    var nm=document.getElementById('add_pict_wnd');
    nm.style.display=b?'':'none';
    var wnd=nm.getElementsByTagName('div')[0];
    if(b){
        var ifrm=document.createElement('iframe');
        ifrm.allowTransparency=true;
        ifrm.frameBorder=0;
        ifrm.src=document._sameURL+document._lang+'/add_gallery/?prfm='+p;
        ifrm.width=wnd.clientWidth-10;
        ifrm.height=wnd.clientHeight-40;
        ifrm.style.position='absolute';
        ifrm.style.left='10px';
        ifrm.style.top='40px';
        wnd.appendChild(ifrm);
    }else{
        var ifrm=wnd.getElementsByTagName('iframe')[0];
        ifrm.contentWindow.close();
        wnd.removeChild(ifrm);
    }
}
function showEditBioWnd(b,p,a){
    setShield(b);
    var nm=document.getElementById('edit_biography_wnd');
    nm.style.display=b?'':'none';
    var wnd=nm.getElementsByTagName('div')[0];
    if(b){
        var ifrm=document.createElement('iframe');
        ifrm.allowTransparency=true;
        ifrm.frameBorder=0;
        ifrm.src=document._sameURL+document._lang+'/add_bio/?'+(a?'view=requests&req=':'prfm=')+p;
        ifrm.width=wnd.clientWidth-10;
        ifrm.height=wnd.clientHeight-40;
        ifrm.style.position='absolute';
        ifrm.style.left='10px';
        ifrm.style.top='40px';
        wnd.appendChild(ifrm);
    }else{
        var ifrm=wnd.getElementsByTagName('iframe')[0];
        ifrm.contentWindow.close();
        wnd.removeChild(ifrm);
    }
}

function editAllCmp(){
    if(!document._allCmp){
        window.location=getLocation({order:"name",genre:document._getVars["genre"],style:document._getVars["style"],
            substyle:document._getVars["substyle"],letter:document._getVars["letter"],
            kind:"M",added_by:document._getVars["added_by"],edited_by:document._getVars["edited_by"]},'/comp_list/')+
            '&editAll=true';
        return;
    }
    var allCmp="";
    var isModer=(document._userCtg=="M"||document._userCtg=="A");
    for(var i=0;i<document._allCmp.length-1;i++){
        if(isModer||document._allCmp[i][cmp_editable]){
            allCmp+="+"+document._allCmp[i][cmp_id];
        }
    }
    showEditCmpWnd(true,"cmp="+allCmp.substring(1));
}
