var Sky_ads="False";
var ok_loadpage=false;


// convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

// *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);
    var is_aix2  = (agt.indexOf("aix 2") !=-1);
    var is_aix3  = (agt.indexOf("aix 3") !=-1);
    var is_aix4  = (agt.indexOf("aix 4") !=-1);
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var is_mpras    = (agt.indexOf("ncr")!=-1);
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
                 is_sco ||is_unixware || is_mpras || is_reliant ||
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));




// Change Frame
function ChangePreviewFrame(frameName,url)
{
  if (top.frames[frameName]) {
	var x = WEB_HOME; //"??";
	var tt = '['+top.frames[frameName].location+']';
	if (tt != '[]') {
	   var test = top.frames[frameName].location.href;
   	   test = test.replace(x,"");
    } else {
	   var test = "[]";
	}

	if (test != url || test == "[]") {
	  top.frames[frameName].location.href = url;
    }
  }

  return;
}

$ans = 0// The functions: TabClicked
function TabClicked(prefix,button_on) {
    var tabOff = "black";
    var tabOn = "red";

	// Change start and end images for Tabs
    for (i=0; i<document.getElementsByTagName('img').length; i++) {
      var theLink = (document.getElementsByTagName('img')[i]);
      //alert(theLink.id+", "+theLink.id.length);
	  if (theLink.id.length > 3) {
	    if (theLink.id.substring(0,5) == prefix) {

		  //if (theLink.id.indexOf("tab_1_") > 0) {
		    //theLink.src = theLink.src.replace("tab_1_",tabOff);
	      //}

		  TestPos = theLink.id.indexOf(button_on);
		  if (TestPos > -1) {
			  theLink.src = theLink.src.replace(tabOff,tabOn);
	      } else if (theLink.src.indexOf(tabOn) > -1) {
			  theLink.src = theLink.src.replace(tabOn,tabOff);
		  }
        }
      }
    }

    // Now find Text part of Tab
    for (i=0; i<document.getElementsByTagName('td').length; i++) {
      var theLink = (document.getElementsByTagName('td')[i]);
	  if (theLink.id.length > 3) {
	    if (theLink.id.substring(0,5) == prefix) {
		  TestPos = theLink.id.indexOf(button_on);
		  if (TestPos > -1) {
			  theLink.style.backgroundImage = theLink.style.backgroundImage.replace(tabOff,tabOn);
		  } else if (theLink.style.backgroundImage.indexOf(tabOn) > -1) {
			  theLink.style.backgroundImage = theLink.style.backgroundImage.replace(tabOn,tabOff);
		  }
        }
      }
    }

    return;
}

// Change Frame
function ChangeFrame(frameName,url) {
	//var x = "<?=$GLOBALS["WEB_HOME"]?>";

  if (top.frames[frameName]) {
	var x = WEB_HOME; //"??";
	var tt = '['+top.frames[frameName].location+']';
	if (tt != '[]') {
	   var test = top.frames[frameName].location.href;
   	   test = test.replace(x,"");
    } else {
	   var test = "[]";
	}

	if (test != url || test == "[]") {
	  top.frames[frameName].location.href = url;
    }
  } else {
	var x = WEB_HOME; //"??";
	var tt = '['+parent.frames[frameName].location+']';
	if (tt != '[]') {
	   var test = parent.frames[frameName].location.href;
   	   test = test.replace(x,"");
    } else {
	   var test = "[]";
	}

	if (test != url || test == "[]") {
	  parent.frames[frameName].location.href = url;
    }
  }
  return;
}

// Void
function linkvoid() {
	return;
}

function b_push(button,graphic,state) {
	if (state == "down") button.src='/images/furniture/'+graphic+'_1_bp.gif';
	else if (state == "up")	button.src='/images/furniture/'+graphic+'_1_b.gif';
	return;
}

function PillClicked(prefix,button_on) {
    var tabOff = "_0_";
    var tabOn = "_1_";
	//alert(prefix+","+button_on);
	//alert(prefix.length);
	// Change start and end images for Tabs
    for (i=0; i<document.getElementsByTagName('img').length; i++) {
      var theLink = (document.getElementsByTagName('img')[i]);
      //alert(theLink.id+", "+theLink.id.length);
	  if (theLink.id.length > 3) {
		  //alert(theLink.id);
	    if (theLink.id.substring(0,prefix.length) == prefix) {

		  //if (theLink.id.indexOf("tab_1_") > 0) {
		    //theLink.src = theLink.src.replace("tab_1_",tabOff);
	      //}

		  TestPos = theLink.id.indexOf(button_on);
		  if (TestPos > -1) {
			  theLink.src = theLink.src.replace(tabOff,tabOn);
	      } else if (theLink.src.indexOf(tabOn) > -1) {
			  theLink.src = theLink.src.replace(tabOn,tabOff);
		  }
        }
      }
    }

    // Now find Text part of Tab
    for (i=0; i<document.getElementsByTagName('td').length; i++) {
      var theLink = (document.getElementsByTagName('td')[i]);
	  if (theLink.id.length > 3) {
	    if (theLink.id.substring(0,prefix.length) == prefix) {
		  TestPos = theLink.id.indexOf(button_on);
		  if (TestPos > -1) {
			  theLink.style.backgroundImage = theLink.style.backgroundImage.replace(tabOff,tabOn);
			  //theLink.style = "pill_on";
			  //alert(theLink.style.class);
		  } else if (theLink.style.backgroundImage.indexOf(tabOn) > -1) {
			  theLink.style.backgroundImage = theLink.style.backgroundImage.replace(tabOn,tabOff);
		  }
        }
      }
    }

    // Now find Text part of Tab
    for (i=0; i<document.getElementsByTagName('a').length; i++) {
      var theLink = (document.getElementsByTagName('a')[i]);
	  if (theLink.id.length > 3) {
	    if (theLink.id.substring(0,prefix.length) == prefix) {
		  TestPos = theLink.id.indexOf(button_on);
		  if (TestPos > -1) {
			  theLink.className = "pill_on";
		  } else {
			  theLink.className = "pill_off";
		  }
        }
      }
    }

    return;
}

function resizeIframe() {

	// Must launched on the body onload event handler for IE
	// Use document.documentElement if you are in Compat mode
	//alert(window.name);
	var wn = window.name;
	i = parent.document.getElementById(wn);
	i.style.height = "50px";
	//iHeight = document.body.scrollHeight;

    iHeight1 = document.body.scrollHeight;
	iHeight2 = document.body.offsetHeight;
	//alert(iHeight1+","+iHeight2);
	if (iHeight2 > iHeight1) iHeight1 = document.body.offsetHeight;
	if (iHeight1 < 100) iHeight1 = 200;
	//alert(iHeight1+","+iHeight2);
	i.style.height = iHeight1 + 5 + "px";

}

// Added by Kevin Smith 30th March 2006 - to fix menu dissappearing
function hide_iframes() {
  for (i=0; i<parent.document.getElementsByTagName('iframe').length; i++) {
    var theIF = (parent.document.getElementsByTagName('iframe')[i]);
	if (theIF.id.substring(0,3) == "hm_") {
	  theIF.style.visibility="hidden";
	}
  }
}

function show_iframes() {
  for (i=0; i<parent.document.getElementsByTagName('iframe').length; i++) {
	var theIF = (parent.document.getElementsByTagName('iframe')[i]);
	if (theIF.id.substring(0,3) == "hm_") {
  	  theIF.style.visibility="visible";
	}
  }
}

function hide_selects() {
  for (i=0; i<parent.document.getElementsByTagName('select').length; i++) {
    var theIF = (parent.document.getElementsByTagName('select')[i]);
	theIF.style.visibility="hidden";
  }
  for (i=0; i<parent.document.getElementsByTagName('embed').length; i++) {
    var theIF = (parent.document.getElementsByTagName('embed')[i]);
    theIF.style.visibility="hidden";
  }

  for (i=0; i<parent.document.getElementsByTagName('iframe').length; i++) {
    var theIF = (parent.document.getElementsByTagName('iframe')[i]);
	if (theIF.id == "hm_cards" || theIF.id == "hm_results") {
	  Iframe = parent.document.getElementsByTagName('iframe')[i].name;
      for (s=0; s<window.frames[Iframe].document.getElementsByTagName('select').length; s++) {
        var theSelIF = (window.frames[Iframe].document.getElementsByTagName('select')[s]);
	    theSelIF.style.visibility="hidden";
      }
	}
  }

}
function show_selects() {
  for (i=0; i<parent.document.getElementsByTagName('select').length; i++) {
    var theIF = (parent.document.getElementsByTagName('select')[i]);
	theIF.style.visibility="visible";
  }
  for (i=0; i<parent.document.getElementsByTagName('embed').length; i++) {
    var theIF = (parent.document.getElementsByTagName('embed')[i]);
    theIF.style.visibility="visible";
  }

  for (i=0; i<parent.document.getElementsByTagName('iframe').length; i++) {
    var theIF = (parent.document.getElementsByTagName('iframe')[i]);
	if (theIF.id == "hm_cards" || theIF.id == "hm_results") {
	  Iframe = parent.document.getElementsByTagName('iframe')[i].name;
      for (s=0; s<window.frames[Iframe].document.getElementsByTagName('select').length; s++) {
        var theSelIF = (window.frames[Iframe].document.getElementsByTagName('select')[s]);
	    theSelIF.style.visibility="visible";
      }
	}
  }
}

function show_odds(id_on,id_off) {
  if (document.getElementById) {
    var returnOnVar = document.getElementById(id_on);
    var returnOffVar = document.getElementById(id_off);
  } else if (document.all) {
    var returnOnVar = document.all[id_on];
    var returnOffVar = document.all[id_on];
  } else if (document.layers) {
    var returnOnVar = document.layers[id_on];
    var returnOffVar = document.layers[id_on];
  }
  returnOnVar.style.visibility = 'visible';
  returnOnVar.style.display = 'block';
  returnOffVar.style.visibility = 'hidden';
  returnOffVar.style.display = 'none';
}

function showCol(ReqCol,ReqPB_id,ReqOutcome_id,ReqHorseArray) {
  //alert(ReqCol+","+ReqPB_id+","+ReqOutcome_id);
  var UserCol = MN_req_cols[(ReqCol+1)];
  var ColType = MN_cols_id[UserCol];
  //document.write("<font color='#00FF00'>["+UserCol+"]["+ColType+"]</font><BR>");

  if (ColType == "b") {
	//alert(UserCol);
    var ReqSpan = 'p_'+ReqPB_id+'_'+ReqOutcome_id;
    //alert(ReqSpan);
    //var NewSpan = "p_"+ReqPB_id+"_"+ReqOutcome_id+"_"+MN_bookmaker_ids[UserCol];
    var NewSpan = "p_"+ReqPB_id+"_"+ReqOutcome_id+"_"+MN_bookmaker_ids[UserCol];
    document.write("<span id='"+NewSpan+"'></span>");
    //document.getElementById(ReqSpan).id=NewSpan;
    //document.write("<font color='#FF0000'>["+ReqCol+"]["+MN_bookmaker_ids[UserCol]+"]["+NewSpan+"]</font><BR>");
    //document.write("<font color='#FF0000'>["+MN_bookmaker_ids[UserCol]+"]</font><BR>");
  } else {
    //ReqSpan = 'MN_'+ReqRaceId+'_'+ReqHorseId;
    //alert(ReqSpan);
    //alert(MN_cols[UserCol]);
    if (MN_cols[UserCol]=="My Odds") {
	  document.write(ReqHorseArray[2]);
    } else {
      document.write("<font color='#0000FF'>["+ReqSpan+"]</font><BR>");
    }
  }
}

function show_news(on_off) {
  if (document.getElementById) {
    var returnTickerVar = document.getElementById('news_ticker');
  } else if (document.all) {
    var returnTickerVar = document.all['news_ticker'];
  } else if (document.layers) {
    var returnTickerVar = document.layers['news_ticker'];
  }

  if (typeof returnTickerVar != 'undefined' && returnTickerVar != null) {
    if (on_off == 'On') {
      returnTickerVar.style.visibility = 'visible';
      returnTickerVar.style.display = 'block';
    } else {
      returnTickerVar.style.visibility = 'hidden';
      returnTickerVar.style.display = 'none';
    }
  }
}


function hideHL(obj) {
	obj.style.background="#FFFFFF";
}
function showHL(obj) {
	obj.style.background="#D9E8F3";
}

//added 24-10-2008 JJ
forumTriggered=0;

function callForum(url) {
   if (navigator.platform.indexOf('Mac') != -1) {
      alert("Videos are available for viewing on PCs only.");
   } else if (navigator.appName != "Microsoft Internet Explorer") {
	  alert("Internet Explorer 6 or Higher is required\n to watch the Tipsters' Forums.");
   } else {
      if (forumTriggered==0) {
         forumTriggered=1;
         OWSize('',url,830,620,'no','yes','no')
         
         setTimeout('resetForumTrigger();',5000);
      }
   }
}
function resetForumTrigger() {
   forumTriggered=0;
}

