/* Fix right highlight image padding */
function fixHighlightImage() {
	
	var sub = document.getElementById('new-sub');
	var imgs = sub.getElementsByTagName('img');

	if (imgs.length == 0)
		return;

	var i = imgs.length-1;
	
	do {
		if (imgs[i].width < 180) {
			imgs[i].style.padding = "0 6px 0 0";
		}
	} while (i--);
}

/* Bet Hover Highlighting - Multiple Cells On A Row */
function toggleHighlightCells(ref) {
	
	var cls = ref.className;
	var tr = ref.parentNode;
	var tds = tr.getElementsByTagName("td");
	
	var ptn = new RegExp("(hvr\\d+?)");
	var res = ptn.exec(cls);
	
	if (res != null) {

		cls = res[1];
		var ref;
		
		for (var i=0; i<tds.length; i++) {
			
			ref = tds[i];
			ptn = new RegExp(cls);
			res = ptn.exec(ref.className);
		
			if (res != null)
				toggleHighlightCell(ref);
		}
	}
}

/* Bet Hover Highlighting - Single Cell */
function toggleHighlightCell(ref) {
	
	if ((ref.style.backgroundColor == "#8bb65c") || (ref.style.backgroundColor == "rgb(139, 182, 92)"))
		return;

	if (ref.style.backgroundColor == "") 
		ref.style.backgroundColor = "#ffffff";
	else
		ref.style.backgroundColor = "";
	
}

/* Bet Hover Highlighting - Single Row */
function toggleNewHighlightRow(ref) {
	var tds = ref.getElementsByTagName("td");
	
	for (var i=0; i<tds.length; i++) {
		if (tds[i].style.backgroundColor == "")
			tds[i].style.backgroundColor = "#efefef";
		else
			tds[i].style.backgroundColor = "";
	}
}

/* Bet Hover Highlighting - Single Row */
function toggleHighlightRow(ref) {
	var tds = ref.getElementsByTagName("td");
	
	for (var i=0; i<tds.length; i++) {
		if (tds[i].style.backgroundColor == "")
			tds[i].style.backgroundColor = "#ffffff";
		else
			tds[i].style.backgroundColor = "";
	}
}

/* Bet Selection Highlighting */
function toggleSelectCell(ref) {
	var trs = ref.getElementsByTagName("tr");
	var tds, td, input;
	
	for (var i=0; i<trs.length; i++) {
		var tds = trs[i].getElementsByTagName("td");
		for (var j=0; j<tds.length; j++) {
			input = tds[j].getElementsByTagName("input");
			if (input.length > 0) {
				if (input[0].checked) {
					tds[j].style.backgroundColor = "#8bb65c";
					tds[j].style.color = "#fff";
				} else {
					tds[j].style.backgroundColor = "";
					tds[j].style.color = "";
				}
			}
		}
	}
}

/* CSS Drop Down IE Fix */
function ieDropDownFix() {
	var uls = document.getElementsByTagName("ul");
	var ul, li, lis, num;
	
	var i=uls.length-1;
	do {
		if (uls[i].className=="dd-mkt" || uls[i].className=="dd-tv") {
			li = uls[i].getElementsByTagName("li");

			li[0].onmouseover=function() {this.className+=" sfhover";}
			li[0].onmouseout=function() {this.className=this.className.replace(new RegExp(" sfhover\\b"), "");}
			
			ul = li[0].getElementsByTagName("ul");
			lis = ul[0].getElementsByTagName("li");

			if (lis.length > 10)
				ul[0].className +=" scroll";
		}
	} while(i--);
}

/* Pop Up Window */
function popup(url, name, feat) {
	var defFeat = 'location=0,statusbar=0,menubar=0,scrollbars=0,';
    defFeat += feat;
	var theWindow = window.open(url, name, defFeat);
	theWindow.focus();
}
