

/****** DROP DOWN BOX CHECKBOX LSIT JS ******/
var CurrentDropDownCheckListID = "";

function CollapseCurrentDropDownCheckList()
{

	if(CurrentDropDownCheckListID != "")
		window.document.getElementById(CurrentDropDownCheckListID + '_' + 'divMain').style.display = 'none';
		
	CurrentDropDownCheckListID = "";
}

function CBDDL_ShowHideMultipleSelection(ControlClientID, evt)
{
	var textBoxMain = window.document.getElementById(ControlClientID + '_' + 'txtMain');
	var divisionMain = window.document.getElementById(ControlClientID + '_' + 'divMain');

	//Collapse Current Menus
	//if(!ForceClose || ForceClose == undefined)
	CollapseCurrentDropDownCheckList();
	
	//removes the 'Select' string txtMain
	switch(textBoxMain.value)
	{
		case 'Select':
			textBoxMain.value = '';
			break;
		case '':
			textBoxMain.value = 'Select';
			break;
		default:
			break;
	}	
	
	var displayStatus = divisionMain.style.display;
	if(displayStatus == 'block')
	{
		divisionMain.style.display = 'none';
	}
	else 
	{
		//Set Current Menu
		CurrentDropDownCheckListID = ControlClientID;
		
		divisionMain.style.display = 'block';
	}
	
	//event.cancelBubble = true;
	var e = (window.event) ? window.event : evt;
	if(e) e.cancelBubble = true;
}

function CBDDL_SetSelection( ControlID, ElementID, Event )
{
	var oCheckboxList = document.getElementById(ElementID);
	var aryLabels = oCheckboxList.getElementsByTagName('label');
	
	var sSelectionText = "";
	
	//Loop Through Labels
	for(i=0;i<aryLabels.length;i++)    
	{        
		var oLabel = aryLabels[i];      
		var oCheckbox = document.getElementById(oLabel.attributes["for"].value);
		
		if(oCheckbox != null && oCheckbox.type=="checkbox")        
		{            
			if(oCheckbox.checked)            
			{   
				sSelectionText += (document.all) ? oLabel.innerText + "," : oLabel.textContent + ",";
			}        
		} 

	}
	
	//Remove Trailing ,
	if(sSelectionText.substr(sSelectionText.length-1) == ",")
		sSelectionText = sSelectionText.substring(0, sSelectionText.length-1);
	
	//Set Selection Text
	var textBoxMain = window.document.getElementById(ControlID + '_' + 'txtMain');
	
	if(sSelectionText == "")
		textBoxMain.value = "None Selected";
	else
		textBoxMain.value = sSelectionText;

}

function CBDDL_getY( oElement )
{
	var iReturnValue = 0;
	while( oElement != null )
	{
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}

	return iReturnValue;
}

function CBDDL_getX( oElement )
{
	var iReturnValue = 0;
	while( oElement != null )
	{
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}

	return iReturnValue;
}

function CBDDL_HideOnFocusLost()
{
	var divCollection = window.document.getElementsByTagName('div');
	for (index = 0; index < divCollection.length; index++)
	{
		var divisionMain = divCollection[index];
		if (divisionMain.id.indexOf('divMain') >= 0 && divisionMain.style.display == 'block')
		{
			var iX1 = CBDDL_getX(divisionMain);
			var iX2 = iX1 + 250;
			var iY1 = CBDDL_getY(divisionMain);
			var iY2 = iY1 + 150;
			
			var iMouseX = event.clientX + document.body.scrollLeft;
			var iMouseY = event.clientY + document.body.scrollTop;
			
			if(!(iMouseX >= iX1 && iMouseX <= iX2 && iMouseY >= iY1 && iMouseY <= iY2))
				divisionMain.style.display = 'none';
			
		}
	}
}

function CBDDL_HideSelectionList(ControlClientID)
{
	var displayStatus = window.document.getElementById(ControlClientID + '_' + 'divMain').style.display;
	if(displayStatus == 'block')
	{
		window.document.getElementById(ControlClientID + '_' + 'divMain').style.display = 'none';
	}
	else 
	{
		window.document.getElementById(ControlClientID + '_' + 'divMain').style.display = 'block';
	}
}

function CancelBubbleEvent(evt)
{
	var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;	
}


function SubmitForm(sBusinessNeedID, sIndustryID, sCompanySizeID)
{

    var oBusinessNeed = document.getElementById(sBusinessNeedID);
    var oIndustry = document.getElementById(sIndustryID);    
    var oCompanySize = document.getElementById(sCompanySizeID);

    
    if (oBusinessNeed.value.indexOf("Select") != -1 && oIndustry.value.indexOf("Select") != -1 && oCompanySize.value.indexOf("Select") != -1)
    {
	    alert("Please select at least one Business Need or Industry or Company Size");
    }
    else
    {
	    var sUrl = "/products_services/solution_finder/results?Match=All";
		
	    if(oBusinessNeed.value.indexOf("Select ") == -1)
		    sUrl += "&BusinessNeed=" + escape(oBusinessNeed.value);
	
	    if(oIndustry.value.indexOf("Select ") == -1)
		    sUrl += "&Industry=" + escape(oIndustry.value);
		
	    if(oCompanySize.value.indexOf("Select ") == -1)
		    sUrl += "&CompanySIze=" + escape(oCompanySize.value);
	
	    //Redirect
	    self.location.href = sUrl;
    }
}