// <copyright file="SelectionUtilitiesPipeline.js" company="BioCentury Publications Inc."> 
// All contents Copyright © 2005-2009 BioCentury Publications, Inc. ALL RIGHTS RESERVED
// 
// http://www.biocentury.com
// </copyright>


var imgRoot = document.location.href.substring(0,document.location.href.toLowerCase().indexOf('bciq')+5)+'Images/';



//-------------------------------------------------------------------------------
// PIPELINE - Reports.aspx
// "Enter a Company Name:" AND "Select a Company List" switch
// Add by Bela Gaspar
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
// check
// ADD - Bela Gaspar
// Descr: "Enter a Company Name:" AND "Select from a Pre-Defined List" switch
// id	- is from "Enter a Company Name:" or from "Select a Company List"
// Used in : FINANCING - Reports.aspx
//-------------------------------------------------------------------------------
function check(id) {
    //document.getElementById(id).checked = true;
    var Refine_ec_a = document.getElementById('Refine_ec_a');
    var criteria = document.getElementsByName('Refine');

    if (id == 'search') {//disable "RESTRICT COMPANY BY:"
        if (checkId == 'search') return false;
        else checkId = 'search';
        if (!resetPipelineRefineCompaniesGroup(false)) {
            //document.getElementById('list').checked = true;
            return false;
        }

        if (document.getElementById('Refine_ec') != null)
            SetLinkDisable("Refine_ec", "javascript:CollapseExpandSection('Refine')", "", true);

        for (var i = 0; i < criteria.length; i++) {
            if (document.getElementById(criteria[i].id.split('_')[0] + '_ec').title == "Collapse Summary")
                document.getElementById(criteria[i].id.split('_')[0] + '_ec_a').click();
            document.getElementById(criteria[i].id.split('_')[0] + '_ec_a').className = "DivHidden";


            var link = document.getElementById('ctl00_cphMain_lb' + criteria[i].id.split('_')[0]);
            link.removeAttribute('href');
            link.onclick = null;
            link.disabled = true;
        }
        if (document.getElementById('Refine_ec') != null &&
            document.getElementById('Refine_ec').attributes["name"] == "Collapse") 
        {
            document.getElementById('Refine_ec').setAttribute('name', 'Collapse');
            document.getElementById('Refine_ec').click();
        }

        //document.getElementById('companyArea').className = 'DivVisible';
        //document.getElementById('listArea').className = 'DivHidden';
    }
    else {//enable
        if (checkId == 'UserCompanyLists') return false;
        else checkId = 'UserCompanyLists';

        if (document.getElementById('Refine_ec') != null)
            SetLinkDisable("Refine_ec", "javascript:CollapseExpandSection('Refine')", "", false);

        for (var i = 0; i < criteria.length; i++) {
            document.getElementById(criteria[i].id.split('_')[0] + '_ec_a').className = "DivVisibleInline";

            var link = document.getElementById('ctl00_cphMain_lb' + criteria[i].id.split('_')[0]);
            link.disabled = false;
            link.setAttribute('href', "javascript: __doPostBack('ctl00$cphMain$lb" + criteria[i].id.split('_')[0] + "', '')");
            eval("link.onclick = function () { if (!confirmChanges()) return false; }");
        }
        if (document.getElementById('Refine_ec') != null &&
            document.getElementById('Refine_ec').attributes["name"] == "Collapse") 
        {
            document.getElementById('Refine_ec').setAttribute('name', 'Collapse');
            document.getElementById('Refine_ec').click();
        }
    }
}	

function resetPipelineRefineCompaniesGroup()
{
	var displayConfirm = (arguments[0] != null) ? arguments[0] : true;
	if (displayConfirm)
	{
		if (!confirm('This will reset "REFINE GROUP OF COMPANIES" criteria. Continue?')) return false;
//		if (top.frames[2].document.getElementById('btnCancel'))
//			top.frames[2].document.getElementById('btnCancel').click();
	}
	
//	theRegionsFilterXML = "";
//	theRegionsSummary = "";
//	theRegionsSelections = [];//new Array("UniverseID=901");
//	
//	theListingStatusFilterXML = "";
//	theListingStatusSummary = "";
//	theListingStatusSelections = [];//new Array("UniverseID=901");

//	theNumberofCompoundsFilterXML = "";
//	theNumberofCompoundsSummary = "";
//	theNumberofCompoundsSelections = [];

	document.getElementById('ctl00_cphMain_lblRegionSummary').innerHTML = SetForDisplay(['All Regions']);
	document.getElementById('ctl00_cphMain_lblRegionSummary').style.color = m_UnSelectionColor;
	SetSessionValue("Region", "null");
	document.getElementById('ctl00_cphMain_lblListingStatusSummary').innerHTML = SetForDisplay(['All Companies']);
	document.getElementById('ctl00_cphMain_lblListingStatusSummary').style.color = m_UnSelectionColor;
	SetSessionValue("ListingStatus", "null");
	document.getElementById('ctl00_cphMain_lblNumberofCompoundsSummary').innerHTML = SetForDisplay(['Any Number of Products']);
	document.getElementById('ctl00_cphMain_lblNumberofCompoundsSummary').style.color = m_UnSelectionColor;
	SetSessionValue("NumberofCompounds", "null");
	
//	document.getElementById('Summary_Regions').innerHTML = SetForDisplay(['All Regions']);
//	document.getElementById('Summary_Regions').style.color = m_UnSelectionColor;
//	document.getElementById('Summary_ListingStatus').innerHTML = SetForDisplay(['All Companies']);
//	document.getElementById('Summary_ListingStatus').style.color = m_UnSelectionColor;
//	document.getElementById('Summary_NumberofCompounds').innerHTML = SetForDisplay(['Any Number of Products']);
//	document.getElementById('Summary_NumberofCompounds').style.color = m_UnSelectionColor;


	return true;
}


//-------------------------------------------------------------------------------
// used in Pipeline Reports.aspx
// reload filters from Session when is called from Charts (Report It)
// added - 08.31.2006 - Bela Gaspar
//-------------------------------------------------------------------------------
/*
// Commented by Bela, on 4/29/2009 - not used anymore
function PipelineReloadFiltersFromSession()
{
	totalSummary = "";
		
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-Role', function(res){
		if(res.error != null) {
			alert('Pipeline-Role ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "")
		{
			document.getElementById('Summary_Role').innerHTML = SetForDisplay(aStr[0].split('_'));
			if (aStr[1] != "3")
				document.getElementById('Summary_Role').style.color = m_SelectionColor;			
			theRoleSummary = aStr[0];
			theRoleSelections = aStr[1].split(',');
			
			totalSummary += '<tr><td><b>Show Product: </b>' + theRoleSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Region', function(res){
		if(res.error != null) {
			alert('Region ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_Regions').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_Regions').style.color = m_SelectionColor;			
			theRegionsSummary = aStr[0];
			theRegionsFilterXML = aStr[2];
			theRegionsSelections = aStr[1].split(',');
			document.getElementById('Region_ec_a').click();
			
			totalSummary += '<tr><td><b>Region: </b>' + theRegionsSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-ListingStatus', function(res){
		if(res.error != null) {
			alert('Pipeline-ListingStatus ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_ListingStatus').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_ListingStatus').style.color = m_SelectionColor;			
			theListingStatusSummary = aStr[0];
			theListingStatusFilterXML = aStr[2];
			theListingStatusSelections = aStr[1].split(',');
			document.getElementById('ListingStatus_ec_a').click();
			
			totalSummary += '<tr><td><b>Public/Private: </b>' + theListingStatusSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-NumberofCompounds', function(res){
		if(res.error != null) {
			alert('Pipeline-NumberofCompounds ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_NumberofCompounds').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_NumberofCompounds').style.color = m_SelectionColor;			
			theNumberofCompoundsSummary = aStr[0];
			theNumberofCompoundsFilterXML = aStr[2];
			theNumberofCompoundsSelections = aStr[1].split(',');
			document.getElementById('NumberofCompounds_ec_a').click();
			
			totalSummary += '<tr><td><b>Number of Products: </b>' + theNumberofCompoundsSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});	
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-ProductName', function(res){
		if(res.error != null) {
			alert('Pipeline-ProductName ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_ProductName').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_ProductName').style.color = m_SelectionColor;			
			theProductNameSummary = aStr[0];
			theProductNameFilterXML = aStr[2];
			theProductNameSelections = aStr[1].split(',');
			document.getElementById('ProductName_ec_a').click();
			
			totalSummary += '<tr><td><b>Product Name: </b>' + theProductNameSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});	
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-ProductDescription', function(res){
		if(res.error != null) {
			alert('Pipeline-ProductDescription ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_ProductDescription').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_ProductDescription').style.color = m_SelectionColor;			
			theProductDescriptionSummary = aStr[0];
			theProductDescriptionFilterXML = aStr[2];
			theProductDescriptionSelections = aStr[1].split(',');
			document.getElementById('ProductDescription_ec_a').click();
			
			totalSummary += '<tr><td><b>Product Description: </b>' + theProductDescriptionSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});	
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-MolecularTarget', function(res){
		if(res.error != null) {
			alert('Pipeline-MolecularTarget ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_MolecularTarget').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_MolecularTarget').style.color = m_SelectionColor;			
			theMolecularTargetSummary = aStr[0];
			theMolecularTargetFilterXML = aStr[2];
			theMolecularTargetSelections = aStr[1].split(',');
			document.getElementById('MolecularTarget_ec_a').click();
			
			totalSummary += '<tr><td><b>Molecular Target: </b>' + theMolecularTargetSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});	
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-MechanismOfAction', function(res){
		if(res.error != null) {
			alert('Pipeline-MechanismOfAction ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_MechanismOfAction').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_MechanismOfAction').style.color = m_SelectionColor;			
			theMechanismOfActionSummary = aStr[0];
			theMechanismOfActionFilterXML = aStr[2];
			theMechanismOfActionSelections = aStr[1].split(',');
			document.getElementById('MechanismOfAction_ec_a').click();
			
			totalSummary += '<tr><td><b>Mechanism of Action: </b>' + theMechanismOfActionSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});	
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-PhaseOfDevelopment', function(res){
		if(res.error != null) {
			alert('Pipeline-PhaseOfDevelopment ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_PhaseOfDevelopment').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_PhaseOfDevelopment').style.color = m_SelectionColor;			
			thePhaseOfDevelopmentSummary = aStr[0];
			thePhaseOfDevelopmentFilterXML = aStr[2];
			thePhaseOfDevelopmentSelections = aStr[1].split(',');
			document.getElementById('PhaseOfDevelopment_ec_a').click();
			
			totalSummary += '<tr><td><b>Phase of Development: </b>' + thePhaseOfDevelopmentSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-DiseaseClass', function(res){
		if(res.error != null) {
			alert('Pipeline-DiseaseClass ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_DiseaseClass').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_DiseaseClass').style.color = m_SelectionColor;			
			theDiseaseClassSummary = aStr[0];
			theDiseaseClassFilterXML = aStr[2];
			theDiseaseClassSelections = aStr[1].split(',');
			document.getElementById('DiseaseClass_ec_a').click();
			
			totalSummary += '<tr><td><b>Disease Category: </b>' + theDiseaseClassSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});

	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-Milestone', function(res){
		if(res.error != null) {
			alert('Pipeline-Milestone ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "MilestoneID=901" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_Milestone').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_Milestone').style.color = m_SelectionColor;			
			theMilestoneSummary = aStr[0];
			theMilestoneFilterXML = aStr[2];
			theMilestoneSelections = aStr[1].split(',');
			document.getElementById('Milestone_ec_a').click();
			
			totalSummary += '<tr><td><b>Milestone: </b>' + theMilestoneSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});		
	
	BCIX.Include.Utilities.CommonUtilities.GetSession('Pipeline-PartnerStatus', function(res){
		if(res.error != null) {
			alert('Pipeline-PartnerStatus ' + res.error.Message);
			return;
		}
		var aStr = [];
		aStr = res.value.split('|');
		if (aStr != "" && aStr[1] != "" && aStr[1] != "UniverseID=901")
		{
			document.getElementById('Summary_PartnerStatus').innerHTML = SetForDisplay(aStr[0].split('_'));
			document.getElementById('Summary_PartnerStatus').style.color = m_SelectionColor;			
			thePartnerStatusSummary = aStr[0];
			thePartnerStatusFilterXML = aStr[2];
			thePartnerStatusSelections = aStr[1].split(',');
			document.getElementById('PartnerStatus_ec_a').click();
			
			totalSummary += '<tr><td><b>Licensed/Unlicensed: </b>' + thePartnerStatusSummary.replace(/_/g, ", ") + '</td></tr>';
		}
	});		
	
	companyListName = "";
	companyListType = "";
	if (checkId == 'search')
	{
		companyListName = document.getElementById('search').value;
		companyListType = "CompanyName";
	}
	else
	{
		companyListName = document.getElementById('UserCompanyLists').options[document.getElementById('UserCompanyLists').selectedIndex].innerHTML;
		companyListType = "CompanyList";
	}
}
*/

//-----------------------------------------------------
// PIPELINE - Role Selection - 
// Added by Bela Gaspar 03/21/07
// Edited by Marius Paltanea 12/12/08
// Role filter in PIPELINE is disabled if drop-down list is "All Companies"
//-----------------------------------------------------
function SetRoleDisableEnable() {
    // Disable Role if Drop-down is All Companies and textbox for one company is not selected
    if (document.getElementById(companyListID)[document.getElementById(companyListID).selectedIndex].value == '0' && 
        checkId != 'search') {
        document.getElementById('Role_ec_a').style.visibility = "hidden"

        CollapseExpand('Role', false);
        
        document.getElementById(lbRoleID).removeAttribute('href');
        document.getElementById(lbRoleID).onclick = null;
        document.getElementById(lbRoleID).disabled = true;
    }
    else {
        document.getElementById('Role_ec_a').style.visibility = "visible";

        CollapseExpand('Role', true);
        
        document.getElementById(lbRoleID).disabled = "";
        document.getElementById(lbRoleID).onclick = function() { if (!confirmChanges()) return false; };
        document.getElementById(lbRoleID).href = "javascript:__doPostBack('" + lbRoleID.replace(/_/g,"$") + "','')"
    }
    //DOMLoaded();
}

function DOMLoaded() 
{
    try
    {
        document.getElementById("PipelineRole").innerHTML = document.getElementById("TDPipelineRole").innerHTML;
    }
    catch (err)
    {}
    
}