﻿function SelectTab(theTabId) {
    if (document.getElementById('tab' + theTabId)) {
        HideTab('1');
        HideTab('2');
        HideTab('3');
        HideTab('4');
        HideTab('5');
        HideTab('6');

        if (theTabId != '0') {
            document.getElementById('tab' + theTabId).className = 'tabHeadingSelected';
            document.getElementById('sublinks' + theTabId).style.display = '';
        }
    }
}

function HideTab(theTabId) {
    if (document.getElementById('tab' + theTabId)) {
        document.getElementById('tab' + theTabId).className = 'tabHeadingNotSelected';
        document.getElementById('sublinks' + theTabId).style.display = 'none';
    }
}

function CreateBookmarkLink(subDomain, title) {
    url = "http://www.southernsportstech.com/" + subDomain + ".start";

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url, "");
    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(url, title);
    }
    else if (window.opera && window.print) { // Opera Hotlist
        return true;
    }
}

function BindSelectAllCheckBoxList(cbSelectAllId, cblItemsId) {
    var cbSelectAll = "#" + cbSelectAllId;
    var cblItems = "#" + cblItemsId + " :checkbox";
    var cblItemsChecked = "#" + cblItemsId + " :checkbox:checked";

    $(cbSelectAll).click(function () {
        $(cblItems).attr('checked', $(this).is(':checked'));
    });

    $(cblItems).click(function () {
        $(cbSelectAll).attr('checked', $(cblItems).length == $(cblItemsChecked).length);
    });
}

function GetCheckBoxListCheckedCount(checkBoxListId) {
    var cblItems = "#" + checkBoxListId + " :checkbox:checked";
    return $(cblItems).length;
}

function GetRadioButtonListCheckedCount(radioButtonListId) {
    var rblItems = "#" + radioButtonListId + " :radio:checked";
    return $(rblItems).length;
}



/* Discount Codes */
function createRandomDiscountCode(textboxDestination, destinationValueLength)
{
	var theValue = createRandomString(destinationValueLength) + '-' + createRandomString(destinationValueLength);
	document.getElementById(textboxDestination).value = theValue;
}

function createRandomString(finalValueLength) { 
	var chars = new Array ('2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','X','Y','Z'); 
	var charCount = chars.length; 
	var outputString='';

   i = 0; 
   do { 
      random = Math.floor(Math.random() * charCount); 
      random = chars[random]; 
      outputString += '' + random;
      i++; 
   } 
   while (i < finalValueLength); 
   
   return outputString;
} 

