//Common
 //This is for bulletin
 function ShowA2Z(redUrl_,Index)
 {
 	var A2ZIndexId = document.getElementById("A2ZTd");
	if(A2ZIndexId.innerHTML=="")
	{
		var A2Z="";A2ZClass ="";
			for(i=65; i<=90; i++)				
			{
				var Alpha = String.fromCharCode(i);
				A2ZClass = (Index==Alpha) ? "IndexLinkSel" : "IndexLink";
				A2Z += "<a href='"+redUrl_+"&Index="+ Alpha +"' class="+ A2ZClass+ ">"+ Alpha +"</a>";
			}
			A2ZClass = (Index=="0-9") ? "IndexLinkSel" : "IndexLink";	
			A2ZIndexId.innerHTML = A2Z + "<a href='"+redUrl_+"&Index=0-9' class="+ A2ZClass +">0-9</a>";
	}
	else
		A2ZIndexId.innerHTML = "";			
}


		
	
function SearchQuote()
	{
	
		
		var SrchQuote = document.getElementById("txt_Symbol").value;
		var PageId = document.getElementById("DD_Options").value;	
		
		if(SrchQuote =="" || SrchQuote=="Enter Company Name")
		{
			alert("Please enter company name ..!!!");
			return false;
		}
		
		else
		{
					var strReplaceAll =SrchQuote;
					var intIndexOfMatch = strReplaceAll.indexOf( "'" );
					while (intIndexOfMatch != -1)
					{
						strReplaceAll = strReplaceAll.replace( "'", "" )
						intIndexOfMatch = strReplaceAll.indexOf( "'" );
						
					}
					var StrUrl = "CompSearch.aspx?schtxt="+strReplaceAll+"&id="+PageId;
					window.location = StrUrl;
		}
				
   }
   
   
   	function EnterScript(e,id)
			{
				if(e.keyCode==13)	
				{
					var Scripid = document.getElementById(id);
					var boolval = SearchQuote1();
					if(boolval)
					return true;
					else
					return false;
				}
			}
			
			
   
function Event(e,id)
{
		if(e.keyCode==13)	
		{
			//var Scripid = document.getElementById(id);
			var boolval = SearchQuote();
			if(boolval)
			return true;
			else
			return false;
		}	
}

function EnterScript1(e,id)
{
	if(e.keyCode==13)	
	{
		var Scripid = document.getElementById(id);
		Scripid.click();
	}
}


function SearchQuote1()
				{
					var SrchQuote = document.getElementById("txt_Symbol").value;
					var PageId = document.getElementById("DD_Options").value;
					var strReplaceAll =SrchQuote;
					var intIndexOfMatch = strReplaceAll.indexOf( "'" );
					while (intIndexOfMatch != -1)
					{
						strReplaceAll = strReplaceAll.replace( "'", "" )
						intIndexOfMatch = strReplaceAll.indexOf( "'" );
						
					}
					var StrUrl = "../profiles/CompSearch.aspx?schtxt="+strReplaceAll+"&id="+PageId;
					//var StrUrl = "../profile/CompanySearch.aspx?schtxt="+SrchQuote+"&id="+PageId;			
					if(SrchQuote =="" || SrchQuote=="Company Name")
					{
						alert("Please enter company name ..!!!");
						return false;
					}
					else 
					{
						window.location=StrUrl;
					}								
				}

function Compempty()
{
	if (document.getElementById("txt_Quote2").value=="Change Company")
	{
  		document.getElementById("txt_Quote2").value="";
	}
}

function Compfill()
{
	var getquote=document.getElementById("txt_Quote2").value;
	if (getquote=="")
	{
		document.getElementById("txt_Quote2").value="Change Company";
	}
}

function HomeCompFill()
{

	var getquote=document.getElementById("txt_Quote2").value;
		if (getquote=="")
		{
			document.getElementById("txt_Quote2").value="Enter Company Name...!!!";
		}

}

function HomeCompEmpty()
{
	if (document.getElementById("txt_Quote2").value=="Enter Company Name...!!!")
	{
  		document.getElementById("txt_Quote2").value="";
	}
}



function CompValidate()
{					
		var SrchQuote = document.getElementById("txt_Quote2").value;
		
	 //	var PageId = document.getElementById("DD_Options").value;
		if(SrchQuote =="" || SrchQuote=="Enter Company Name...!!!" || SrchQuote=="Change Company")
		{
			alert("Please enter company name ..!!!");
			return false;
		}
		else 
		{
				var strReplaceAll =SrchQuote;
				var intIndexOfMatch = strReplaceAll.indexOf( "'" );
				while (intIndexOfMatch != -1)
				{
					strReplaceAll = strReplaceAll.replace( "'", "" )
					intIndexOfMatch = strReplaceAll.indexOf( "'" );
					
				}
				var StrUrl = "../Profiles/CompSearch.aspx?schtxt="+strReplaceAll+"&id=13";						
				window.location=StrUrl;
		}		
}

//Home Page Popup - For Loading Data to market commentary from NewsData.aspx Using AJAX  
	function GetNewsDetail(SrNo,secId,SubSecId,opt)
	{	
		document.getElementById("cm_window").style.display='inline';		
		document.getElementById("cont_window").style.display='none';
	
	
		var currentDivObj
		if(opt=="main")
		{	
			currentDivObj = document.getElementById("NewsId");
			currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
		}
		else
		{			
			currentDivObj = document.getElementById("NewsId2");
			currentDivObj.innerHTML ="<img src=../images/loading1.gif>";		
		}
		CreateXmlHttp();
		document.body.style.cursor = "progress";

		var requestUrl = "../HomeNewsData.aspx?secno="+ secId +"&SubSecno="+ SubSecId+"&SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		if(XmlHttp)
		{
					XmlHttp.onreadystatechange = function(){getDetails(opt);};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);					
		}
	}
	
	function getDetails(opt)
	{
		// To make sure receiving response data from server is completed
		if(XmlHttp.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(XmlHttp.status == 200)
			{
				if(opt=="main")
					document.getElementById("NewsId").innerHTML = XmlHttp.responseText;
				else
					document.getElementById("NewsId2").innerHTML = XmlHttp.responseText;
					document.body.style.cursor = "auto";
			}
			else
			{
				if(opt=="main")
					document.getElementById("NewsId").innerHTML = "<img src='../images/loading1.gif'>";
				else
					document.getElementById("NewsId2").innerHTML = "<img src='../images/loading1.gif'>";
			}
		}
	}
//End of Common

function Browser()
 {
  var ua, s, i;
  this.isIE    = false;
  this.isNS    = false;
  this.version = null;
  ua = navigator.userAgent;
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) 
  {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0)
   {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
   }

  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0)
   {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}




var browser = new Browser();
var clockTimeoutID;
//Global Variables
var XmlHttp,XmlHttp1,XmlHttp2;
	
function CreateXmlHttp()
	{
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;
					
			}
		}
		if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
	}
	
function CreateXmlHttp1()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp1 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp1 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp1 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp1 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp1 = new XmlHttpRequest();
		}
	}
	
function CreateXmlHttp2()
	{
		//Creating object of XmlHttp in IE
		try
		{
			XmlHttp2 = new ActiveXObject("Msxml2.XmlHttp");
		}
		catch(e)
		{
			try
			{
				XmlHttp2 = new ActiveXObject("Microsoft.XmlHttp");
			} 
			catch(oc)
			{
				XmlHttp2 = null;	
			}
		}
		//Creating object of XmlHttp in Mozilla and Safari 
		if(!XmlHttp2 && typeof XmlHttpRequest != "undefined") 
		{
			XmlHttp2 = new XmlHttpRequest();
		}
	}
	

//**** Function ExchngTimeClock Is used for to find out the market hours --- The ticker will automatically refresh only in market timings *****//			
function ExchngTimeClock(Exchg,PGType)
{
	var time = new Date()
	var hour = time.getHours()
	if (hour >= 10 && hour <= 20)
			clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"','"+ PGType +"')",600000);
}	
//**** Function killClock Is used for killing clock timer  *****//
 function killClock(){
	clearTimeout(clockTimeoutID);
	}		


  
//For Other Pages
function getOtherPages(opt)
{
	document.getElementById("cont_window").style.display='inline';
	document.getElementById("cm_window").style.display='none';
	
	var idOtherPages = document.getElementById("ContactUsId");
	CreateXmlHttp1();
	idOtherPages.innerHTML ="<img src=../images/loading1.gif>";
	var requestUrlOther = "../otherpages.aspx?opt=contactus&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();		
	//alert(opt);
	if(XmlHttp1)	
	{			
		XmlHttp1.onreadystatechange = function(){getOtherData(idOtherPages);};
		XmlHttp1.open("GET", requestUrlOther,  true);
		XmlHttp1.send(null);
	}
}

function getOtherData(id)
{	
	if(XmlHttp1.readyState == 4)
	{		
		if(XmlHttp1.status == 200)
		{			
			id.innerHTML = XmlHttp1.responseText; 
		}
	}
}
	
//For Loading News from NewsData.aspx Using AJAX
function GetNewsDet(secId,SrNo)
	{
		var currentDivObj = document.getElementById(SrNo);
		if(currentDivObj.style.display=='inline'){
				currentDivObj.style.display ='none';eval("document.IMG"+SrNo+".src = '../images/plus.gif'");}
			else
			{
				currentDivObj.style.display ='inline';
				eval("document.IMG"+SrNo+".src = '../images/maines.gif'");
				var tblObj=document.getElementById("NewsId").getElementsByTagName("td");
				var IdName;
				for(var i=1;i<tblObj.length;i++){
					IdName = tblObj[i].id;
					if(IdName)
						if(IdName!=SrNo){
							document.getElementById(IdName).style.display = "none";eval("document.IMG"+IdName+".src = '../images/plus.gif'");}}

				if(currentDivObj.innerHTML=="")
				{
					currentDivObj.innerHTML ="<img src=../images/loading1.gif>";
					CreateXmlHttp2();
					document.body.style.cursor = "progress";
					var requestUrl = "../Markets/NewsData.aspx?SecId="+ secId +"&SrNo="+ SrNo +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
					if(XmlHttp2)	{
								XmlHttp2.onreadystatechange = function(){getNewsDetResp(SrNo);};
								XmlHttp2.open("GET", requestUrl,  true);
								XmlHttp2.send(null);
							}
				}
			}	
	}
	
//Called when response comes back from server Only For NewsData
function getNewsDetResp(SrNo)
{
	// To make sure receiving response data from server is completed
	if(XmlHttp2.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp2.status == 200)
		{
			document.getElementById(SrNo).innerHTML = XmlHttp2.responseText;
			document.body.style.cursor = "auto";
		}
		else
			document.getElementById(SrNo).innerHTML = "<img src='../images/cm_loading.gif'>";
	}
}




 function PartnerWithUs()
 {
	var str1=document.getElementById("txt_Email").value
	var filter1=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	if(document.getElementById("txt_Name").value == " ")
	{
	alert("Name Field cannot be empty..!!");
	document.getElementById("txt_Name").focus() 
	return (false);
	} 
	
	if(document.getElementById("txt_Name").value == "")
	{
	alert("Please Enter Name..!!");
	document.getElementById("txt_Name").focus() 
	return (false);
	} 
	if(document.getElementById("txtAddress").value == " ")
	{
	alert("Address cannot be empty..!!");
	document.getElementById("txtAddress").focus() 
	return (false);
	} 
	
	if(document.getElementById("txtAddress").value == "")
	{
	alert("Please Enter Address..!!");
	document.getElementById("txtAddress").focus() 
	return (false);
	} 

	
	if((document.getElementById("txtPhoneRes").value == "")&&(document.getElementById("txtPhoneOffice").value == "")&&(document.getElementById("txtPhoneMobile").value == ""))
	{
	alert("Please Enter atleast one Telephone..!!");
	document.getElementById("txtPhoneRes").focus() 
	return (false);
	} 
	if (document.getElementById("txt_Email").value == "")
	  {
	    alert("Please enter a valid E-Mail ID..!!");
	    document.getElementById("txt_Email").focus();
	    return (false);  
	  }
	if (!filter1.test(str1))
	 {  
		alert("Invalid E-mail Address! Please re-enter..!!");
		document.getElementById("txt_Email").focus();
		return (false)
	 }	   
	if(document.getElementById("txtComments").value == " ")
	{
		alert("Comments cannot be empty..!!");
		document.getElementById("txtComments").focus() 
		return (false);
	}
	if(document.getElementById("txtComments").value == "")
	{
		alert("Please Enter Comments..!!");
		document.getElementById("txtComments").focus() 
		return (false);
	}
	
 }
 


