function SetRadioButtonCheck(groupName,curRadioBtn)
{
    //Utility function to make sure only one radio button gets
    //checked that belong to the same group name,
    //Group names can be altered by .NET if 
    //they reside in seperate user controls with same group names
	var radioBtns = document.getElementsByTagName("input");
	for(i = 0; i < radioBtns.length; i++)
	{
		var radioBtn = radioBtns[i];
		if (radioBtn.type == 'radio')
		{
			if (radioBtn.name.indexOf(groupName) >= 0)
			{
				radioBtn.checked = false;
				SetUnselectedBorder(radioBtn);
			}
		}
	}
	curRadioBtn.checked = true;
	SetSelectedBorder(curRadioBtn);
}

function SetUnselectedBorder(radioBtn)
{
    //Sets the "unselected" classnames for the borders
    var strClientID = GetCommonClientID(radioBtn);
    
    SetUnselectedElement(strClientID+"tdPricing");
    SetUnselectedElement(strClientID+"tdBestOffer");
    SetUnselectedElement(strClientID+"divPriceInner");
    SetUnselectedElement(strClientID+"tdBottomLeft");
    SetUnselectedElement(strClientID+"tdBottomRight");    
}

function SetSelectedBorder(radioBtn)
{
    //Sets the "Selected" classnames for the borders
    
    var strClientID = GetCommonClientID(radioBtn);
    
    SetSelectedElement(strClientID+"tdPricing");
    SetSelectedElement(strClientID+"tdBestOffer");
    SetSelectedElement(strClientID+"divPriceInner");
    SetSelectedElement(strClientID+"tdBottomLeft");
    SetSelectedElement(strClientID+"tdBottomRight");
}

function SetUnselectedElement(elementName)
{
    //Remove "-g" from className
    var elementID = document.getElementById(elementName);
    var idx = elementID.className.indexOf("-g");
    if (idx != -1)
        elementID.className = elementID.className.substring(0,idx);
}

function SetSelectedElement(elementName)
{
    //Add "-g" to className
    var elementID = document.getElementById(elementName);
    var idx = elementID.className.indexOf("-g");
    if (idx == -1)
        elementID.className = elementID.className+"-g";
}

function GetCommonClientID(radioBtn)
{
    return radioBtn.id.substring(0,radioBtn.id.indexOf("rBtnPlan"));
}
		
function ToggleView (divExpColID, detailsDivID, collapseClass, expandClass) 
{  
    //Toggles the class names of html elements
    divExpCollapse = document.getElementById(divExpColID);
    divExpCollapse.className = (divExpCollapse.className == expandClass) ? divExpCollapse.className = collapseClass : divExpCollapse.className = expandClass;
    detailsDiv = document.getElementById(detailsDivID); 
    detailsDiv.className = (detailsDiv.className == 'show') ? detailsDiv.className = 'hide' : detailsDiv.className = 'show'; 
    return true;    
}

function ShowRegion (elementIdToShow, elementIdToHide, secondElementToShow , secondElementToHide) 
{  
    elementToShow = document.getElementById(elementIdToShow);
    elementToHide = document.getElementById(elementIdToHide);
    if(elementToShow) elementToShow.style.display = "block";
    if(elementToHide) elementToHide.style.display = "none";

    secondElementToShow = document.getElementById(secondElementToShow);
    secondElementToHide = document.getElementById(secondElementToHide);
    if (secondElementToShow) secondElementToShow.style.display = "block";
    if (secondElementToHide) secondElementToHide.style.display = "none";
    
    return true;
}
    
// function for showing/displaying tooltips in signup user controls
function ShowToolTip(spanID) {
    var span = document.getElementById(spanID);
    if (span != null) {
        span.style.display = "inline";
    }
}
function HideToolTip(spanID) {
    var span = document.getElementById(spanID);
    if (span != null) {
        span.style.display = "none";
    }
}
         
// On IE6 for certain users, we were credit card & billing address 
// onfocus, onblur were behaving weird. This function will use IE specific
//methods instead.
function UpdateIE6Events(elementId, toolTipId) {
    var element = document.getElementById(elementId);
    if(element && element != null) {
        element.onfocusin = function() { ShowToolTip(toolTipId); }
        element.onfocusout = function() { HideToolTip(toolTipId); }
        element.onfocus = function() {};
        element.onblur = function() {};
    }
}

//This method is called for IE6 on page load & left empty intentionally
// so that if we run into issues with more controls once we go live
// we can call UpdateIE6Events() for with hardcoded IDs here.
function UpdateIE6EventsEmpty()
{
}