var xmlHttp
var strErr
var strWhereTo
var strDir
var strAppType
var strPageType
var intNoOfQuestionPerPage
var intPageNo
var intPageCount
var intSq="0"
var intEq="0"
var isResult
var AppType
var ysnAllStage=0
/*Variables used in disease descriptor section:start*/
var ctId=''
var hdVal=''
var hdName=''
var txtVal=''
var ysnDescriptorChecked=0
/*Variables used in disease descriptor section:end*/
/*
function NewSearchTrial(id)
{	
	alert(id)	
	var url = "SelectDrugSupportivePage.aspx?ysnisRevised="+id+"&r="+Math.random();
	
	try
	{  // Firefox, Opera 8.0+, Safari  
	xmlHttp=new XMLHttpRequest();  
	}
	catch (e)
	{  // Internet Explorer  
		try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch (e)
			{   
				try
				{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
				{     
					alert("Your browser does not support AJAX!");     
					return false;      
				}
			}  
		}
	xmlHttp.onreadystatechange=function()
		{
		if(xmlHttp.readyState==4)
		{
			var str = xmlHttp.responseText;
			//window.location='../trialcheck/'    
			
		}
			
		}   
	if(url != null)
	{
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null); 
	}
}
*/

function getQueryVariable(variable) 
{  
	var query = window.location.search.substring(1); 
	var vars = query.split("&")
	for (var i=0;i<vars.length;i++) 
	{    
		var pair = vars[i].split("=");    
		if (pair[0] == variable) 
		{      
			return pair[1]
		}  
	}
	return null 
}
function CheckAge()
{
	var objAge=document.getElementById('txtAge')
	//alert(objAge)
	if(objAge!=null && objAge.value.length!=0)
	{
		//alert(objAge.value)
		var rexNumber=new RegExp(/[^0-9]/)
		if(objAge.value.match(rexNumber))
		{
			alert("That is not a valid age.")
			return false
		}
	}
	return true
}
/*Adding indicator for the screening progress:Start*/
function getNextQuestionIndicator(strWhereTo,strDir,strResult)
{ 
	/*Implementing the virtual page view technique to record the screening second page hit*/
	pageTracker._trackPageview('/vpv/tck-step2/');
	if(CheckAge())
	{
		var pageStatus=document.getElementById('pageStatus')
		AppType=document.getElementById('hdAppType')
		progress_update_CTHBase();
		
		//the below check is to handle -continuosly press Enter key 
		if(pageStatus==null || (pageStatus!=null && pageStatus.value=="0"))
		{
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return false
			}
			setDefaultSettingForAppType(0)
			isResult=strResult
			var strAnsware=getAllAnswer()
			var url="ajaxsupportivepage.aspx"
			url=url+"?strWhereTo="+strWhereTo
			url=url+"&hdPageDetails="+intSq+"|"+intEq
			url=url+"&strDir="+strDir
			if(strAnsware!=null && strAnsware.length!=0 && strAnsware!='')
				url=url+"&strAns="+strAnsware
			if(getQueryVariable('isRevised')!=null)
				url=url+"&isRevised='y'"
			if(AppType!=null)
			{
				url=url+"&AppType="+AppType.value	
			}
			url=url+"&sid="+Math.random()
			if(pageStatus!=null)
			{
				pageStatus.value="1"
			}
			xmlHttp.onreadystatechange = function()//Samim Sougata changes for sending parameter ajax func
			{
				stateChanged(strWhereTo);
			};
			//xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
	}
//	sizeSpacer()
	return false
}
function progress_update_CTHBase() {

if(document.getElementById('divCTHProgressBar')!=null)
{
	document.getElementById('divCTHProgressBar').style.visibility = 'visible';
	document.getElementById('divCTHProgressBar').innerHTML="<label class='CWS-Std-Label'>TrialCheck&reg; is working, please wait.</label><br>"+
															"<img src='images/bar.gif'>";
}

}
function progress_stop_CTHBase() {
if(document.getElementById('divCTHProgressBar')!=null)
{
	document.getElementById('divCTHProgressBar').style.visibility = 'hidden';
	document.getElementById('divCTHProgressBar').innerHTML="";
	
}

}
/*Adding indicator for the screening progress:End*/

function getNextQuestion(strWhereTo,strDir,strResult)
{ 
	if(CheckAge())
	{
		var pageStatus=document.getElementById('pageStatus')
		AppType=document.getElementById('hdAppType')
		
		//the below check is to handle -continuosly press Enter key 
		if(pageStatus==null || (pageStatus!=null && pageStatus.value=="0"))
		{
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return false
			}
			setDefaultSettingForAppType(0)
			isResult=strResult
			var strAnsware=getAllAnswer()
			var url="ajaxsupportivepage.aspx"
			url=url+"?strWhereTo="+strWhereTo
			url=url+"&hdPageDetails="+intSq+"|"+intEq
			url=url+"&strDir="+strDir
			if(strAnsware!=null && strAnsware.length!=0 && strAnsware!='')
				url=url+"&strAns="+strAnsware
			if(getQueryVariable('isRevised')!=null)
				url=url+"&isRevised='y'"
			if(AppType!=null)
			{
				url=url+"&AppType="+AppType.value	
			}
			url=url+"&sid="+Math.random()
			if(pageStatus!=null)
			{
				pageStatus.value="1"
			}
			xmlHttp.onreadystatechange = function()//Samim Sougata changes for sending parameter ajax func
			{
				stateChanged(strWhereTo);
			};
			//xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
	}
//	sizeSpacer()
	return false
}
function setDefaultSettingForAppType(check)
{
	var pageDetails=document.getElementById('hdPageDetails')
	if(pageDetails!=null)
	{
		pageDetails=pageDetails.value
		if(pageDetails!='' && pageDetails.value!='undefined')
		{
			pageDetails=pageDetails.split("|")
			if(pageDetails.length>1)
			{
				intSq=pageDetails[0]
				intEq=pageDetails[1]
				if(check==1)
					isResult=pageDetails[2]
			}
		}
		else
		{
			intSq="0"
			intEq="0"
		}
	}
}
function disableEnterKey(event)
{
	setDefaultSettingForAppType(1)
	event = event? event : window.event;
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if ((keyCode == 13) || (keyCode == 10))
	{
		//event.keyCode=0
		//event.returnValue = false;
		//event.cancel = true;
		// These are disabled to prevent the accidental firing of an event
		// associated with a control in the browser.
		// The code that originally handled this worked similiar to a callback method
		// in that it would be called in response to an event occuring on the users machine.
		// In some case the previous arrow would recieve the focus if the user clicked on the 
		// page. Subsequently, when enter is pressed the event of clicking the previous imagebutton
		// is raised and the user goes backwards. Page traversal is still handled using the code-behind
		// technique.
		//window.event.keyCode = 0
		//compliance()
		getNextQuestion(((intEq*1)+1),'1',isResult)
		return false
	}
}


function getAllAnswer()
{
	var strRet=''
	var intRemainingQuestion=(intEq-intSq)+1
	var intStartQuestion=intSq*1
	switch(intStartQuestion)
	{
		case 1:
			var objZipCode=document.getElementById('txtZipCode')
			if(objZipCode!=null)
				strRet=objZipCode.value
			strRet=strRet+';'
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 2:
			var objGender=document.getElementsByName('rdbtnlstGender')
			var strGender=getRadioButtonValue(objGender)
			strRet=strRet+strGender+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 3:
			var objEthnic=document.getElementsByName('rdbtnlstEThnicity')
			var strEthnic=getRadioButtonValue(objEthnic)
			strRet=strRet+strEthnic+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 4:
			var objAnatomicalSite=document.getElementsByName('rdbtnlstCancerType')
			var strAnatomicalsite=getRadioButtonValue(objAnatomicalSite)
			strRet=strRet+strAnatomicalsite+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 5:
			var objAnatomicalSubSite=document.getElementsByName('rdbtnlstCancerSubType')
			var strAnatomicalsubsite=getRadioButtonValue(objAnatomicalSubSite)
			strRet=strRet+strAnatomicalsubsite+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		/*Section Added for getting answer for disease descriptor:start*/
		case 6:
			var objDiseaseDescriptor=document.getElementById('hdSubClassificationValue')
			var DiseaseDescriptorName = document.getElementById('hdSubClassificationName')
			if(objDiseaseDescriptor!=null)
			{
				strRet=strRet+objDiseaseDescriptor.value +"*"+DiseaseDescriptorName.value.replace('+','^') +";"
			}
			objDiseaseDescriptor=document.getElementById('hdMarkerValue')
			DiseaseDescriptorName = document.getElementById('hdMarkerName')
			if(objDiseaseDescriptor!=null)
			{
				strRet=strRet+objDiseaseDescriptor.value +"*"+DiseaseDescriptorName.value.replace('+','^') +";"
			}
			objDiseaseDescriptor=document.getElementById('hdOtherValue')
			DiseaseDescriptorName = document.getElementById('hdOtherName')
			if(objDiseaseDescriptor!=null)
			{
				strRet=strRet+objDiseaseDescriptor.value +"*"+DiseaseDescriptorName.value.replace('+','^') +";"
			}
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		/*Section Added for getting answer for disease descriptor:end*/
		case 7:
			var objKindOfTreatment=document.getElementsByName('rdbtnlstTreatmentHistory')
			var strTreatmentKind=getRadioButtonValue(objKindOfTreatment)
			strRet=strRet+strTreatmentKind+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 8:
			var objStage=document.getElementsByTagName('input')
			var strStage=getDiseaseStage(objStage)
			strRet=strRet+strStage+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 9:
			var objAge=document.getElementById('txtAge')
			if(objAge!=null)
				strRet=strRet+objAge.value+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 10:
			var objDailyActivity=document.getElementsByName('rdbtnlstDailyActivity')
			var strDailyActivity=getRadioButtonValue(objDailyActivity)
			strRet=strRet+strDailyActivity+";"
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 11:
			/*var objDrug=document.getElementById('drplstDrug')
			if(objDrug!=null)
			{
				var strText=objDrug.value
				var strValue=''
				var hElement=document.getElementById('ACB_drplstDrug')
				var hAc=hElement.hAutocomplete
				var hArr = hAc.aData
				for(hArrKey in hArr)
				{
					if(hArr[hArrKey]==strText)
					{
						strValue=hArrKey
						break
					}
				}
				strRet=strRet+strValue+";"
			}
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break*/
			var objDrug=document.getElementById('hdDrugValue')
			var drugName = document.getElementById('hdDrugName')
			if(objDrug!=null)
			{
				strRet=strRet+objDrug.value +"*"+drugName.value +";"
			}
			intRemainingQuestion--
			if(intRemainingQuestion>0);
			else
				break
		case 12:
			var objPhase=document.getElementsByName('rdbtnlstPhase')
			var strPhase=getRadioButtonValue(objPhase)
			strRet=strRet+strPhase
			if(ysnAllStage==0)
				strRet=strRet+ ";0"
			else
				strRet=strRet+ ";1"
			break
		default:
			//alert('Invalid Page')
			break
	}
	//strRet=strRet.trimEnd(';')
	
	return strRet
}


//function getCurrentPageName()
//{
//	var sPath = window.location.pathname
//	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1)
//	return sPage
//}


function stateChanged(strWhereTo)//samim sougata add parameter
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var str=xmlHttp.responseText
		//Adding indicator
		progress_stop_CTHBase();
		if(str.length==0)
		{
			window.location.reload();
		}

		if(xmlHttp.status==200)
		{
			/*section added to check the validity for the zip code, entered by the user:start*/
			var strTemp=xmlHttp.responseText
			if(strTemp!='')
			{
				strTemp = strTemp.substring(strTemp.indexOf('<div id="pnlScreeningSteps"'),strTemp.length);
				strTemp = strTemp.substring(0,strTemp.indexOf('</div>'));
				strTemp=strTemp.substring(strTemp.indexOf('>')+1,strTemp.length);
				
			}
			if(strTemp.toUpperCase().indexOf('FALSE')!=-1)
			{
				if(document.getElementById('lblZipCodeVaildationMsg')!=null)
				{
					if(document.getElementById('pageStatus')!=null)
						document.getElementById('pageStatus').value='0';
					document.getElementById('lblZipCodeVaildationMsg').innerHTML='The Zip Code you entered either not valid or does not exist in the TrialCheck &reg; system. Please specify correct Zip Code.'
					var objZip=document.getElementById('txtZipCode')
					if(objZip!=null)
					{
						objZip.scrollIntoView(true);
						objZip.focus();	
					}
				}
				return false;
			}
			/*section added to check the validity for the zip code, entered by the user:end*/

			if(isResult=='-1')
			{	
				var strtemp=str.substring(str.indexOf("<form"),str.length)
				strtemp=strtemp.substring(0,strtemp.indexOf(">")+1)
				str=str.replace(strtemp,"")
				str=str.replace("</form>","")
				document.getElementById('pnlMainContent').innerHTML=''
				document.getElementById('pnlMainContent').innerHTML=str
				
				var pnlLeftSection=document.getElementById('pnlLeftSection')
				var pnlScreeningSteps=document.getElementById('pnlScreeningSteps')
				if(pnlLeftSection!=null && pnlScreeningSteps!=null)
					document.getElementById('pnlLeftSection').innerHTML=document.getElementById('pnlScreeningSteps').innerHTML
				MakeEditableDropDown()
				document.all('Table1').scrollIntoView(true);
				//document.all('pnlMainContent').scrollIntoView(true)
				if(str.indexOf("Welcome to TrialCheck")>0)
					show('XXXX','XXXX');//samim sougata add 2 parameters only
			}
			else
			{
				document.getElementById('pnlMainContent').innerHTML=''
				var strLocation=window.location.toString()
				var qindex=strLocation.indexOf("?")
				if(qindex!=-1)
					strLocation=strLocation.substring(0,qindex)
				//alert(strLocation)
				var memid=getQueryVariable("memid")
				//alert(memid)
				if(memid!=null)
					window.location=strLocation+"?memid="+memid+"&intAppMode=1&audit=1"
				else
					window.location="ScreeningComplete.aspx"
					//window.location=strLocation+"?intAppMode=1&audit=1"
					
				document.all('Table1').scrollIntoView(true);
			}
		}
		if(strWhereTo==1)
		{
		CaptureEvents('null','PreviousButton')//samim sougata added the function//samim+sougata
		}
		else if(strWhereTo==5 ||strWhereTo==6)
		{
		CaptureEvents('null','NextButton')//samim sougata added the function
		}
		else if(strWhereTo==20)
		{
		
		CaptureEvents('null','FinishButton')//samim sougata added the function
		}
	}
}

function MakeEditableDropDown()
{
	var drplstDrug=document.getElementById('drplstDrug')
	if(drplstDrug!=null)
	{
		if( cAutocomplete.CB_AUTOINIT )
		{
			ForceInitialization()
		}
	}
}


//function getchkValue(id)
//{
//	var objGender=document.getElementsByTagName('input')
//}
function getRadioButtonValue(rdbtnlstId)
{
	if(rdbtnlstId!=null)
	{
		for(var i=0;i<rdbtnlstId.length;i++)
		{
			if(rdbtnlstId[i].checked)
			{
				return rdbtnlstId[i].value
			}
		}
	}
	return ''
}
function getDiseaseStage(chklstId)
{
	var strchkValue=''
	var intCounterTtLen=0
	var intCounterchk=0
	if(chklstId!=null)
	{
		for(var i=0;i<chklstId.length;i++)
		{
			if(chklstId[i].type=='checkbox' && chklstId[i].id.indexOf('chklstDiseaseStage')!=-1)
			{
				intCounterTtLen++;
				if(chklstId[i].checked)
				{
					strchkValue+=chklstId[i].value+","
					intCounterchk++;
				}
			}
		}
		
	}
	
	if(intCounterchk==intCounterTtLen)
		ysnAllStage=1
	else
		ysnAllStage=0
		
	return strchkValue
}
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function CaptureEvents(id,type)//Calling ajax page populate temp datatable\\samim and sougata
{
	var strValue = "";
	var intQuesId="";
	var url="/CancerTrialsHelpDemo/trialcheck/ajaxsupportiveeventcapture.aspx" //samim and sougata
	//alert(type+"ss"+ id);
	switch(type)
	{
	
		case 'text':	
			strValue=document.getElementById(id).value;
			strControlId=id.substring(3,id.length)
			
			if(strControlId=="ZipCode")
			{
				url=url+"?intQuesId=1"
				url=url+"&strEventName=TextChange"
				url=url+"&strEventSource="+strControlId
				url=url+"&strSource="+document.URL
				url=url+"&strEventSourceType=Textbox"
				url=url+"&strFunctionName=ScreeningEvent"
				url=url+"&strEventValue="+strValue
				url=url+"&sid="+Math.random()
				
			}
			if(strControlId=="Age")
			{
				url=url+"?intQuesId=9" //question id is increamented by 1 as one question is added (disease descriptor)
				url=url+"&strEventName=TextChange"
				url=url+"&strEventSource="+strControlId
				url=url+"&strSource="+document.URL
				url=url+"&strEventSourceType=Textbox"
				url=url+"&strFunctionName=ScreeningEvent"
				url=url+"&strEventValue="+strValue
				url=url+"&sid="+Math.random()
			}
			/*Section added for drug:start*/
			if(strControlId=="Drug")
			{
				url=url+"?intQuesId=11"
				url=url+"&strEventName=TextChange"
				url=url+"&strEventSource="+strControlId
				url=url+"&strSource="+document.URL
				url=url+"&strEventSourceType=Textbox"
				url=url+"&strFunctionName=ScreeningEvent"
				url=url+"&strEventValue="+strValue
				url=url+"&sid="+Math.random()
			}
			/*Section added for drug:end*/
			/*Section added for disease descriptor:start*/
			if(strControlId=="SubClassification" || strControlId=="Marker" || strControlId=="Other")
			{
				url=url+"?intQuesId=6"
				url=url+"&strEventName=TextChange"
				url=url+"&strEventSource="+strControlId
				url=url+"&strSource="+document.URL
				url=url+"&strEventSourceType=Textbox"
				url=url+"&strFunctionName=ScreeningEvent"
				url=url+"&strEventValue="+strValue
				url=url+"&sid="+Math.random()
			}
			/*Section added for disease descriptor:end*/
			break
		case 'radio':
			
			 var strRadControlGroupName=document.getElementsByName(id);
			
			for (var x = 0; x < strRadControlGroupName.length; x++)
				{
					if (strRadControlGroupName[x].checked)
					{
					   	strValue=strRadControlGroupName[x].nextSibling.innerText;
					  
					}
				}
			strControlId=id.substring(8,id.length)
			
			switch(strControlId)
			{
				case 'Gender':
					url=url+"?intQuesId=2"
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break
				case 'Ethnicity':
					url=url+"?intQuesId=3"
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()
					break
				case 'CancerType':
					url=url+"?intQuesId=4"
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break 
				case 'CancerSubType':
					url=url+"?intQuesId=5"
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break 
				case 'TreatmentHistory':
					url=url+"?intQuesId=7" //question id is increamented by 1 as one question is added (disease descriptor)
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break 
				case 'DailyActivity':
					url=url+"?intQuesId=10" //question id is increamented by 1 as one question is added (disease descriptor)
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break 
				case 'Phase':
					url=url+"?intQuesId=11" //question id is increamented by 1 as one question is added (disease descriptor)
					url=url+"&strEventName=OnClick"
					url=url+"&strEventSource="+strControlId
					url=url+"&strSource="+document.URL
					url=url+"&strEventSourceType=RadioButton"
					url=url+"&strFunctionName=ScreeningEvent"
					url=url+"&strEventValue="+strValue
					url=url+"&sid="+Math.random()					
					break 
					
					
			}
			
			
			break
			
		/*case 'DropDownlist': //currently dropdownlist for drug is removed
		
			strValue=document.getElementById(id).value;
			strControlId=id.substring(6,id.length)	
			url=url+"?intQuesId=10"			
			url=url+"&strEventName=OnChange"
			url=url+"&strEventSource="+strControlId
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=DropDownlist"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue="+strValue
			url=url+"&sid="+Math.random()
			break*/
			
		case 'checkbox':
		
			strValue=document.getElementById(id).nextSibling.innerText;
			strControlId=id.substring(6,18)	
			url=url+"?intQuesId=8"	//question id is increamented by 1 as one question is added (disease descriptor)		
			url=url+"&strEventName=OnClick"
			url=url+"&strEventSource="+strControlId
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=CheckBox"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue="+strValue
			url=url+"&sid="+Math.random()
			break
		case 'NextButton'://samim+sougata
		
			strValue="";
			strControlId=""	
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSource=NextButton"
			url=url+"&strEventSourceType=NextButton"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue=null"
			url=url+"&sid="+Math.random()
			break
		case 'FinishButton':
			strValue="";
			strControlId=""	
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strEventSource=ShowTrialResult"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=ShowButton"
			url=url+"&strEventValue=null"
			url=url+"&sid="+Math.random()
			break
		case 'PreviousButton'://samim+sougata
			strValue="";
			strControlId=""	
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strEventSource=PreviousButton"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=PreviousButton"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue=null"
			url=url+"&sid="+Math.random()
			break
		case 'HtmlAnchorVisitorType'://samim and Sougata start
			strControlId=id.substring(15,id.length)
			
		    //alert(strControlId)
			strValue="";
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSource=VisitorType"
			url=url+"&strFunctionName=VisitorType"
			url=url+"&strEventSourceType=HtmlAnchor"
			if(strControlId=="Patient")
		    {
				url=url+"&strEventValue=1"
			}
			if(strControlId=="Healthcare")
		    {
				url=url+"&strEventValue=2"
			}
			if(strControlId=="PatientAdvocate")
		    {
				url=url+"&strEventValue=3"
			}
			if(strControlId=="LeadershipCouncils")
		    {
				url=url+"&strEventValue=4"
			}
			url=url+"&sid="+Math.random()			
			break
			//samim and Sougata end
		case 'HtmlAnchor':
			strControlId=id.substring(15,id.length)
		    //alert(strControlId)
			strValue="";
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSource=Question Help"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventSourceType=HtmlAnchor"
			if(strControlId=="1")
			{
				url=url+"&strEventValue=Zip"
			}	
			if(strControlId=="2")
			{
				url=url+"&strEventValue=Gender"
			}	
			if(strControlId=="3")
			{
				url=url+"&strEventValue=Ethnic background"
			}	
			if(strControlId=="4")
			{
				url=url+"&strEventValue=Cancer Type"
			}
			if(strControlId=="5")
			{
				url=url+"&strEventValue=Kind of Myeloma"
			}
			//question id is increamented by 1 as one question is added (disease descriptor)
			
			if(strControlId=="6")
			{
				url=url+"&strEventValue=Disease Descriptor"
			}
			
			if(strControlId=="7")
			{
				url=url+"&strEventValue=Treatment History"
			}
		    if(strControlId=="8")
		    {
				url=url+"&strEventValue=Cancer Stage"
			}
			if(strControlId=="9")
		    {
				url=url+"&strEventValue=Age"
			}
			if(strControlId=="10")
		    {
				url=url+"&strEventValue=Daily Activity"
			}
			if(strControlId=="11")
		    {
				url=url+"&strEventValue=Drug"
			}
			if(strControlId=="12")
		    {
				url=url+"&strEventValue=Phase"
			}
			url=url+"&sid="+Math.random()
			break
			
		case 'HtmlAnchorAnswerHelp':
			strControlId=id.split('#')
		    strValue="";
			url=url+"?intQuesId=-1"			
			url=url+"&strEventName=Onclick"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=HtmlAnchor"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue="+strControlId[0]
			if(strControlId[1]=="4")
			{
				url=url+"&strEventSource=Cancer Type Answer Help"
			}
			if(strControlId[1]=="5")
			{
				url=url+"&strEventSource=Kind of Myeloma Answer Help"				
			}
			//question id is increamented by 1 as one question is added (disease descriptor)
			
			if(strControlId[1]=="6")
			{
				url=url+"&strEventSource=Disease Descriptor Answer Help"				
			}
			
			if(strControlId[1]=="7")
			{
				url=url+"&strEventSource=Treatment History Answer Help"				
			}
		    if(strControlId[1]=="8")
		    {
				url=url+"&strEventSource=Cancer Stage Answer Help"
			}
			if(strControlId[1]=="10")
		    {
				url=url+"&strEventSource=Daily Activity Answer Help"
			}
			url=url+"&sid="+Math.random()
			//alert(url)
			break
			
		case 'MenuTab':
			url=url+"?intQuesId=-1"				
			url=url+"&strEventName=OnClick"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSource="+id
			url=url+"&strEventSourceType=TabButton"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue="+id
			url=url+"&sid="+Math.random()
			break
			
		default:
		    if(type!='XXXX')
		    {
			url=url+"?intQuesId=-1"				
			url=url+"&strEventName=null"
			url=url+"&strEventSource=null"
			url=url+"&strSource="+document.URL
			url=url+"&strEventSourceType=null"
			url=url+"&strFunctionName=ScreeningEvent"
			url=url+"&strEventValue=null"
			url=url+"&sid="+Math.random()
			alert(url)
			}
			break
			
				
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return false
	}
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=analyticsStatechange 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	return;		
}
//Created by samim and sougata
function analyticsStatechange()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			var str=xmlHttp.responseText
			

			if(xmlHttp.status==200)
			{
			
			
			}
		}	

}

//Created By Arijit
	function NNKeyCap(thisOne) 
	{
		alert(thisOne);
		/*if (thisOne.modifiers & Event.SHIFT_MASK) 
		{
			
		}*/
		var key = thisOne.which
		//alert(key);
	}
	function keycheck1(letter,id)
	{
		var type="P";
		var url = "SelectDrugSupportivePage.aspx?s="+letter+"&type="+type+"&r="+Math.random();
		keychecktest(url,id);
	}
	function keychecktest(url,id)
	{
		document.getElementById('txtSearchDrug').value='Type the name to filter the list below';
		//document.getElementById('txtSearchDrug').focus();
		
		if(document.getElementById(id)!=null)
		{
			document.getElementById(id).style.color='#800080';
		}
		try
			{  // Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
			}
		catch (e)
		{  // Internet Explorer  
			try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
			}
			catch (e)
				{   
					try
					{      
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
					}
					catch (e)
					{     
						alert("Your browser does not support AJAX!");     
						return false;      
					}
				}  
			}
		xmlHttp.onreadystatechange=function()
			{
			//alert(xmlHttp.readyState)
			if(xmlHttp.readyState==4)
			{
				var str = xmlHttp.responseText;    
	           
				if(str.indexOf('Error') == -1)
				{      
					str = str.substring(str.indexOf('<div id="dv"'),str.lastIndexOf('</div>'));
					//alert(str)
					if(document.getElementById('lstDrug') != null)
					{
						document.getElementById('lstDrug').style.display = 'block';            
					}
					document.getElementById('dvMain').innerHTML = str;
					
				}
				else if(str.indexOf('Error') > -1)
				{
					document.getElementById('dvMain').innerHTML = "<span class='CWS-Std-Text'>No Match Found.</span>"
				}
				
			}
	         
			}   
		if(url != null)
		{
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null); 
		} 
	}
	function keycheck(e)
	{
		//Track key
		var KeyID = (window.event) ? event.keyCode : e.keyCode;
		var charp = String.fromCharCode(KeyID); // get the character of the pressed key 
		
		var xmlHttp;
	    //Main Function
	   	if(KeyID == 8)
		{    
			var url = "SelectDrugSupportivePage.aspx?s=-1&r="+Math.random();
		}
		else if((KeyID >= 65 && KeyID < 91) || (KeyID >= 48 && KeyID < 58) || (KeyID >= 96 && KeyID < 106) || KeyID == 32 || KeyID==189)
		{
			if (KeyID >= 96 && KeyID < 106)
				charp=KeyID-96
				
			if(KeyID==189)
				charp='-';
				
			var url = "SelectDrugSupportivePage.aspx?s="+charp+"&r="+Math.random();
		}
		//alert(charp)
		try
			{  // Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
			}
		catch (e)
		{  // Internet Explorer  
			try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
			}
			catch (e)
				{   
					try
					{      
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
					}
					catch (e)
					{     
						alert("Your browser does not support AJAX!");     
						return false;      
					}
				}  
			}
		xmlHttp.onreadystatechange=function()
			{
			//alert(xmlHttp.readyState)
			if(xmlHttp.readyState==4)
			{
				var str = xmlHttp.responseText;    
	           
				if(str.indexOf('Error') == -1)
				{      
					str = str.substring(str.indexOf('<div id="dv"'),str.lastIndexOf('</div>'));
					//alert(str)
					//if(document.getElementById('lstDrug') != null)
					//{
					//	document.getElementById('lstDrug').style.display = 'block';            
					//}
					document.getElementById('dvMain').innerHTML = str;
					
				}
				else if(str.indexOf('Error') > -1)
				{
					document.getElementById('dvMain').innerHTML = "<span class='CWS-Std-Text'>No Match Found.</span>"
				}
				
			}
	         
			}   
		if(url != null)
		{
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null); 
		} 
	}
	
   function DrugSupportivePage()
    {
		document.onkeyup = keycheck
		//var sndr = window.event.srcElement; //to track the object that initiates keypress 
		//alert(sndr)
		//  var pre = this.document.getElementById ("tt2").value; //get the value of the hidden textbox 
		//var key = window.event.keyCode;  //track the currently pressed key 
		//var charp = String.fromCharCode(key); // get the character of the pressed key
    }
    function select(text,DrugValue)
    { 
		
		var txtDrugObj= window.opener.document.getElementsByTagName('input');
		for(j=0;j<txtDrugObj.length;j++)
		{
			if(txtDrugObj[j].id!=null && txtDrugObj[j].type=='text')
			{
				if(txtDrugObj[j].id.indexOf('txtDrug')!=-1)
				{
					txtDrugObj[j].value=text;
				}
			}
			if(txtDrugObj[j].id!=null && txtDrugObj[j].type=='hidden')
			{
				if(txtDrugObj[j].id.indexOf('hdDrugValue')!=-1)
				{
					txtDrugObj[j].value=DrugValue;
				}
				if(txtDrugObj[j].id.indexOf('hdDrugName')!=-1)
				{
					txtDrugObj[j].value=text;
				}
			}
		}
		self.close();
		
    }
    function Reset()
    {
		var txtDrugObj= document.getElementsByTagName('input');
		for(j=0;j<txtDrugObj.length;j++)
		{
			if(txtDrugObj[j].id!=null && txtDrugObj[j].type=='text')
			{
				if(txtDrugObj[j].id.indexOf('txtDrug')!=-1)
				{
					txtDrugObj[j].value='';
				}
			}
			if(txtDrugObj[j].id!=null && txtDrugObj[j].type=='hidden')
			{
				if(txtDrugObj[j].id.indexOf('hdDrugValue')!=-1)
				{
					txtDrugObj[j].value='';
				}
				if(txtDrugObj[j].id.indexOf('hdDrugName')!=-1)
				{
					txtDrugObj[j].value='';
				}
			}
		}
    }
    /*Following function used to set the text box for disease descriptor when any 
    disease descriptor is selected from the popup*/
    function selectDiseaseDescriptor(text,DiseaseDescriptorValue)
    { 
		
		var txtDiseaseDescriptorObj= window.opener.document.getElementsByTagName('input');
		for(j=0;j<txtDiseaseDescriptorObj.length;j++)
		{
			if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='text')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf('txtDiseaseDescriptor')!=-1)
				{
					txtDiseaseDescriptorObj[j].value=text;
				}
			}
			if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='hidden')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf('hdDiseaseDescriptorValue')!=-1)
				{
					txtDiseaseDescriptorObj[j].value=DiseaseDescriptorValue;
				}
				if(txtDiseaseDescriptorObj[j].id.indexOf('hdDiseaseDescriptorName')!=-1)
				{
					txtDiseaseDescriptorObj[j].value=text;
				}
			}
		}
		self.close();
		
    }
    
   /*Following function used to set the text box for disease descriptor when any 
    disease descriptor is selected from the popup and also set the hidden field values*/
    function selectDiseaseDescriptor(ctrlId)
	{
		var tableElement
		var ddValue=''
	    var ddName=''
	    var ddValueTemp=''
	    var ddNameTemp=''
	    var txtValueCheck=''
	    var checkBoxCtrl=null
	    var ysnNetscape='0'
	    /*Checking web-browser:start*/
	    if(navigator.appName=='Netscape')
			ysnNetscape='1'
		/*Checking web-browser:end*/
		
		if(ctrlId=='1')
			tableElement = document.getElementById('dgDiseaseDescriptorDupli');
		else
			tableElement = document.getElementById('dgDiseaseDescriptor');
			
		if(ctrlId=='1')
		{
			hdVal='hdSubClassificationValue'
			hdName='hdSubClassificationName'
			txtVal='txtSubClassification'
		}
		if(ctrlId=='2')
		{
			hdVal='hdMarkerValue'
			hdName='hdMarkerName'
			txtVal='txtMarker'
		}
		if(ctrlId=='3')
		{
			hdVal='hdOtherValue'
			hdName='hdOtherName'
			txtVal='txtOther'
		}
	   
		ysnDescriptorChecked=1;
		/*identify select all option:start*/
	    /*var txtDiseaseDescriptorObj= document.getElementsByTagName('input');
		for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
		{
			if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='checkbox')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf('chkSelectAll')!=-1)
				{
					txtDiseaseDescriptorObj[j].parentNode.disabled=false;
					txtDiseaseDescriptorObj[j].disabled=false;
					if(txtDiseaseDescriptorObj[j].checked)
					{
						ysnDescriptorChecked=1;
						break;
					}
				}
			}
		}*/
	   /*Resetting fields:start*/
		var txtDiseaseDescriptorObjarea= window.opener.document.getElementsByTagName('textarea');
		for(var j=0;j<txtDiseaseDescriptorObjarea.length;j++)
		{
			if(txtDiseaseDescriptorObjarea[j]!=null )
			{
				if(txtDiseaseDescriptorObjarea[j].id.indexOf(txtVal)!=-1)
						txtDiseaseDescriptorObjarea[j].value='';
			}
		}
		txtDiseaseDescriptorObj= window.opener.document.getElementsByTagName('input');
		for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
		{
			if(txtDiseaseDescriptorObj[j]!=null && txtDiseaseDescriptorObj[j].type=='text')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf(txtVal)!=-1)
					txtDiseaseDescriptorObj[j].value='';
			}
			if(txtDiseaseDescriptorObj[j]!=null && txtDiseaseDescriptorObj[j].type=='hidden')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf(hdVal)!=-1)
					txtDiseaseDescriptorObj[j].value='';
				if(txtDiseaseDescriptorObj[j].id.indexOf(hdName)!=-1)
					txtDiseaseDescriptorObj[j].value='';
			}
		}
		/*Resetting fields:end*/
	    if(tableElement!=null)
	    {
			for (var i=0;i<tableElement.rows.length;i++)
			{
				
				var rowElem 
				var cellstrDescriptor
				var cellcntDescriptor
				
				rowElem = tableElement.rows[i];
				if(ysnNetscape=='1')
				{
					cellstrDescriptor = rowElem.cells[0].childNodes[1];
					cellcntDescriptor = rowElem.cells[1];
				}
				else
				{
					cellstrDescriptor = rowElem.cells[0].firstChild;
					cellcntDescriptor = rowElem.cells[1].firstChild;
				}
				
				if (cellstrDescriptor.checked)
				{
					var cntDescriptor
					var strDescriptor
					if(ysnNetscape=='1')
					{
						cntDescriptor=cellcntDescriptor.childNodes[1].innerHTML;
						strDescriptor=rowElem.cells[0].childNodes[2].innerHTML;
					}
					else
					{
						cntDescriptor=cellcntDescriptor.innerText;
						strDescriptor=cellstrDescriptor.parentElement.innerText;
					}
					
					txtDiseaseDescriptorObjarea= window.opener.document.getElementsByTagName('textarea');
				
					if(txtDiseaseDescriptorObjarea[ctrlId-1].id!=null )
					{
						if(txtDiseaseDescriptorObjarea[ctrlId-1].id.indexOf(txtVal)!=-1)
						{
							txtDiseaseDescriptorObjarea[ctrlId-1].value=strDescriptor+'\n'+txtDiseaseDescriptorObjarea[ctrlId-1].value;
							
						}
					}
					/*setting hidden fields' value:start*/
					txtDiseaseDescriptorObj= window.opener.document.getElementsByTagName('input');
					for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
					{
						if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='hidden')
						{
							if(txtDiseaseDescriptorObj[j].id.indexOf(hdVal)!=-1)
								txtDiseaseDescriptorObj[j].value=cntDescriptor+','+txtDiseaseDescriptorObj[j].value;
							if(txtDiseaseDescriptorObj[j].id.indexOf(hdName)!=-1)
								txtDiseaseDescriptorObj[j].value=strDescriptor+','+txtDiseaseDescriptorObj[j].value;
						}
					}
					/*setting hidden fields' value:end*/
				} 
		   }
		   /*Appending the select all value for Marker and Other disease descriptors:start*/
			txtDiseaseDescriptorObj= window.opener.document.getElementsByTagName('input');
			for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
			{
				if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='hidden')
				{
					if(txtDiseaseDescriptorObj[j].id.indexOf(hdVal)!=-1)
					{
						if(txtDiseaseDescriptorObj[j].value!='' && txtDiseaseDescriptorObj[j].value!='0')
						{
						if(ysnDescriptorChecked==1)
							txtDiseaseDescriptorObj[j].value=rtrim(txtDiseaseDescriptorObj[j].value,',')+'^1';
						else
							txtDiseaseDescriptorObj[j].value=rtrim(txtDiseaseDescriptorObj[j].value,',')+'^0';
						}
					}
					if(txtDiseaseDescriptorObj[j].id.indexOf(hdName)!=-1 && txtDiseaseDescriptorObj[j].value!='')
						txtDiseaseDescriptorObj[j].value=rtrim(txtDiseaseDescriptorObj[j].value,',');
				}
			}
			/*Appending the select all value for Marker and Other disease descriptors:end*/
			if(txtDiseaseDescriptorObjarea!=null)
			{
	           txtValueCheck=txtDiseaseDescriptorObjarea[ctrlId-1].value
	           txtDiseaseDescriptorObjarea[ctrlId-1].value=ltrim(rtrim(txtValueCheck,','),',')
			}
			        
	    }
	    	/*Calling ajax:satr*/
			txtDiseaseDescriptorObj= window.opener.document.getElementsByTagName('input');
			var strValue=''
			for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
			{
				if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='hidden')
				{
					if(txtDiseaseDescriptorObj[j].id.indexOf(hdVal)!=-1)
						strValue=txtDiseaseDescriptorObj[j].value
				}
			}
			
			var url = "SelectDiseaseDescriptorSupportivePage.aspx?selectedValue="+strValue+"&r="+Math.random();
			try
			{  // Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
			}
			catch (e)
			{  // Internet Explorer  
				try
				{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}
				catch (e)
					{   
						try
						{      
							xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
						}
						catch (e)
						{     
							alert("Your browser does not support AJAX!");     
							return false;      
						}
					}  
				}
			xmlHttp.onreadystatechange=function()
				{
					if(xmlHttp.readyState==4)
					{
						var str = xmlHttp.responseText;    
						self.close();
					}
			        
				}   
			if(url != null)
			{
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null); 
			}
			/*Calling ajax:end*/ 
		//self.close();
	}
	
   /*Resetting the appropriate text box and hidden field when the select buttoon is clicked*/
	function ResetDiseaseDescriptor(ctrlId)
    {
		var ddName=''
		if(ctrlId=='1')
		{
			hdVal='hdSubClassificationValue'
			hdName='hdSubClassificationName'
			txtVal='txtSubClassification'
		}
		if(ctrlId=='2')
		{
			hdVal='hdMarkerValue'
			hdName='hdMarkerName'
			txtVal='txtMarker'
		}
		if(ctrlId=='3')
		{
			hdVal='hdOtherValue'
			hdName='hdOtherName'
			txtVal='txtOther'
		}
		
		var txtDiseaseDescriptorObjarea= document.getElementsByTagName('textarea');
		for(var j=0;j<txtDiseaseDescriptorObjarea.length;j++)
		{
			if(txtDiseaseDescriptorObjarea[j]!=null )
			{
				if(txtDiseaseDescriptorObjarea[j].id.indexOf(txtVal)!=-1)
					txtDiseaseDescriptorObjarea[j].value='';
			}
		}
		var txtDiseaseDescriptorObj= document.getElementsByTagName('input');
		for(var j=0;j<txtDiseaseDescriptorObj.length;j++)
		{
			if(txtDiseaseDescriptorObj[j]!=null && txtDiseaseDescriptorObj[j].type=='text')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf(txtVal)!=-1)
					txtDiseaseDescriptorObj[j].value='';
			}
			if(txtDiseaseDescriptorObj[j]!=null && txtDiseaseDescriptorObj[j].type=='hidden')
			{
				if(txtDiseaseDescriptorObj[j].id.indexOf(hdVal)!=-1)
					txtDiseaseDescriptorObj[j].value='';
				if(txtDiseaseDescriptorObj[j].id.indexOf(hdName)!=-1)
					txtDiseaseDescriptorObj[j].value='';
			}
		}
		txtDiseaseDescriptorObj= document.getElementsByTagName('input');
		for(j=0;j<txtDiseaseDescriptorObj.length;j++)
		{
			if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='checkbox')
			{
				if(ctrlId=='2')
				{
					if(txtDiseaseDescriptorObj[j].id.indexOf('chkMarker')!=-1)
					{
							txtDiseaseDescriptorObj[j].parentNode.disabled=true;
							txtDiseaseDescriptorObj[j].disabled=true;
					}
				}
				if(ctrlId=='3')
				{
					if(txtDiseaseDescriptorObj[j].id.indexOf('chkOther')!=-1)
					{
						txtDiseaseDescriptorObj[j].parentNode.disabled=true;
						txtDiseaseDescriptorObj[j].disabled=true;
					}
				}
			}
		}
    }

/*Function to open the disease descriptor selection popup*/
    function OpenDiseaseDescriptor()
    {
		ResetDiseaseDescriptor();
		var drpDiseaseDescriptorObj= document.getElementsByTagName('select');
		
		for(j=0;j<drpDiseaseDescriptorObj.length;j++)
		{
			
			if(drpDiseaseDescriptorObj[j].id.indexOf('drplstPSGeneralCategory')!=-1)
			{
				var cancertype=drpDiseaseDescriptorObj[j].options[drpDiseaseDescriptorObj[j].selectedIndex].value
				var cancertypeName=drpDiseaseDescriptorObj[j].options[drpDiseaseDescriptorObj[j].selectedIndex].text
				window.open('../trialcheck/SelectDiseaseDescriptor.aspx?cancertype='+cancertype+'','','toolbar=no,menubar=no,top=100,left=400,width=300,height=330,scrollbars=no');
				
				
			}
		}
    }
/*Functions for Disease Descriptor ajax page*/
    function loadDiseaseDescriptor(e)
	{
		//Track key
		var KeyID = (window.event) ? event.keyCode : e.keyCode;
		var charp = String.fromCharCode(KeyID); // get the character of the pressed key 
		var xmlHttp;
	    //Main Function
	   	if(KeyID == 8)
		{    
			var url = "SelectDiseaseDescriptorSupportivePage.aspx?s=-1&r="+Math.random();
		}
		else if((KeyID >= 65 && KeyID < 91) || (KeyID >= 48 && KeyID < 58) || (KeyID >= 96 && KeyID < 106) || KeyID == 32 || KeyID==189 || KeyID==187 || KeyID==109 || KeyID==107)
		{
			if (KeyID >= 96 && KeyID < 106)
				charp=KeyID-96
			if(KeyID==189 ||KeyID==109 )
				charp='-';
			if(KeyID==187 || KeyID==107)
			charp='plus';
			var url = "SelectDiseaseDescriptorSupportivePage.aspx?s="+charp+"&r="+Math.random();
		}
		
		try
		{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
		}
		catch (e)
		{  // Internet Explorer  
			try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
			}
			catch (e)
			{   
				try
				{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
				{     
					alert("Your browser does not support AJAX!");     
					return false;      
				}
			}  
		}
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				var str = xmlHttp.responseText;    
				if(str.indexOf('Error') == -1)
				{      
					if(ctId=='1')
						str = str.substring(str.indexOf('<div id="dvDupli"'),str.lastIndexOf('</div>'));
					else
						str = str.substring(str.indexOf('<div id="dv"'),str.lastIndexOf('</div>'));
					if(ctId=='1')
						document.getElementById('dvMainDupli').innerHTML = str;
					else
						document.getElementById('dvMain').innerHTML = str;
				}
				else if(str.indexOf('Error') > -1)
				{
					if(ctId=='1')
						document.getElementById('dvMainDupli').innerHTML = "<span class='CWS-Std-Text'>No Match Found.</span>"
					else
						document.getElementById('dvMain').innerHTML = "<span class='CWS-Std-Text'>No Match Found.</span>"
				}
			}
		}   
		if(url != null)
		{
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null); 
		} 
	}
	
   function DiseaseDescriptorSupportivePage(ctrlId)
    {
		ctId=ctrlId
		document.onkeyup = loadDiseaseDescriptor
    }

function CheckDiseaseDescriptor()
    {
		
		var drpDiseaseDescriptorObj= document.getElementsByTagName('select');
		var cancertype=''
		var diseasedescriptor=''
		var ysnCheck=true
		
		var txtDiseaseDescriptorObj= document.getElementsByTagName('textarea');
				for(j=0;j<txtDiseaseDescriptorObj.length;j++)
				{
				
					if(txtDiseaseDescriptorObj[j].id!=null)
					{
						if(txtDiseaseDescriptorObj[j].id.indexOf('txtDiseaseDescriptor')!=-1)
						{
							txtDiseaseDescriptorObj[j].value='';
							
						}
					}
					
				}
				
		
		   for(j=0;j<drpDiseaseDescriptorObj.length;j++)
			{
				
				if(drpDiseaseDescriptorObj[j].id.indexOf('drplstPSGeneralCategory')!=-1)
				{
					cancertype=drpDiseaseDescriptorObj[j].options[drpDiseaseDescriptorObj[j].selectedIndex].value
					
				}
				
			}
		
			
		
			var url = "SelectDiseaseDescriptorSupportivePage.aspx?cancertype="+cancertype+"&r="+Math.random();
		
			try
				{  // Firefox, Opera 8.0+, Safari  
				xmlHttp=new XMLHttpRequest();  
				}
			catch (e)
			{  // Internet Explorer  
				try
				{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}
				catch (e)
					{   
						try
						{      
							xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
						}
						catch (e)
						{     
							alert("Your browser does not support AJAX!");     
							return false;      
						}
					}  
				}
			xmlHttp.onreadystatechange=function()
				{
				if(xmlHttp.readyState==4)
				{
					var str = xmlHttp.responseText; 
					          
					if(str.indexOf('Error') == -1)
					{      
						str = str.substring(str.indexOf('<div id="dv"'),str.lastIndexOf('</div>'));
						
						var trDD=document.getElementById('_ctl0_trDD') 
						var hdDDvisible=document.getElementById('hdDDvisible') 
						//hdDDvisible.value="false";	
						if(str.indexOf('false')!=-1)
						{
							//alert('Please change the disease descriptor applicable for the selected cancer type.')
							trDD.style.display = 'none'; 
							hdDDvisible.value="false";	
							return false;
						}
						else
						{
						 trDD.style.display = ''; 
						 hdDDvisible.value="true";	
						  
						}
						
					}
					
				}
		         
				}   
			if(url != null)
			{
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null); 
			}  
		
		return true;
		
    }

function ddvis() 
{ 
   var trDD=document.getElementById('_ctl0_trDD'); 
   var hdDDvisible=document.getElementById('hdDDvisible') 
	if(trDD!=null) 
	{ 
		if(hdDDvisible.value=="false")
		{
		 trDD.style.display = 'none'; 
		}
		if(hdDDvisible.value=="")
		{
		 trDD.style.display = 'none'; 
		}
	} 
}

function SelectAllCheckboxesDD()
		{
			setTimeout('SelectAllCheckboxes()', 10);	
		}

		function SelectAllCheckboxes()
		{
			var chkDDObj = document.getElementsByTagName('input');
			var chkDDall = document.getElementById('chkSelectAll');
			
			for(i=0;i<chkDDObj.length;i++)
			{
				if(chkDDObj[i]!=null)
				{
					if(chkDDObj[i].type=='checkbox' && chkDDObj[i].id.indexOf('chkDiseaseDescriptor')!=-1)
					{
					
					if(chkDDall.checked==true)
						chkDDObj[i].checked = true;
					else	
						chkDDObj[i].checked = false;	
					}
				}
				
			}
			
			//waitbox.releaseCapture();
			//waitbox.style.cursor = "default";
			return;
		}
		
		function chkdd()
		{
			var chkDDObj = document.getElementsByTagName('input');
			var chkDDall = document.getElementById('chkSelectAll');
			var k=1;
			var l=1;
			
			for(i=0;i<chkDDObj.length;i++)
			{
				if(chkDDObj[i]!=null)
				{
					if(chkDDObj[i].type=='checkbox' && chkDDObj[i].id.indexOf('chkDiseaseDescriptor')!=-1)
					{
						k++
						if(chkDDObj[i].checked==true)
						{
							l++
						}
						if(k==l)
						{
							chkDDall.checked=true;
						}
						else
							chkDDall.checked=false;
					}
				}
				
			}
		}
/*Resetting the Zip Code Validation message when user clicks on the zipcode field:start*/
function resetZipCode()
{
	var objZip=document.getElementById('lblZipCodeVaildationMsg')
	if(objZip!=null)
	{
		objZip.innerHTML=''
	}
}
/*Resetting the Zip Code Validation message when user clicks on the zipcode field:end*/
function trim(str, chars)    
{   
	return ltrim(rtrim(str, chars), chars);   
}   
     
function ltrim(str, chars)    
{   
	chars = chars || "\\s";   
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");   
}   
     
function rtrim(str, chars)    
{   
	chars = chars || "\\s";   
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");   
}
/*setting the hidden field values when check boxes are clicked against Marker and Other disease descriptors*/   
function getCheckedDescriptor(ctrlId)
{
	var ysnChecked=''
	if(ctrlId=='1')
		hdVal='hdSubClassificationValue'
	if(ctrlId=='2')
		hdVal='hdMarkerValue'
	if(ctrlId=='3')
		hdVal='hdOtherValue'

	var txtDiseaseDescriptorObj= document.getElementsByTagName('input');
	var ysnChecked=0
	for(j=0;j<txtDiseaseDescriptorObj.length;j++)
	{
		if(txtDiseaseDescriptorObj[j].id!=null && txtDiseaseDescriptorObj[j].type=='checkbox')
		{
			if(txtDiseaseDescriptorObj[j].id.indexOf('chkSelectAll')!=-1)
			{
				txtDiseaseDescriptorObj[j].parentNode.disabled=false;
				txtDiseaseDescriptorObj[j].disabled=false;
				if(txtDiseaseDescriptorObj[j].checked)
				{
					ysnDescriptorChecked=1;
					ysnChecked=ctrlId+'|'+'^1'
					break;
				}
				else
				{
					ysnDescriptorChecked=0;
					ysnChecked=ctrlId+'|'+'^0'
					break;
				}
			}
		}
	}
	
	var url = "SelectDiseaseDescriptorSupportivePage.aspx?ysnChecked="+ysnChecked+"&r="+Math.random();
			try
			{  // Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
			}
			catch (e)
			{  // Internet Explorer  
				try
				{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}
				catch (e)
					{   
						try
						{      
							xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
						}
						catch (e)
						{     
							alert("Your browser does not support AJAX!");     
							return false;      
						}
					}  
				}
			xmlHttp.onreadystatechange=function()
				{
				if(xmlHttp.readyState==4)
				{
					var str = xmlHttp.responseText;    
			       
				}
			        
				}   
			if(url != null)
			{
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null); 
			}
	
}

/*deselect other than the selected radio button*/  
function SetUniqueRadioButton(current,selectedId,ctrlId) 
{ 
	var count=0
	for(i = 0; i < document.forms[0].elements.length; i++) 
	{ 
		elm = document.forms[0].elements[i] 
		if (elm.type == 'radio') 
		{
			elm.checked = false;
		}
		if (elm.type == 'checkbox' && elm.checked==true) 
		{
			count++
		}
		 
	} 

	var obj=document.getElementsByTagName('label');
	for(var j=0;j<obj.length;j++)
	{
		if(obj[j].innerHTML=='Unknown')
		{
			var objCheck=obj[j].parentNode.getElementsByTagName('input');
			for(var k=0;k<objCheck.length;k++)
			{
				if(objCheck[k].type=='checkbox')
				{
					if(count==1 && selectedId=='0')
						objCheck[k].checked=true;
					else
						objCheck[k].checked=false;
				
				}
			}
			
		}
		
	}
	if(current.type=='radio')
		current.checked = true;
	
	
	if(current.checked==false)
		selectedId=selectedId+','
		
	var url = "SelectDiseaseDescriptorSupportivePage.aspx?selectedValue="+selectedId+"&r="+Math.random();
			try
			{  // Firefox, Opera 8.0+, Safari  
			xmlHttp=new XMLHttpRequest();  
			}
			catch (e)
			{  // Internet Explorer  
				try
				{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}
				catch (e)
					{   
						try
						{      
							xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
						}
						catch (e)
						{     
							alert("Your browser does not support AJAX!");     
							return false;      
						}
					}  
				}
			xmlHttp.onreadystatechange=function()
				{
				if(xmlHttp.readyState==4)
				{
					var str = xmlHttp.responseText;    
			       
				}
			        
				}   
			if(url != null)
			{
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null); 
			}
				
}

function ClearAll()
{
	for(i = 0; i < document.forms[0].elements.length; i++) 
	{ 
		elm = document.forms[0].elements[i] 
		if (elm.type == 'radio' || elm.type == 'checkbox') 
			elm.checked = false; 
	}
}
