function init_onup() {

   var ajaxRequest;  // The variable that makes Ajax possible!
	var filename;	
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	
	catch (e) {
		// Internet Explorer Browsers
		try {
		
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		
		catch (e)  {
		
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			
			catch (e) {
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	return ajaxRequest;
}


function ShowModel(div_id) {
	
	
	var ajaxRequest;
	ajaxRequest=init_onup();
	resTextFlag = 0;
	
	obj = document.getElementById(div_id);
	
	ajaxRequest.onreadystatechange = function(){
	
		if(ajaxRequest.readyState == 4) {
	
					// Initializing Div Objects
			obj = document.getElementById(div_id);
			
				resText=ajaxRequest.responseText;
				//obj.align="center";
				//alert(obj.style.display);
				obj.innerHTML = resText;
								
				if(obj.id=="kse100") {
					document.getElementById("ksetab1").innerHTML = "<img src=/market-data/images/top_symbol/volume_slected.png name=Image9 id=Image9 width=96 height=26 border=0>";
				}
				
				if(obj.id=="mykse") {
					document.getElementById("ksetab1").innerHTML = "<img src=/mykse/images/regular_up.gif name=Image3 id=Image3 width=64 height=26 border=0>";
				}
				
				
		} else {
			
			//obj.align="center";
			tbl_str = "<table width=10%  cellpadding=1  cellspacing=1 bgcolor=#ffffff style=\"margin-left:40%;  margin-top:30%;\"> ";
			tbl_str = tbl_str + "<tr><td align=center><img src=/calc/calWaiting.gif></td></tr></table>";
			
			obj.innerHTML = tbl_str;
			
		}
			
		
	} //call back function
	
	
	
		try {
		
			  static_obj = document.getElementById("static_img");
			} catch(e) {  }
			
	
		try {
				
				fly_obj = document.getElementById("fly_img");
			} catch(e) { }
			
			try {	
				
				graph_obj = document.getElementById("graph_container");
			} catch(e) { }
			
			
			try { 
				notices_obj = document.getElementById("div_notices");
				
			} catch(e) { }
			
			
			try { 
				ticker_obj = document.getElementById("div_ticker");
				
			} catch(e) { }
			
			try { 
			
				rpt_obj = document.getElementById("analysis_rpt_div");
				
			} catch(e) { }


			try { 
			
				cmp_obj = document.getElementById("company");
				
			} catch(e) { }

		
			// Handling model window Hide and show
			
			
			if(obj.style.display=="none")  {
				
				obj.style.display = "block";
				
				try {
				
					graph_obj.innerHTML = "<img src=/images/dd.jpg border=0 />"
				
				} catch(e) { }
				
				try {
					
					static_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					fly_obj.style.display = "none";
				} catch(e) { }
				
				try {
				
					notices_obj.style.display = "none";
				} catch(e) { }	
				
				try {
				
					ticker_obj.style.display = "none";
				} catch(e) { }	
				
				try {
				
					rpt_obj.style.display = "none";
				} catch(e) { }	
				
				try {
				
					cmp_obj.style.display = "none";
				} catch(e) { }	
					
			
			} else {
				
				obj.style.display = "none";
				
				try {
		
					static_obj.style.display = "none";
				} catch(e) { }
				
				try {
					
					fly_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					notices_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					ticker_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					rpt_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					cmp_obj.style.display = "block";
				} catch(e) { }

				
				try {
					
					GetGraph('1'); //show graph tab 1
				} catch(e) { }
					
			}	//else
	
	//alert(obj.id);
	
	
	switch (obj.id) {
		
		case "kse100":
			filepath = "/market-data/kse-100.php";
		break;
		
		case "kse30":
			filepath = "/market-data/kse-30.php";
		break;
		
		case "kmi30":
			filepath = "/market-data/kmi-30.php";
		break;
		
		case "kseshare":
			filepath = "/market-data/KSE-All-share.php";
		break;
		case "sector":
		
			company_index = document.getElementById("company").selectedIndex;
			company_val = document.getElementById("company").options[company_index].value;
			//alert(company_val);
			filepath = "/listing-companies/analysis_report_model.php?compid="+company_val;
			//filepath = "/listing-companies/test.php?compid="+company_val;
			
			//alert(filepath);
			
		break;
		
		case "registrar":
			filepath = "/listing-companies/registar_model.php";
		break;
		
		case "mykse":
			filepath = "/mykse/mykse.php";
		break;
		
		case "graph_all_share":
			filepath = "/graph/kse_all_share.php";
		break;
		
		case "graph_all_share_history":
			filepath = "/graph/kse_all_share_his.php";
		break;
		
		case "graph_kse100":
			filepath = "/graph/kse100.php";
		break;
		
		case "graph_kse30":
			filepath = "/graph/kse30.php";
		break;
		
		case "graph_kmi30":
			filepath = "/graph/kmi30.php";
		break;
		
	} //switch


	//alert(filepath);

		ajaxRequest.open("GET", filepath+'?rand='+Math.random(), true);
		//ajaxRequest.open("GET", filepath, true);
		ajaxRequest.send(null);

}// function

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ShowIndexSummary(filepath) {
	
	if(arguments.length==2)
	{
		obj = document.getElementById(arguments[1]);
		obj.style.display = "none";
		return;
	}
	var ajaxRequest;
	ajaxRequest=init_onup();
	resTextFlag = 0;
	
	if(filepath=="sectorIndex.php")
		obj = document.getElementById("sectorIndex");	
	else
		obj = document.getElementById("kseIndex");
		
		
		
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
	
					// Initializing Div Objects
			//obj = document.getElementById(div_id);
			
				resText=ajaxRequest.responseText;
				//obj.align="center";
				//alert(obj.style.display);
				obj.innerHTML = resText;
								
				/*if(obj.id=="kse100") {
					document.getElementById("ksetab1").innerHTML = "<img src=/market-data/images/top_symbol/volume_slected.png name=Image9 id=Image9 width=96 height=26 border=0>";
				}
				
				if(obj.id=="mykse") {
					document.getElementById("ksetab1").innerHTML = "<img src=/mykse/images/regular_up.gif name=Image3 id=Image3 width=64 height=26 border=0>";
				}*/
				
				
		} else {
			//alert(ajaxRequest.readyState);
			//obj.align="center";
			tbl_str = "<table width=10%  cellpadding=1  cellspacing=1 bgcolor=#ffffff style=\"margin-left:40%;  margin-top:30%;\"> ";
			tbl_str = tbl_str + "<tr><td align=center><img src=/calc/calWaiting.gif></td></tr></table>";
			
			obj.innerHTML = tbl_str;
			
		}
			
		
	} //call back function
	
	
	
		try {
		
			  //static_obj = document.getElementById("static_img");
			} catch(e) {  }
			
	
		try {
				
				//fly_obj = document.getElementById("fly_img");
			} catch(e) { }
			
			try {	
				
				//graph_obj = document.getElementById("graph_container");
			} catch(e) { }
			
			
			try { 
				//notices_obj = document.getElementById("div_notices");
				
			} catch(e) { }
			
			
			try { 
				ticker_obj = document.getElementById("div_ticker");
				
			} catch(e) { }
			
			try { 
			
				//rpt_obj = document.getElementById("analysis_rpt_div");
				
			} catch(e) { }


			try { 
			
				//cmp_obj = document.getElementById("company");
				
			} catch(e) { }

		
			// Handling model window Hide and show
			
			
			if(obj.style.display=="none")  {
				
				obj.style.display = "block";
				
				/*try {
				
					graph_obj.innerHTML = "<img src=/images/dd.jpg border=0 />"
				
				} catch(e) { }
				
				try {
					
					static_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					fly_obj.style.display = "none";
				} catch(e) { }
				
				try {
				
					notices_obj.style.display = "none";
				} catch(e) { }	*/
				
				try {
				
					ticker_obj.style.display = "none";
				} catch(e) { }	
				
				/*try {
				
					rpt_obj.style.display = "none";
				} catch(e) { }	
				
				try {
				
					cmp_obj.style.display = "none";
				} catch(e) { }	*/
					
			
			} else {
				
				obj.style.display = "none";
				
				/*try {
		
					static_obj.style.display = "none";
				} catch(e) { }
				
				try {
					
					fly_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					notices_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					ticker_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					rpt_obj.style.display = "block";
				} catch(e) { }
				
				try {
				
					cmp_obj.style.display = "block";
				} catch(e) { }

				
				try {
					
					GetGraph('1'); //show graph tab 1
				} catch(e) { }*/
					return;
			}	//else
	
		
		//ajaxRequest.open("GET", filepath+'?rand='+Math.random(), true);
		ajaxRequest.open("GET", filepath, true);
		
		ajaxRequest.send(null);

}// function