var xmlHttp = null;
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function getDistrictAlbum(str)
{
	document.getElementById('tabsEx1').style.display='inline';
	document.getElementById('generaldisplay').style.display='none';
	var id=str;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="getphoto.php";
	var q="getConstituency";
	url=url+"?method="+q+"&distid="+id;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			//alert(xmlHttp.responseText);
			//alert(xmlHttp.responseXML);
			/*var constitu ="";
			var id ="";
			var tot="";
			var xmlDoc=xmlHttp.responseXML;	
			
			tot =xmlDoc.getElementsByTagName("const").length;html="";
			for(var i=0;i<tot; i++)
			{
				
				var const_id =xmlDoc.getElementsByTagName("constituncyID").item(i).firstChild.data;
				var const_name =xmlDoc.getElementsByTagName("constituencyname").item(i).firstChild.data;
				
				
				html+='<div><table onclick="'+const_id+'.slideit();"><tr><td >'+const_name+'</td><td><img src="images/down-arrow.PNG" /></td></tr></table><div id="'+const_id+'">'+const_name+'</div></div>';
				var div = document.createElement("div");
					div.className="const-div";				
					var table = document.createElement("table");
					table.setAttribute("id","tbl_const_id"+const_id);				
					var tr =  document.createElement("tr");
					var ltd =  document.createElement("ltd");
					textnode=document.createTextNode(const_name);
					ltd.appendChild(textnode);
					var rtd =  document.createElement("rtd");
					var img = document.createElement("img");
					img.src="images/down-arrow.PNG";
					rtd.appendChild(img);
					tr.appendChild(ltd);
					tr.appendChild(rtd);
					table.appendChild(tr);
					div.appendChild(table);				
					var div2 = document.createElement("div");
					div2.setAttribute("id",const_id);
					div2.innerHTML=const_id;
					div.appendChild(div2);
				document.getElementById('photocontent').appendChild(div);
				obj_const_id_name = "obj_const_id"+const_id;*/	
				
				//document.getElementById("tbl_const_id"+const_id).onclick=obj_const_id_name.slideit;	
				document.getElementById('photocontent').innerHTML=xmlHttp.responseText;
			//}
			//for(var i=0;i<tot; i++)
			//{				
				/*var const_id = xmlDoc.getElementsByTagName("constituncyID").item(i).firstChild.data;
				const_id_obj = xmlDoc.getElementsByTagName("constituncyID").item(i).firstChild.data;
				this.const_id_obj=const_id_obj;
				const_id_obj = new animatedcollapse(const_id,500,false,'block',true);	*/			
			//}
			
		}
	}
}
/*function showmenu()
{
		alert("df");
}*/
function getConstituencyAlbums(str)
{
	
	var id=str;
	var disp='photocontent_cid_'+id;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="getphoto.php";
	var q="getcandidates";
	url=url+"?method="+q+"&constid="+id;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(disp).innerHTML=xmlHttp.responseText;
			//initSlideDownMenu();
		}
	}
}

function getalbums(constid,candidate)
{
	
	var idconst=constid;
	var candidateid=candidate;
	var show='photocontent_cid_'+constid+'_candid_'+candidate;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="getphoto.php";
	var q="getalbumphoto";
	url=url+"?method="+q+"&constituencyid="+idconst+"&candidate="+candidateid;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			
			document.getElementById(show).innerHTML=xmlHttp.responseText;
			
		}
	}
}
function generaldisplay()
{
	document.getElementById('tabsEx1').style.display='inline';
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="getphoto.php";
	var q="getgeneral";
	url=url+"?method="+q;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById('generaldisplay').innerHTML=xmlHttp.responseText;
			
		}
	}
}
