var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var socketConn = false;
var isSent = false;
		
		function myFlash_DoFSCommand(command, args)                {
		  var myFlashObj = InternetExplorer ? myFlash : document.myFlash;
		 
		
		 
			 if(command == "loaded"){
			 	socketConn = false;
			 	//dbg("in loaded" + loggedInUserId);
			 	if(!isSent){		 	
				 	//dbg("logg = " + loggedInUserId)
				 	if(loggedInUserId>0 && credential.length>0){
				 		doPassVar(loggedInUserId, credential)
				 	}else{
				 			isSent = true;
				 			stoForUserID = setInterval("lookForUserId();", 1000);
				 	}
				 }
			 }else if(command == "newMessage"){
			 	clearInterval(im_sto);
			 	//dbg("inNewMEssage");
			 	socketConn = true;		
			 	clearInterval(im_sto); 		
			 	getIMOnComplete(args);
			 }else if(command == "unconnect"){
			 		socketConn = false;
			 		dbg("in unconnect");
			 		clearInterval(im_sto);
			 		im_sto = setInterval("getIM()", messageRequestDelay);
			 }else if(command == "userOk"){
			 		socketConn = true;
			 		clearInterval(im_sto);
			 		dbg("in userOk")
			 			
			 }else if(command == "action"){
			 	alert("action : " + args);
			 	if(args == "close"){
			 		closeFlower();
			 	}
			 }
		 
		}
		
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	  document.write('on error resume next \n');
	  document.write('Sub myFlash_FSCommand(ByVal command, ByVal args)\n');
	  document.write(' call myFlash_DoFSCommand(command, args)\n');
	  document.write('end sub\n');
	  document.write('</SCRIPT\> \n');
	} 
	
	
		
	function doPassVar(userId, credential){
		isSent = true;
		writer = new CmdWriter(1);
		writer.appendStr(userId);
		writer.appendStr(credential);
		writer.endOfObject();
		
		window.document.myFlash.SetVariable("serverStr", writer.Buffer);
		/*
		window.document.myFlash.SetVariable("myVal", credential);
			window.document.myFlash.SetVariable("userId", userId);
			window.document.myFlash.SetVariable("credential", credential);
			*/
			window.document.myFlash.TCallFrame("/",1);
	} 
	
	function lookForUserId(){
		if(loggedInUserId>0 && credential.length>0){
			doPassVar(loggedInUserId, credential);
			clearInterval(stoForUserID);
		}
	}
	
	