﻿var stopped = false;
var isjavaenabled=true;
var isDemoUpdating=false;
function countdown(obj)
{
    this.obj		= obj;
    this.CountFrom		= 0;
    this.DisplayFormat	= "%%S%% Seconds.";
    this.CountActive	= true;
    this.DisplayStr;
    		
    this.CountBack		= cd_CountBack;
    this.Setup		= cd_Setup;
    this.OnVideoStopped = cd_OnVideoStopped;
}
    		
function cd_OnVideoStopped(){
    //document.getElementById("clock1").innerHTML = "Stopped";
	stopped = true;
}
function rules(url) {	
var features="directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=440,height=420";
var baseUrl = "http://smartlivecasino-proxy.casinomodule.com";
var ruleURL = baseUrl + url;
var remote = open(ruleURL, "rules", features); 
}

function cd_CountBack(secs)
{
	if (stopped){
	    var clip = document.getElementById("clipstreamlive");
        if (clip)
        {
		    clip.play_video(0, -1);
  	    }
	}		    			
   	if (this.CountActive){ 
    	setTimeout(this.obj +".CountBack(" + (secs + 1) + ")", 990);
	}
}
    		
function cd_Setup()
{
    this.CountBack(this.CountFrom);
}
		    
var cd1 = new countdown('cd1');
cd1.Div			= "clock1";
cd1.CountFrom		= 0;
		    
function Load(j)
{
    var browser=navigator.appName		
}

var clip = document.getElementById("clipstreamlive");
if (clip)
{
	clip.set_callbackOnStop("cd_OnVideoStopped()");
	cd1.Setup();
}


function openPage(page,width,height,scroll,status){
    var popup = window.open(page,'gameW','left=0,top=0,resizable='+ scroll +',menubar='+ scroll +',toolbar='+ scroll +',width='+width+',height='+height+',scrollbars=' + scroll + ',status=' + status)
    popup.focus();
}
function resize(width, height)
{
    window.resizeTo(width,height);
}

function openPageInFull(page,width,height,scroll,status){
    var popup = window.open(page,'gameW','left=0,top=0,resizable='+ scroll +',menubar='+ scroll +',toolbar='+ scroll +',width='+width+',height='+height+',scrollbars=' + scroll + ',status=' + status + ',location=' + scroll + ',directories=' + scroll)
    popup.focus();
}

function resize(width, height)
{
    window.resizeTo(width,height);
}
function openMini(page, width, height)
{
    var popup = window.open(page,'mini','width=' + width + ',height=' + height + ',scrollbars=1');
    popup.focus();
}

function resizemyWindow(width,height)
{    
    
    window.resizeTo(width,height);
    myWindowWidth = width;
    myWindowHeight = height;
    if( typeof( window.innerWidth ) == 'number' ) 
    {    
      myinnerWidth = window.innerWidth;
      myinnerHeight = window.innerHeight;
    } 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
	    //IE 6+ in 'standards compliant mode'
	    myinnerWidth = document.documentElement.clientWidth;
	    myinnerHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
	    //IE 4 compatible
	    myinnerWidth = document.body.clientWidth;
	    myinnerHeight = document.body.clientHeight;
	}

     if (myinnerHeight!=height)
   myWindowHeight = myWindowHeight + (height-myinnerHeight);
   window.resizeTo(width,myWindowHeight);
}

function CheckJava()
{
    b = false;
    try{        
        var t = document.getElementById("testappletId");
	      b = t.isJavaVersionOKTest();
    }catch(err){
      b = false;
    }
    b=true;
    isjavaenabled=b;
    if (!b)
    {
        var message = "<b><h2><font color='red'>Warning</font></h2></b>";
        message+="<b><span class='txtgrey12'>To play you need to install the missing Java Plugin by clicking link below.</span></b><br><br>";
        message+="<a href='http://www.java.com/en/download/index.jsp' target='_blank'><img src=/images/default/javalogosun.jpg border=0></a>";
        message+="<br/><br/>";
	    var messager = document.getElementById("messageId");
	    messager.innerHTML=message;
	    toggleLayer("gameapplet");
    }          
    else
        SetJaveIsEnabled();
              
}

function log(message) {
 var client = new XMLHttpRequest();
 client.open("POST", "/log");
 client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
 client.send(message);
}

function createXMLHttpRequestObject()
{
  // xmlHttp will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // try to instantiate the native XMLHttpRequest object
  try
  {
    // create an XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
    }
    catch(e) { }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}


function SetJaveIsEnabled() {
/*
 var client = createXMLHttpRequestObject();
 client.open("GET", "/en/javaenabled.aspx");
 client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
 client.send(null);
 */
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
    
    if (elem!=null)
    elem.innerHTML='';
  /*vis = elem.style;  
  
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';*/
}

function Load(j,k)
{    	
    setTimeout('displayVideo("<%=ConfigurationSettings.AppSettings["Video_Codebase"]%>")', 5000);        
}

function LoadRouletteStream()
{    	
    var vDiv = document.getElementById("video");
    vDiv.innerHTML=getRouletteStreamImage();
}

function LoadLottoStream()
{    	
    var vDiv = document.getElementById("video");
    vDiv.innerHTML=getLottoStreamImage();    
}

function displayVideo(codebase)
{
    displayFlashVideo("/Pages/swf/stream.swf?streamUrl=rstream2");
    /*var vDiv = document.getElementById("video");
	vDiv.innerHTML = getVideoAppletTag(codebase);*/
	
}

function LoadFlashVideo(streamLocation,streamName)
{

	var swfLocation = "/Pages/swf/stream.swf?streamUrl="+ streamLocation + "&streamName="+streamName;
	/*var k = 'setTimeout(displayFlashVideo("'+swfLocation + '"),1000);';
    eval(k);*/
    var so = new SWFObject(swfLocation, "gameVideoStream", "320", "240", "9", "#000000");
    so.addParam("menu", "false");
    so.addParam("allowFullScreen", "true");
    so.write("video");
}

function displayFlashVideo(streamLocation)
{    
    var so = new SWFObject(streamLocation, "gameVideoStream", "320", "240", "9", "#000000");
    so.addParam("menu", "false");
    so.addParam("allowFullScreen", "true");
    so.write("video");
}

function getRouletteStreamImage(){      
	var str = "<img id='strRoulette' style='visibility:visible;' src='../images/default/livetv_f1.jpg'";	
	str+="onclick='displayVideo(\"http://rstream.smartlivecasino.com\");'";
	str+="onMouseOut=\"MM_swapImgRestore();\"";
	str+="onMouseOver=\"MM_swapImage('real','','../images/default/livetv_f2.jpg',1);\">";
	return str;
}
function getLottoStreamImage(){      
	var str = "<img id='strRoulette' style='visibility:visible;' src='../images/default/livetv_r2_c2.jpg'";	
	str+="onclick='displayVideo(\"http://lstream.smartlivecasino.com\");'";
	str+="onMouseOut=\"MM_swapImgRestore();\"";
	str+="onMouseOver=\"MM_swapImage('real','','../images/default/livetv_r2_c2.jpg',1);\">";
	return str;
}

function getVideoAppletTag(codebase){
	var str = "<applet mayscript codebase='" + codebase + "' archive='clipstreamlive.zip' ";
	str += "code='clipstreamlive.class' alt='ClipstreamLive' name='clipstreamlive' width='320' height='239'>";
	str += "<param name='AutoBitrate' value='true'>";
	str += "<param name='VideoURL1' value='Medium,200,/live128.vcs'>";
	str += "<param name='VideoURL2' value='High,300,/live256.vcs'>";
	str += "<param name='AutoPlay' value='true'>";
	str += "<param name='VideoBufferSize' value='0'>";
	str += "<param name='BackgroundColor' value='#000000'>";
	str += "<param name='TextColor' value='#006600'>";
	str += "<param name='SeekEnable' value='false'>";
	str += "<param name='PanelEnable' value='false'>";
	str += "<param name='PanelLayout' value='MC'>";
	str += "<param name='PanelImagesURL' value='buttons.gif'>";		
	str += "<param name='PanelImageWidth' value='1,1,1,1,1,1,1,250,66'>";
	str += "<param name='PanelResizable' value='false'>";
	str += "<param name='PanelPosition' value='Right'>";
	str += "<param name='SeekMargin' value='10,50'>";
	str += "<param name='PanelFlash' value='0'>";
	str += "<param name='VideoTitleImageURL' value='title.gif'>";
	str += "<param name='VideoEdgeColor' value='#000000'>";
	str += "</applet>";	
	return str;
}

function GetFlashAppletDomObject (movieName) 
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? document.getElementById(movieName) : document[movieName];
}

 function NotifyFlashAppletOnWindowClosed () 
 {
    GetFlashAppletDomObject("cc1").browserWindowClosed("window_closed");
 }
 
function getBrowserInfo()
{
	return navigator.appName;
}

