function Test(str)
{
alert(str);
}


function getFlashMovieObject()
{
   return window.document.Pushlet;
}

function StopFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	flashMovie.StopPlay();
}

function PlayFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	flashMovie.Play();
}

function RewindFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	flashMovie.Rewind();
}

function NextFrameFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	// 4 is the index of the property for _currentFrame
	var currentFrame=flashMovie.TGetProperty("/", 4);
	var nextFrame=parseInt(currentFrame);
	if (nextFrame>=10)
		nextFrame=0;
	flashMovie.GotoFrame(nextFrame);		
}

function SendDataToFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	flashMovie.SetVariable("/:message", document.Form1.Data.value);
	flashMovie.GotoFrame(1);
}

function ReceiveDataFromFlashMovie()
{
	var flashMovie=getFlashMovieObject();
	var message=flashMovie.GetVariable("/:message");
	document.Form1.Data.value=message;
}

function CreateNewRoom(targetuserName)
{
	var flashMovie=getFlashMovieObject();
	flashMovie.SetVariable("/:message", targetuserName);
	flashMovie.GotoFrame(1);
}

function Reconnect(roomid, targetuserid)
{
	//window.UserOnline.iframe_Online.SetGrid(roomid, targetuserid);
	
	var flashMovie=getFlashMovieObject();
	flashMovie.GotoFrame(0);
}

function openpopup(roomid, targetuserid, myuserid, myself)
{
	self.focus();
	
	var popurl="/chat/ChatConsole.aspx?roomid=" +  roomid + "&targetuserid=" + targetuserid;
	
	var where_to;
	
	if (myself==1)
	{
		where_to = true;
	}else
	{
		where_to= confirm(myuserid + " want to chat with you, press o.k to accept or cancel to ingore it!");
	}

	if (where_to== true)
	{
		winpops=window.open(popurl,"newWin"+roomid,"width=545,height=385,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=Yes,fullscreen=No") 
		
	}
	else
	{
	}
	
	Reconnect(roomid, targetuserid);
}

function PopUpUserOnline()
{
		var popurl="/chat/UserOnlinePage.aspx"
		UserOnline = window.open(popurl,"UserOnline","width=252,height=400,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=Yes,fullscreen=No")
		return true;
}

function CreateChannel()
{
	var logged = GetCookie("etopps");
	var showpopup = GetCookie("showpopup");

	if (typeof(logged) == "string" && logged.indexOf("SessionID", 1)!= -1) 
    	{
		

		if (showpopup != 'Y'){
			SetCookie('showpopup', 'Y');
			PopUpUserOnline();
		}
	}
}

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 getCookieVal(offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
     endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value)
{
	document.cookie = name + '=' + value  + '; path=/'
}

