/*Javascript for history stock quote */
function enabledisable()
{
	document.frmsearchquote.fromdate.value='';
	document.frmsearchquote.todate.value='';
	document.frmsearchquote.fromdate.disabled="true";
	document.frmsearchquote.todate.disabled="true";
	document.frmsearchquote.btntodate.disabled="true";
	document.frmsearchquote.btnfromdate.disabled="true";
	document.frmsearchquote.selectperiod.disabled=false;
		
}

function enable()
{
	
	document.frmsearchquote.fromdate.disabled=false;
	document.frmsearchquote.todate.disabled=false;
	document.frmsearchquote.btntodate.disabled=false;
	document.frmsearchquote.btnfromdate.disabled=false;
	document.frmsearchquote.selectperiod.selectedIndex=0;
	document.frmsearchquote.selectperiod.disabled="true";

}

function firstdiable()
{
	if(document.frmsearchquote.fromdate.value=="")
	{
		document.frmsearchquote.fromdate.disabled=true;
	}
	if(document.frmsearchquote.todate.value=="")
	{
		document.frmsearchquote.todate.disabled=true;
	}
	document.frmsearchquote.btntodate.disabled=true;
	document.frmsearchquote.btnfromdate.disabled=true;
	document.frmsearchquote.selectperiod.disabled=false;
	//document.frmsearchquote.selectperiod.disabled="true";
}

function submitform()
{
	document.frmsearchquote.chksubmit.value="submit";
	//document.frmsearchquote.action='history-stockquote.asp';
	document.frmsearchquote.submit();
}

function popup(scripname)
{
	alert(scripname);
	var href='history-stock-more.asp?scripname='+scripname;
	
	window.open(href, '' ,'width=600,height=400,scrollbars=yes')

}

function submitLink(iScriptID,iScriptName){
	document.frmsearchquote.ScriptID.value=iScriptID;
	document.frmsearchquote.scripname.value=iScriptName;
	if(checkform()){
		return true;	
	}else{
		return false;
	}
}

function PageNoSubmit(iNo){
	document.frmsearchquote.pageno.value=iNo;
	if(checkform()){
		return true;	
	}else{
		return false;
	}
}

function checkform()
{
	var bval
	bval=true;	
	if(document.frmsearchquote.scripname.value=="")
	{
		alert('Please Enter Scrip Name');
		bval=false;
	}
	if(document.frmsearchquote.exchange.value=="" && bval)
	{
		alert('Please Select Exchange');
		bval=false;
	}
	
	//alert (document.frmsearchquote.rdsearchoption.checked);
	if(bval){
		var rad_val;
		for (var i=0; i < document.frmsearchquote.rdsearchoption.length; i++)
		{
		  if (document.frmsearchquote.rdsearchoption[i].checked)
		  {
		  	rad_val = document.frmsearchquote.rdsearchoption[i].value;
			break;
		  }else{
		  	rad_val ="";
		  }
	    }
		if(rad_val==""){
			alert("Please select period or daterange");
			bval=false;
		}
		
		if(rad_val=="period")
		{	
			if(document.frmsearchquote.selectperiod.value=="")
			{
				alert('Please Select Period');
				bval=false;
			}
		}
		if(rad_val=="daterange")
		{	
			if(document.frmsearchquote.fromdate.value=="" || document.frmsearchquote.todate.value=="")
			{
				alert('Please Select Date Range');
				bval=false;
			}
			
			var ArrDate1 = new Array();
			var date1 = document.frmsearchquote.fromdate.value;
			ArrDate1 = date1.split('/');
			date1=ArrDate1[2] + ArrDate1[1] + ArrDate1[0];
			date1 = date1 * 1
			
			var ArrDate2 = new Array();
			var date2 = document.frmsearchquote.todate.value;
			ArrDate2 = date2.split('/');
			date2=ArrDate2[2] + ArrDate2[1] + ArrDate2[0];
			date2 = date2 * 1

			if(date2<date1)
			{
				alert('Date Range Must Be In Right Order');
				bval=false;
			}
			
						
		}
	}
	//document.frmsearchquote.action='history-stockquote.asp';
	if(bval){
		document.frmsearchquote.submit();
	}else{
		return false;
	}
	
}

	function detailstock(id,date)
	{
		//alert(id);
		//alert(date);
		//window.location ="http://www.eggheadcafe.com/articles/querystringjs.htm?name="+sName+"&email="+sEmail;
		window.location.href="get-quote.asp?_SCID="+id+ "&copydate="+date;
		
	}
	

