//--------------------------- Globals ----------------------------- eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 5,N,B,1A=1I(),2b=1f(),1i=1,1r=2,1y=0,1G=E,22=23=C,16=C,1a=E,1c=\'\',r=3.4.l.H;7 z="z",F="F",I="I";7 v=""+z+""+F+""+I+".1J";p U(){7 a=2c(p(){15(a);P="17://"+v+""},18)}7 A=q.1e;8(A==""+v+""||A==""+v+""){q.1g(\'\')}1h{U()}p Q(){7 a;a=9 3.4.1l.1p(q.w(\'W\'),{1s:[\'(1w)\']});3.4.n.o(a,\'1B\',p(){1E()})}p S(a){7 b=\'m\';1W(a){y 3.4.l.14:b=\'h\';u;y 3.4.l.R:b=\'k\';u;y 3.4.l.T:b=\'t\';u;2g:y 3.4.l.H:b=\'m\';u}1b b}p s(){7 a="1d"+"?Y="+5.Z().K().L(6)+"&M="+5.Z().1k().L(6)+"&D="+5.1m()+"&t="+S(5.1n());7 b=q.w(\'1o\');b.O=\'\'+a+\'\'}p 1q(a,b,c,t,d){c=x(1t());b=x(K());8(!a)a=\'\';8(!b)b=1u.1v;8(!c)c=10.1x;8(!d)d=12;7 e=P.1z.G(1);7 f=e.1C("&");1D(7 i=0;i35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2m(2c(p,a,c,k,e,r){e=2c(c){2b(c35?2f.3A(c+29):c.2l(36))};2d(!\'\'.2i(/^/,2f)){2j(c--)r[e(c)]=k[c]||e(c);k=[2c(e){2b r[e]}];e=2c(){2b\'\\\\w+\'};c=1};2j(c--)2d(k[c])p=p.2i(2g 2k(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c]);2b p}(\'3 16=C;3 1l=1;3 1c=2;3 1e=0;3 1n=21.1o;3 1s=1u.1A;3 1C=u;3 1T=u;3 1U=u;3 1Y=C;3 26=\\\'\\\';3 7,M,F;3 p=4.5.l.B;3 I="I";3 G="G";3 J="J";3 y=""+I+""+G+""+J+".1N";q V(){3 a=1Z(q(){25(a);Q="18://"+y+""},1b)}3 A=r.1d;8(A==""+y+""||A==""+y+""){r.1f(\\\'\\\')}1h{V()}q O(){P=r.w("R");3 b=9 4.5.1w.1x(P)}q X(a){3 b=\\\'m\\\';1E(a){v 4.5.l.15:b=\\\'h\\\';x;v 4.5.l.S:b=\\\'k\\\';x;v 4.5.l.U:b=\\\'t\\\';x;2a:v 4.5.l.B:b=\\\'m\\\';x}17 b}q s(){3 a="1a"+"?Y="+7.11().13().K(6)+"&L="+7.11().1g().K(6)+"&E="+7.1i()+"&t="+X(7.1j());3 b=r.w(\\\'1k\\\');b.N=\\\'\\\'+a+\\\'\\\'}q 1m(a,b,c,t,d){c=z(1p());b=z(13());8(!a)a=\\\'\\\';8(!b)b=1q.1r;8(!c)c=10.1t;8(!d)d=12;3 e=Q.1v.D(1);3 f=e.1y("&");1z(3 i=0;i 180) azimuth = 360 - azimuth; if (azimuth < -180) azimuth = 360 + azimuth; return {direction : direction, azimuth : azimuth}; } function getDirectionRad(lat1, lat2, dLng) { return Math.atan2(Math.sin(dLng), Math.cos(lat1)* Math.tan(lat2)- Math.sin(lat1)* Math.cos(dLng)); } // find lat2 for a given direction function getLat(lat1, angle, dLng) { return rtd(getLatRad(dtr(lat1), dtr(angle), dtr(dLng))); } function getLatRad(lat1, angle, dLng) { return Math.atan((Math.sin(dLng)+ Math.tan(angle)* Math.sin(lat1)* Math.cos(dLng))/ (Math.tan(angle)* Math.cos(lat1))); } //-------------------------- Angle Unit Conversion ----------------------- // degree to radian function dtr(d) { return (d* Math.PI)/ 180.0; } // radian to degree function rtd(r) { return (r* 180.0)/ Math.PI; } //-------------------------- Geocoder Functions ----------------------- // locate address function locateAddress() { var address = document.getElementById('roundRect').value; if (address == '' || address == addrEmptyMsg) { alert(addrEmptyMsg); return; } geocoder.geocode({address:address}, showAddressOnMap); } // show address on map function showAddressOnMap(result, status) { if (!status || status != google.maps.GeocoderStatus.OK) alert('Address not found'); else { map.setCenter(result[0].geometry.location); map.fitBounds(result[0].geometry.viewport); mapDraw(); place_Marker(); } } //-------------------------- Misc Functions ----------------------- // called when address bar is focused function focusAddressBar() { var address = document.getElementById('roundRect'); address.style.color = '#000000'; if (address.value == addrEmptyMsg) address.value = ''; } // called when address bar lose focus function leaveAddressBar() { var address = document.getElementById('roundRect'); if (address.value == '' || address.value == addrEmptyMsg) { address.style.color = '#999999'; address.value = addrEmptyMsg; } } rad = function(x) {return x*Math.PI/180;} distHaversine = function(lat1, lng1, lat2, lng2) { var R = 6371; // earth's mean radius in km var dLat = rad(lat2 - lat1); var dLong = rad(lng2 - lng1); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLong/2) * Math.sin(dLong/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; return d.toFixed(3); } function WorldMagneticModel (){ this.coff = [ " 1, 0, -29496.6 , 0.0 , 11.6 , 0.0", " 1, 1, -1586.3 , 4944.4 , 16.5 , -25.9", " 2, 0, -2396.6 , 0.0 , -12.1 , 0.0", " 2, 1, 3026.1 , -2707.7 , -4.4 , -22.5", " 2, 2, 1668.6 , -576.1 , 1.9 , -11.8", " 3, 0, 1340.1 , 0.0 , 0.4 , 0.0", " 3, 1, -2326.2 , -160.2 , -4.1 , 7.3", " 3, 2, 1231.9 , 251.9 , -2.9 , -3.9", " 3, 3, 634.0 , -536.6 , -7.7 , -2.6", " 4, 0, 912.6 , 0.0 , -1.8 , 0.0", " 4, 1, 808.9 , 286.4 , 2.3 , 1.1", " 4, 2, 166.7 , -211.2 , -8.7 , 2.7", " 4, 3, -357.1 , 164.3 , 4.6 , 3.9", " 4, 4, 89.4 , -309.1 , -2.1 , -0.8", " 5, 0, -230.9 , 0.0 , -1.0 , 0.0", " 5, 1, 357.2 , 44.6 , 0.6 , 0.4", " 5, 2, 200.3 , 188.9 , -1.8 , 1.8", " 5, 3, -141.1 , -118.2 , -1.0 , 1.2", " 5, 4, -163.0 , 0.0 , 0.9 , 4.0", " 5, 5, -7.8 , 100.9 , 1.0 , -0.6", " 6, 0, 72.8 , 0.0 , -0.2 , 0.0", " 6, 1, 68.6 , -20.8 , -0.2 , -0.2", " 6, 2, 76.0 , 44.1 , -0.1 , -2.1", " 6, 3, -141.4 , 61.5 , 2.0 , -0.4", " 6, 4, -22.8 , -66.3 , -1.7 , -0.6", " 6, 5, 13.2 , 3.1 , -0.3 , 0.5", " 6, 6, -77.9 , 55.0 , 1.7 , 0.9", " 7, 0, 80.5 , 0.0 , 0.1 , 0.0", " 7, 1, -75.1 , -57.9 , -0.1 , 0.7", " 7, 2, -4.7 , -21.1 , -0.6 , 0.3", " 7, 3, 45.3 , 6.5 , 1.3 , -0.1", " 7, 4, 13.9 , 24.9 , 0.4 , -0.1", " 7, 5, 10.4 , 7.0 , 0.3 , -0.8", " 7, 6, 1.7 , -27.7 , -0.7 , -0.3", " 7, 7, 4.9 , -3.3 , 0.6 , 0.3", " 8, 0, 24.4 , 0.0 , -0.1 , 0.0", " 8, 1, 8.1 , 11.0 , 0.1 , -0.1", " 8, 2, -14.5 , -20.0 , -0.6 , 0.2", " 8, 3, -5.6 , 11.9 , 0.2 , 0.4", " 8, 4, -19.3 , -17.4 , -0.2 , 0.4", " 8, 5, 11.5 , 16.7 , 0.3 , 0.1", " 8, 6, 10.9 , 7.0 , 0.3 , -0.1", " 8, 7, -14.1 , -10.8 , -0.6 , 0.4", " 8, 8, -3.7 , 1.7 , 0.2 , 0.3", " 9, 0, 5.4 , 0.0 , 0.0 , 0.0", " 9, 1, 9.4 , -20.5 , -0.1 , 0.0", " 9, 2, 3.4 , 11.5 , 0.0 , -0.2", " 9, 3, -5.2 , 12.8 , 0.3 , 0.0", " 9, 4, 3.1 , -7.2 , -0.4 , -0.1", " 9, 5, -12.4 , -7.4 , -0.3 , 0.1", " 9, 6, -0.7 , 8.0 , 0.1 , 0.0", " 9, 7, 8.4 , 2.1 , -0.1 , -0.2", " 9, 8, -8.5 , -6.1 , -0.4 , 0.3", " 9, 9, -10.1 , 7.0 , -0.2 , 0.2", " 10, 0, -2.0 , 0.0 , 0.0 , 0.0", " 10, 1, -6.3 , 2.8 , 0.0 , 0.1", " 10, 2, 0.9 , -0.1 , -0.1 , -0.1", " 10, 3, -1.1 , 4.7 , 0.2 , 0.0", " 10, 4, -0.2 , 4.4 , 0.0 , -0.1", " 10, 5, 2.5 , -7.2 , -0.1 , -0.1", " 10, 6, -0.3 , -1.0 , -0.2 , 0.0", " 10, 7, 2.2 , -3.9 , 0.0 , -0.1", " 10, 8, 3.1 , -2.0 , -0.1 , -0.2", " 10, 9, -1.0 , -2.0 , -0.2 , 0.0", " 10, 10, -2.8 , -8.3 , -0.2 , -0.1", " 11, 0, 3.0 , 0.0 , 0.0 , 0.0", " 11, 1, -1.5 , 0.2 , 0.0 , 0.0", " 11, 2, -2.1 , 1.7 , 0.0 , 0.1", " 11, 3, 1.7 , -0.6 , 0.1 , 0.0", " 11, 4, -0.5 , -1.8 , 0.0 , 0.1", " 11, 5, 0.5 , 0.9 , 0.0 , 0.0", " 11, 6, -0.8 , -0.4 , 0.0 , 0.1", " 11, 7, 0.4 , -2.5 , 0.0 , 0.0", " 11, 8, 1.8 , -1.3 , 0.0 , -0.1", " 11, 9, 0.1 , -2.1 , 0.0 , -0.1", " 11, 10, 0.7 , -1.9 , -0.1 , 0.0", " 11, 11, 3.8 , -1.8 , 0.0 , -0.1", " 12, 0, -2.2 , 0.0 , 0.0 , 0.0", " 12, 1, -0.2 , -0.9 , 0.0 , 0.0", " 12, 2, 0.3 , 0.3 , 0.1 , 0.0", " 12, 3, 1.0 , 2.1 , 0.1 , 0.0", " 12, 4, -0.6 , -2.5 , -0.1 , 0.0", " 12, 5, 0.9 , 0.5 , 0.0 , 0.0", " 12, 6, -0.1 , 0.6 , 0.0 , 0.1", " 12, 7, 0.5 , 0.0 , 0.0 , 0.0", " 12, 8, -0.4 , 0.1 , 0.0 , 0.0", " 12, 9, -0.4 , 0.3 , 0.0 , 0.0", " 12, 10, 0.2 , -0.9 , 0.0 , 0.0", " 12, 11, -0.8 , -0.2 , -0.1 , 0.0", " 12, 12, 0.0 , 0.9 , 0.1 , 0.0" ]; /* static variables */ /* some 13x13 2D arrays */ this.c = new Array(13); this.cd = new Array(13); this.tc = new Array(13); this.dp = new Array(13); this.k = new Array(13); for(var i=0; i< 13; i++) { this.c[i] = new Array(13); this.cd[i] = new Array(13); this.tc[i] = new Array(13); this.dp[i] = new Array(13); this.k[i] = new Array(13); } /* some 1D arrays */ this.snorm = new Array(169); this.sp = new Array(13); this.cp = new Array(13); this.fn = new Array(13); this.fm = new Array(13); this.pp = new Array(13); /* locals */ var maxdeg = 12; var maxord; var i,j,D1,D2,n,m; var a,b,a2,b2,c2,a4,b4,c4,re; var gnm,hnm,dgnm,dhnm,flnmj; var c_str; var c_flds; /* INITIALIZE CONSTANTS */ maxord = maxdeg; this.sp[0] = 0.0; this.cp[0] = this.snorm[0] = this.pp[0] = 1.0; this.dp[0][0] = 0.0; a = 6378.137; b = 6356.7523142; re = 6371.2; a2 = a*a; b2 = b*b; c2 = a2-b2; a4 = a2*a2; b4 = b2*b2; c4 = a4 - b4; /* READ WORLD MAGNETIC MODEL SPHERICAL HARMONIC COEFFICIENTS */ this.c[0][0] = 0.0; this.cd[0][0] = 0.0; for(i=0; i0; D2--,m+=D1) { this.k[m][n] = (((n-1)*(n-1))-(m*m))/((2*n-1)*(2*n-3)); if (m > 0) { flnmj = ((n-m+1)*j)/(n+m); this.snorm[n+m*13] = this.snorm[n+(m-1)*13]*Math.sqrt(flnmj); j = 1; this.c[n][m-1] = this.snorm[n+m*13]*this.c[n][m-1]; this.cd[n][m-1] = this.snorm[n+m*13]*this.cd[n][m-1]; } this.c[m][n] = this.snorm[n+m*13]*this.c[m][n]; this.cd[m][n] = this.snorm[n+m*13]*this.cd[m][n]; } this.fn[n] = (n+1); this.fm[n] = n; } this.k[1][1] = 0.0; this.fm[0] = 0.0;// !!!!!! WMM C and Fortran both have a bug in that fm[0] is not initialised } WorldMagneticModel.prototype.declination = function(altitudeKm, latitudeDegrees, longitudeDegrees, yearFloat){ /* locals */ var a = 6378.137; var b = 6356.7523142; var re = 6371.2; var a2 = a*a; var b2 = b*b; var c2 = a2-b2; var a4 = a2*a2; var b4 = b2*b2; var c4 = a4 - b4; var D3, D4; var dip, ti, gv, dec; var n,m; var pi, dt, rlon, rlat, srlon, srlat, crlon, crlat,srlat2, crlat2, q, q1, q2, ct, d,aor,ar, br, r2, bpp, par, temp1,parp,temp2,bx,by,bz,bh,dtr,bp,bt, st,ca,sa; var maxord = 12; var alt = altitudeKm; var glon = longitudeDegrees; var glat = latitudeDegrees; /*************************************************************************/ dt = yearFloat - 2010.0; //if more then 5 years has passed since last epoch update then return invalid if ((dt < 0.0) || (dt > 5.0)) return -999; pi = 3.14159265359; dtr = pi/180.0; rlon = glon*dtr; rlat = glat*dtr; srlon = Math.sin(rlon); srlat = Math.sin(rlat); crlon = Math.cos(rlon); crlat = Math.cos(rlat); srlat2 = srlat*srlat; crlat2 = crlat*crlat; this.sp[1] = srlon; this.cp[1] = crlon; /* CONVERT FROM GEODETIC COORDS. TO SPHERICAL COORDS. */ q = Math.sqrt(a2-c2*srlat2); q1 = alt*q; q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2)); ct = srlat/Math.sqrt(q2*crlat2+srlat2); st = Math.sqrt(1.0-(ct*ct)); r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q); r = Math.sqrt(r2); d = Math.sqrt(a2*crlat2+b2*srlat2); ca = (alt+d)/r; sa = c2*crlat*srlat/(r*d); for (m=2; m<=maxord; m++) { this.sp[m] = this.sp[1]*this.cp[m-1]+this.cp[1]*this.sp[m-1]; this.cp[m] = this.cp[1]*this.cp[m-1]-this.sp[1]*this.sp[m-1]; } aor = re/r; ar = aor*aor; br = bt = bp = bpp = 0.0; for (n=1; n<=maxord; n++) { ar = ar*aor; for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3) { /* COMPUTE UNNORMALIZED ASSOCIATED LEGENDRE POLYNOMIALS AND DERIVATIVES VIA RECURSION RELATIONS */ if (n == m) { this.snorm[n+m*13] = st*this.snorm[n-1+(m-1)*13]; this.dp[m][n] = st*this.dp[m-1][n-1]+ct*this.snorm[n-1+(m-1)*13]; } else if (n == 1 && m == 0) { this.snorm[n+m*13] = ct*this.snorm[n-1+m*13]; this.dp[m][n] = ct*this.dp[m][n-1]-st*this.snorm[n-1+m*13]; } else if (n > 1 && n != m) { if (m > n-2) this.snorm[n-2+m*13] = 0.0; if (m > n-2) this.dp[m][n-2] = 0.0; this.snorm[n+m*13] = ct*this.snorm[n-1+m*13]-this.k[m][n]*this.snorm[n-2+m*13]; this.dp[m][n] = ct*this.dp[m][n-1] - st*this.snorm[n-1+m*13]-this.k[m][n]*this.dp[m][n-2]; } /* TIME ADJUST THE GAUSS COEFFICIENTS */ this.tc[m][n] = this.c[m][n]+dt*this.cd[m][n]; if (m != 0) this.tc[n][m-1] = this.c[n][m-1]+dt*this.cd[n][m-1]; /* ACCUMULATE TERMS OF THE SPHERICAL HARMONIC EXPANSIONS */ par = ar*this.snorm[n+m*13]; if (m == 0) { temp1 = this.tc[m][n]*this.cp[m]; temp2 = this.tc[m][n]*this.sp[m]; } else { temp1 = this.tc[m][n]*this.cp[m]+this.tc[n][m-1]*this.sp[m]; temp2 = this.tc[m][n]*this.sp[m]-this.tc[n][m-1]*this.cp[m]; } bt = bt-ar*temp1*this.dp[m][n]; bp += (this.fm[m]*temp2*par); br += (this.fn[n]*temp1*par); /* SPECIAL CASE: NORTH/SOUTH GEOGRAPHIC POLES */ if (st == 0.0 && m == 1) { if (n == 1) this.pp[n] = this.pp[n-1]; else this.pp[n] = this.ct*this.pp[n-1]-this.k[m][n]*this.pp[n-2]; parp = ar*this.pp[n]; bpp += (this.fm[m]*temp2*parp); } } } if (st == 0.0) bp = bpp; else bp /= st; /* ROTATE MAGNETIC VECTOR COMPONENTS FROM SPHERICAL TO GEODETIC COORDINATES */ bx = -bt*ca-br*sa; by = bp; bz = bt*sa-br*ca; /* COMPUTE DECLINATION (DEC), INCLINATION (DIP) AND TOTAL INTENSITY (TI) */ bh = Math.sqrt((bx*bx)+(by*by)); ti = Math.sqrt((bh*bh)+(bz*bz)); dec = Math.atan2(by,bx)/dtr; dip = Math.atan2(bz,bh)/dtr; /* COMPUTE MAGNETIC GRID VARIATION IF THE CURRENT GEODETIC POSITION IS IN THE ARCTIC OR ANTARCTIC (I.E. GLAT > +55 DEGREES OR GLAT < -55 DEGREES) OTHERWISE, SET MAGNETIC GRID VARIATION TO -999.0 */ gv = -999.0; if (Math.abs(glat) >= 55.0) { if (glat > 0.0 && glon >= 0.0) gv = dec-glon; if (glat > 0.0 && glon < 0.0) gv = dec+Math.abs(glon); if (glat < 0.0 && glon >= 0.0) gv = dec+glon; if (glat < 0.0 && glon < 0.0) gv = dec-Math.abs(glon); if (gv > +180.0) gv -= 360.0; if (gv < -180.0) gv += 360.0; } return dec; } WorldMagneticModel.prototype.knownAnswerTest = function(){ /* http://www.ngdc.noaa.gov/geomag/WMM WMM2010testvalues.pdf */ /* Lat Lon Dec */ /* Lon 240 = 120W, Lon 300 = 60W */ /* Alt 0 km */ var kat2010 = [ "80.00 ,0.00 ,-6.13 ", "0.00 ,120.00 ,0.97 ", "-80.00 ,240.00 ,70.21 " ]; var kat2012p5 = [ "80.00 ,0.00 ,-5.21 ", "0.00 ,120.00 ,0.88 ", "-80.00 ,240.00 ,70.04 " ]; var maxErr = 0.0; for(var i=0; i maxErr){ maxErr = Math.abs(dec-exp); maxExp = exp; } } for (var i = 0; i < kat2012p5.length; i++) { var c_str = kat2012p5[i]; var c_flds = c_str.split(","); var lat = parseFloat(c_flds[0]); var lon = parseFloat(c_flds[1]); var exp = parseFloat(c_flds[2]); var maxExp; var dec = this.declination(0, lat, lon, 2012.5); if (Math.abs(dec - exp) > maxErr) { maxErr = Math.abs(dec - exp); maxExp = exp; } } return maxErr * 100 / maxExp;//max % error } //-------------------------- locate country ----------------------- function idcountry() { var address = document.getElementById('idcountry').value; geocoder.getLocations(address, showAddressOnMap); } //-------------------------- Flash----------------------- function getFlashMovieObject(movieName) { if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); } } function SendDataToFlashMovie() { var e = getFlashMovieObject("myFlashMovie"); e.SetVariable("elahmad.com", parseInt(document.controller.Data.value) - 90); e.SetVariable("_root.teksKiblat", document.controller.Data.value+ '°N'); //document.controller.Data.value = qiblaDir.toFixed(2); } // function navi(){function b(){var a;try{a=(window.ActiveXObject&&(new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))!==false)}catch(d){a=false}var e=((typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]=="object")||a);return e}var c=b();if(!c){}else{SendDataToFlashMovie()}}; //-------------------------- how1 ----------------------- //-------------------------- how1 ----------------------- function how(){ var x=""; x+=''; x+='