	var inputJSON;

	function loadXMLDoc(url) {
		req = false;
		
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
	//		try {
	//			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
	//		   } catch (e) {
	//			alert("Permission UniversalBrowserRead denied.");
	//		   }
			try {
				req = new XMLHttpRequest();
			} catch(e) {
				req = false;
			}    
		} else if(window.ActiveXObject) {
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					req = false;
				}
			}
		}
		if(req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send("");
		}
	}

	function processReqChange() {
		// only if req shows "loaded"
		if (req.readyState == 4) {
			// only if "OK"
			if (req.status == 200) {
			   inputJSON = req.responseText;
			   makeTable(inputJSON);
			} else {
				alert("There was a problem retrieving the XML data:\n" +
					req.statusText);
			}
		}
	}

	function loadJSON(url) {
		loadXMLDoc (url);
	}

	function makeTable(inputJSON) {	
	  buildCostumTable(inputJSON, "");
	}
	
	function buildCostumTable(inputJSON, countryArg) {	
		inputJSON = eval ("ooJSON="+inputJSON);
		//alert("no. of rows : " + sumit.OOoConsultant_Form.length);
		
		var tableData	=	ooJSON.OOoConsultant_Form;

		 var abc	=	'<table class="decorate" summary="Third Party Resources" border="0" cellspacing="0" cellpadding="0">' 
			+	'<caption>Third Party Resources</caption>'
			+	'<colgroup>	<col width="15%"><col width="15%"><col width="56%"> <col width="2%"><col width="2%"><col width="2%"><col width="2%"><col width="2%"><col width="2%"><col width="2%"> </colgroup> 	<tr> 		<th colspan=10 class="consult">Training (or training materials)-  b>T</b></th> 	</tr> 	<tr> 		<th COLSPAN=9 class="consult">Light customization (macros, templates, ...) - <b>L</b></Th>  		<th  class="consult-empty"></th> 	</tr> 	<tr> 		<th COLSPAN=8 class="consult">Installation (support, pre-installation or distribution) -  <b>I</b></th> 		<th class="consult-empty"></th><th class="consult-empty"></th> 	</tr> 	<tr> 	<th COLSPAN=7 class="consult">Help desk services, general support - <b>H</b></th> 	<th class="consult-empty"></th><th class="consult-empty"></th><th class="consult-empty"></th> 	</tr> 	<tr> 		<th COLSPAN=6 class="consult">Software programming (on demand / custom) - <b>S</b></th> 		<th  class="consult-empty"></th><th class="consult-empty"></th><th class="consult-empty"></th> 		<th class="consult-empty"></th> 	</tr> 	<tr> 		<th COLSPAN=5 class="consult">Custom programming (plug-ins, addons, etc) - <b>P</b></th> <th class="consult-empty"></th><th  class="consult-empty"></th><th class="consult-empty"></th> 	<th class="consult-empty"></th><th class="consult-empty"></th> 	</tr> 	<tr> 		<th COLSPAN=4 class="consult">Contribution to the project - <b>C</b></th> 		<th class="consult-empty"></th><th  class="consult-empty"></th><th class="consult-empty"></th> 		<th class="consult-empty"></th><th class="consult-empty"></th><th  class="consult-empty"></th> 	</tr> 	<tr> 		<th>Country</th><th>Local Region</th><th>Consultant or Organization</th> 		<th class="consult-empty"></th><th class="consult-empty"></th><th class="consult-empty"></th> 		<th class="consult-empty"></th><th  class="consult-empty"></th><th class="consult-empty"></th> 		<th class="consult-empty"></th>	</tr> <TBODY> 	<TR> 		<TD HEIGHT=20 ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B>Global</B></TD> <TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 			<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 	<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 			<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> <TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 			<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 	<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> 			<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR="#B0B0B0"><B><BR></B></TD> <TD ALIGN=CENTER VALIGN=MIDDLE  BGCOLOR="#B0B0B0"><B><BR></B></TD> 	</TR> </TBODY> 	<TBODY> 	';

		var htmlText = abc;
		var selectMenu = document.getElementById("Country_DropDwnMenue")
		if(selectMenu.innerHTML == ""){
		    var selectContent = "<option value=\"\">Select a country</option>\n";
		    var countryCount = 0;
		    var pastIndex = tableData[0].Country.replace(/["'"]/g,'');
		    
		    for(var select_i = 0; select_i < tableData.length; select_i++){
			var stripString = tableData[select_i].Country.replace(/["'"]/g,'');
			
			if(stripString != pastIndex){
			    selectContent += "<option value=\""+pastIndex+"\">"+pastIndex+" ("+ countryCount +")</option>\n";
			    countryCount = 1;
			    
			}else{
			    countryCount++;
			    
			}
		      pastIndex = stripString;
		      
		    }
		    selectMenu.innerHTML = selectContent;
		    
		}
		for (var l_i=0; l_i<tableData.length; l_i++) {
//
// Insert an IF that pick up the value of the dropdown and executes the maketable
// Take the value of the drop down (country parameter) and exclude on null value
//	
			var table_row	=	tableData[l_i];
			if(countryArg == table_row.Country.replace(/["'"]/g,'') || countryArg == "" ){
			  
			  htmlText		+=	"<tr><td>" + table_row.Country.replace(/["'"]/g,'') + "</td><td>" + table_row.Region.replace(/["'"]/g,'') + "</td><td>" + table_row.Consultant_Organization.replace(/["'"]/g,'') + "</td><td>" + table_row.Contributor.replace(/["'"]/g,'') + "</td><td>" + table_row.Custom_Programing.replace(/["'"]/g,'') + "</td><td>" + table_row.Software_Programing.replace(/["'"]/g,'') + "</td><td>" + table_row.Help_desk.replace(/["'"]/g,'') + "</td><td>" + table_row.Installation.replace(/["'"]/g,'') + "</td><td>" + table_row.Light_costumization.replace(/["'"]/g,'') + "</td><td>" + table_row.Training.replace(/["'"]/g,'') + "</td></tr>";
			}//else{
			// alert("-"+countryArg+"-");
			// return 0;
			//}
		}
		htmlText += "<TBODY></TABLE>";
		var l_div = document.getElementById ("tableDiv");
		l_div.innerHTML = htmlText;
	}

	var feed = loadJSON('http://creator.zoho.com/jza/oooconsultant/json/OOoConsultant_Form_View/');
