//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    function include(file){
        document.write('<script type="text/javascript" src="'+file+'"></script>');
    }
//------------------------------------------------------------------------------
	var cap_cities = new Array();
		cap_cities['cap'] = cap_cities[1] = "Capital city";
		cap_cities['angels'] = cap_cities[2] =  "Angels city",
		cap_cities['demons'] = cap_cities[3] = "Demons city",
		cap_cities['devils'] = cap_cities[4] = "Devils city",
		cap_cities['sun'] = cap_cities[5] = "Suncity",
		cap_cities['emer'] = cap_cities[6] = "Emeralds city",
		cap_cities['sand'] = cap_cities[7] = "Sandcity",
		cap_cities['moon'] = cap_cities[8] = "Mooncity",
		cap_cities['east'] = cap_cities[9] = "East city",
		cap_cities['newcap'] = cap_cities[10] = "New Capital city";
		cap_cities['cap_prig'] = cap_cities[11] = " Capital city";
		cap_cities['emer_prig'] = cap_cities[12] = " Emeralds city";
	var city_index = new Array();
		city_index['cap'] = 1;
		city_index['angels'] = 2;
		city_index['demons'] = 3;
		city_index['devils'] = 4;
		city_index['sun'] = 5;
		city_index['emer'] = 6;
		city_index['sand'] = 7;
		city_index['moon'] = 8;
		city_index['east'] = 9;
		city_index['newcap'] = 10;
//		city_index['cap_prig'] = 99;
//		city_index['emer_prig'] = 98;
	var c_icon = new Array();
		c_icon['cap'] = 'capital';
		c_icon['angels'] = 'angels';
		c_icon['demons'] = 'demons';
		c_icon['devils'] = 'devils';
		c_icon['sun'] = 'sun';
		c_icon['emer'] = 'emeralds';
		c_icon['sand'] = 'sand';
		c_icon['moon'] = 'moon';
		c_icon['east'] = 'east';
		c_icon['newcap'] = 'newcap';
//------------------------------------------------------------------------------
    function show(a, b){
		var b = document.getElementById(b);
		if(b.style.display){
				b.style.display='';
				a.title = "";
		}
		else{
				b.style.display='none';
				a.title = "";
		}
    }
	/*function show(a, id){
        $$(document.getElementById(id)).slideToggle('fast');
    }*/		

//------------------------------------------------------------------------------
	function up(){
		document.write('<a title="" href="javascript:{window.scroll(0,0)}"><img src="/img/up.gif" alt="up" width="12" height="12" border="0" /></a>');
	}

//------------------------------------------------------------------------------
	function unique(){
		return Math.floor(Math.random()*123456789/Math.random());
	}

//------------------------------------------------------------------------------
	function align_str(align){
		var alt = "";
//    		if (align == 0) alt"&nbsp;";
		if (align>=1 && align<2) alt = " ";
		if (align>=2 && align<3) alt = "";
		if (align>=3 && align<4) alt = " ";
		if (align>=7 && align<8) alt = " ";
		if (align>=50 && align<51) alt = "";

		return '<img src="http://img.combats.com/i/align'+align+'.gif" width="12" height="15" alt="'+alt+'" title="'+alt+'" border="0" />';
	}

//------------------------------------------------------------------------------
	function pers(login, align, klan, level, city){
        var text = '';
        if(city){
			text += brandcity_img(city);
        }
		if(align){
			text += ' '+align_str(align);
		}
        if(klan){
			text += klan_img(klan);
		}
        text += '<b>';
        text += login;
        if(level.length){
            text += '['+level+']';
        }
        text += '</b>';
		if(login && level !== ''){
	        text += '<a href="http://capitalcity.combats.com/inf.pl?login='+login+'" target="_blank"><img src="http://img.combats.com/i/inf.gif" width="12" height="11" alt=".  '+login+'" border="0" /></a>';
		}

        document.write(text);
        //return text;
	}

//------------------------------------------------------------------------------
	function pers2(login, align, klan, level, city){
        var text = '';
        if(city){
			text += brandcity_img(city);
        }
		if(align){
			text += ' '+align_str(align);
		}
        if(klan){
			text += klan_img(klan);
		}
        text += '<b>';
        text += login;
		
		level = parseInt(level)
        if(level >= 0 && level <= 21){
            text += '['+level+']';
        }
        text += '</b>';
        text += '<a href="http://capitalcity.combats.com/inf.pl?login='+login+'" target="_blank"><img src="http://img.combats.com/i/inf.gif" width="12" height="11" alt=".  '+login+'" border="0" /></a>';

        //document.write(text);
        return text;
	}

//------------------------------------------------------------------------------
	function klan_img(klan, align){
		var text = '';
		if(align){
			text += align_str(align);
		}
		text += '<a href="http://capitalcity.combats.com/encicl/klan/'+klan+'.html" target="_blank"><img src="http://img.combats.com/i/klan/'+klan+'.gif" width="24" height="15" alt=" '+klan+'" border="0" /></a>';
		return text;
	}

//------------------------------------------------------------------------------
	function brandcity_img(city){
		//http://img.combats.com
        if(city_index[city]){
            return '<img alt="'+cap_cities[city]+'" src="/i/city/brand/'+city_index[city]+'.gif" width="27" title="'+cap_cities[city]+'" border="0" />';
		}
		return '';
	}
//------------------------------------------------------------------------------
	function city(city){
	    if(cap_cities[city]){
		  document.write(brandcity_img(city)+'<b>'+cap_cities[city]+'</b>');
	    } else {
		  document.write('<b>'+city+'</b>');
	    }
	}
//------------------------------------------------------------------------------
	function city2(city){
		var text = '';
	    if(cap_cities[city]){
		  text += brandcity_img(city)+'<b>'+cap_cities[city]+'</b>';
	    } else {
		  text += city.bold();//'<b>'+city+'</b>';
	    }
		return text;
	}
//------------------------------------------------------------------------------
	function city_icon(iCity){
		var text = '';
	    if(c_icon[iCity]){
		  text += '<img src="/img/city_icons/' + c_icon[iCity] + '.gif" width="17" height="15" alt="' + cap_cities[iCity] + '" />';
	    }
		return text;
	}
//------------------------------------------------------------------------------
	function popup(id){
		var obj = document.getElementById(id);
		obj.style.display = (obj.style.display) ? ('') : ('none');
	}
//------------------------------------------------------------------------------
	function $(id){
		return document.getElementById(id);
	}
//------------------------------------------------------------------------------
	function $w(text){
		document.write(text);
	}
//------------------------------------------------------------------------------
	function email(name, d2, d1, text){
		var mail = name + '@' + d2 + '.' + d1;
		if(!text){
			text = mail;
		}
		document.write('<a href="mailto:'+mail+'">'+text+'</a>');
	}
//------------------------------------------------------------------------------
	function setCookie ( sName, sValue, nDays ) {
		var expires = "";
		if ( nDays ) {
			var d = new Date();
			d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 );
			expires = "; expires=" + d.toGMTString();
		}
	
		document.cookie = sName + "=" + sValue + expires + "; path=/";
	};
	function getCookie(sName) {
		var re = new RegExp( "(\;|^)[^;]*(" + sName + ")\=([^;]*)(;|$)" );
		var res = re.exec( document.cookie );
		return res != null ? res[3] : null;
	}

	function removeCookie( name ) {
		setCookie( name, "", -1 );
	}
//------------------------------------------------------------------------------
	function print_r(o){
		var text = '';
		for(prop in o){
			text += prop+" = ("+ typeof(o[prop]) +") "+o[prop]+"\n";
		}
		alert(text);
	}

