//////////////////////////////// Check if the page has scrolled down ////////////////////////////////

var prevDiv = ''; // previously populated div

//////////////////////////////// Clear previous div before populating new ////////////////////////////////
function others(act)

{ 

            if (act == "showit")

            {

                        //alert(act)

                        //document.getElementById('selectimg1').style.display='block';

                        document.getElementById('searchBox').style.display='block';

            }

            else if (act == "hideit")

            {//alert(act)

//document.getElementById('select1').innerHTML = '   <select name="select" style="width:220"><option selected>All Categories</option></select>';

//document.getElementById('selectimg1').style.display='none';

document.getElementById('searchBox').style.display='none';

            }

}


function rollDownDiv(urlval,divval)
{
	alert('indiatimes');
	if (prevDiv != '')
	{	
		clearDiv(prevDiv); // clear any div which is previously populated
	}
	//document.getElementById('searchBox').style.display = 'none'; // Hide Search dropdown on IE
	populatediv(urlval,divval,true);
}

//////////////////////////////// populate div ////////////////////////////////
function populatediv(urlval,divval,isDrop)
{
	try 
	{
		var xmlhttp=false;
		var status=0;

		//CHECKING VALUE OF xmlhttp IS TRUE

		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP");
		
		if (xmlhttp)
		{
			//checking the state of http object
			xmlhttp.onreadystatechange=function() 
			{
				if (xmlhttp.readyState==4)
				{
					if (xmlhttp.status==200)
					{
						document.getElementById(divval).innerHTML=xmlhttp.responseText;
						if(isDrop)
						{
							prevDiv = divval;
						}
					}
					else if (xmlhttp.status==404) status=0
					else status=0
				}
			}
			xmlhttp.open("GET",urlval,true);
			xmlhttp.send(null);
		}
	}
	catch (e) 
	{
		xmlhttp = false; 
	}	
}



//////////////////////////////// populate div ////////////////////////////////
function populatediv2(urlval,divval,isDrop)
{
	
//	alert("hi");
//alert(urlval);
	try 
	{
		var xmlhttp=false;
		var status=0;

		//CHECKING VALUE OF xmlhttp IS TRUE

		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP");
		
		if (xmlhttp)
		
		{
			//alert(divval);
			//checking the state of http object
			xmlhttp.onreadystatechange=function() 
			{
				
				if (xmlhttp.readyState==4)
				{
					
					if (xmlhttp.status==200)
					{ 
					alert("hi");
						
						document.getElementById(divval).innerHTML=xmlhttp.responseText;
						//document.getElementById("ajax").innerHTML=xmlhttp.responseText;
						
						if(isDrop)
						{
							prevDiv = divval;
							
						}
					}
					else if (xmlhttp.status==404) status=0
					
					else status=0
				}
			}
			
			xmlhttp.open("GET",urlval,true);
			xmlhttp.send(null);
		}
	}
	catch (e) 
	{
		xmlhttp = false; 
	}	
}


//////////////////////////////// Clear div ////////////////////////////////
function clearAll(showallStores,showallCategories,callCenter)
{
	document.getElementById(showallStores).innerHTML='';
	document.getElementById(showallCategories).innerHTML='';
	document.getElementById(callCenter).innerHTML='';
	//document.getElementById(SpecialShops).innerHTML='';
	//document.getElementById(e).innerHTML='';
	//document.getElementById(f).innerHTML='';
	document.getElementById('searchBox').style.display = 'block';
	//document.getElementById('selectimg1').style.display = 'none';
	
}

function clearDiv(divval)
{			
	document.getElementById(divval).innerHTML='';
	document.getElementById('searchBox').style.display = 'block';
	//document.getElementById('selectimg1').style.display = 'none';

}


