<?php
 // Interactive Map of India - RJM Programming - December, 2014
 // Thanks to Wikipedia and Google and Mobilefish and Maps of India
 //http://www.rjmprogramming.com.au/PHP/BubbleChart/bubble_chart.php?title=Correlation%20between%20Literacy,%20Population%20Density%20and%20Population%20of%20India&label=%27ID%27&value=Literacy,Population%20Density,%27Region%27,Population&data=,%20[~~,0.9,0.8,%27Kerala%27,2000000]%20,%20[~~,0.3,0.2,%27Uttar%20Pradesh%27,1000000]
 //http://www.rjmprogramming.com.au/PHP/TreemapChart/treemap_chart.php?title=Literacy%20versus%20Population%20Density%20in%202011%20in%20India&label=%27India%27&value=%27Region%27,%20%27Literacy%20%28%%29%27,%20%27Population%20Density%20%28per%20square%20km%29%27&data=,%20[~India~,null,0,0]%20,%20[~Kerala~,%27India%27,10,10]%20,%20[~Tamil%20Nadu~,%27India%27,20,20]
 //http://www.rjmprogramming.com.au/PHP/Map/map.php?title=Places&label=['Lat',&value='Lon', 'Name']&data=
 //http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Population%20by%20Region%20in%20India&task=Population&desc=Percentage&data=,%20[~Tamil%20Nadu~,10]%20,%20[~Odisha~,90]
 //http://www.rjmprogramming.com.au/PHP/AnnotatedTimelineChart/annotatedtimeline_chart.php?title=Indian%20Region%20Establishment%20Date&desc1=&title1=&text1=&desc2=&title2=&text2=&data=[newDate%281936,4,1%29,1,~Odisha~,~Establishment%20Date~,1,~Odisha~,~Establishment%20Date~],[newDate%282014,11,17%29,1,~Tamil%20Nadu~,~Establishment%20Date~,1,~Tamil%20Nadu~,~Establishment%20Date~],[newDate%282014,11,26%29,1,~Goa~,~Establishment%20Date~,1,~Goa~,~Establishment%20Date~]
 //http://www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php?title=Areas%20of%20Indian%20Regions&label=Region&value=Area%20%28square%20km%29&data=,%20[~Odisha~,123456]%20,%20[~Tamil%20Nadu~,234567]

 $mapstyle = 'usemap="#sh80879"';
 $mapstuff = '';
 $two = 'opacity:0.6;z-index:0';
 $astyle = '';
 $rhs = '';
 $bodystuff = 'setTimeout(later,1000);';
 $udirname = "http://en.wikipedia.org/";
 $divinfo = "";
 $bigcoords = "10,304,14,300,22,302,26,293,35,293,39,293,43,297,47,296,51,294,59,291,61,297,65,297,72,293,66,292,70,287,61,268,61,264,54,262,51,258,53,244,45,243,41,238,41,230,48,224,56,218,56,215,60,211,64,217,65,220,73,217,83,216,90,213,93,205,98,199,100,195,108,191,114,185,117,176,121,170,132,167,130,161,137,153,143,145,142,142,145,137,142,132,145,126,151,124,157,124,161,118,153,115,146,113,143,111,145,107,139,107,125,100,124,92,124,83,123,73,122,67,125,65,130,62,135,60,137,54,133,51,129,50,129,47,129,44,124,42,118,39,117,35,108,35,108,32,109,25,115,23,117,21,118,14,125,14,130,16,134,16,130,11,137,13,143,10,149,9,155,11,160,9,162,14,166,19,177,26,185,30,187,37,199,42,198,45,208,47,212,44,217,40,221,37,230,37,233,33,237,37,247,38,250,44,252,46,249,64,242,68,240,68,240,72,239,78,229,79,228,79,228,83,231,88,227,90,228,96,236,97,239,102,240,109,236,113,231,116,229,116,225,110,218,113,221,124,224,130,226,135,223,135,227,144,231,140,236,145,239,149,246,150,253,155,261,160,268,165,256,175,255,181,255,187,250,197,259,203,260,200,274,208,277,213,287,218,289,215,299,222,301,219,305,225,313,226,316,230,319,226,328,226,331,226,341,227,343,228,344,234,355,239,363,239,363,243,368,244,370,243,380,243,383,247,389,243,390,245,397,246,409,245,413,241,413,234,408,229,410,220,410,216,411,212,421,207,425,208,424,214,425,219,423,222,425,225,425,229,428,233,432,235,438,235,448,235,454,230,464,233,474,233,486,229,493,228,490,224,490,216,480,215,481,209,488,209,491,208,498,208,502,204,501,202,510,195,511,189,524,188,527,178,538,170,539,175,552,176,558,166,564,164,568,169,564,178,573,174,574,179,570,187,573,189,575,187,588,189,594,197,585,204,590,214,589,216,583,209,573,214,568,219,560,224,556,229,550,231,552,241,550,252,548,256,543,260,546,264,544,272,541,282,538,292,527,291,526,292,522,293,522,301,523,312,522,314,518,313,518,322,520,326,518,332,516,337,513,335,508,332,507,324,504,320,503,316,503,309,501,302,501,299,492,300,493,305,490,310,490,314,486,315,484,310,483,313,478,300,479,294,485,292,488,289,490,289,493,284,498,282,498,275,503,275,502,271,496,268,475,269,460,270,449,268,450,260,448,257,450,252,446,249,442,247,440,252,434,251,431,249,430,245,429,247,424,245,419,241,416,244,418,248,414,250,412,256,417,262,421,265,424,265,427,264,425,267,429,269,430,272,424,272,419,272,420,276,416,279,415,281,414,285,420,289,425,292,427,295,424,302,424,306,428,309,430,313,433,314,433,320,435,332,439,344,437,349,430,352,430,340,427,345,426,349,426,352,420,350,417,348,417,341,417,337,413,333,416,339,416,350,406,351,397,355,393,360,395,370,394,379,385,386,375,392,368,396,366,390,360,395,356,403,351,411,343,421,334,427,322,438,314,446,306,452,301,458,302,464,299,468,292,471,287,472,280,472,279,479,273,484,271,484,266,483,256,488,254,497,255,512,256,524,257,534,260,544,257,554,251,566,247,573,248,583,250,595,252,606,250,608,243,604,235,609,234,616,232,621,235,626,230,620,230,625,236,630,228,629,221,632,215,635,213,643,208,650,204,652,199,657,194,653,187,648,183,641,176,632,174,624,176,620,171,612,170,605,166,598,163,588,160,580,153,572,148,562,142,549,138,537,137,531,136,524,135,515,127,507,121,494,120,486,113,477,110,466,110,458,108,446,104,428,102,418,106,413,101,414,101,406,106,408,101,403,100,399,96,396,100,389,105,379,105,371,100,366,98,358,109,352,98,352,98,353,102,346,94,350,97,344,105,341,90,339,91,345,91,346,87,346,87,349,92,357,88,362,81,366,73,370,65,373,54,371,47,361,38,353,32,346,26,338,25,335,32,339,37,334,47,332,54,327,59,323,56,320,49,325,40,327,33,327,23,320,19,316,16,312,21,304,12,309";
 $downbot = '<svg xmlns="http://www.w3.org/2000/svg" style="opacity:0.3;z-index:-2;position:absolute;top:60px;left:10px;" width="600" height="708"></svg>';
 if (isset($_GET['jigsaw'])) {
   //$mapstyle = '';
   $mapstyle = 'usemap="#sh80879"';
   $rhs = 'background-color:red;';
   $two='opacity:0.1;z-index:20;';
   //$bodystuff = ' onclick="fomc(event);" onmousemove="fomm(event);" onmousedown="fomd(event);"';
   $bodystuff = ' ontouchdown="fomd(event);" onmousedown="fomd(event);"';
   $astyle = "\n" . '<style> a { display:none; }  .draggable { cursor: move; } </style>' . "\n";
   $downbot = str_replace('<svg xmlns="http://www.w3.org/2000/svg" style="opacity:0.3;z-index:-2;position:absolute;top:60px;left:10px;" width="600" height="708">', "\n" . '<SVG xmlns="http://www.w3.org/2000/svg" style="opacity:0.95;z-index:-12;position:absolute;top:60px;left:10px;" width="600" height="708" onclick=null;><polygon onclick=null; title="India" alt="white" id="sp0" points="' . $bigcoords . '" fill="yellow" /></SVG><SVG id="newsvg" xmlns="http://www.w3.org/2000/svg" style="opacity:1.0;z-index:-40;position:absolute;top:60px;left:10px;" width="600" height="708"></SVG><svg xmlns="http://www.w3.org/2000/svg" style="opacity:1.0;z-index:13;position:absolute;top:60px;left:610px;background-color:black;" width="1600" height="1708">', $downbot);
   $mapstuff = ' onclick="ffoc(this.id);" ';
 }
 if (isset($_GET['ajaxindiaplusstate'])) {
   if (file_exists(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower(urldecode($_GET['ajaxindiaplusstate']))) . ".smalltalk")) {
     echo "<h1>Thanks to <a target=_blank href='http://en.wikipedia.org/wiki/" . str_replace('National_Capital_Territory_of_New_Delhi', 'Delhi', str_replace('+', '_', str_replace(' ', '_', urldecode($_GET['ajaxindiaplusstate'])))) . "' title='Wikipedia'>Wikipedia</a> ...</h1>" . file_get_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower(urldecode($_GET['ajaxindiaplusstate']))) . ".smalltalk");
     exit;
   }
 } else if (isset($_GET['indiaplusstate'])) {
   if (file_exists(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower(urldecode($_GET['indiaplusstate']))) . ".smalltalk")) {
     $divinfo = "<h1>Thanks to <a target=_blank href='http://en.wikipedia.org/wiki/" . str_replace('National_Capital_Territory_of_New_Delhi', 'Delhi', str_replace('+', '_', str_replace(' ', '_', urldecode($_GET['indiaplusstate'])))) . "' title='Wikipedia'>Wikipedia</a> ...</h1>" . file_get_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower(urldecode($_GET['indiaplusstate']))) . ".smalltalk");
   }
 }
 $bubblechart = "";
 $treemapchart = "";
 $mapchart = "";
 $piechart = "";
 $columnchart = "";
 $timelinechart = "";
 $numstates = 0;
 $wording = array();
 $coordstring = array();
 $urls = array();
 $blurbs = array();
 $literacy = array();
 $population = array();
 $density = array();
 $latis = array();
 $longis = array();
 $cols = array("#afeeee", "#ffe4b5", "#d3d3d3", "#ffdead", "#eee8aa", "#ffebcd", "#fff8dc", "#ffa500", "#faebd7", "#f8f8ff", "#f0fff0", "#fffafa", "#ffffe0", "#e0ffff", "#fff0f5", "#e6e6fa", "#f5f5f5", "#fffacd", "#f0ffff", "#fffff0", "#f5fffa", "#ffefd5", "#f0e68c", "#ffe4c4", "#fdf5e6", "#fffaf0"); //

 $mobilefishstring = '
<img src="political-map.jpg" ' . $mapstyle . ' width="600" height="708" alt="click map" border="0" />
<map id="sh80879" name="sh80879" style="z-index:30;">
<!-- Region 1 Tamil Nadu -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Tamil Nadu") . ' title="Tamil Nadu" coords="190,653,193,645,192,641,191,635,193,629,195,623,192,622,194,610,192,606,186,607,183,597,185,593,181,590,178,586,176,580,172,576,181,576,189,574,198,570,204,565,198,562,202,559,202,551,207,550,214,553,219,553,226,546,232,544,239,543,241,539,248,539,255,534,259,535,259,545,259,551,255,558,250,567,246,575,249,580,249,590,250,598,250,604,242,604,234,610,232,619,229,627,221,631,214,637,211,646,204,651,197,656,191,655" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Tamil+Nadu%22") . ' target="_blank" />
<!-- Region 2 Kerala -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Kerala") . ' title="Kerala" coords="190,651,193,644,190,638,193,633,195,627,196,622,191,621,194,617,192,611,193,607,188,607,185,606,184,604,184,599,185,594,181,592,183,587,181,585,176,585,177,582,173,580,172,576,174,575,170,569,164,570,157,564,153,556,149,554,141,549,148,564,152,569,158,580,165,590,167,600,173,610,173,619,175,622,171,622,175,632,180,638,184,644,191,652" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Kerala%22") . ' target="_blank" />
<!-- Region 3 Goa -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Goa") . ' title="Goa" coords="126,506,130,500,131,492,130,485,127,488,125,491,124,484,121,482,118,487,123,493,123,497,126,502" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Goa%22") . ' target="_blank" />
<!-- Region 4 Jammu and Kashmir -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Jammu and Kashmir") . ' title="Jammu and Kashmir" coords="158,120,170,113,167,104,176,102,186,98,190,104,199,109,207,104,212,112,218,108,219,114,225,111,229,118,233,115,238,113,240,108,237,105,237,96,230,96,227,91,230,89,229,85,227,80,235,79,238,75,241,73,240,71,237,68,242,68,242,65,246,63,248,61,250,56,253,47,253,43,248,40,240,37,235,34,231,34,230,37,225,37,216,39,210,45,206,46,198,46,195,40,189,37,186,32,181,28,174,23,168,19,162,12,160,8,154,12,148,8,141,13,138,17,131,13,133,17,125,15,118,17,113,23,108,29,108,35,113,35,116,35,119,40,127,44,130,45,131,50,134,53,136,55,133,60,128,62,128,64,122,69,124,77,125,84,125,88,124,96,128,101,133,104,139,106,144,108,145,107,145,113,153,116,158,118" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Jammu+and+Kashmir%22") . ' target="_blank" />
<!-- Region 5 Himachal Pradesh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Himachal Pradesh") . ' title="Himachal Pradesh" coords="169,113,169,110,167,105,172,105,176,102,182,99,185,98,189,103,195,106,202,105,205,103,208,109,210,115,217,112,214,110,219,112,218,118,222,125,226,131,225,135,226,143,216,143,210,143,207,148,206,153,205,160,203,164,195,160,193,157,190,154,186,150,183,146,184,142,179,141,178,138,176,142,173,135,168,127,165,124,165,121,170,117" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Himachal+Pradesh%22%22") . ' target="_blank" />
<!-- Region 6 Punjab -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Punjab") . ' title="Punjab" coords="142,172,146,171,154,173,156,178,161,176,166,176,170,178,170,174,172,173,174,168,180,165,182,164,189,161,188,156,187,151,184,148,184,143,177,138,175,141,170,134,169,129,166,126,164,122,169,116,168,113,161,119,156,123,149,125,145,128,144,133,146,136,143,140,144,144,140,148,136,152,133,157,130,163,127,166,124,167,130,170,139,170" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Punjab%22%22") . ' target="_blank" />
<!-- Region 7 Uttarakhand -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Uttarakhand") . ' title="Uttarakhand" coords="205,160,206,157,207,152,210,144,216,144,222,144,230,146,228,144,229,137,234,141,238,146,241,150,246,148,253,154,253,157,260,162,269,165,262,171,255,178,255,182,253,190,250,198,239,194,231,190,225,188,224,187,228,183,222,179,218,175,215,172,213,178,209,178,207,178,203,175,208,169,211,166,206,164" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Uttarakhand%22%22") . ' target="_blank" />
<!-- Region 8 National Capital Territory of New Delhi -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("National Capital Territory of New Delhi") . ' title="National Capital Territory of New Delhi" coords="186,205,188,201,188,198,193,196,196,202,197,205,195,209,193,207,189,205" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22National+Capital+Territory+of+New+Delhi%22") . ' target="_blank" />
<!-- Region 9 Haryana -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Haryana") . ' title="Haryana" coords="196,206,193,207,189,204,186,207,186,204,190,203,189,197,193,194,192,185,194,177,195,170,199,166,203,163,195,161,191,158,191,155,187,152,188,158,187,164,179,169,174,170,173,176,171,177,163,176,158,177,156,180,154,176,151,173,147,170,143,173,142,180,144,187,148,186,153,188,157,188,161,193,162,200,166,204,170,211,170,216,169,220,173,220,175,216,175,213,180,214,188,210,189,215,189,222,193,220,194,220,199,216,200,212,199,207,197,206" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Haryana%22") . ' target="_blank" />
<!-- Region 10 Uttar Pradesh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Uttar Pradesh") . ' title="Uttar Pradesh" coords="202,162,206,166,206,171,206,175,208,178,212,178,213,171,218,179,224,183,227,184,226,186,230,191,237,195,241,198,244,197,249,202,253,199,260,203,261,199,274,208,276,211,289,219,289,216,299,222,304,221,305,224,313,226,315,229,316,225,326,226,327,232,330,237,335,240,337,243,332,243,327,246,331,247,334,251,331,256,338,261,341,264,339,266,335,266,330,268,322,271,318,274,315,279,318,283,322,289,321,291,317,298,317,304,309,305,306,302,305,299,305,294,307,292,304,288,300,289,298,289,294,286,288,284,284,280,281,278,276,279,275,283,267,283,267,279,260,281,257,281,257,277,255,274,247,276,247,279,239,280,238,276,236,278,232,276,227,274,221,278,225,289,230,296,228,300,221,296,218,298,214,291,214,284,218,278,216,274,219,270,226,269,224,266,228,257,231,252,228,245,222,244,214,242,211,239,203,239,197,242,199,237,200,232,196,227,195,223,195,221,199,217,199,207,197,201,194,194,193,186,192,176,196,169,200,166" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Uttar+Pradesh%22") . ' target="_blank" />
<!-- Region 11 Bihar -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Bihar") . ' title="Bihar" coords="412,242,414,246,411,250,406,253,406,256,410,262,412,266,414,267,408,267,406,271,401,270,395,274,393,281,393,286,385,289,378,290,371,284,365,284,365,290,361,290,356,291,352,294,353,293,347,291,342,294,341,296,338,293,335,292,336,287,335,292,332,291,331,288,330,290,326,290,322,289,319,286,317,278,319,273,326,270,330,264,335,264,342,264,340,260,335,260,333,256,331,255,333,249,329,247,333,246,339,243,333,240,333,236,328,229,327,227,335,226,342,228,342,233,353,239,356,240,363,238,365,242,365,246,369,243,377,245,384,246,387,246,389,243,392,246,397,246,401,244,408,245" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Bihar%22") . ' target="_blank" />
<!-- Region 12 Jharkhand -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Jharkhand") . ' title="Jharkhand" coords="406,268,408,274,408,278,408,283,409,286,407,291,403,297,401,301,398,300,396,304,393,304,388,307,381,308,379,308,379,311,372,311,370,314,370,319,376,325,384,323,387,329,388,334,387,339,382,336,377,335,376,333,374,334,372,345,367,343,364,342,358,342,358,344,355,344,353,343,355,340,354,336,345,336,343,337,340,339,335,338,334,336,336,329,341,326,336,325,333,320,333,317,332,315,332,310,329,313,326,306,323,304,320,301,318,297,318,292,321,289,325,290,328,290,333,289,337,292,339,294,344,293,346,292,348,290,349,293,354,293,358,289,363,289,364,284,371,284,376,288,378,289,381,292,382,288,389,286,393,286,393,278,395,273,402,272,403,271" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Jharkhand%22") . ' target="_blank" />
<!-- Region 13 West Bengal -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("West Bengal") . ' title="West Bengal" coords="405,352,404,349,400,347,400,344,395,347,394,345,393,341,389,341,388,339,392,339,389,333,386,328,382,327,385,324,381,323,375,321,371,321,370,319,372,313,373,309,379,313,382,309,387,308,391,303,396,303,400,300,403,296,406,294,408,290,408,287,408,281,408,277,406,272,406,269,406,266,411,265,413,265,409,261,406,257,411,249,412,244,410,242,411,238,411,235,410,232,408,228,413,229,417,228,423,228,424,228,425,228,425,229,426,233,429,234,438,234,439,234,444,235,444,239,444,242,444,246,442,248,441,251,439,253,437,253,434,251,431,245,430,244,428,246,428,246,424,246,421,245,420,243,418,241,418,248,415,249,414,251,413,255,416,259,419,263,423,265,424,263,426,266,429,269,429,271,425,272,424,271,421,270,420,274,419,276,415,278,414,282,414,286,417,289,425,291,425,292,428,297,426,300,424,304,424,306,427,310,428,313,431,315,432,315,432,324,435,331,435,334,435,337,436,341,439,348,436,345,436,341,435,347,435,350,429,348,427,348,430,344,430,340,427,344,427,348,427,350,424,350,420,347,420,345,418,339,415,344,415,349,413,349,409,352,406,352" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22West+Bengal%22") . ' target="_blank" />
<!-- Region 14 Sikkim -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Sikkim") . ' title="Sikkim" coords="410,232,415,232,419,228,424,227,427,224,424,222,423,217,426,216,426,212,425,209,423,208,419,208,414,211,410,213,411,217,411,223,409,227,409,230,410,233" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Sikkim%22") . ' target="_blank" />
<!-- Region 15 Arunachal Pradesh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Arunachal Pradesh") . ' title="Arunachal Pradesh" coords="550,221,553,229,561,223,568,218,572,212,578,212,580,211,589,217,592,217,588,211,585,206,585,205,588,200,594,197,595,193,592,193,590,189,575,187,571,188,569,187,572,182,575,181,573,176,573,173,567,176,567,172,569,171,563,165,556,170,553,171,551,176,542,174,537,172,531,175,525,180,524,186,518,190,513,190,509,196,504,201,499,202,502,205,496,209,493,209,486,211,483,210,482,209,478,215,484,218,488,218,490,223,489,227,494,228,499,226,508,226,514,226,518,228,524,220,532,213,544,208,551,204,560,199,564,198,566,199,562,205,565,210,568,213,560,216,553,220" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Arunachal+Pradesh%22") . ' target="_blank" />
<!-- Region 18 Tripura -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Tripura") . ' title="Tripura" coords="497,282,498,287,499,288,501,291,499,295,498,299,494,300,492,304,489,307,488,315,487,319,486,320,484,314,484,311,483,314,479,304,478,301,478,294,482,292,487,289,493,288,495,285" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Tripura%22") . ' target="_blank" />
<!-- Region 19 Meghalaya -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Meghalaya") . ' title="Meghalaya" coords="499,270,503,268,509,265,506,264,505,262,503,259,502,255,496,255,492,255,497,251,497,248,492,248,488,248,485,252,482,251,479,255,473,252,468,252,459,252,455,254,452,254,450,259,449,259,449,264,449,267,453,270,457,270,462,270,465,270,472,269,478,269,484,268,491,268,494,268,498,268" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Meghalaya%22") . ' target="_blank" />
<!-- Region 20 Assam -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Assam") . ' title="Assam" coords="443,248,446,243,446,239,445,235,452,235,454,234,456,231,461,234,465,233,474,232,482,231,486,230,488,229,495,227,503,225,507,227,514,227,522,227,527,219,532,212,533,211,540,209,548,203,554,202,560,198,565,197,563,202,562,207,564,211,565,212,558,216,552,221,544,224,539,229,536,236,532,238,531,242,531,247,526,249,520,251,519,255,517,258,522,264,518,269,513,278,513,285,509,282,508,281,506,287,503,290,500,290,498,284,496,281,497,275,498,272,502,272,501,270,506,266,507,262,505,260,501,256,499,255,495,255,494,249,494,248,488,249,481,251,477,256,474,257,472,254,467,251,464,251,457,251,454,255,452,257,449,259,447,255" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Assam%22") . ' target="_blank" />
<!-- Region 21 Odisha -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Odisha") . ' title="Odisha" coords="405,352,401,349,398,347,398,344,396,345,393,345,389,342,386,339,383,337,380,337,377,335,373,333,373,336,373,339,372,343,372,347,368,345,362,343,358,344,354,345,353,344,354,340,355,336,351,336,344,336,340,339,337,339,329,340,328,343,323,349,322,353,320,356,319,361,319,365,316,367,312,367,309,367,305,368,301,371,301,376,301,382,302,388,308,392,308,396,302,395,298,393,293,391,291,391,290,391,290,394,290,398,293,397,295,403,296,407,296,411,295,415,292,422,289,425,287,428,283,430,281,440,284,441,288,439,291,437,294,435,298,435,300,429,300,424,301,423,303,424,307,428,310,427,314,427,315,426,314,424,314,421,318,419,322,419,322,415,326,411,327,412,328,413,332,416,337,417,342,415,345,412,347,410,349,411,354,405,358,401,360,400,358,397,365,392,366,396,377,391,382,388,382,386,385,386,390,384,392,382,391,378,395,376,394,374,394,370,392,363,394,358,398,354,404,354" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Odisha%22") . ' target="_blank" />
<!-- Region 22 Chhattisgarh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Chhattisgarh") . ' title="Chhattisgarh" coords="281,440,282,431,285,431,288,429,290,426,293,421,297,418,298,415,298,408,294,403,293,403,293,400,291,396,290,395,291,392,292,390,298,393,299,393,303,393,306,396,307,396,309,393,308,391,302,390,302,388,302,384,300,382,300,377,300,371,303,373,304,371,304,368,307,364,312,366,318,364,320,361,322,357,324,353,325,347,325,342,328,340,330,340,333,337,331,336,333,333,335,331,339,325,337,325,336,324,334,323,331,322,333,318,331,318,331,315,329,313,330,310,327,312,322,306,321,303,319,300,319,297,316,304,312,308,308,307,305,304,303,307,300,307,296,307,291,308,287,308,285,306,283,307,283,309,283,313,283,315,288,316,293,318,295,318,293,325,290,328,287,328,287,332,283,335,280,337,277,337,273,338,272,345,270,347,268,349,266,356,265,360,264,361,263,364,262,365,260,368,261,375,264,379,264,380,263,385,260,385,260,387,261,390,261,392,258,396,263,398,265,400,267,401,270,405,268,408,264,406,260,409,258,412,258,416,258,419,258,422,263,422,265,424,266,427,269,431,269,432,272,438,272,442,277,441" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Chhattisgarh%22") . ' target="_blank" />
<!-- Region 23 Telangana -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Telangana") . ' title="Telangana" coords="289,438,285,440,280,440,279,437,273,440,273,438,269,432,267,425,263,422,258,422,256,420,252,420,249,420,250,414,250,410,250,406,250,404,247,401,242,401,240,402,236,401,232,401,230,402,227,397,222,397,218,397,217,400,215,405,214,408,210,408,207,409,205,414,206,420,202,424,200,430,201,435,202,438,200,441,200,444,196,445,202,446,199,448,199,451,199,452,199,454,198,456,198,463,198,467,197,470,196,470,200,472,199,473,199,477,199,480,199,482,205,483,208,483,212,488,218,482,221,482,228,479,231,477,235,477,235,472,242,468,251,468,254,466,254,463,256,461,259,465,264,464,264,459,270,456,278,455,280,452,282,449,283,445,288,444,290,441" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Telangana%22") . ' target="_blank" />
<!-- Region 24 Andhra Pradesh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Andhra Pradesh") . ' title="Andhra Pradesh" coords="349,410,346,410,343,412,342,414,339,417,336,417,331,417,329,414,329,410,322,414,317,418,315,421,315,426,312,427,311,426,307,427,305,429,302,424,301,428,301,433,300,434,297,434,291,436,287,440,286,445,284,450,280,451,274,456,270,460,267,460,264,460,264,459,262,461,262,465,256,462,253,462,253,465,253,468,247,467,240,469,238,470,236,472,236,478,233,478,229,478,228,479,228,482,223,481,220,481,215,483,214,485,209,485,205,484,201,484,197,483,195,482,189,481,189,488,189,492,191,496,191,499,188,503,184,504,184,508,184,514,187,519,188,524,190,516,197,519,195,527,196,528,199,531,203,529,205,526,210,525,213,531,213,533,215,533,217,533,218,538,220,540,223,543,220,548,215,549,215,552,217,557,220,555,223,553,225,548,225,544,228,544,232,544,236,546,239,543,241,540,245,540,250,539,253,536,254,531,256,531,256,526,256,522,258,518,260,514,256,510,255,508,255,501,255,493,258,486,264,481,267,481,268,481,268,488,273,481,274,484,277,476,279,472,281,472,287,472,292,470,298,466,300,466,301,462,300,460,300,458,303,453,311,449,318,444,325,437,331,430,336,428,342,423,345,417,347,413" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Andhra+Pradesh%22") . ' target="_blank" />
<!-- Region 25 Karnataka -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Karnataka") . ' title="Karnataka" coords="142,548,149,553,152,553,152,557,154,560,157,563,161,569,167,572,169,570,173,573,179,577,182,577,188,573,197,573,200,570,206,567,203,564,199,564,199,561,201,558,201,556,203,551,211,552,215,551,219,548,221,545,221,541,217,538,217,533,212,532,211,528,209,527,203,530,200,531,197,530,193,527,191,527,193,523,197,520,193,518,188,519,186,522,186,519,186,515,184,513,184,510,185,507,185,506,185,501,191,501,191,493,188,492,190,486,190,484,192,480,194,480,198,480,199,477,199,475,201,474,199,473,196,472,194,469,197,468,199,463,198,460,198,458,198,455,197,454,198,451,203,449,200,446,198,446,199,444,202,437,201,433,201,430,198,431,197,429,196,428,191,431,189,432,187,435,185,441,182,442,179,443,175,446,175,450,175,451,168,450,165,450,161,450,158,447,157,450,158,452,159,459,155,460,153,460,151,460,147,460,144,462,142,465,141,466,138,466,135,466,132,467,131,471,132,472,137,474,134,479,132,483,131,485,128,488,129,492,129,495,130,500,129,502,126,506,131,510,135,518,137,523,138,529,138,534,139,539,139,543" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Karnataka%22") . ' target="_blank" />
<!-- Region 26 Maharashtra -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Maharashtra") . ' title="Maharashtra" coords="119,488,121,484,123,485,127,487,129,484,132,482,134,477,135,474,133,473,130,469,132,466,135,466,138,466,140,463,146,460,146,458,151,459,154,459,160,458,162,458,160,453,159,450,159,447,163,450,169,450,172,450,176,449,175,444,179,442,184,439,186,435,191,432,193,431,194,428,196,430,200,431,203,426,207,419,208,417,207,413,208,408,211,411,214,407,216,402,216,395,225,398,231,401,236,403,240,403,244,402,248,402,250,403,251,407,249,410,249,415,249,420,252,421,257,421,259,417,259,414,259,410,261,408,262,406,265,405,270,407,272,405,269,401,265,400,264,398,261,394,261,390,262,387,264,382,263,380,263,377,261,374,261,370,260,366,263,363,260,363,258,358,255,355,251,358,247,358,246,358,243,358,240,356,237,353,234,354,232,357,229,358,225,359,223,359,220,358,217,356,212,361,209,364,203,364,199,363,200,354,199,353,193,355,190,355,186,355,184,360,183,363,181,365,178,369,175,369,172,369,172,366,168,362,159,362,153,361,149,357,145,356,139,354,139,351,136,349,132,349,124,351,122,354,122,357,128,357,136,359,128,361,126,364,120,365,120,367,125,370,128,375,123,378,120,381,118,378,116,375,114,378,115,381,113,386,108,387,106,386,106,385,102,386,101,387,100,393,100,397,102,403,102,409,105,420,105,428,108,441,109,452,110,458,110,467,114,474,117,483" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Maharashtra%22") . ' target="_blank" />
<!-- Region 27 Madhya Pradesh -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Madhya Pradesh") . ' title="Madhya Pradesh" coords="222,277,225,271,227,273,229,278,234,282,237,279,243,280,246,282,249,277,254,274,259,276,259,279,257,283,267,282,272,283,275,284,281,279,286,280,288,284,293,289,301,288,305,288,305,297,306,304,304,308,298,308,292,308,287,307,283,306,283,312,288,317,294,318,292,324,288,328,287,334,281,337,274,339,271,344,268,348,267,355,262,364,255,358,253,355,250,360,243,357,238,356,232,357,227,359,224,359,219,359,217,357,212,361,204,363,198,360,200,356,195,355,190,357,187,358,183,360,181,364,178,369,172,369,171,362,164,361,156,361,150,360,149,356,142,356,137,353,137,350,133,350,129,350,128,344,131,335,137,330,134,323,143,322,138,316,143,313,146,309,148,305,146,299,146,295,146,288,148,285,153,282,157,281,157,286,160,289,165,291,165,296,164,301,163,304,158,306,162,310,167,305,172,301,174,298,180,300,183,298,186,302,190,300,186,297,188,293,191,294,193,292,189,288,188,288,188,284,192,281,195,281,198,279,197,275,195,272,191,276,188,276,183,276,182,272,181,268,182,261,189,257,199,251,207,247,212,244,216,241,222,242,229,246,231,251,230,257,227,264,223,269,218,272,215,276,216,278,214,285,214,288,215,291,215,295,217,299,221,296,224,300,227,301,227,298,229,294,226,289,223,283,223,280,221,279" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Madhya+Pradesh%22") . ' target="_blank" />
<!-- Region 28 Gujarat -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Gujarat") . ' title="Gujarat" coords="100,388,105,387,107,384,109,388,112,386,115,386,115,382,115,374,119,379,122,379,124,376,124,372,123,369,122,368,120,366,123,365,125,361,128,360,133,360,135,357,128,357,123,357,123,352,127,352,132,348,131,343,129,339,132,336,135,333,136,328,135,324,130,321,128,319,121,317,117,312,116,308,114,304,112,300,112,298,113,294,112,291,108,294,103,293,96,290,89,288,84,288,75,287,68,287,69,294,64,298,62,296,59,296,59,293,51,294,47,296,43,293,37,294,31,294,28,292,24,293,22,299,16,299,12,302,11,304,13,305,20,303,16,308,18,312,20,317,25,320,32,324,38,327,51,322,59,322,54,327,50,333,42,337,30,338,30,335,23,335,29,342,38,353,46,362,54,371,59,375,66,374,76,370,87,364,92,356,92,352,87,352,87,347,92,346,94,342,91,341,98,340,106,341,99,342,98,353,108,352,100,361,103,366,104,369,104,376,102,381" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Gujarat%22") . ' target="_blank" />
<!-- Region 29 Rajasthan -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Rajasthan") . ' title="Rajasthan" coords="67,287,77,287,84,287,93,288,98,292,105,296,108,292,113,295,110,298,115,302,117,302,118,306,118,308,122,315,130,318,135,326,144,323,138,320,138,316,144,316,145,312,146,307,146,304,144,300,144,295,145,287,147,283,151,284,154,282,156,283,156,287,161,286,166,292,163,301,158,303,158,307,164,309,169,304,173,299,178,299,184,299,189,303,186,295,186,292,191,293,191,291,186,287,186,282,191,279,198,278,197,276,197,272,192,275,188,275,183,272,181,267,185,262,193,256,200,249,206,245,213,241,214,241,208,239,204,238,200,242,198,238,201,235,202,232,198,228,197,224,194,220,192,221,189,223,188,216,188,210,186,212,184,215,181,218,177,213,173,215,173,221,170,217,169,211,166,208,164,205,162,200,162,195,160,189,153,186,151,185,148,186,144,186,144,181,143,178,141,175,143,171,138,171,131,171,126,169,121,171,118,175,116,180,114,186,111,190,105,195,98,198,95,203,93,206,90,212,87,216,81,217,73,218,69,221,65,220,62,213,60,212,53,217,50,222,44,228,39,233,39,238,42,242,46,242,50,243,53,245,53,249,53,252,52,256,52,263,56,264,60,264,64,264,62,268,63,271,65,275,68,281" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Rajasthan%22") . ' target="_blank" />
<!-- Region 17 Mizoram -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Mizoram") . ' title="Mizoram" coords="500,302,501,287,502,290,505,287,507,281,510,284,514,285,517,288,522,292,522,298,522,304,523,310,523,312,520,313,517,312,518,321,519,325,520,329,519,332,517,336,515,335,509,333,507,324,504,319,501,314,501,309,500,305" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Mizoram%22") . ' target="_blank" />
<!-- Region 16 Manipur -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Manipur") . ' title="Manipur" coords="522,292,517,290,514,289,513,283,513,276,516,273,519,267,521,260,523,263,525,265,527,262,527,258,534,258,538,256,539,254,543,258,545,264,546,266,545,270,543,274,542,281,540,288,537,294,530,293,525,291" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Manipur%22") . ' target="_blank" />
<!-- Region 30 Nagaland -->
<area ' . $mapstuff . ' shape="poly" alt=' . idize("Nagaland") . ' title="Nagaland" coords="552,222,552,229,551,232,549,234,552,241,552,244,549,248,549,253,546,256,544,258,542,256,537,256,531,256,526,256,524,261,524,263,519,264,519,262,519,260,517,257,521,254,522,253,526,248,529,250,529,244,533,237,540,231,546,226,547,224" ' . hrefize("href=https://www.google.com.au/?gfe_rd=cr&ei=R3CKVNOLL8bu8we4p4K4Bw&gws_rd=ssl#q=%22Nagaland%22") . ' target="_blank" />
<area shape="default" nohref alt="" />
</map>
';

function hrefize($t) {
  if (isset($_GET['jigsaw'])) return '';
  return str_replace('""','"',str_replace('href=h', 'href="h', ($t . '"')));
}

function idize($t) {
  return '"' . $t . '" id="sR' . str_replace("Jammu_and_Kashmir", "JAK", str_replace("National_Capital_Territory_of_New_Delhi", "NCTND", str_replace(" ", "_", str_replace("+", "_", $t)))) . '"';
}

function tableize($t) {
  if ($t == "") return $t;
  return "<table><tbody><tr><td colspan=6><h1>Google Chart <a target=_blank title='Google chart page' href='https://developers.google.com/chart/interactive/docs/index'>ideas</a>&nbsp;below ... </h1></td></tr><tr>" . str_replace("<form ", "<td><form ", str_replace("</form>", "</form></td>", str_replace("<select ", "<td><select ", str_replace("</select>", "</select></td>",  $t)))) . "</tr></tbody></table>" . "<iframe style='height:800px;width:1000px;' name='mybubble' id='mybubble' title='India State Google Bubble Chart' src='javascript:none;'></iframe>";
}

function randomize($midtoend) {
    $retval = $midtoend;
    $newmidbit = '" points="';
    $newlastbit = str_replace($newmidbit, '', $midtoend);
    $newmidbit = '" class="draggable" onclick="oc(event);" onmousedown="omd(event);" onmousemove="omm(event);" ondragstart="drag(event)" draggable="true" points="';
    $xoff = rand(0, 300);
    $yoff = rand(0, 800);
    $newstartbit = "_" . $xoff . "_" . $yoff;
    $xylist = explode(",", $newlastbit);
    $retval = $newstartbit . $newmidbit . ($xylist[0] + $xoff);
    for ($ip=1; $ip<sizeof($xylist); $ip++) {
      if (($ip % 2) == 1) {
        $retval .= "," . ($xylist[$ip] + $yoff);
      } else {
        $retval .= "," . ($xylist[$ip] + $xoff);
      }
    }
    return $retval;
}

function relative_to_absolute($inth) {
    global $udirname;
    //$low = strtolower($inth);
    $outth = $inth;
    $ideas = array(" href='", ' href="', " Href='", ' Href="', " HREF='", ' HREF="', " href=", " Href=", " HREF=", " src='", ' src="', " Src='", ' Src="', " SRC='", ' SRC="', " src=", " Src=", " SRC=");
    if ($udirname != "") {
     for ($m=0; $m<sizeof($ideas); $m++) {
      $huhs = explode($ideas[$m], $inth);
      if (sizeof($huhs) > 1) {
        for ($ii=(sizeof($huhs) - 1); $ii>=1; $ii--) {
          if (strtolower(str_replace("file", "http", strtolower(substr($huhs[$ii], 0, 4)))) == "http") {
            $outth = $outth;
          } else if (substr($huhs[$ii], 0, 1) != "/" && substr($huhs[$ii], 0, 1) != "'" && substr($huhs[$ii], 0, 1) != '"') {
            $outth = str_replace($huhs[$ii], $udirname . $huhs[$ii], $outth);
          } else if (substr($huhs[$ii], 1, 1) != "/" && substr($huhs[$ii], 0, 1) != "'" && substr($huhs[$ii], 0, 1) != '"') {
            $outth = str_replace($huhs[$ii], substr($udirname, 0, (strlen($udirname) - 1)) . $huhs[$ii], $outth);
          }
        }
      }
     }
    }
    return $outth;
}

function nextnumber($inst) {
  $startfound = false;
  $endfound = false;
  $cn = "00";
  $jh = 0;
  while (!$endfound && $jh < strlen($inst)) {
    if (!$startfound && (substr($inst, $jh, 1) == ">" || substr($inst, $jh, 1) == ">") && substr($inst, ($jh + 1), 1) >= "0" && substr($inst, ($jh + 1), 1) <= "9") {
      $startfound = true;
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . "yes" . $cn . "\n");
      $cn = "";
    } else if ($startfound && ((substr($inst, $jh, 1) >= "0" && substr($inst, $jh, 1) <= "9") || substr($inst, $jh, 1) == ".")) {
      $cn .= substr($inst, $jh, 1);
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . $cn . "\n");
    } else if ($startfound && substr($inst, $jh, 1) == "/") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "%") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "&") {
      $endfound = true;
    } else if ($startfound && (substr($inst, $jh, 1) >= "A" && substr($inst, $jh, 1) <= "Z")) {
      $endfound = true;
    } else if ($startfound && (substr($inst, $jh, 1) >= "a" && substr($inst, $jh, 1) <= "z")) {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == " ") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "<") {
      $endfound = true;
    }
    $jh++;
  } 
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . $cn . "\n");
  
  return $cn;
}

function nextdate($inst) {
  $startfound = false;
  $endfound = false;
  $cn = "00";
  $day = "1";
  $month = "1";
  $jh = 0;
  while (!$endfound && $jh < strlen($inst)) {
    if (!$startfound && (substr($inst, $jh, 1) == ">" || substr($inst, $jh, 1) == ">") && substr($inst, ($jh + 1), 1) >= "0" && substr($inst, ($jh + 1), 1) <= "9") {
      $startfound = true;
      $dateis = explode(" ", str_replace("&#160;", " ", str_replace("<", " ", str_replace("&nbsp;", " ", substr($inst, ($jh + 1))))));
      if (sizeof($dateis) >= 3) {
        $endfound = true;
        $day = $dateis[0];
        $month = $dateis[1];
        if ($dateis[1] == "Jan" || $dateis[1] == "January") $month = "1";
        if ($dateis[1] == "Feb" || $dateis[1] == "February") $month = "2";
        if ($dateis[1] == "Mar" || $dateis[1] == "March") $month = "3";
        if ($dateis[1] == "Apr" || $dateis[1] == "April") $month = "4";
        if ($dateis[1] == "May" || $dateis[1] == "May") $month = "5";
        if ($dateis[1] == "Jun" || $dateis[1] == "June") $month = "6";
        if ($dateis[1] == "Jul" || $dateis[1] == "July") $month = "7";
        if ($dateis[1] == "Aug" || $dateis[1] == "August") $month = "8";
        if ($dateis[1] == "Sep" || $dateis[1] == "September") $month = "9";
        if ($dateis[1] == "Oct" || $dateis[1] == "October") $month = "10";
        if ($dateis[1] == "Nov" || $dateis[1] == "November") $month = "11";
        if ($dateis[1] == "Dec" || $dateis[1] == "December") $month = "12";
        if (substr($month,0,1) < "1" || substr($month,0,1) > "9") return $dateis[0] . ",1,1";
        return $dateis[2] . "," . $month . "," . $day;
      }
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . "yes" . $cn . "\n");
      $cn = "";
    } else if ($startfound && ((substr($inst, $jh, 1) >= "0" && substr($inst, $jh, 1) <= "9") || substr($inst, $jh, 1) == ".")) {
      $cn .= substr($inst, $jh, 1);
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . $cn . "\n");
    } else if ($startfound && substr($inst, $jh, 1) == "/") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "%") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "&") {
      $endfound = true;
    } else if ($startfound && (substr($inst, $jh, 1) >= "A" && substr($inst, $jh, 1) <= "Z")) {
      $endfound = true;
    } else if ($startfound && (substr($inst, $jh, 1) >= "a" && substr($inst, $jh, 1) <= "z")) {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == " ") {
      $endfound = true;
    } else if ($startfound && substr($inst, $jh, 1) == "<") {
      $endfound = true;
    }
    $jh++;
  } 
  //file_put_contents(dirname(__FILE__) . "/xxx.zz", file_get_contents(dirname(__FILE__) . "/xxx.zz") . $cn . "\n");
  
  return $cn;
}


function processmap($inmap) {
  global $numstates, $wording, $coordstring, $urls, $blurbs, $mapchart, $columnchart, $timelinechart, $piechart, $treemapchart, $bubblechart, $downbot, $cols, $two, $literacy, $population, $density, $latis, $longis;
  $suffix = "<div style='position:absolute;top:100px;left:0px;opacity:0.5;z-index:3;'></div>";
  $atitle = explode(' title="', $inmap);
  for ($i=1; $i<sizeof($atitle); $i++) {
    $spare = explode('"', $atitle[$i]);
    $wording[sizeof($wording)] = $spare[0];
    $population[sizeof($wording) - 1] = 0;
    $density[sizeof($wording) - 1] = 0.0;
    $literacy[sizeof($wording) - 1] = 0.0;
    $latis[sizeof($wording) - 1] = 0.0;
    $longis[sizeof($wording) - 1] = 0.0;
  }
  $aurls = explode(' href="', $inmap);
     
  if ($mapchart == "") {
   if (isset($_SERVER['HTTP_USER_AGENT'])) {
      $agent = $_SERVER['HTTP_USER_AGENT'];
      if (strlen(strstr($agent, 'Firefox')) > 0) {
   		$mapchart = "\n<select style='margin-top:-24px;' onchange='document.getElementById(\"mybubble\").src=this.value;' id='myselect' name='myselect' title=\"Functionality via Google Maps ... please see https://developers.google.com/chart/interactive/docs/gallery/map ... thanks.\"><option value=''>Select Indian State Google Map ...</option></select>";
      } else {
      	$mapchart = "\n<select style='margin-top:-12px;' onchange='document.getElementById(\"mybubble\").src=this.value;' id='myselect' name='myselect' title=\"Functionality via Google Maps ... please see https://developers.google.com/chart/interactive/docs/gallery/map ... thanks.\"><option value=''>Select Indian State Google Map ...</option></select>";
      }
   } else {
      $mapchart = "\n<select style='margin-top:0px;' onchange='document.getElementById(\"mybubble\").src=this.value;' id='myselect' name='myselect' title=\"Functionality via Google Maps ... please see https://developers.google.com/chart/interactive/docs/gallery/map ... thanks.\"><option value=''>Select Indian State Google Map ...</option></select>";
   }
  }
  for ($i=1; $i<sizeof($aurls); $i++) {
    $spare = explode('"', $aurls[$i]);
    $urls[sizeof($urls)] = $spare[0];
    if (file_exists(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".talk") && file_exists(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk")) {
    $blurbs[sizeof($urls) - 1] = file_get_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".talk");
    } else {
    $blurbs[sizeof($urls) - 1] = file_get_contents('http://en.wikipedia.org/wiki/' . str_replace("National_Capital_Territory_of_New_Delhi", "Delhi", str_replace("+", "_", str_replace(" ", "_", $wording[sizeof($urls) - 1]))) . ''); //     $spare[0]);
    file_put_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".talk", $blurbs[sizeof($urls) - 1]);
    }
     $tpop = 0.0;
     $ipop = 0;
     $xlat = 0.0;
     $xlong = 0.0;
     $ptwo = 1;
     $dtwo = 1;
     $popsrural = explode("Total", "ngfdhgfdg");
     $lats = explode("params=", $blurbs[sizeof($urls) - 1]);
     if (sizeof($lats) > 1) {
  //file_put_contents(dirname(__FILE__) . "/aa.z", str_replace(".", "_", $lats[1]));
       $alatlong = explode("_", $lats[1]);
       $latlong = explode("_", str_replace(".", "_", $lats[1]));
       if (sizeof($latlong) >= 6) {
         if ($alatlong[1] == "S") {
           $xlat = (0.0 - $alatlong[0]);
           if ($alatlong[3] == "W") {
             $xlong = (0.0 - $alatlong[2]);
           } else if ($latlong[3] == "E") {
             $xlong = (0.0 + $alatlong[2]);
           }
         } else if ($alatlong[1] == "N") {
           $xlat = (0.0 + $alatlong[0]);
           if ($alatlong[3] == "W") {
             $xlong = (0.0 - $alatlong[2]);
           } else if ($alatlong[3] == "E") {
             $xlong = (0.0 + $alatlong[2]);
           }
         } else if ($latlong[2] == "S") {
           $xlat = (0.0 - $latlong[0]) + ($latlong[1] / 60.0);
           if ($latlong[5] == "W") {
             $xlong = (0.0 - $latlong[3]) + ($latlong[4] / 60.0);
           } else if ($latlong[5] == "E") {
             $xlong = (0.0 + $latlong[3]) + ($latlong[4] / 60.0);
           }
         } else if ($latlong[2] == "N") {
           $xlat = (0.0 + $latlong[0]) + ($latlong[1] / 60.0);
           if ($latlong[5] == "W") {
             $xlong = (0.0 - $latlong[3]) + ($latlong[4] / 60.0);
           } else if ($latlong[5] == "E") {
             $xlong = (0.0 + $latlong[3]) + ($latlong[4] / 60.0);
           }
         } else if ($latlong[3] == "S") {
           $xlat = (0.0 - $latlong[0]) + ($latlong[1] / 60.0) + ($latlong[2] / 3600.0);
         } else if ($latlong[3] == "N") {
           $xlat = (0.0 + $latlong[0]) + ($latlong[1] / 60.0) + ($latlong[2] / 3600.0);
         }
         if ($latlong[7] == "W") {
           $xlong = (0.0 - $latlong[4]) + ($latlong[5] / 60.0) + ($latlong[6] / 3600.0);
         } else if ($latlong[7] == "E")  {
           $xlong = (0.0 + $latlong[4]) + ($latlong[5] / 60.0) + ($latlong[6] / 3600.0);
         }
         if ($xlat != 0.0 && $xlong != 0.0) $mapchart = str_replace("</option></select>",  "</option><option value=\"http://www.rjmprogramming.com.au/PHP/Map/map.php?title=" . $wording[sizeof($urls) - 1] . " (use - zoom)&label=['Lat',&value='Lon', 'Name']&data=, [" . $xlat . ", " . $xlong . ", ~" . $wording[sizeof($urls) - 1] . "~] \">" . $wording[sizeof($urls) - 1] . "</option></select>", $mapchart);
  //file_put_contents(dirname(__FILE__) . "/a.z", $lats[0] . " ... " . $lats[3] . " ... " . $xlat . " , " . $xlong);

       }
     }
     $estdates = explode(">Establish", $blurbs[sizeof($urls) - 1]);
     $preareas = explode(">Area", $blurbs[sizeof($urls) - 1]);
     $lits = explode("Literacy<", $blurbs[sizeof($urls) - 1]);
     $dens = explode("Density<", $blurbs[sizeof($urls) - 1]);
     $prepops = explode(">Population", $blurbs[sizeof($urls) - 1]);
     if (sizeof($prepops) > 1) {
     $pops = explode(">Urban", $prepops[1]);
     if (sizeof($pops) == 1) {
     $pops = explode("Total", $prepops[1]);
     } else {
     $ptwo = 2;
     $apops = explode("Total", $prepops[1]);
     if (sizeof($apops) > 1) {
       if (strlen($apops[0]) < strlen($pops[0])) {
         $ptwo = 1;
         $pops = explode("Total", $prepops[1]);
       }
     }
     if ($ptwo == 2) $popsrural = explode(">Rural", $prepops[1]);
     }
     } else {
     $pops = explode("Total", "ngfdhgfdg");
     }
     if (sizeof($dens) == 1 && sizeof($pops) >= 2) {
     $prepops = explode(">Area", $blurbs[sizeof($urls) - 1]);
     if (sizeof($prepops) > 1) {
     $dtwo = 2;
     $dens = explode("Total", $prepops[1]); // calculate density as population / area
     }
     }
     //file_put_contents(dirname(__FILE__) . "/x.z", file_get_contents(dirname(__FILE__) . "/x.z") . $wording[sizeof($urls) - 1] . " " . sizeof($lits) . " " . sizeof($dens) . " " . sizeof($pops) . "\n");

     if (sizeof($estdates) > 1) {
     if ($timelinechart == "") {
      $timelinechart = "\n<form name='myformc' id='myformc' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/AnnotatedTimelineChart/annotatedtimeline_chart.php'><input type='hidden' name='title' id='title' value=\"Indian Region Establishment Date\"></input><input type='hidden' name='desc1' id='desc1' value=\"\"></input><input type='hidden' name='task' id='task' value=\"\"></input><input type='hidden' name='data' id='data' value=\"data=\" /><input type='hidden' name='title1' id='title1' value=\"\"></input><input type='hidden' name='text1' id='text1' value=\"\"></input><input type='hidden' name='title2' id='title2' value=\"\"></input><input type='hidden' name='text2' id='text2' value=\"\"></input><input type='submit' name='csubmit' id='csubmit' value='Timeline Chart ...' style='display:block;'></form>\n";
	 }
     $timelinechart = str_replace("data=,", "", str_replace("\" />", ",[newDate(" . nextdate(substr($estdates[1],11)) . "),1,~" . str_replace(" ", "%20", $wording[sizeof($urls) - 1])  . "~,~Establishment%20Date~,1,~" . str_replace(" ", "%20", $wording[sizeof($urls) - 1])  . "~,~Establishment%20Date~]\" />", $timelinechart));
     }

     if (sizeof($preareas) > 1) {
     $areatots = explode("Total", $preareas[1]); 
     if (sizeof($areatots) > 1) {
     if ($columnchart == "") {
      $columnchart = "\n<select id='mysell' name='mysell' onchange='document.getElementById(\"myforml\").action=this.value; document.getElementById(\"lsubmit\").click();'><option value=''>Select Column/Area/Bar chart ...</option><option value='http://www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php'>Column Chart ...</option><option value='http://www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php'>Bar Chart ...</option><option value='http://www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php'>Area Chart ...</option></SELECT>\n<FORM name='myforml' id='myforml' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php'><input type='hidden' name='title' id='title' value=\"Areas of Indian Regions\"></input><input type='hidden' name='label' id='label' value=\"Region\"></input><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='value' id='value' value=\"Area (square km)\"></input><input type='submit' name='lsubmit' id='lsubmit' value='Column Chart ...' style='display:none;'></form>\n";
      //$columnchart = "\n<form name='myforml' id='myforml' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php'><input type='hidden' name='title' id='title' value=\"Areas of Indian Regions\"></input><input type='hidden' name='label' id='label' value=\"Region\"></input><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='value' id='value' value=\"Area (square km)\"></input><input type='submit' name='lsubmit' id='lsubmit' value='Column Chart ...' style='display:block;'></form>\n";
      //$columnchart = "\n<form name='myforml' id='myforml' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php'><input type='hidden' name='title' id='title' value=\"Areas of Indian Regions\"></input><input type='hidden' name='label' id='label' value=\"Region\"></input><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='value' id='value' value=\"Area (square km)\"></input><input type='submit' name='lsubmit' id='lsubmit' value='Column Chart ...' style='display:block;'></form>\n";
	 }
     $columnchart = str_replace("\" />", ",[~" . $wording[sizeof($urls) - 1] . "~,"  . nextnumber($areatots[1])  . "]\" />", $columnchart);
     }
     }

	 if (sizeof($pops) >= 2 && (sizeof($lits) < 2 || sizeof($dens) < 2)) {
     $population[sizeof($urls) - 1] = nextnumber($pops[1]);
     if ($ptwo == 2) $population[sizeof($urls) - 1] += nextnumber($popsrural[1]);
     if ($piechart == "") {
 //http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Population%20by%20Region%20in%20India&task=Population&desc=Percentage&data=,%20[~Tamil%20Nadu~,10]%20,%20[~Odisha~,90]
      $piechart = "\n<form name='myformp' id='myformp' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php'><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='desc' id='desc' value=\"Percentage\"></input><input type='hidden' name='title' id='title' value=\"Population by Region in India in 2011\"></input><input type='hidden' name='task' id='task' value=\"Population\"></input><input type='submit' name='psubmit' id='psubmit' value='Pie Chart ...' style='display:block;'></form>\n";
	 }
     $piechart = str_replace("\" />", ", [~" . $wording[sizeof($urls) - 1] . "~,0] \" />", $piechart);
     } else if (sizeof($pops) >= 1 && (sizeof($lits) < 2 || sizeof($dens) < 2)) {
     $population[sizeof($urls) - 1] = nextnumber($pops[0]);
     if ($piechart == "") {
 //http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Population%20by%20Region%20in%20India&task=Population&desc=Percentage&data=,%20[~Tamil%20Nadu~,10]%20,%20[~Odisha~,90]
      $piechart = "\n<form name='myformp' id='myformp' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php'><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='desc' id='desc' value=\"Percentage\"></input><input type='hidden' name='title' id='title' value=\"Population by Region in India in 2011\"></input><input type='hidden' name='task' id='task' value=\"Population\"></input><input type='submit' name='psubmit' id='psubmit' value='Pie Chart ...' style='display:block;'></form>\n";
	 }
     $piechart = str_replace("\" />", ", [~" . $wording[sizeof($urls) - 1] . "~,0] \" />", $piechart);
     } else if (sizeof($lits) >= 2 && sizeof($dens) >= 2 && sizeof($pops) >= 2) {
     $population[sizeof($urls) - 1] = nextnumber($pops[1]);
     if ($ptwo == 2) $population[sizeof($urls) - 1] += nextnumber($popsrural[1]);
     $tpop += $population[sizeof($urls) - 1];
     $ipop++;
     //file_put_contents(dirname(__FILE__) . "/xx.zz", file_get_contents(dirname(__FILE__) . "/xx.zz") . $wording[sizeof($urls) - 1] . " pop " . $literacy[sizeof($urls) - 1] . " " . $density[sizeof($urls) - 1] . " " . $population[sizeof($urls) - 1] . "\n");
     $density[sizeof($urls) - 1] = nextnumber($dens[1]);
     if ($dtwo == 2 && 2 == 2) {
       $dd = $density[sizeof($urls) - 1];
       $density[sizeof($urls) - 1] = ((0.01 + $population[sizeof($urls) - 1]) / $dd);
     }
     //file_put_contents(dirname(__FILE__) . "/xx.zz", file_get_contents(dirname(__FILE__) . "/xx.zz") . $wording[sizeof($urls) - 1] . " dens " . $literacy[sizeof($urls) - 1] . " " . $density[sizeof($urls) - 1] . " " . $population[sizeof($urls) - 1] . "\n");
     $literacy[sizeof($urls) - 1] = nextnumber($lits[1]);
     
     if ($bubblechart == "") {
      $bubblechart = "\n<form name='myform' id='myform' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/BubbleChart/bubble_chart.php'><input type='hidden' name='value' id='value' value=\"Literacy (%),Population Density (per square km),'Region',Population\"></input><input type='hidden' name='title' id='title' value='Correlation between Literacy, Population Density and Population (2011) of India'></input><input type='hidden' name='label' id='label' value=\"'ID'\"></input><input type='hidden' name='data' id='data' value=\"\" /><input onclick='document.getElementById(\"mybubble\").style.display=\"block\";' type='submit' name='submit' id='submit' value='Please show Bubble Chart ...' style='display:block;'></form>\n";
     }
 //http://www.rjmprogramming.com.au/PHP/TreemapChart/treemap_chart.php?title=Literacy%20versus%20Population%20Density%20in%202011%20in%20India&label=%27India%27&value=%27Region%27,%20%27Literacy%20%28%%29%27,%20%27Population%20Density%20%28per%20square%20km%29%27&data=,%20[~India~,null,0,0]%20,%20[~Kerala~,%27India%27,10,10]%20,%20[~Tamil%20Nadu~,%27India%27,20,20]
     if ($treemapchart == "") {
      $treemapchart = "\n<form name='myformt' id='myformt' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/TreemapChart/treemap_chart.php'><input type='hidden' name='value' id='value' value=\"'Region', 'Literacy (%)', 'Population Density (per square km)'\"></input><input type='hidden' name='title' id='title' value='Correlation between Literacy, Population Density (2011) of India'></input><input type='hidden' name='label' id='label' value=\"'India'\"></input><input type='hidden' name='data' id='data' value=\", [~India~,null,0,0] \" /><input type='submit' name='tsubmit' id='tsubmit' value='Treemap Chart ...' style='display:block;'></form>\n";
     }
     
     if ($piechart == "") {
 //http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Population%20by%20Region%20in%20India&task=Population&desc=Percentage&data=,%20[~Tamil%20Nadu~,10]%20,%20[~Odisha~,90]
      $piechart = "\n<form name='myformp' id='myformp' target='mybubble' method='POST' action='http://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php'><input type='hidden' name='data' id='data' value=\"\" /><input type='hidden' name='desc' id='desc' value=\"Percentage\"></input><input type='hidden' name='title' id='title' value=\"Population by Region in India in 2011\"></input><input type='hidden' name='task' id='task' value=\"Population\"></input><input type='submit' name='psubmit' id='psubmit' value='Pie Chart ...' style='display:block;'></form>\n";
	 }

     //$bubblechart = str_replace("' />", ",%20[~~," . $literacy[sizeof($urls) - 1] . "," . $density[sizeof($urls) - 1] . ",%27" . str_replace(" ", "%20", $wording[sizeof($urls) - 1]) . "%27," . $population[sizeof($urls) - 1] . "]%20' />", $bubblechart);
     $bubblechart = str_replace("\" />", ", [~~," . $literacy[sizeof($urls) - 1] . "," . $density[sizeof($urls) - 1] . ",'" . $wording[sizeof($urls) - 1] . "'," . $population[sizeof($urls) - 1] . "] \" />", $bubblechart);
     $treemapchart = str_replace("\" />", ", [~" . $wording[sizeof($urls) - 1] . "~,'India'," . $literacy[sizeof($urls) - 1] . "," . $density[sizeof($urls) - 1] . "] \" />", $treemapchart);
     $piechart = str_replace("\" />", ", [~" . $wording[sizeof($urls) - 1] . "~,0] \" />", $piechart);

     //file_put_contents(dirname(__FILE__) . "/xx.zz", file_get_contents(dirname(__FILE__) . "/xx.zz") . $wording[sizeof($urls) - 1] . " " . $literacy[sizeof($urls) - 1] . " " . $density[sizeof($urls) - 1] . " " . $population[sizeof($urls) - 1] . "\n");
     } 
    
  if (1 == 2) {
  try {
  $doc = new DOMDocument();
  $doc->preserveWhiteSpace = FALSE;
  $before = libxml_use_internal_errors(true);
  $doc->loadHTML($blurbs[sizeof($urls) - 1]);
  libxml_use_internal_errors($before);  
  $docb = true;
  foreach ($doc->getElementsByClassName("infobox") as $link) {
    file_put_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk", $link->C14N());
  }
  } catch (Exception $e) {
  throw new Exception( 'Something really wrong', 0, $e);
  }
  } else if (!file_exists(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk")) {
    $idiv = explode("infobox", relative_to_absolute($blurbs[sizeof($urls) - 1]));
    if (sizeof($idiv) > 1) {
     $aprefix = '<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table class="infobox';
     $jdivt = explode("</table>", $idiv[1]);
     $jdiv = explode("</div>", $idiv[1]);
     $jdivs = explode("<div ", $idiv[1]);
     if (strlen($jdivt[0]) > strlen($jdiv[0]) && strlen($jdivt[0]) > strlen($jdivs[0])) {
     file_put_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk", $aprefix . $jdivt[0] . "</table></div>");
     } else if (strlen($jdivs[0]) < strlen($jdiv[0])) {
     file_put_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk", $aprefix . $jdiv[0] . "</table></div>");
     } else {
     file_put_contents(dirname(__FILE__) . "/" . str_replace(" ", "+", strtolower($wording[sizeof($urls) - 1])) . ".smalltalk", $aprefix . $jdivs[0] . "</table></div>");
     }
    }
  } 
  
  
  
  }
  
    for ($i=1; $i<sizeof($aurls); $i++) {
      $piechart = str_replace("[~" . $wording[$i - 1] . "~,0]", "[~" . $wording[$i - 1] . "~," . $population[$i - 1] . "]", $piechart);
    }
  
  $acoords = explode(' coords="', $inmap);
  for ($i=1; $i<sizeof($acoords); $i++) {
    $spare = explode('"', $acoords[$i]);
    $coordstring[sizeof($coordstring)] = $spare[0];
    if (isset($_GET['jigsaw'])) {
    $downbot = str_replace('</svg>', "\n" . '<polygon title="' . $wording[sizeof($coordstring) - 1] . '" alt="' . str_replace("#","", $cols[(sizeof($coordstring) - 1)  % sizeof($cols)]) . randomize('" points="' . $spare[0]) . '" id="sp' . str_replace("Jammu_and_Kashmir", "JAK", str_replace("National_Capital_Territory_of_New_Delhi", "NCTND", str_replace(" ", "_", str_replace("+", "_", $wording[sizeof($coordstring) - 1])))) . '" fill="' . $cols[(($i - 1) % sizeof($cols))] . '" /></svg>', $downbot);
	} else {
    $downbot = str_replace('</svg>', "\n" . '<polygon title="' . $wording[sizeof($coordstring) - 1] . '" alt="' . str_replace("#","", $cols[(sizeof($coordstring) - 1)  % sizeof($cols)]) . '" id="sp' . str_replace("Jammu_and_Kashmir", "JAK", str_replace("National_Capital_Territory_of_New_Delhi", "NCTND", str_replace(" ", "_", str_replace("+", "_", $wording[sizeof($coordstring) - 1])))) . '" points="' . $spare[0] . '" fill="' . $cols[(($i - 1) % sizeof($cols))] . '" /></svg>', $downbot);
	}
    $coords = explode(',', $coordstring[sizeof($coordstring) - 1]);
    $x = $coords[0];
    $rjj = 1.0;
    for ($ii=2; $ii<(sizeof($coords) - 2); $ii+=2) {
      $x = ($rjj * $x  + $coords[$ii]) / (1.0 + $rjj);
      $rjj = $rjj + 1.0;
    }
    $y = $coords[1];
    $rjj = 1.0;
    for ($ii=3; $ii<(sizeof($coords) - 2); $ii+=2) {
      $y = ($rjj * $y  + $coords[$ii]) / (1.0 + $rjj);
      $rjj = $rjj + 1.0;
    }
    $presuffix = " onmouseout='yehbut();' onmouseover='zok=1; url=\"" . str_replace("=%22", "=%22Famous+People+from+", $urls[sizeof($coordstring) - 1]) . "\"; parseurl(); setTimeout(xget, 4000); ' ";
    $aid = "id=aR" . str_replace("Jammu_and_Kashmir", "JAK", str_replace("National_Capital_Territory_of_New_Delhi", "NCTND", str_replace(" ", "_", str_replace("+", "_", $wording[sizeof($coordstring) - 1]))));
    $ss="";
    if (isset($_GET['jigsaw'])) $ss="border:5px solid green;font-weight:bold;padding: 4 4 4 4;";
    $suffix = str_replace("</div>", "<a " . $aid . " href='india_map.php?indiaplusstate=" . str_replace(" ", "+", $wording[sizeof($coordstring) - 1]) . "' " . $presuffix . " style='" . $ss . "text-decoration:none;font-size:10px;color:red;position:absolute;top:" . ($y - 57) . "px;left:" . ($x - 10) . "px;opacity:1.0;z-index:3;'>" . str_replace("National Capital Territory of New Delhi", "NCTND", $wording[sizeof($coordstring) - 1]) . "</a></div>", $suffix);
  }
  return str_replace('img src', 'img style="' . $two . ';" src', $inmap) . $suffix;
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="UTF-8" />
<title>Political Map of India - Thanks to http://www.mapsofindia.com/free-download/free-download-india-political-maps.html</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<!--
How to install the image map:
Copy and paste the img, map and area blocks into the body of your page.
 
This imagemap is created at Mobilefish.com.
http://www.mobilefish.com/services/image_map/image_map.php 
-->
<?php echo $astyle; ?>
<script type='text/javascript'>
var url='';
var tdih='';
var otdih;
var zhr=null;
var zok=0;
var wo=null;
var lasturl='';
var lastone='';
var lastcol='';
var expectnext='';
var numfound=0;

function ffoc(evid) {
    //if (expectnext != '') alert(evid + " vs " + expectnext);
    if (evid == expectnext) {
      var cxooiuone=document.getElementById(evid);
      var aone=document.getElementById(evid.replace("sR", "aR"));
      var xooiuone=document.getElementById(evid.replace("sR", "sp"));
      xooiuone.setAttribute("points", cxooiuone.coords); 
      var newsvg=document.getElementById("newsvg");
      newsvg.innerHTML = newsvg.innerHTML + xooiuone.outerHTML
      xooiuone.style.display = "none";
      aone.style.display = "block";
      //alert("found");
      numfound = numfound + 1;
      var otscore=document.getElementById("tscore");
      otscore.innerHTML = "<h2>&nbsp;&nbsp;Found " + numfound + " out of 30 in today's jigsaw</h2>";
      if (numfound >= 30) {
        var oscore=document.getElementById("sp0");
        oscore.style.display='none';
        alert("Congratulations!");
      }
      expectnext='';
    } else if (expectnext != '') {
      var ottscore=document.getElementById("tscore");
      ottscore.innerHTML = "<h2>&nbsp;&nbsp;Found " + numfound + " out of 30 in today's jigsaw ... try somewhere else</h2>";
    }
}

function foc(ev) {
    //if (ev.target.id.indexOf("sP") != -1) {
    //  expectnext = ev.target.id.replace("sP", "sR");
    //  alert("Vs " + expectnext);
    //}
    //alert(19870 + ev.target.id);
}

function fomd(evid) {
    var sexpectnext = evid.target.id.toString();
    //alert("?" + sexpectnext);
    if (("*" + sexpectnext).indexOf("*sp") != -1) {
    //alert("!" + sexpectnext);
      expectnext = sexpectnext.replace("sp", "sR");
      //alert("Vs " + expectnext);
    } else {
      ffoc(sexpectnext);
    }
    //alert(19871 + ev.target.id);
}

function fomm(ev) {
    document.title=ev.target.id.replace("JAK","Jammu and Kashmir").replace("NCTND", "National Capital Territory of New Delhi").replace("sp","").replace("+"," ").replace("+"," ").replace("+"," ") + " ... where does it go on left hand map";
}

function oc(ev) {
    //alert(9870 + ev.target.id);
}

function omd(ev) {
    //alert(9871 + ev.target.id);
}

function omm(ev) {
    document.title=ev.target.id.replace("JAK","Jammu and Kashmir").replace("NCTND", "National Capital Territory of New Delhi").replace("sp","").replace("+"," ").replace("+"," ").replace("+"," ") + " ... where does it go on left hand map";
}

function allowDrop(ev) {
    //ev.preventDefault();
}

function drag(ev) {
  //alert(999);
}

function drop(ev) {
    //var evpageX = ev.pageX, evpageX2;
    //var evpageY = ev.pageY, evpageY2;
    //ev.preventDefault();
}

function later() {
  if (1 == 2) {
  var os=document.getElementById('submit');
  os.click();
  } else {
  var fos=document.getElementById('myform');
  fos.submit();
  }
}

function getXMLHttpRequest() 
{
    if (window.XMLHttpRequest) {
        return new window.XMLHttpRequest;
    }
    else {
  try {
    return new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      return new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      return false;
    }
  }
    }
}


function yehBut() {
  if (1 == 2) {
  zok = 0;
  url = '';
  }
}

function backto() {
  if (lastone != '' && lastcol != '') {
     var ooiuone=document.getElementById(lastone);
     //alert(lastcol);
     ooiuone.setAttribute("fill", "#" + lastcol); 
     lastcol='';
     lastone='';
  }
}

function parseurl() {
  if (url != "") {
     sts = url.split("%22");
     //alert("sp" + sts[1].replace("Famous+People+from+","").replace(" ", "_").replace("+", "_").replace(" ", "_").replace("+", "_").replace("Jammu_and_Kashmir", "JAK").replace("National_Capital_Territory_of_New_Delhi", "NCTND"));
     var oiuone=document.getElementById("sp" + sts[1].replace("Famous+People+from+","").replace(" ", "_").replace("+", "_").replace(" ", "_").replace("+", "_").replace("Jammu_and_Kashmir", "JAK").replace("National_Capital_Territory_of_New_Delhi", "NCTND"));
     if (oiuone != null) {
         lastone="sp" + sts[1].replace("Famous+People+from+","").replace(" ", "_").replace("+", "_").replace(" ", "_").replace("+", "_").replace("Jammu_and_Kashmir", "JAK").replace("National_Capital_Territory_of_New_Delhi", "NCTND");
         lastcol=oiuone.getAttribute("alt").substring(0,6);
     //alert("lastcol=" + lastcol);
         oiuone.setAttribute("fill", "white"); 
         setTimeout(backto, 4000);
     //alert("Xsp" + sts[1].replace("Famous+People+from+","").replace(" ", "_").replace("+", "_"));
     } 
  }
}

function woxget() {
   if (zok == 1 && url != '' && lasturl != url) {
     if (wo != null) wo.close();
     wo = null;
     lasturl=url;
     sts = url.split("%22");
     wo=window.open(url, sts[1], 'top=100,left=700,width=900,height=800');
     parseurl();
     url='';
     zok=0;
   } else if (wo != null && 1 == 2) {
     wo.close();
   }
}

function xget(evt) {
   if (zok == 1 && url != '') {
     zhr = getXMLHttpRequest();
   } //else {
     //zok = 1;
   //}

   if (zhr != null) {
    zhr = zhr;
   } else {
    try {
     zhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
     try {
      zhr = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (failed) {
      zhr = false;
     }
    }
   }
   
   if (zhr) {
   //alert(987);
     if (url != '') {
     //alert(url);
     var ststwo = url.split("%22");
     //zhr.open("GET", url, true);
     zhr.open("GET", "<?php echo "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . str_replace("?" . $_SERVER['QUERY_STRING'], "", $_SERVER['REQUEST_URI']); ?>" + "?ajaxindiaplusstate=" + ststwo[1].replace("Famous+People+from+",""), true);
     zhr.onreadystatechange = showStuff;
     zhr.send(null);
     setTimeout(woxget, 2000);
     parseurl();
     //url='';
     }
   } else {
     zok = 1; //alert("Sorry ... no XMLHttpRequest possible");
   }

}


function showStuff(evt) {
  if (zok == 1 && zhr != null) {
  var mybase = document.getElementById('iinfo');
  if (mybase == null || tdih == '') {
      tdih = '<div id="iinfo" style="display:block;"></div>';
      document.getElementById('info').innerHTML = tdih;
      mybase = document.getElementById('iinfo');
  }
  if (zhr.readyState == 4) {
    if (zhr.status == 200) {
    //alert(zhr.responseText);
      mybase.innerHTML = zhr.responseText;
    }
  }
  }
}

function onmo() {
  var areas=document.getElementsByTagName("area");
  var iareas, what;
  for (iareas=0; iareas<areas.length; iareas++) {
    if (iareas == 0 && tdih == "") {
      if (1 == 123) {
      tdih = '<div id="iinfo" style="display:block;"></div>';
      document.getElementById('info').innerHTML = tdih;
      //tdih="";
      }
    }
    what=areas[iareas].coords + '"';
    if (tdih != "" && 1 == 2) {
    document.body.innerHTML=document.body.innerHTML.replace(what, what + ' onmouseout="yehbut();" onmouseover="url=' + "'" + areas[iareas].href.replace("22", "22Famous+People+from+") + "'; parseurl(); setTimeout(woxget, 4000); " + ' " '); 
    } else {
    document.body.innerHTML=document.body.innerHTML.replace(what, what + ' onmouseout="yehbut();" onmouseover="zok=1; url=' + "'" + areas[iareas].href.replace("22", "22Famous+People+from+") + "'; parseurl(); setTimeout(xget, 1000); " + ' " '); 
    }
  }
}
</script>
</head>
<body onload="onmo();<?php echo $bodystuff; ?>">
<table style="width:100%;"><tbody>
<tr><td><h1>India</h1></td>
<td id='tscore'>
<?php  
if (isset($_GET['jigsaw'])) {
  echo "<ul><li>Click/touch on Indian state at right for today's jigsaw</li><li>Click/touch Indian map for where that state is positioned ... get to 30</li></ul></td>\n";
} else {
  echo "<ul><li>Hover over Indian map states for Famous People and/or Wikipedia information to right (thanks)</li><li>Click/touch Indian map state for Web information on new webpage</li></ul></td>\n";
}
?>
</tr></tbody></table>
<div align='center' style='margin-top:-20px;'>
<table align='center' style="width:100%;"><tbody>
<tr><td>
<!-- START COPY -->
<?php echo processmap($mobilefishstring); ?>
<!-- END COPY -->
</td><td id="info" style=position:absolute;left:620px;><?php echo tableize($bubblechart . $treemapchart . $mapchart . $piechart . $timelinechart . $columnchart) . $divinfo; ?></td>
</tr></tbody></table>
</div>
<?php echo $downbot; ?>
</body>
</html>
