document.domain = document.domain.substring(document.domain.indexOf('.') +1);

//var memberSvr = 'https://members.macauslot.com/';

var sMemberSvrHostOnly = 'members.macauslot.com';
var sAppsSvrHostOnly = 'apps.macauslot.com';
var sWWWSvrHostOnly = 'web.macauslot.com';
var sWWWNSvrHostOnly = 'www.macauslot.com';


var sMemberSvr = 'http://'+sMemberSvrHostOnly;
var sMemberSSLSvr = 'http://'+sMemberSvrHostOnly;
var sAppsSvr = 'http://'+sAppsSvrHostOnly;

var sWWWSvr = 'http://'+sWWWSvrHostOnly;
var sWWWNSvr = 'http://'+sWWWNSvrHostOnly;
var sFJTSite = 'h'+'ttp://translation.macauslot.com:89/gate/gb/';

var sUnderConstructionURL = '/'+'slot/html/construction.html';

var sWarningURL = '/'+'slot/html/login/warning.html';


 
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// DDMenu

  var eOpenMenu = null;
  function OpenMenu(eSrc,eMenu){
    eMenu.style.left = eSrc.parentElement.offsetLeft + divMenuBar.offsetLeft;
    eMenu.style.top = divMenuBar.offsetHeight + divMenuBar.offsetTop;
    eMenu.style.visibility = "visible";
    eOpenMenu = eMenu;
  }

  function CloseMenu(eMenu){
    eMenu.style.visibility = "hidden";
    eOpenMenu = null;
  }

  function MenuBar_over(){
    var eSrc = window.event.srcElement;
	//alert(eSrc.tagName.toUpperCase());
    if ("A" == eSrc.tagName.toUpperCase()|"IMG" == eSrc.tagName.toUpperCase()){
      var eMenu = document.all[eSrc.parentElement.id.replace("tdMenuBarItem","divMenu")];
	  if (eOpenMenu && eOpenMenu != eMenu){
        CloseMenu(eOpenMenu);}
      if (eMenu){
		  OpenMenu(eSrc,eMenu);}
    }
  }

  function MenuBar_out(){
    var eTo = window.event.toElement;
    if (eOpenMenu && eTo && !eOpenMenu.contains(eTo) && "tblMenuBar" != eTo.id){
      CloseMenu(eOpenMenu)}
	}

  function Menu_out(){
    var eSrc = window.event.toElement;
    if (eOpenMenu && !eOpenMenu.contains(eSrc) && !divMenuBar.contains(eSrc)){
      CloseMenu(eOpenMenu)}
	}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function leapto(item)    {
var site=item.selectedIndex;
 if (site==0)      ;
 		if (site>=1)
 			{ window.location.href=item.options[site].value;
	}
}

function openPopup(sURL, iWidth, iHeight){
  //  var oNewWindow;
   //window.open(sURL,'','alwaysRaised=yes,menubar=no,toolbar=no,resizable=no,scrollbars=no,status=no,top=0,left=0,height='+iHeight+',width='+iWidth);
   //For Debug purposes
   window.open(sURL,'Content','alwaysRaised=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=no,status=yes,top=0,left=0,height='+iHeight+',width='+iWidth);
}

function openPopupDetails(sURL, iWidth, iHeight, sEx, sWinName, iLeft, iTop, bIsReturn){
   var w=window.open(sURL,(sWinName ? sWinName : 'PopupDetailsWin'),(sEx ? sEx : '')+'alwaysRaised=yes,resizable=yes,status=yes,top='+(iTop ? iTop : 0)+',left='+(iLeft ? iLeft : 0)+',height='+iHeight+',width='+iWidth);
   w.focus();
   if(bIsReturn) return w;
}

function openPopupCenter(sURL, iWidth, iHeight, sWinName){
   var w = 1024, h = 768;

   if (document.all) {
      /* the following is only available after onLoad */
      w = screen.width;
      h = screen.height;
   }
   else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
   }


   var leftPos = (w-iWidth)/2, topPos = (h-iHeight)/2;
   window.open(sURL,sWinName,'alwaysRaised=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=no,status=yes,top='+topPos+',left='+leftPos+',height='+iHeight+',width='+iWidth);
   sWinName.focus;
}

function openPopupCenterScrollBars(sURL, iWidth, iHeight, sWinName){
   var w = 1024, h = 768;

   if (document.all) {
      /* the following is only available after onLoad */
      w = screen.width;
      h = screen.height;
   }
   else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
   }


   var leftPos = (w-iWidth)/2, topPos = (h-iHeight)/2;
   window.open(sURL,sWinName,'alwaysRaised=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no,top='+topPos+',left='+leftPos+',height='+iHeight+',width='+iWidth);
   sWinName.focus;
}


function openPopupCenterPage(sURL, iWidth, iHeight, sEx, sWinName, iTop, bIsReturn){
	//   var w = 480, h = 340;

	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	   h = document.body.offsetHeight;
	   w = window.screen.availWidth;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}

	var leftPos = (w-iWidth)/2, topPos = (h-iHeight)/2;
	var w = window.open(sURL,(sWinName ? sWinName : 'PopupDetailsWin'),(sEx ? sEx : '')+'alwaysRaised=yes,menubar=no,toolbar=auto,resizable=yes,scrollbars=yes,status=yes,top='+(iTop ? iTop : 0)+',left='+leftPos+',height='+iHeight+',width='+iWidth);
	w.focus;

	if(bIsReturn) return w;
}

function changeWindowOpenerURL(sURL){
	window.opener.location = sURL;
}


var tabShow=0;

function hidefooter() {
  if (tabShow == 1) {
    if (document.all) {
      parent.bottomFrame.document.body.cols="80,*,30";
      tabShow = 0;
      return;
    }
  }

  if (tabShow == 0) {
    if (document.all) {
      parent.bottomFrame.document.body.cols="80,100%,0%";
      tabShow = 1;
    }
  }
}

function getDateTime(iLangID)
{
		//define variable
		var Jsay;
		var Jdayr;
		var Jtoday= new Date();
		var Jyear= Jtoday.getFullYear(); Jmonth=Jtoday.getMonth()+1;
		var weekday=new Array ("&#26143;&#26399;&#26085;","&#26143;&#26399;&#19968;","&#26143;&#26399;&#20108;","&#26143;&#26399;&#19977;","&#26143;&#26399;&#22235;","&#26143;&#26399;&#20116;","&#26143;&#26399;&#20845;");
		//var weekday=new Array ("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
		if (iLangID == 3){
			var weekday=new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		}

		Jday= Jtoday.getDay(); Jdate=Jtoday.getDate();
		Jhrs= Jtoday.getHours(); Jmin=Jtoday.getMinutes();
		Jmin=((Jmin < 10) ? "0" : "") + Jmin;
		Jsec=Jtoday.getSeconds();
		Jsec=((Jsec < 10) ? "0" : "") + Jsec;
		document.write("<font class=\"normalwhite\">");
		document.write(Jyear+"/"+Jmonth+"/"+Jdate);
		document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		document.write(weekday[Jday]);
		document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		document.write(Jhrs+":"+Jmin);
		document.write("</font>");
}

function getLoginPopup(iLangID){
//	parent.main.location.href = memberSvr+'/soccer/jsp/homepage/homepage.jsp?langid='+iLangID;
//	parent.bottomFrame.location.href = memberSvr+'/slot/jsp/navigation/logincheck.jsp?langid='+iLangID;
//	parent.location.href = 'https://members.macauslot.com/soccer/jsp/index.jsp';
//parent.location.href = 'http://192.168.128.63/soccer/jsp/index.jsp?langid='+iLangID;
	openPopupCenter('h'+'ttp://'+sMemberSvrHostOnly+'/slot/jsp/login/sessioncreate.jsp?langid='+iLangID, 400, 180,'login');
}


function getLogoutPopup(iLangID){
	openPopupCenter('h'+'ttp://'+sMemberSvrHostOnly+'/slot/jsp/login/login.jsp?Logout=true&langid='+iLangID, 400, 180,'login');
}


function bookmark(){
    var ver = navigator.appName;
    var num = parseInt(navigator.appVersion);
    if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) {
        window.external.AddFavorite(sUrl,sTitle);
    }else{
        alert('Press (Ctrl+D) to bookmark this page!');
    }
}

function setAsHomepage(){
    if (document.all){
      document.write('<a href="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\''+sUrl+'\');" class="bottombar">'+sBookmarkCaption+'</a>');
    }else{
        document.write('<a href="javascript:void(0);" onClick="alert(\'Make this site your home page: Go to Preferences in the Edit Menu. Choose Navigator from the list on the left. Click on the \"Use Current Page\" button.\');" class="bottombar">'+sBookmarkCaption+'</a>');
    }
}

function leapto(item)    {
var site=item.selectedIndex;
 if (site==0)      ;
 		if (site>=1)
 			{ window.location.href=item.options[site].value;
	}
}


function redirectHTML(sportstype, slang){
	top.menuframe.location.href = sWWWSvr + '/slot/html/navigation/'+slang+'-navigation.html';
	document.location.href = sWWWSvr + '/slot/html/homepage/'+slang+'-home.html';
	parent.slotframeset.rows = "124,*,0";
}

function redirectHTMLWin(sportstype, slang, window){
	top.menuframe.location.href = sWWWSvr + '/slot/html/navigation/'+slang+'-navigation.html';
	window.location.href = sWWWSvr + '/slot/html/homepage/'+slang+'-home.html';
	window.parent.slotframeset.rows = "124,*,0";
}

function redirectHTMLFromPopup(sportstype, slang){
	window.opener.top.menuframe.location.href = sWWWSvr + '/slot/html/navigation/'+slang+'-navigation.html';
	window.opener.top.main.location.href = sWWWSvr + '/slot/html/homepage/'+slang+'-home.html';
	window.opener.parent.slotframeset.rows = "124,*,0";
	alert('Your session is expire!');
	this.close();
}

function showTicker(){
	if (parent.slotframeset.rows == "124,*,50"){
		parent.slotframeset.rows = "124,*,0";
	}	else if (parent.slotframeset.rows == "124,*,0"){
		parent.slotframeset.rows = "124,*,50";
	}	else	{
		parent.slotframeset.rows = "124,*,50";
	}
}

function Frame($1) {
	if ($1 == "Show") { FrameSize = "160,*" }
	if ($1 == "Hide") { FrameSize = "0,*" }
	parent.slotframeset.cols = FrameSize;
}

function clickOnBanner(sUrl,iBannerid) {
    if(bPersonalize == true)
        openPopupDetails(sMemberSvr + '/slot/jsp/common/banner.jsp?url='+sUrl+'&bid='+iBannerid,600,500,'scrollbars=yes,','Banner');
    else
        openPopupDetails(sUrl,600,500,'scrollbars=yes,','Banner');
}

function getUserName(){
    document.writeln(username);
}

function getUserSlotpoint(){
    document.writeln(slotpoint);
}

function getStyle(iType, iTeam1ID, iTeam2ID, sLink){

    if(iType == 1){
        if((iMyFavSocTeamID == iTeam1ID || iMyFavSocTeamID == iTeam2ID) && iMyFavSocTeamID != 0)
            document.writeln("<a href=\"javascript:openPopupDetails('"+sLink+"',600,600,'scrollbars=yes,','News')\" class=\"homenewsgreen\">");
        else
            document.writeln("<a href=\"javascript:openPopupDetails('"+sLink+"',600,600,'scrollbars=yes,','News')\" class=\"homenewsblue\">");
    }else if(iType == 2){
        if((iMyFavNbaTeamID == iTeam1ID || iMyFavNbaTeamID == iTeam2ID) && iMyFavNbaTeamID != 0)
            document.writeln("<a href=\"javascript:openPopupDetails('"+sLink+"',600,600,'scrollbars=yes,','News')\" class=\"homenewsorange\">");
        else
            document.writeln("<a href=\"javascript:openPopupDetails('"+sLink+"',600,600,'scrollbars=yes,','News')\" class=\"homenewsblue\">");
    }
}

function getAppletHead(sColor1, sColor2, sOn1, sOff1, sOn2, sOff2){
        document.writeln("    <applet archive=\"Scroll.jar\" code=\"TScrollUpTab.class\" width=\"212\" height=\"158\" align=\"middle\">");
        document.writeln("    <param name=\"backgroundColor\" value=\""+sColor1+"\">                                                   ");
        document.writeln("    <param name=\"backgroundColor2\" value=\""+sColor2+"\">                                                  ");
        document.writeln("    <param name=\"defaultTextColor\" value=\"0, 0, 0\">                                                      ");
        document.writeln("    <param name=\"heightLightColor\" value=\"0, 0, 255\">                                                    ");
        document.writeln("    <param name=\"heightLightColor2\" value=\"255, 0, 0\">                                                   ");
        document.writeln("    <param name=\"defaultFont\" value=\"Dialog, plain, 11\">                                                 ");
        document.writeln("    <param name=\"leftRightMargin\" value=\"1\">                                                             ");
        document.writeln("    <param name=\"topMargin\" value=\"22\">                                                                  ");
        document.writeln("    <param name=\"defaultTextAllignment\" value=\"center\">                                                  ");
        document.writeln("    <param name=\"scrollDelay\" value=\"30\">                                                                ");
        document.writeln("    <param name=\"defaultTarget\" value=\"_self\">                                                           ");
        document.writeln("    <param name=\"boundIndicator\" value=\"^\">                                                              ");
        document.writeln("    <param name=\"boundIndicator2\" value=\"#\">                                                             ");
        document.writeln("    <param name=\"Tab1OnImg\" value=\""+sOff1+"\">                                                 ");
        document.writeln("    <param name=\"Tab1OffImg\" value=\""+sOn1+"\">                                                 ");
        document.writeln("    <param name=\"Tab2OnImg\" value=\""+sOff2+"\">                                                 ");
        document.writeln("    <param name=\"Tab2OffImg\" value=\""+sOn2+"\">                                                 ");
}

function getEngAppletHead(){
        document.writeln("    <applet archive=\"Scroll.jar\" code=\"TScrollUp.class\" width=\"513\" height=\"95\" align=\"middle\">");
        document.writeln("    <param name=\"backgroundColor\" value=\"255,255,255\">                                                   ");
        document.writeln("    <param name=\"backgroundColor2\" value=\"255,255,255\">                                                  ");
        document.writeln("    <param name=\"defaultTextColor\" value=\"0, 0, 0\">                                                      ");
        document.writeln("    <param name=\"heightLightColor\" value=\"0, 0, 255\">                                                    ");
        document.writeln("    <param name=\"heightLightColor2\" value=\"255, 0, 0\">                                                   ");
        document.writeln("    <param name=\"defaultFont\" value=\"Dialog, plain, 12\">                                                 ");
        document.writeln("    <param name=\"leftRightMargin\" value=\"1\">                                                             ");
        document.writeln("    <param name=\"topMargin\" value=\"0\">                                                                  ");
        document.writeln("    <param name=\"defaultTextAllignment\" value=\"left\">                                                  ");
        document.writeln("    <param name=\"scrollDelay\" value=\"30\">                                                                ");
        document.writeln("    <param name=\"defaultTarget\" value=\"_self\">                                                           ");
        document.writeln("    <param name=\"boundIndicator\" value=\"^\">                                                              ");
        document.writeln("    <param name=\"boundIndicator2\" value=\"#\">                                                             ");
}

function getAppletTail(){
        document.writeln("  </applet>                                                                                                  ");
}
function getAppletFnt(id){
    document.writeln("    <param name=\"font"+id+"\" value=\"Dialog, bold, 14\">                                                        ");
}
function getAppletAln(id,sValue){
    document.writeln("    <param name=\"textAllignment"+id+"\" value=\""+sValue+"\">                                                        ");
}
function getAppletMsg(id, sValue){
    document.writeln("    <param name=\"message"+id+"\" value=\""+sValue+"\">                                                        ");
}
function getAppletUrl(id, sValue){
    document.writeln("    <param name=\"destinationUrl"+id+"\" value=\""+sValue+"\">                                                        ");
    document.writeln("    <param name=\"target"+id+"\" value=\"players\">                                                        ");
}

function getAppletCusMsg(id, sPreValue, sName1, sValue, sName2, sPosValue, iType, iHomeid, iAwayid){
    if(iHomeid != 0 && ((iType == 1 && iMyFavSocTeamID == iHomeid) || (iType == 2 && iMyFavNbaTeamID == iHomeid)))
        sName1 = "#"+sName1+"#";
    if(iAwayid != 0 && ((iType == 1 && iMyFavSocTeamID == iAwayid) || (iType == 2 && iMyFavNbaTeamID == iAwayid)))
        sName2 = "#"+sName2+"#";
    document.writeln("    <param name=\"message"+id+"\" value=\""+sPreValue+sName1+" "+sValue+" "+sName2+sPosValue+"\">                                    ");
}


function gotoURL(sURL, sportsType, iLangID, bLoggedIn){
	var sLangArray = new Array("ch-", "sc-", "en-");

	var sLoggedInURL = "html";
	var sLanguageTabURL = ('/'+sportsType+'/'+sLoggedInURL+'/navigation/'+sLangArray[iLangID-1]+'navigation_notab.html');



	if (bLoggedIn){
		sLoggedInURL = "jsp";
		sLanguageTabURL = ('/'+sportsType+'/'+sLoggedInURL+'/navigation/'+'navigation.jsp?notabs=true&langid='+iLangID);
	}

//	if (this.location.href.indexOf("notab") == -1) 
//	  this.location.href=sLanguageTabURL;
	top.main.location.href=sURL;
}

function lDesc(sDesc){
	top.window.status='Link Description';
	return true;
}

function getexpirydate( nodays){
    var UTCstring;
    Today = new Date();
    nomilli=Date.parse(Today);
    Today.setTime(nomilli+nodays*24*60*60*1000);
    UTCstring = Today.toUTCString();
    return UTCstring;
}
function getcookie(cookiename) {
    var cookiestring=""+document.cookie;
    var index1=cookiestring.indexOf(cookiename);
    if (index1==-1 || cookiename=="") return ""; 
    var index2=cookiestring.indexOf(';',index1);
    if (index2==-1) index2=cookiestring.length; 
    return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
    cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
    document.cookie=cookiestring;
    if(!getcookie(name)){
        return false;
    }else{
        return true;
    }
}

// odds specific open popup function
function openOddsPopup(sURL, iWidth, iHeight, sWinName){
   var w = 1024, h = 768;

   if (document.all) {
      /* the following is only available after onLoad */
      w = screen.width;
      h = screen.height;
   }
   else if (document.layers) {
      w = window.innerWidth;
      h = window.innerHeight;
   }


   var leftPos = (w-iWidth)/2, topPos = (h-iHeight)/2;
   window.open(sURL,sWinName,'alwaysRaised=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=yes,status=no,top='+topPos+',left='+leftPos+',height='+iHeight+',width='+iWidth);
   sWinName.focus;
}
