var translations = {'days':'days','day':'day','hours':'hours','hour':'hour','mins':'mins','min':'min','Tournament Started':'Tournament Started'};

function setTranslations(days, day, hours, hour, mins, min, tournamentStarted)
{
    translations['days']=days;
    translations['day']=day;
    translations['hours']=hours;
    translations['hour']=hour;
    translations['mins']=mins;
    translations['min']=min;
    translations['Tournament Started'] = tournamentStarted;
}
// Recursive - find the first child element that has the specified class
function getChildByClass(elem, className)
{
    var found = null;

    if (elem.className != undefined)
    {
        if (elem.className.indexOf(className) > -1)
        {
            found = elem;
        }
        else
        {
            var children = elem.childNodes;
        
            if(children.length > 0)
            {
                for (j=0; j < children.length && found == null; j++)
                {
                    found = getChildByClass(children[j], className);
                }
            }
        }
    }
    
    return found;
}

// Check or Uncheck all checkboxes in a form
function checkUncheckAll(FormName, FieldName){
    var CheckValue = 'true';
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	var checkAll = $('checkAll');
	CheckValue = checkAll.getProperty("checked");
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

function uncheckCheckAll(FormName){
    if(!document.forms[FormName])
		return;
    var checkAll = $('checkAll');
	checkAll.checked = false;
}


// trim the specified characters in the specified string
function Trim(str, chars)
{
    var i;
    
    for (i = 0; i < chars.length; i++)
    {
        str = str.replace(chars.charAt(i), "");
    }   
    
    return str;
}

// Pop the specified url in a maximized window
function popMax(url)
{
    window.open(url,'','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left=0,top=0,width=' + 
        screen.availWidth + ',height=' + screen.availHeight + ',copyhistory=yes');
}

// Extracts the number from the specified string
function extractNumber(str)
{
    var result = '';
    
    for (var i = 0; i < str.length; i++)
    {
        var char = str.charAt(i);
        if ((char >= '0' && char <= '9') || char == '.')
        {
            result += char;
        } else if ( i>1 && !((char >= '0' && char <= '9') || char == '.' || (char >= '0' && char <= '9') || char == ',')) {
            return parseFloat(result);
        }
    }
    
    return parseFloat(result);
}

// This function determines if the specified point is in the specified element
function IsPointInElementRect(element, point)
{
    var rectElement = $(element).getBoundingClientRect(); // rect of the element
    var returnCode = false;
    
    if ((point.x >= rectElement.left) &&
        (point.x <= rectElement.right) &&
        (point.y >= rectElement.top) &&
        (point.y <= rectElement.bottom)
       )
    {
        returnCode = true;
    }
    
    return returnCode;
}




