var countryCodes = {"AF":"Afghanistan","AL":"Albania","DZ":"Algeria","AS":"American Samoa","AD":"Andorra","AO":"Angola","AI":"Anguilla","AQ":"Antarctica","AG":"Antigua and Barbuda","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BS":"The Bahamas","BH":"Bahrain","BD":"Bangladesh","BB":"Barbados","BY":"Belarus","BE":"Belgium","BZ":"Belize","BJ":"Benin","BM":"Bermuda","BT":"Bhutan","BO":"Bolivia","BA":"Bosnia and Herzegovina","BW":"Botswana","BV":"Bouvet Island","BR":"Brazil","IO":"British Indian Ocean Territory","VG":"British Virgin Islands","BN":"Brunei Darussalam","BG":"Bulgaria","BF":"Burkina Faso","MM":"Burma","BI":"Burundi","KH":"Cambodia","CM":"Cameroon","CA":"Canada","CV":"Cape Verde","KY":"Cayman Islands","CF":"Central African Republic","TD":"Chad","CL":"Chile","CN":"China","CX":"Christmas Island","CC":"Cocos (Keeling) Islands","CO":"Colombia","KM":"Comoros","CD":"Congo, Democratic Republic of the","CG":"Congo, Republic of the","CK":"Cook Islands","CR":"Costa Rica","CI":"Cote d'Ivoire","HR":"Croatia","CU":"Cuba","CY":"Cyprus","CZ":"Czech Republic","DK":"Denmark","DJ":"Djibouti","DM":"Dominica","DO":"Dominican Republic","TL":"East Timor","EC":"Ecuador","EG":"Egypt","SV":"El Salvador","GQ":"Equatorial Guinea","ER":"Eritrea","EE":"Estonia","ET":"Ethiopia","FK":"Falkland Islands (Islas Malvinas)","FO":"Faroe Islands","FJ":"Fiji","FI":"Finland","FR":"France","GF":"French Guiana","PF":"French Polynesia","TF":"French Southern and Antarctic Lands","GA":"Gabon","GM":"The Gambia","GE":"Georgia","DE":"Germany","GH":"Ghana","GI":"Gibraltar","GR":"Greece","GL":"Greenland","GD":"Grenada","GP":"Guadeloupe","GU":"Guam","GT":"Guatemala","GN":"Guinea","GW":"Guinea-Bissau","GY":"Guyana","HT":"Haiti","HM":"Heard Island and McDonald Islands","VA":"Holy See (Vatican City)","HN":"Honduras","HK":"Hong Kong (SAR)","HU":"Hungary","IS":"Iceland","IN":"India","ID":"Indonesia","IR":"Iran","IQ":"Iraq","IE":"Ireland","IL":"Israel","IT":"Italy","JM":"Jamaica","JP":"Japan","JO":"Jordan","KZ":"Kazakhstan","KE":"Kenya","KI":"Kiribati","KP":"Korea, North","KR":"Korea, South","KW":"Kuwait","KG":"Kyrgyzstan","LA":"Laos","LV":"Latvia","LB":"Lebanon","LS":"Lesotho","LR":"Liberia","LY":"Libya","LI":"Liechtenstein","LT":"Lithuania","LU":"Luxembourg","MO":"Macao","MK":"Macedonia, The Former Yugoslav Republic of","MG":"Madagascar","MW":"Malawi","MY":"Malaysia","MV":"Maldives","ML":"Mali","MT":"Malta","MH":"Marshall Islands","MQ":"Martinique","MR":"Mauritania","MU":"Mauritius","YT":"Mayotte","MX":"Mexico","FM":"Micronesia, Federated States of","MD":"Moldova","MC":"Monaco","MN":"Mongolia","MS":"Montserrat","MA":"Morocco","MZ":"Mozambique","NA":"Namibia","NR":"Nauru","NP":"Nepal","NL":"Netherlands","AN":"Netherlands Antilles","NC":"New Caledonia","NZ":"New Zealand","NI":"Nicaragua","NE":"Niger","NG":"Nigeria","NU":"Niue","NF":"Norfolk Island","MP":"Northern Mariana Islands","NO":"Norway","OM":"Oman","PK":"Pakistan","PW":"Palau","PA":"Panama","PG":"Papua New Guinea","PY":"Paraguay","PE":"Peru","PH":"Philippines","PN":"Pitcairn Islands","PL":"Poland","PT":"Portugal","PR":"Puerto Rico","QA":"Qatar","RE":"Reunion","RO":"Romania","RU":"Russia","RW":"Rwanda","SH":"Saint Helena","KN":"Saint Kitts and Nevis","LC":"Saint Lucia","PM":"Saint Pierre and Miquelon","VC":"Saint Vincent and the Grenadines","WS":"Samoa","SM":"San Marino","ST":"Sao Tome and Principe","SA":"Saudi Arabia","SN":"Senegal","SC":"Seychelles","SL":"Sierra Leone","SG":"Singapore","SK":"Slovakia","SI":"Slovenia","SB":"Solomon Islands","SO":"Somalia","ZA":"South Africa","GS":"South Georgia and the South Sandwich Islands","ES":"Spain","LK":"Sri Lanka","SD":"Sudan","SR":"Suriname","SJ":"Svalbard","SZ":"Swaziland","SE":"Sweden","CH":"Switzerland","SY":"Syria","TW":"Taiwan","TJ":"Tajikistan","TZ":"Tanzania","TH":"Thailand","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad and Tobago","TN":"Tunisia","TR":"Turkey","TM":"Turkmenistan","TC":"Turks and Caicos Islands","TV":"Tuvalu","UG":"Uganda","UA":"Ukraine","AE":"United Arab Emirates","GB":"United Kingdom","US":"United States","UM":"United States Minor Outlying Islands","UY":"Uruguay","UZ":"Uzbekistan","VU":"Vanuatu","VE":"Venezuela","VN":"Vietnam","VI":"Virgin Islands","WF":"Wallis and Futuna","EH":"Western Sahara","YE":"Yemen","YU":"Yugoslavia","ZM":"Zambia","ZW":"Zimbabwe","PS":"Palestinian Territory, Occupied"};
var regionCodes = {"AL":"Alabama","AK":"Alaska","AZ":"Arizona","AR":"Arkansas","CA":"California","CO":"Colorado","CT":"Connecticut","DE":"Delaware","DC":"District of Columbia","FL":"Florida","GA":"Georgia","HI":"Hawaii","ID":"Idaho","IL":"Illinois","IN":"Indiana","IA":"Iowa","KS":"Kansas","KY":"Kentucky","LA":"Louisiana","ME":"Maine","MD":"Maryland","MA":"Massachusetts","MI":"Michigan","MN":"Minnesota","MS":"Mississippi","MO":"Missouri","MT":"Montana","NE":"Nebraska","NV":"Nevada","NH":"New Hampshire","NJ":"New Jersey","NM":"New Mexico","NY":"New York","NC":"North Carolina","ND":"North Dakota","OH":"Ohio","OK":"Oklahoma","OR":"Oregon","PA":"Pennsylvania","RI":"Rhode Island","SC":"South Carolina","SD":"South Dakota","TN":"Tennessee","TX":"Texas","UT":"Utah","VA":"Virginia","WA":"Washington","WV":"West Virginia","WI":"Wisconsin","WY":"Wyoming","VT":"Vermont","US":"United States"};

var token = "";

var application = 1;

var globErrorMessage = '';

var blocked = 0;

var busyFlag = 0;

var globalRefreshUrl = '';

var privateProfileTimer = '';

var currOpt = {s: ",", d: "", c: "0"};

var swfu;

var timeout = 10000;

var landSellRatio = 2;
var financySellQtyMax = 5;

var IE = document.all?true:false;
var tempX = 0;
var tempY = 0;

var execAgain = "";

var fbScr = '';
var msScr = '';
var fb = new Object;
fb['facebook'] = 0;
fb['myspace'] = 0;

var smdObj = new Array();
var landList = new Array();
var bldList = new Array();
var playerProfile = new Array();
var weaponList = new Array();
var armorList = new Array();
var vehicleList = new Array();
var technologyList = new Array();
var miscItemList = new Array();
var missionList = new Array();

var nums = new Array();
nums['loginMinLength'] = 3;
nums['loginMaxLength'] = 10;
nums['passwordMinLength'] = 6;
nums['passwordMaxLength'] = 25;

var timers = new Array();
timers['begin'] = 0;
timers['cashflow'] = new Array();
timers['health'] = new Array();
timers['energy'] = new Array();
timers['stamina'] = new Array();
timers['achflow'] = new Array();

timers['cashflow']['freq'] = 3600;
timers['cashflow']['qty'] = 0;
timers['cashflow']['count'] = -1;
timers['cashflow']['instance'] = '';

timers['health']['freq'] = 180;
timers['health']['qty'] = 0;
timers['health']['count'] = -1;
timers['health']['instance'] = '';

timers['energy']['freq'] = 240;
timers['energy']['qty'] = 0;
timers['energy']['count'] = -1;
timers['energy']['instance'] = '';

timers['stamina']['freq'] = 240;
timers['stamina']['qty'] = 0;
timers['stamina']['count'] = -1;
timers['stamina']['instance'] = '';

timers['achflow']['freq'] = 3600;
timers['achflow']['qty'] = 0;
timers['achflow']['count'] = -1;
timers['achflow']['instance'] = '';

var playStyle = new Array();
playStyle[1] = "The Anarchist";
playStyle[2] = "The Peacekeeper";
playStyle[3] = "The Druid";

var itemTypes = new Array();
itemTypes[1] = "weapon";
itemTypes[2] = "armor";
itemTypes[3] = "vehicle";
itemTypes[4] = "miscItem";

var titles = new Array();
titles['person'] = 'Person';
titles['signin'] = 'Sign in';
titles['signup'] = 'Sign up';
titles['forgot_pass'] = 'Forgot Password';
titles['storypage'] = 'Story';
titles['home'] = 'Home';
titles['messages'] = new Array();
titles['messages']['inbox'] = 'My inbox';
titles['messages']['outbox'] = 'My outbox';
titles['messages']['create'] = 'Create new message';
titles['property'] = new Array();
titles['property']['land'] = 'List of all lands';
titles['property']['building'] = 'List of available buildings';
titles['bank'] = 'Bank';
titles['medic'] = 'Doctor';
titles['recruit'] = new Array();
titles['recruit']['send'] = 'Send invitaions';
titles['recruit']['my'] = 'My invitaions';
titles['recruit']['fromme'] = 'Invitations from me';
titles['squad'] = new Array();
titles['squad']['friends'] = 'Friend list';
titles['squad']['squads'] = 'Squad list';
titles['squad']['requests'] = 'My requests';
titles['inventory'] = new Array();
titles['inventory']['weapon'] = 'Weapon';
titles['inventory']['armor'] = 'Armor';
titles['inventory']['vehicle'] = 'Vehicles';
titles['inventory']['technology'] = 'Technologies';
titles['profile'] = new Array();
titles['profile']['my_public_profile'] = 'My public profile';
titles['profile']['public_profile'] = 'Player\'s Profile: ';
titles['profile']['private_profile'] = 'Private Profile';
titles['profile']['inventory'] = 'Inventory';
titles['profile']['friends'] = 'Friends';
titles['missions'] = new Array();
titles['missions']['main'] = 'Missions';
titles['achievement'] = new Array();
titles['achievement']['bonus'] = 'Achievement Bonus';
titles['achievement']['payment'] = 'Paypal offer';
titles['achievement']['technology'] = 'Technologies';
titles['achievement']['earned'] = 'Earned Achievements';
titles['combat'] = new Array();
titles['combat']['fight'] = 'List of fights';
titles['combat']['hitlist'] = 'Hitlist';
titles['combat']['bounty'] = 'Bounty';
titles['leaders'] = new Array();

var Templates = new Array();
Templates['home'] = new Array();
Templates['faq'] = new Array();
Templates['messages'] = new Array();
Templates['profile'] = new Array();
Templates['recruit'] = new Array();
Templates['property'] = new Array();
Templates['inventory'] = new Array();
Templates['missions'] = new Array();
Templates['combat'] = new Array();
Templates['leadersboard'] = new Array();
Templates['squad'] = new Array();
Templates['bank'] = new Array();
Templates['achievement'] = new Array();
Templates['medic'] = new Array();
Templates['forum'] = new Array();
Templates['missions'] = new Array();
Templates['test'] = new Array();

var achievements = new Array();
achievements[1] = {5: 5, 10: 10, 15: 15, 20: 20, 25: 25, 30: 30, 35: 35, 40: 40, 45: 45, 50: 50, 55: 55, 60: 60, 70: 70, 75: 75, 80: 80, 85: 85, 90: 90, 95: 95, 100: 100};
achievements[2] = {10: 10, 25: 25, 50: 50, 75: 75, 100: 100, 200: 200, 300: 300, 400: 400, 500: 500, 750: 750, 1000: 1000};
achievements[3] = {5: 5, 10: 10, 25: 25, 50: 50, 75: 75, 100: 100, 200: 200, 300: 300, 400: 400, 500: 500, 750: 750, 1000: 1000};
achievements[4] = {10: 10, 20: 20, 30: 30, 40: 40, 50: 50, 60: 60, 70: 70, 80: 80, 90: 90, 100: 100};
achievements[5] = {1: 1};
achievements[6] = {25: 25, 50: 50, 100: 100, 500: 500, 750: 750, 1000: 1000};

var errorList = new Array();
errorList[0] = 'Undefined.';

errorList[1] = 'Sorry, our site is under maintenance. Stay tuned, and come back soon.';

errorList[10000] = 'Access denied.';

errorList[11000] = 'Invalid credentials.';
errorList[11001] = 'Failed to start session.';
errorList[11002] = 'Session has expired. Please login again.';
errorList[11003] = 'This name already exists.';
errorList[11004] = 'This email already registered.';
errorList[11005] = 'Passwords don\'t match.';
errorList[11006] = 'Invalid playing style.';
errorList[11007] = 'Invalid application.';
errorList[11008] = 'Invalid photo.';
errorList[11009] = 'Unknown error.';
errorList[11010] = 'Failed to process photo.';
errorList[11011] = 'Invalid avatar.';
errorList[11012] = 'Failed to add friend.';
errorList[11013] = 'Failed to add squad member.';
errorList[11014] = 'Invalid invitation code.';
errorList[11015] = 'Invalid captcha.';
errorList[11016] = 'Photo too large.';
errorList[11017] = 'Invalid preview token.';
errorList[11018] = 'Invalid confirmation code.';
errorList[11019] = 'Invalid name length.';
errorList[11020] = 'Invalid name.';
errorList[11021] = 'Invalid password length.';
errorList[11022] = 'Invalid email.';
errorList[11023] = 'Invalid confirmation code.';
errorList[11024] = 'Invalid iphone registration code.';
errorList[11025] = 'Invalid DEVICE ID.';
errorList[11026] = 'Duplicate DEVICE ID.';
	
errorList[20000] = 'No such character.';
errorList[20001] = 'Method disabled.';
errorList[20002] = 'Stub method.';
errorList[20003] = 'Invalid application configuration.';
errorList[20004] = 'Invalid character id.';
errorList[20005] = 'Invalid captcha.';
// Parameters
errorList[21000] = 'Invalid param.';
errorList[21001] = 'Message text too large.';
errorList[21002] = 'Message text is empty.';
errorList[21003] = 'Message text is invalid.';
errorList[21004] = 'Unable to edit message.';
errorList[21005] = 'Unable to delete message.';
errorList[21006] = 'Unable to send message.';
errorList[21007] = 'No such message.';
errorList[21008] = "You don't have rights to delete this message.";
errorList[21009] = "Unable to send yourself.";
// Property activities
errorList[22000] = 'Unable to buy.';
errorList[22001] = 'Unable to sell.';
errorList[22002] = 'Need more cash.';
errorList[22003] = 'Need more lands.';
errorList[22004] = 'No free lands.';
errorList[22005] = 'No such building.';
errorList[22006] = 'No such land.';
errorList[22007] = 'You level too low for buying this land.';
errorList[22008] = 'You level too low for buying this building.';
errorList[22009] = 'Unable to buy - not enough cash.';
errorList[22010] = 'Unable to sell - not enough buildings.';
errorList[22011] = 'Unable to sell - not enough lands.';
errorList[22012] = 'Unable To Purchase - Not Enough AP.';
errorList[22013] = 'Unable to buy building - limit exceeded.';
// if price is an item
errorList[22014] = 'Unable to buy - not enough required items.';
errorList[22015] = 'Unable to buy - limit exceeded.';
// Bank activities
errorList[23000] = 'Not enough cash.';
errorList[23001] = 'Not enough cash in bank.';
// Medic activities
errorList[24000] = 'Unable to heal - health is full.';
errorList[24001] = 'Unable to heal - not enough cash.';
errorList[24002] = 'Unable to heal - not enough ACH.';
errorList[24003] = 'Unable to recharge energy - energy is full.';
errorList[24004] = 'Unable to recharge stamina - stamina is full.';
errorList[24005] = 'Unable to recharge energy - not enough ACH.';
errorList[24006] = 'Unable to recharge stamina - not enough ACH.';
// Recruit
errorList[25001] = 'Unable to recruit - already recruited.';
errorList[25002] = 'Failed to accept invite.';
errorList[25003] = 'Failed to cancel invite.';
errorList[25004] = 'Failed to reject invite.';
errorList[25005] = 'Failed to kick.';
errorList[25006] = 'Unable to recruit yourself.';
errorList[25007] = 'Unable to accept yourself.';
errorList[25008] = 'Unable to reject yourself.';
errorList[25009] = 'Unable to cancel yourself.';
errorList[25010] = 'Unable to kick yourself.';
errorList[25011] = 'Unable to send invite - already registered.';
errorList[25012] = 'Unable to send invite - already invited.';
errorList[25013] = 'Unable to send mail.';
// Items
errorList[26000] = 'Invalid item type.';
errorList[26001] = 'No such item.';
errorList[26002] = 'You level too low for buying this item.';
errorList[26003] = 'Unable to sell - not enough items.';
// Mission
errorList[27000] = 'No such mission.';
errorList[27001] = 'Your level too low.';
errorList[27002] = 'Your energy is too low.';
errorList[27003] = 'Your squad too small.';
errorList[27004] = 'You don\'t have required item.';
errorList[27005] = 'Not enough items.';
// Trigger
errorList[28000] = 'Cant execute mission.';
errorList[28001] = 'Cant change energy.';
errorList[28002] = 'Cant change exp.';
errorList[28003] = 'Cant start trigger.';
errorList[28004] = 'Cant change health.';
errorList[28005] = 'Cant change stamina.';
errorList[28006] = 'Cant change gold.';
errorList[28007] = 'Cant change ACH.';
errorList[28008] = 'Can`t fight.';
errorList[28009] = 'Failed to change bounty.';
// Character Stats
errorList[29001] = 'Not enough stat points.';
errorList[29002] = 'Failed to upgrade stats.';
// Database
errorList[30000] = 'Invalid query.';
errorList[30001] = 'Inconsistent data.';

errorList[40000] = 'Profile update failed.';
errorList[40001] = 'Invalid first name.';
errorList[40002] = 'Invalid last name.';

errorList[41000] = 'Timer not started.';
errorList[41001] = 'Timer in progress.';
errorList[41002] = 'Nothing to update.';
errorList[41003] = 'Timer reset not allowed.';

// Technology
errorList[42000] = 'No such technology.';
errorList[42001] = 'You level too low for buying this technology.';
errorList[42002] = 'Invalid technology type.';
errorList[42003] = 'No technologies for character.';
errorList[42004] = 'Unavailable technology - invalid character permissions.';
// Combat
errorList[44000] = 'Invalid opponent.';
errorList[44001] = 'Your health is too low.';
errorList[44002] = 'Opponent\`s health is too low.';
errorList[44003] = 'Your stamina is too low.';
errorList[44004] = 'Opponent\`s stamina is too low.';
errorList[44005] = 'Your level differs.';
errorList[44006] = 'You are unable to retaliate against this player.';
errorList[44007] = 'You are unable to attack this player and claim your own bounty.';
// Bounty
errorList[45000] = 'Unable to set yourself.';
errorList[45001] = 'Unable to set bounty on friend.';
errorList[45002] = 'Unable to set bounty on squad member.';
// Hitlist
errorList[46000] = 'Unable to add yourself.';
errorList[46001] = 'Hitlist size exceed.';
errorList[46002] = 'Unable to add friend.';
errorList[46003] = 'Unable to add squad member.';
errorList[46004] = 'Unable to delete yourself.';
errorList[46005] = 'Unable to add - Already exists.';
// Achievement
errorList[47000] = 'Invalid bonus type.';
errorList[47001] = 'Progress handling.';
errorList[47002] = 'Can`t change name to the same.';
errorList[47003] = 'Can`t change name - already exists.';
errorList[47004] = 'Invalid faction.';
errorList[47005] = 'Can`t change faction to the same.';
errorList[47006] = 'Unable to unassign.';
// Shopoffers
errorList[48000] = 'No such offer.';
//Wall
errorList[49000] = 'Access denied.';
//Forgot password
errorList[50000] = 'Invalid token.';
// Mail invites
errorList[51000] = 'Invalid first name TO.';
errorList[51001] = 'Missing first name TO.';
errorList[51002] = 'Invalid last name TO.';
errorList[51003] = 'Missing last name TO.';
errorList[51004] = 'Invalid first name FROM.';
errorList[51005] = 'Missing first name FROM.';
errorList[51006] = 'Invalid last name FROM.';
errorList[51007] = 'Missing last name FROM.';
//redeem
errorList[52000] = 'No such Redeem code.';
//reset pass
errorList[53000] = 'Invalid token.';