$(document).ready(
	function()
	{
		$('#myAccordion').Accordion(
			{
				headerSelector	: 'dt',
				panelSelector	: 'dd',
				activeClass		: 'myAccordionActive',
				hoverClass		: 'myAccordionHover',
				panelHeight		: 295,
				speed			: 300
			}
		);
	}
);

var initialZoom = "-21,-36,53,38";
function initiateCountryList(){
	// need to load the download button here
	$.ajax({
	   type: "POST",
	   url: "inc/xml_DownloadProfile.asp",
	   data: "CountryID=0",
	   success: function(msg){
		 $("#t2").html(msg);
	   }
	 });
	
	writeFlashMap(1);
	$.ajax({
	   type: "POST",
	   url: "inc/xml_CountryList.asp",
	   data: "",
	   success: function(msg){
		 $("#datacontent").html(msg);
		 setTimeout('reBuild(2)',1500);
	   }
	 });
}
function DataInfo(){
	mapFlashCom(initialZoom);
	$.ajax({
	   type: "POST",
	   url: "inc/xml_DataInfo.asp",
	   data: "",
	   success: function(msg){
		 $("#datacontent").html(msg);
		 setTimeout('reBuild(2)',1500);
	   }
	 });
}
function flashMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
	return window[movieName];
  } else {
	return document[movieName];
  }
}
function mapFlashCom(cord){
	flashMovie('MapClient').ZoomTo(cord);
}
function changeCountry(id){
	// need to load the download button here
	$.ajax({
	   type: "POST",
	   url: "inc/xml_DownloadProfile.asp",
	   data: "CountryID="+id+"",
	   success: function(msg){
		 $("#t2").html(msg);
	   }
	 });
	//now fetch all other info for country
	$.ajax({
	   type: "POST",
	   url: "inc/xml_CountryDetails.asp",
	   data: "CountryID="+id+"&isSensitivy=true",
	   success: function(msg){
		 $("#datacontent").html(msg);
		 setTimeout('reBuild(1)',1500);
	   }
	 });
}
function reBuild(typ){
	var accHeight;
	if(typ == 1){
		accHeight = 330;
	}
	if(typ == 2){
		accHeight = 250;
	}
	$('#myAccordion').Accordion(
		{
			headerSelector	: 'dt',
			panelSelector	: 'dd',
			activeClass		: 'myAccordionActive',
			hoverClass		: 'myAccordionHover',
			panelHeight		: accHeight,
			speed			: 300
		}
	);
}
function writeFlashMap(num){
	var server = "&Server=http://gomedia.co.za/WMS/wms.asp";
	var maxZoomOut = "&WMSBBox="+initialZoom+"&MaxZoomOut=1";
	var xmlData = "&Layers=Countries,Topography,Non%20GIWACAF%20countries";
	var layersToShow = "";
	var xmlData2 = ",Builtup areas,Coastlines,Waterbodies,Inundated,Rivers,Streams,Railroads,Highways,Roads,Trails,Borders,Cities,Settlements,Spot elevations,Airports,Ocean features";
	//var xmlData2 = ",Bathymetry,Countries,Topography";
	//layersToShow = ",Angola,Benin,Cameroon,Capeverde,Congo,DRC,Equitorialguinea,Gabon,Gambia,Ghana,Guinea,Guineabissau,Ivorycoast,Liberia,Mauritania,Namibia,Nigeria,Saotome,Senegal,Sierraleon,Togo";
	var thaID;
	//server = "";
	if(num==1){
		xmlData = xmlData + "" + xmlData2;
		var soProfile = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox="+initialZoom+""+maxZoomOut+""+xmlData+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
		soProfile.write("flashcontent");
		delete soProfile;
	}
	if(num==2){
		thaID = $("input[@name=conv]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Conventions.asp",
			data: "conventionID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile2 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile2.write("flashcontent");
				delete soProfile2;
			}
		});
	}
	if(num==3){
		thaID = $("input[@name=cont]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Contingency.asp",
			data: "ContingencyID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile3 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile3.write("flashcontent");
				delete soProfile3;
			}
		});
	}
	if(num==4){
		thaID = $("input[@name=Auth]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Authority.asp",
			data: "AuthorityTypeID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile3 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile3.write("flashcontent");
				delete soProfile3;
			}
		});
	}
	if(num==5){
		thaID = $("input[@name=Agree]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Agreements.asp",
			data: "AuthorityTypeID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile4 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile4.write("flashcontent");
				delete soProfile4;
			}
		});
	}
	if(num==6){
		thaID = $("input[@name=Auth2]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Authority.asp",
			data: "AuthorityTypeID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile5 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile5.write("flashcontent");
				delete soProfile5;
			}
		});
	}
	if(num==7){
		thaID = $("input[@name=sens]:checked").val();
		$.ajax({
			type: "POST",
			url: "inc/xml_sens_Sensitivity.asp",
			data: "SensitivityID="+thaID+"",
			success: function(msg){
				layersToShow = "" + msg + "";
				xmlData = xmlData + layersToShow + xmlData2;
				var soProfile6 = new SWFObject("map/MapSymbols.swf?WMS=wacaf"+server+"&BGColor=0xCCFAFF&BBox=-21,-36,53,38"+xmlData+""+maxZoomOut+"", "MapClient", "100%", "100%", "6", "#CCFAFF");
				soProfile6.write("flashcontent");
				delete soProfile6;
			}
		});
	}
}
function changeTab(me){
	if(me==1){
		/*document.getElementById("tab1").src = "images/tab1.gif";
		document.getElementById("tab2").src = "images/tab2a.gif";*/
		document.getElementById("t1").style.display = '';
		document.getElementById("t2").style.display = 'none';
	}else{
		/*document.getElementById("tab2").src = "images/tab2.gif";
		document.getElementById("tab1").src = "images/tab1a.gif";*/
		document.getElementById("t2").style.display = '';
		document.getElementById("t1").style.display = 'none';
	}
}