//for directions.js



newX("Code","Country","City","(latitude/longitude)","","")


newX("CA","Costa Rica","San Jose'","9:57:00N 84:05:00W","","")
newX("CA","Panama'","Ciudad de Panama'","9:04:01N 79:22:59W","","")
newX("EU","Rusia","Moscow","55:45:00N 37:37:00E","","")
newX("EU","Alemania","Berlin","52:31:00N 13:20:00E","","")
newX("EU","Inglaterra","London","51:30:00N 0:07:00W","","")
newX("EU","Fransia","Pari's","48:51:00N 2:20:00E","","")
newX("NA","Canada'","Toronto","43:40:12N 79:22:12W","","")
newX("EU","Italia","Rome","41:52:00N 12:37:00E","","")
newX("EU","Espan~a","Madrid","40:26:00N 3:42:00W","","")
newX("SA","Colombia","Bogota'","4:38:00N 74:06:00W","","")
newX("AS","China","Beijing","39:55:00N 116:23:00E","","")
newX("AS","Corea","Seoul","37:35:00N 127:03:00E","","")
newX("AS","Japo'n","Tokyo","35:41:00N 139:44:00E","","")
newX("SA","Uraguay","Montevideo","34:50:00S 56:10:00W","","")
newX("SA","Argentina","Buenos Aires","34:20:00S 58:30:00W","","")
newX("SA","Chile","Santiago","33:26:00S 70:40:00W","","")
newX("ME","Israel","Jerusalem","31:46:00N 35:14:00E","","")
newX("AF","Egipto","Cairo","30:00:00N 31:17:00E","","")
newX("SA","Paraguay","Asuncio'n","25:14:00S 57:31:00W","","")

newX("AS","Vietnam","Hanoi","21:02:00N 105:51:00E","","")



newX("SA","Bolivia","La Paz","16:31:01S 68:10:59W","","")
newX("SA","Brasil","Brasilia","15:52:00S 47:55:00W","","")
newX("CA","Guatemala","Ciudad de Guatemala","14:34:59N 90:31:59W","","")
newX("CA","Honduras","Tegucigalpa","14:04:00N 87:13:00W","","")
newX("CA","El Salvador","San Salvador","13:42:00N 89:07:01W","","")
newX("CA","Nicaragua","Managua","12:10:00N 86:16:00W","","")
newX("SA","Peru'","Lima","12:06:00S 76:55:00W","","")
newX("SA","Venezuela","Caracas","10:30:00N 66:58:00W","","")
newX("SA","Ecuador","Quito","0:07:59S 78:28:59W","","")

newPhrase("CA",111,"[X1:City], [X1:Country], es un ciudad que esta' norte de [X2:City], [X2:Country].//TF:isNorthof(\"[X1:City]\",\"[X2:City]\")")
newPhrase("SA",111,"[X1:City], [X1:Country], es un ciudad que esta' este de [X2:City], [X2:Country].//TF:isEastof(\"[X1:City]\",\"[X2:City]\")")
newPhrase("SA",111,"[X1:City], [X1:Country], es un ciudad que esta' oesta de [X2:City], [X2:Country].//TF:!isEastof(\"[X1:City]\",\"[X2:City]\")")
newPhrase("SA",111,"[X1:City], [X1:Country], es un ciudad que esta' sur de [X2:City], [X2:Country].//TF:!isNorthof(\"[X1:City]\",\"[X2:City]\")")





function isNorthof(a,b){
 return checkdir(a,b,"N")
}

function isEastof(a,b){
 return checkdir(a,b,"E")
}

function checkdir(a,b,nsew){

 var a="00"+latlong(a).split(" ")[nsew=="N"||nsew=="S"?0:1].replace(/\:/g,"")
 var b="00"+latlong(b).split(" ")[nsew=="N"||nsew=="S"?0:1].replace(/\:/g,"")
 var sa=a
 var sb=b
 a=parseFloat("."+a.substring(a.length-8,a.length))
 b=parseFloat("."+b.substring(b.length-8,b.length))
 a=(sa.indexOf("S")>=0||sa.indexOf("W")>=0?-1:1)*a
 b=(sb.indexOf("S")>=0||sb.indexOf("W")>=0?-1:1)*b
 return(a>b)
}

function latlong(city){
 for(var i=0;i<XOptions.length;i++){
  if(XOptions[i][2]==city)return XOptions[i][3]
 }
 return ""
}

//end of functions for directions.js

