var g_Setup = window.external;
var gTvCountryCode = new Array("3;93;Afghanistan;_TVSystem_SECAM",
							   "6;355;Albania;_TVSystem_PAL",
							   "4;213;Algeria;_TVSystem_PAL",
							   "10;684;American Samoa;_TVSystem_NTSC",
							   "8;376;Andorra;_TVSystem_SECAM",
						       "9;244;Angola;_TVSystem_PAL",
							   "11;54;Argentina;_TVSystem_PAL",
							   "7;374;Armenia;_TVSystem_NONE",
							   "302;297;Aruba;_TVSystem_NTSC",
							   "12;61;Australia, Chrismas and Cocos Islands;_TVSystem_PAL",
							   "14;43;Austria;_TVSystem_PAL",
							   "5;994;Azerbaijan;_TVSystem_SECAM",
							   "22;242;Bahamas;_TVSystem_NTSC",
							   "17;973;Bahrain;_TVSystem_PAL",
							   "23;880;Bangladesh;_TVSystem_PAL",
							   "29;375;Belarus;_TVSystem_SECAM",
							   "21;32;Belgium;_TVSystem_PAL",
							   "24;501;Belize;_TVSystem_NTSC",
							   "28;229;Benin;_TVSystem_SECAM",
							   "20;441;Bermuda;_TVSystem_NTSC",
							   "26;591;Bolivia;_TVSystem_NTSC",
							   "25;387;Bosnia Herzegovina;_TVSystem_PAL",
							   "19;267;Botswana;_TVSystem_PAL",
							   "32;55;Brazil;_TVSystem_PAL",
							   "37;673;Brunei;_TVSystem_PAL",
							   "35;359;Bulgaria;_TVSystem_SECAM",
							   "245;226;Burkina Faso;_TVSystem_SECAM",
							   "27;95;Burma (Union of Myanmar);_TVSystem_NTSC",
							   "38;257;Burundi;_TVSystem_SECAM",
							   "40;855;Cambodia;_TVSystem_SECAM",
							   "49;237;Cameroon;_TVSystem_PAL",
							   "39;2;Canada;_TVSystem_NTSC",
							   "57;238;Cape Verde Islands;_TVSystem_PAL",
							   "307;345;Cayman Island;_TVSystem_PAL",
							   "55;236;Central African Republic;_TVSystem_SECAM",
							   "41;235;Chad;_TVSystem_SECAM",
							   "46;56;Chile;_TVSystem_NTSC",
							   "45;86;China;_TVSystem_PAL",
							   "45;860755;China ShenZhen Area;_TVSystem_PAL",
							   "51;57;Colombia;_TVSystem_NTSC",
							   "312;682;Cook Islands;_TVSystem_PAL",
							   "54;506;Costa Rica;_TVSystem_NTSC",
							   "108;385;Croatia;_TVSystem_PAL",
							   "323;53;Cuba, Guantanamo Bay;_TVSystem_NTSC",
							   "59;357;Cyprus;_TVSystem_PAL",
							   "75;420;Czech Republic;_TVSystem_SECAM",
							   "61;45;Denmark;_TVSystem_PAL",
							   "314;246;Diego Garcia ;_TVSystem_NTSC",
							   "62;253;Djibouti;_TVSystem_SECAM",
							   "0xFFFFFFFF;809;Dominian Republic;_TVSystem_NTSC",
							   "66;593;Ecuador;_TVSystem_NTSC",
							   "67;20;Egypt;_TVSystem_PAL",
							   "72;503;El Salvador;_TVSystem_NTSC",
							   "69;240;Equatorial Guinea;_TVSystem_SECAM",
							   "70;372;Estonia;_TVSystem_SECAM",
							   "73;251;Ethiopia;_TVSystem_PAL",
							   "315;500;Falkland Islands (Islas Malvinas);_TVSystem_PAL",
							   "81;298;Faroe Islands;_TVSystem_PAL",
							   "78;679;Fiji Islands;_TVSystem_NTSC",
							   "77;358;Finland;_TVSystem_PAL",
							   "84;33;France;_TVSystem_SECAM",
							   "330;596;French Antilles (Martinique);_TVSystem_SECAM",
							   "317;594;French Guiana;_TVSystem_SECAM",
							   "318;689;French Polynesia;_TVSystem_SECAM",
							   "87;241;Gabon;_TVSystem_SECAM",
							   "86;220;Gambia;_TVSystem_PAL",
							   "88;995;Georgia;_TVSystem_SECAM",
							   "94;49;Germany;_TVSystem_PAL",
							   "89;233;Ghana;_TVSystem_PAL",
							   "90;350;Gibraltar;_TVSystem_PAL",
							   "98;30;Greece;_TVSystem_SECAM",
							   "93;299;Greenland;_TVSystem_PAL",
							   "321;590;Guadeloupe;_TVSystem_SECAM",
							   "322;671;Guam;_TVSystem_NTSC",
							   "99;502;Guatemala;_TVSystem_NTSC",
							   "100;224;Guinea Republic;_TVSystem_PAL",
							   "196;245;Guinea-Bissau;_TVSystem_PAL",
							   "101;592;Guyana;_TVSystem_NTSC",
							   "103;509;Haiti;_TVSystem_NTSC",
							   "106;504;Honduras;_TVSystem_NTSC",
							   "104;852;Hong Kong;_TVSystem_PAL",
							   "109;36;Hungary;_TVSystem_SECAM",
							   "110;354;Iceland;_TVSystem_PAL",
							   "113;91;India;_TVSystem_PAL",
							   "111;62;Indonesia;_TVSystem_PAL",
							   "116;98;Iran;_TVSystem_SECAM",
							   "121;964;Iraq;_TVSystem_SECAM",
							   "68;353;Ireland;_TVSystem_PAL",
							   "117;972;Israel;_TVSystem_PAL",
							   "253;39;Italy, Vatican City;_TVSystem_PAL",
							   "0xFFFFFFFF;225;Ivory Coast (Cote D'Ivoire);_TVSystem_SECAM",
							   "124;876;Jamaica;_TVSystem_NTSC",
							   "122;81;Japan;_TVSystem_NTSC",
							   "126;962;Jordan;_TVSystem_PAL",
							   "137;7001;Kazakhstan;_TVSystem_SECAM",
							   "129;254;Kenya;_TVSystem_PAL",
							   "133;686;Kiribati Republic;_TVSystem_NONE",
							   "131;850;Korea (North);_TVSystem_SECAM",
							   "134;82;Korea (South);_TVSystem_NTSC",
							   "136;965;Kuwait;_TVSystem_PAL",
							   "130;7002;Kyrgyzstan;_TVSystem_SECAM",
							   "138;856;Laos;_TVSystem_NONE",
							   "140;371;Latvia;_TVSystem_PAL",
							   "139;961;Lebanon;_TVSystem_SECAM",
							   "146;266;Lesotho;_TVSystem_PAL",
							   "142;231;Liberia;_TVSystem_PAL",
							   "148;218;Libya;_TVSystem_SECAM",
							   "141;370;Lithuania;_TVSystem_SECAM",
							   "147;352;Luxembourg;_TVSystem_PAL",
							   "151;853;Macau;_TVSystem_PAL",
							   "19618;389;Macedonia;_TVSystem_PAL",
							   "149;261;Madagascar;_TVSystem_SECAM",
							   "156;265;Malawi;_TVSystem_PAL",
							   "167;60;Malaysia;_TVSystem_PAL",
							   "165;960;Maldives;_TVSystem_PAL",
							   "157;223;Mali;_TVSystem_SECAM",
							   "163;356;Malta;_TVSystem_PAL",
							   "199;692;Marshall Islands;_TVSystem_NTSC",
							   "162;222;Mauritania;_TVSystem_SECAM",
							   "160;230;Mauritius;_TVSystem_SECAM",
							   "331;269;Mayotte Island, Comoros;_TVSystem_NONE",
							   "166;52;Mexico;_TVSystem_NTSC",
							   "80;691;Micronesia;_TVSystem_NTSC",
							   "21242;808;Midway Islands, Wake Island;_TVSystem_NTSC",
							   "152;373;Moldova;_TVSystem_NONE",
							   "158;377;Monaco;_TVSystem_SECAM",
							   "154;976;Mongolia;_TVSystem_SECAM",
							   "159;212;Morocco;_TVSystem_SECAM",
							   "168;258;Mozambique;_TVSystem_PAL",
							   "27;95;Myanmar;_TVSystem_NTSC",
							   "254;264;Namibia;_TVSystem_PAL",
							   "178;977;Nepal;_TVSystem_PAL",
							   "176;31;Netherlands;_TVSystem_PAL",
							   "133;599;Netherlands Antilles;_TVSystem_PAL",
							   "334;687;New Caledonia;_TVSystem_SECAM",
							   "183;64;New Zealand;_TVSystem_PAL",
							   "182;505;Nicaragua;_TVSystem_NTSC",
							   "173;227;Niger;_TVSystem_SECAM",
							   "175;234;Nigeria;_TVSystem_PAL",
							   "336;672;Norfolk Island;_TVSystem_PAL",
							   "177;47;Norway;_TVSystem_PAL",
							   "164;968;Oman;_TVSystem_PAL",
							   "190;92;Pakistan;_TVSystem_PAL",
							   "195;680;Palau;_TVSystem_NTSC",
							   "192;507;Panama;_TVSystem_NTSC",
							   "194;675;Papua New Guinea;_TVSystem_PAL",
							   "185;595;Paraguay;_TVSystem_PAL",
							   "187;51;Peru;_TVSystem_NTSC",
							   "201;63;Philippines;_TVSystem_NTSC",
							   "191;48;Poland;_TVSystem_SECAM",
							   "193;351;Portugal;_TVSystem_PAL",
							   "202;787;Puerto Rico;_TVSystem_NTSC",
							   "197;974;Qatar;_TVSystem_PAL",
							   "198;262;Reunion Island;_TVSystem_SECAM",
							   "200;40;Romania;_TVSystem_SECAM",
							   "203;7;Russia;_TVSystem_PAL",
							   "204;250;Rwanda;_TVSystem_SECAM",
							   "214;378;San Marino;_TVSystem_NONE",
							   "0xFFFFFFFF;239;Sao Tome and Principe;_TVSystem_NONE",
							   "205;966;Saudi Arabia;_TVSystem_SECAM",
							   "210;221;Senegal Republic;_TVSystem_SECAM",
							   "208;248;Seychelle Islands;_TVSystem_PAL",
							   "213;232;Sierra Leone;_TVSystem_PAL",
							   "215;65;Singapore;_TVSystem_PAL",
							   "143;421;Slovakia;_TVSystem_SECAM",
							   "212;386;Slovenia;_TVSystem_PAL",
							   "30;677;Solomon Islands;_TVSystem_PAL",
							   "216;252;Somalia;_TVSystem_PAL",
							   "209;27;South Africa;_TVSystem_PAL",
							   "217;34;Spain;_TVSystem_PAL",
							   "42;94;Sri Lanka;_TVSystem_PAL",
							   "206;508;St. Pierre and Miquelon;_TVSystem_SECAM",
							   "219;249;Sudan;_TVSystem_PAL",
							   "181;597;Suriname;_TVSystem_NTSC",
							   "260;268;Swaziland;_TVSystem_PAL",
							   "221;46;Sweden;_TVSystem_PAL",
							   "223;41;Switzerland, Liechtenstein;_TVSystem_PAL",
							   "222;963;Syria;_TVSystem_SECAM",
							   "237;886;Taiwan;_TVSystem_NTSC",
							   "228;7003;Tajikistan;_TVSystem_SECAM",
							   "239;255;Tanzania;_TVSystem_PAL",
							   "227;66;Thailand;_TVSystem_PAL",
							   "232;228;Togo;_TVSystem_SECAM",
							   "231;676;Tonga;_TVSystem_PAL",
							   "225;1868;Trinidad and Tobago;_TVSystem_NTSC",
							   "234;216;Tunisia;_TVSystem_SECAM",
							   "349;1649;Turks and Caicos Islands;_TVSystem_NONE",
							   "235;90;Turkey;_TVSystem_PAL",
							   "238;7004;Turkmenistan;_TVSystem_SECAM",
							   "240;256;Uganda;_TVSystem_PAL",
							   "241;380;Ukraine;_TVSystem_SECAM",
							   "224;971;United Arab Emirates;_TVSystem_PAL",
							   "242;44;United Kingdom;_TVSystem_PAL",
							   "244;1;United States;_TVSystem_NTSC",
							   "246;598;Uruguay;_TVSystem_NONE",
							   "252;340;U.S. Virgin Islands;_TVSystem_NTSC",
							   "247;7005;Uzbekistan;_TVSystem_SECAM",
							   "249;58;Venezuela;_TVSystem_NTSC",
							   "251;84;Vietnam;_TVSystem_PAL",
							   "352;681;Wallis and Futuna Islands;_TVSystem_SECAM",
							   "217;34;Western Sahara;_TVSystem_PAL",
							   "259;685;Western Samoa;_TVSystem_NONE",
							   "261;967;Yemen Arab Repulic;_TVSystem_PAL",
							   "44;243;Zaire (Congo (DRC));_TVSystem_NONE",
							   "263;260;Zambia;_TVSystem_PAL",
							   "239;259;Zanzibar;_TVSystem_PAL",
							   "264;263;Zimbabwe;_TVSystem_PAL"
							   ); 

	function ConvertTvVal(TVformat)
	{	
		var strValue; 
		
		switch (TVformat)
		{
		case "_TVSystem_PAL":
		case "_TVSystem_SECAM":
			strValue = "2";
			break;
		default :
		case "_TVSystem_NTSC":
		case "_TVSystem_NONE":
			strValue = "1";
			break;
		}
		return (strValue);
	}
	
	function ConvertDefLangCode(Lang)
	{	
		var strValue; 
		
		switch (Lang)
		{
		case "CS":			 // Chinese (Simplified)
			strValue = "86";
			break;
		case "CT":			 // Chinese (Tradtional)
			strValue = "886";
			break;
		case "NL":           // Dutch
			strValue = "31";
			break;
		case "FR":           // Frence(France)
			strValue = "33";
			break;
		case "DE":           // German
			strValue = "49";
			break;
		case "IT":           // Italian
			strValue = "39";
			break;
		case "JP":           // Japanese
			strValue = "81";
			break;
		case "KR":           // Korean
			strValue = "82";
			break;
		case "BR":           // Portuguese (Brazil)
			strValue = "55";
			break;
		case "ES":           // Spanish
			strValue = "34";
			break;
		case "PL":           // Polish
			strValue = "48";
			break;
		case "PT":           // Portuguese (Portugal)
			strValue = "351";
			break;
		case "NO":           // Norwegian
			strValue = "47";
			break;
		case "SV":           // Sweden
			strValue = "46";
			break;
		case "DK":           // Danish
			strValue = "45";
			break;
		case "TR":           // Turkey
			strValue = "90";
			break;
		case "SU":           // Finnish
			strValue = "358";
			break;
		case "TH":           // Thai
			strValue = "66";
			break;
		case "RU":           // Russian
			strValue = "7";
			break;
		default :	         // English
		case "EN":			 // English
			strValue = "1";
			break;
		}
		return (strValue);
	}

	// get TV informations from TVdef.js 
	function GetTVFormat(countryCode)
	{
		var TvInfo, TvFormat, strSemiColon = ";";
		
		for (var x = 0; x < gTvCountryCode.length; x++)
		{
			TvInfo = gTvCountryCode[x].split(strSemiColon);
			if (countryCode == TvInfo[1])
				TvFormat = ConvertTvVal(TvInfo[3]);
		}
		return (TvFormat);
	}

	function SetProperty(obj)
	{
		if (null != obj)
		{
			g_Setup.SetProperty("COUNTRY_CODE", obj.value);
			g_Setup.SetProperty("TV_FORMAT", GetTVFormat(obj.value));
		}
	}
