/*
 *      Copyright (c) 2007-2010, Institute of Computing (IC) at the University
 *      of Campinas (UNICAMP) and Nucleus of Informatics Applied to Education
 *      (NIED) at UNICAMP
 *      All rights reserved.
 *      
 *      Redistribution and use in source and binary forms, with or without
 *      modification, are permitted provided that the following conditions are
 *      met:
 *      
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with the
 *        distribution.
 *      * Neither the name of the  nor the names of its
 *        contributors may be used to endorse or promote products derived from
 *        this software without specific prior written permission.
 *      
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *      OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


/* <![CDATA[ */
var qa = null ;
var qa_image = null ;
var pi_counter = 1 ;
var nro=0;
var position=0;
intro=0; //HH: var intro = 0;
cerrar=0; //HH: var cerrar = 0;

function fecharCO(){
	var y=document.getElementById("ctlConversas");
	y.innerHTML="diego";
}

function Intro(){
	if(intro==0){
		showDiv();
		intro++;
	}
}

function Cerrar(){
	if(cerrar==0){
		hideDiv();
		cerrar++;
	}
}

//ocultar ctl
function hideDiv() { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('ctlConversas').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.ctlConversas.visibility = 'hidden';  
		} 
		else { // IE 4 
			document.all.ctlConversas.style.visibility = 'hidden'; 
		} 
	} 
}

//mostrar ctl
function showDiv() { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('ctlConversas').style.visibility = 'visible'; 
	} 
	else {
		if (document.layers) { // Netscape 4 
			document.ctlConversas.visibility = 'visible';
		}
		else { // IE 4 
			document.all.ctlConversas.style.visibility = 'visible'; 
		}
	}
} 


	// Esse mtodo serve apenas para colocarmos a sintex correta para acessar o objeto Flash.
	function verificarNavegador(id) {
		return document.getElementById(id);
/*
		if ((navigator.appName.indexOf("Microsoft") != -1)  || (navigator.appName.indexOf("Opera") != -1) ) {
			return window[id];
		} else {
			return document[id];
		}
*/
	}


	function entrar($userid){
		CreateDiv($userid);
	}
	
	function atualizarConversas(){
		verificarNavegador("ctl9k").contarConversas();
	}

	function invitar($remoteuser){
		verificarNavegador("ctl9k").EnviarConvite($remoteuser);
	}
	
	function fecharChatVila(salaid){
		if(document.getElementById(salaid)){
		document.getElementById(salaid).style.display = 'none';}
	}

	function sairConversasOnline(){
	verificarNavegador("ctl9k").FecharConversas();
	 }

	function InvitarUser($sala,$userinvitado,$nroconversa){
	
		if(document.getElementById($sala)){
			if(document.getElementById($sala).style.visibility=='hidden')
				{document.getElementById($sala).style.visibility = 'visible';}
			if(document.getElementById($sala).style.display=='none')
				{document.getElementById($sala).style.display = 'block';}
		}
		else{ 
			CreateDivChat($sala);

			var LoadVideoSwf = '<object type=\"application/x-shockwave-flash\" data=\"./ConversasOnline/Conversar6jc_2.swf\" width=\"270\" height=\"370\"><param name=\"movie\" value=\"./ConversasOnline/Conversar6jc_2.swf\" /><param name=flashVars value=\"sala='+$sala+'&userinvitado='+$userinvitado+'&nroconversa='+$nroconversa+'\" /><param name=\"wmode\" value=\"transparent\" /></object>';
			loadEmbeddedVideo($sala, LoadVideoSwf);
			CreateTitleChat($sala);
		}
	
	}
	
	function CreateTitleChat($sala){
	var overLayer = document.createElement("div"); 
	document.body.appendChild(overLayer); 
	overLayer.style.position = "absolute"; 
	overLayer.style.background = "white"; 
	overLayer.style.bottom = 0; 
	overLayer.style.left = position*274; 
	overLayer.style.width = "16.7em"; 
	overLayer.style.height = "2em"; 
	overLayer.style.border = "1px solid blue"; 
	overLayer.style.cursor = "crosshair"; 
	overLayer.innerHTML = "<h3 onmousedown=\"drag( event );\" onmousemove=\"move( event );\" onmouseup=\"drop( event )\"><span id="+$sala+"TitleB>.</span><a href=\"javascript:close('"+$sala+"')\" class=\"close\">X</a><a href=\"javascript:maximize('"+$sala+"')\" class=\"minimize\">^</a></h3>";
	overLayer.id = $sala+"TitleChat"; 
	overLayer.style.visibility="hidden";
	position++;
	}

	function CreateDivChat($userid) {
	var overLayer = document.createElement("div"); 
	document.body.appendChild(overLayer); 
	overLayer.style.position = "absolute"; 
	overLayer.style.background = "white"; 
	overLayer.style.bottom = 0; 
	overLayer.style.left = position*274; 
	overLayer.style.width = "16.7em"; 
	overLayer.style.height = "24.5em"; 
	overLayer.style.border = "1px solid red"; 
	overLayer.style.cursor = "crosshair"; 
	overLayer.innerHTML = "<h3 onmousedown=\"drag( event );\" onmousemove=\"move( event );\" onmouseup=\"drop( event )\"><span id="+$userid+"Title>.</span><a href=\"javascript:close('"+$userid+"')\" class=\"close\">X</a><a href=\"javascript:minimize('"+$userid+"')\" class=\"minimize\">-</a></h3>";
	overLayer.id = $userid; 
	
}

//load flash
	
			var loadEmbeddedVideo = function(id, embeddedCode) {
				document.getElementById(id).innerHTML += fixEmbeddedVideo(embeddedCode);
			}
			
			var fixEmbeddedVideo = function(embedCode) {
					return embedCode;
			}


//fim load

	function verificarDiv($sala){
	if(document.getElementById($sala)){
		if(document.getElementById($sala).style.visibility=='hidden')
			 {
			  document.getElementById($sala).style.visibility = 'visible'; 
			  document.getElementById($sala+"TitleChat").style.visibility='hidden'; 
			  }
		if(document.getElementById($sala).style.display=='none')
			 {document.getElementById($sala).style.display = 'block';}
	   }
	}


function Title(sala,usrName){
var y=document.getElementById(sala+"Title");
var b=document.getElementById(sala+"TitleB");
if(y.innerHTML ==".")
{y.innerHTML=usrName;
 b.innerHTML=usrName;

}
else{
y.innerHTML = y.innerHTML +" "+ usrName;
b.innerHTML = y.innerHTML +" "+ usrName;
}
}
	
//style="overflow:hidden;"

/* ]]> */
//style="overflow:hidden;"

