var updown=1;
function Imp_t1(a, b, c, d){

	for(var i=1;i<b;i++)
	{
		if(i==a){
		
		document.getElementById(c+""+i).style.display = "block";
		//$('#'+c+i).fadeIn(1000); 
		//$('#'+c+i).show();
		document.getElementById(d+""+i).className = "mb_tab3_on";
		
		}
		else{
		document.getElementById(c+""+i).style.display = "none";
		//$('#'+c+i).hide();
		//$('#'+c+i).fadeOut(1);
		document.getElementById(d+""+i).className = "mb_tab3_off";
		
		}
		
	}
}
////////////////////
//function h_t2(a, b, c, d){
//	for(var i=1;i<b;i++)
//	{
//		if(i==a){
//		document.getElementById(c+i).style.display = "block";
//		document.getElementById(d+i).className = "mb_tab2_on";
//		}
//		else{
//		document.getElementById(c+i).style.display = "none";
//		document.getElementById(d+i).className = "mb_tab2_off";
//		}
//	}
//}
////////////////////
function bse_nse_tab(passstr)
{
		if(passstr=='bse')
			{
				if(updown==0)
				{
					nsebseup(updown);
				}
			document.getElementById('bsetab').style.display = "block";
			document.getElementById('nsetab').style.display = "none";
			document.getElementById('c_bse').className = "hp_tab3_on";
			document.getElementById('c_nse').className = "hp_tab3_off";
			document.getElementById('bseprice').style.display = "block";
			document.getElementById('nseprice').style.display = "none";
			}
		else if (passstr=='nse')
			{

			if(updown==0)
				{
					nsebseup(updown);
				}
			document.getElementById('nsetab').style.display = "block";
			document.getElementById('bsetab').style.display = "none";
			document.getElementById('c_nse').className = "hp_tab3_on";
			document.getElementById('c_bse').className = "hp_tab3_off";
			document.getElementById('nseprice').style.display = "block";
			document.getElementById('bseprice').style.display = "none";
			}
}
////////////////////
function nsebseup(passupdown)
{
	if(passupdown==1)
	{
		updown=0;
		var fillplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";
		$("#nsebsemaindiv").slideUp(500);
		$("#bsenseplmi").attr("src",fillplus);		
		document.getElementById('c_bse').className = "hp_tab3_off";
		document.getElementById('c_nse').className = "hp_tab3_off";
	}
	else
	{
		updown=1;
		var fillplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif";
		$("#nsebsemaindiv").slideDown(500);
		$("#bsenseplmi").attr("src",fillplus);		
		bse_nse_tab('bse');
	}
		
}
////////////////////


function post_histsearch(search_param)
{
	document.histsearch_frm.range.value=search_param;
	//document.histsearch_frm.action="http://markets.moneycontrol.com/technicals/histlogin.php";
	document.histsearch_frm.action="http://indiaearnings.moneycontrol.com/sub_india/histdata.php";
	document.histsearch_frm.submit();
}

//////////////////////

function compare_peers()
{
	compval=document.compare_search.companyname.value;
	
	if(compval.length < 3 || compval=='Enter Company Name')
		{
			alert("Please enter minimum 3 characters for search");
			document.compare_search.companyname.focus();
			return false;
		}
	document.compare_search.action="http://indiaearnings.moneycontrol.com/sub_india/compsearch_result.php?companyname="+escape(compval)+"&fname=price&searchtype=new";
	
		document.compare_search.submit();		
		//return true;
}

//////////////////

function company_info_search()
{
	compval=document.company_info.companyname.value;

	dropselc=document.company_info.type_info.value;
	
	if(compval.length < 3 || compval=='Enter Company Name')
		{
			alert("Please enter minimum 3 characters for search");
			document.company_info.companyname.focus();
			return false;
		}

		if(dropselc.length < 1)
		{
			alert("Please select a criteria");
			document.company_info.type_info.focus();
			return false;
		}

	document.company_info.action="http://indiaearnings.moneycontrol.com/sub_india/compsearch_result.php?companyname="+escape(compval)+"&fname=price&searchtype=new";
	
		document.company_info.submit();		
		//return true;
}

//////////////////

function company_main_search()
{
	compval5=document.compsearchmain.compsearch.value;
	
	if(compval5.length < 3 || compval5=='Enter Company Name')
		{
			alert("Please enter minimum 3 characters for search");
			document.compsearchmain.compsearch.focus();
			return false;
		}
	document.compsearchmain.action="http://indiaearnings.moneycontrol.com/sub_india/compsearch_result.php?companyname="+escape(compval5)+"&fname=price&searchtype=new";
	
		document.compsearchmain.submit();		
		//return true;
}

function keyword_footsearch()
{
	compval5=document.keyword_search.keyword.value;	
	if(compval5.length < 3 || compval5=='company, keywords, results, by year etc.')
	{
		alert("Please enter minimum 3 characters for search");
		document.keyword_search.keyword.focus();
		return false;
	}
	document.keyword_search.action="http://indiaearnings.moneycontrol.com/sub_india/searchresult.php?search_str="+escape(compval5);
	document.keyword_search.submit();	
}

function keyword_mainsearch()
{
	compval5=document.keyword_search_top.keyword_main.value;	
	if(compval5.length < 3 || compval5=='company, results, by year etc.')
	{
		alert("Please enter minimum 3 characters for search");
		document.keyword_search_top.keyword_main.focus();
		return false;
	}
	document.keyword_search_top.action="http://indiaearnings.moneycontrol.com/sub_india/searchresult.php?search_str="+escape(compval5);
	document.keyword_search_top.submit();	
}

///////////////New Ticker

var tWidth='650px';                  // width (in pixels)
var tHeight='23px';                  // height (in pixels)
var tcolour='#F6F8E0';               // background colour:
var moStop=true;                     // pause on mouseover (true or false)
var fontfamily = 'arial,sans-serif'; // font for content
var tSpeed=2;                       // scroll speed (1 = slow, 5 = fast)
var cps=tSpeed;
var aw, mq;
var fsz = parseInt(tHeight) - 4;
function startticker()
{
	if (document.getElementById) 
	{
		var tick = '<div style="position:relative;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"';
		if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;"><\/div><\/div>';

		document.getElementById('ticker').innerHTML = tick;
		mq = document.getElementById("mq"); mq.style.left=(parseInt(tWidth)+10)+"px";
		mq.innerHTML='<span id="tx">'+content+'<\/span>'; 
		aw = document.getElementById("tx").offsetWidth; 
		lefttime=setInterval("scrollticker()",50);
		
	}
} 
function scrollticker()
{
	mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";
} 

//var content='<img src="http://img1.moneycontrol.com/images/india_earning/earn2008/bull1.gif" align="absmiddle" style="margin-left:15px;"/> <a href="#" class="bl_12">Mercator Singapore FY08 revenue up 72% at USD 146.2 m</a>  <img src="http://img1.moneycontrol.com/images/india_earning/earn2008/bull1.gif" align="absmiddle" style="margin-left:15px;"/> <a href="#" class="bl_12">Rupee breaches 41/USD in opng trade; last touch</a>';



function companyfact(cfpass)
{
	
	for (cfcnt=1; cfcnt<=4; cfcnt++)
	{
		if(cfpass==cfcnt)
		{
			
			if($("#cfactpm_"+cfcnt).attr("src")=="http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif")
			{
				$("#cfdiv_"+cfcnt).slideUp(250);
				var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";	
				$("#cfactpm_"+cfcnt).attr("src",cfactplus);	
				
			}
			else
			{			
				$("#cfdiv_"+cfcnt).slideDown(500);
				var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif";	
				$("#cfactpm_"+cfcnt).attr("src",cfactplus);	
			}
			
		}
		else
		{
			$("#cfdiv_"+cfcnt).slideUp(500);
			var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";	
			$("#cfactpm_"+cfcnt).attr("src",cfactplus);	
		}

	}	
}

/////////////////////

function table_collapse()
{
			
			if($("#resimg_plmi").attr("src")=="http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif")
			{
				$("#results_table").slideUp(500);
				var imgresult = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";	
				$("#resimg_plmi").attr("src",imgresult);

			}
			else
			{
				$("#results_table").slideDown(500);
				var imgresult = "http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif";	
				$("#resimg_plmi").attr("src",imgresult);
			}
}
  
//////////////////////////

function view_analysis(vapass)
{
		for (vacnt=1; vacnt<=5; vacnt++)
	{
		if(vapass==vacnt)
		{
			
			if($("#viewicon_"+vacnt).attr("src")=="http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif")
			{
				$("#views_ana_"+vacnt).slideUp(250);
				var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";	
				$("#viewicon_"+vacnt).attr("src",cfactplus);	
				
			}
			else
			{			
				$("#views_ana_"+vacnt).slideDown(500);
				var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/close_icon.gif";	
				$("#viewicon_"+vacnt).attr("src",cfactplus);	
			}
			
		}
		else
		{
			$("#views_ana_"+vacnt).slideUp(500);
			var cfactplus = "http://img1.moneycontrol.com/images/india_earning/earn2008/open_icon.gif";	
			$("#viewicon_"+vacnt).attr("src",cfactplus);	
		}

	}	
}



