//Version-1.3.0.2
// Copyright (c) Microgaming 2006
// Combine NewWindow.js and Cookies.js + additional useful goodies.

////////////
// Was newWindow.js
var agt=navigator.userAgent.toLowerCase(); 

var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
            && (agt.indexOf('webtv')==-1)); 
var is_nav4up = (is_nav && (is_major >= 4)); 
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie4up  = (is_ie  && (is_major >= 4)); 

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);

function NewWindow(mypage, myname, w, h, scroll, toolbar, fullscreen)
{
  var winprops = "";

  if (fullscreen)
    winprops = "width=" + (screen.availWidth - 10) + ",height=" + (screen.availHeight - 30) + ",location=no,menubar=no,personalbar=no,resizable=no,screenX=0,screenY=0,locationbar=no,scrollbars="+scroll+",directories=no,statusbar=no,toolbar=no";
  else
  {
    if (w >= 0 && h >= 0)
    {
      var winl = (screen.width - w) / 2;
      var wint = (screen.height - h) / 2;

      winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl;
    }
    winprops = winprops + ',scrollbars='+scroll+',toolbar='+toolbar+',resizable';
  }

  var win = window.open(mypage, myname, winprops)

  if (parseInt(navigator.appVersion) >= 4)
  {
   // win.window.focus();
  }

  if (fullscreen && is_ie4up)
    win.moveTo(0,0);
}

////////////
// Was Cookies.js
var seconds = 1000,
    minutes = 60 * 1000,
    hours   = 60 * 60 * 1000,
    days    = 24 * 60 * 60 * 1000,
    weeks   = 7 * 24 * 60 * 60 * 1000,
    months  = 30 * 24 * 60 * 60 * 1000;

function getCookieVal (offset)
{
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen)
  {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}  

function SetCookie(name,value,expires,path,domain,secure)
{
  var theDate = new Date();
  theDate.setTime(theDate.getTime() + expires);

  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + theDate.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);   
  var cval = GetCookie (name);  
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

///////////////
// pulled from t3start
var ArgList = new Array(10);

function cleanArg(arg) {
  var tempArg = "";
  tempArg += arg;
  
  var nStart = 0;
  while (' ' == tempArg.charAt(nStart))
    nStart++;

  var nEnd = tempArg.length - 1;
  while (nEnd > 0 && ' ' == tempArg.charAt(nEnd))
   nEnd--;

  tempArg = tempArg.substring(nStart, nEnd + 1);
  return (tempArg);
}

function parseArgs(args) {
  for (i = 0; i < 10; i++)
    ArgList[i] = null;

  var tempString = "";

  tempString += args;

  if (0 != tempString.length)
    tempString += ",";

  var delimeter = tempString.indexOf(',');
  var numArgs = 0;
  while (delimeter !=-1) {
    var argLength = tempString.length;
    ArgList[numArgs] = cleanArg(tempString.substring(0,delimeter));

    tempString = tempString.substring(delimeter+1,argLength);
    numArgs++;
    delimeter = tempString.indexOf(',');
  }

  return (numArgs);
}

// MS E-o-l-a-s workaround.
function addFlashControl(codeBase, pluginsPage, movieToLoad) {
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
				'codebase="' + codeBase + '" ' +
				'ID="Menu" WIDTH="100%" HEIGHT="100%">\n' +
				'<PARAM NAME=movie VALUE="' + movieToLoad + '">\n' +
				'<PARAM NAME=menu VALUE=false>\n' +
				'<PARAM NAME=quality VALUE=high>\n' +
				'<PARAM NAME=bgcolor VALUE=#000000>\n' +
				'<PARAM NAME="SCALE" VALUE="showall">\n\n' +
				
				'<embed src="' + movieToLoad + '" ' +
				'quality="high" bgcolor="#000000" width="100%" height="100%" ' +
				'name="Menu" align="middle" SCALE="showall" menu="false" ' +
				'allowScriptAccess="sameDomain" swLiveConnect="true" ' +
				'type="application/x-shockwave-flash" ' +
				'pluginspage="' + pluginsPage + '" />\n\n' +
				
				'</OBJECT>\n');
}

function findSID4()
{
	var tempsID4 = null;
	rreg = GetCookie("RReg");
	// have the loader, so save this
	if (rreg == "true")
	{
		tempsID4 = 0;
	}else
	{
		greg = GetCookie("GReg");
		if (greg == "true")
		{
			tempsID4 = 1;
		}
	}
	return tempsID4;
}

