/*function getFlashVar(){
	alert(document.URL.split("?"));
	if(document.URL.split("?"))	{
			var variaveis=document.URL.split("?");
			var quebra = variaveis[1].split("=");
			return quebra[1];
		}
	}
*/

function getCharEnc(valor){
	var t = valor;
	while((t.indexOf("&#")>=0 && t.indexOf(";")>=0) && (t.indexOf("&#")<t.indexOf(";")) ){
		var dado = t.substring(t.indexOf("&#"), t.indexOf(";")+1);
		t = t.replace(dado,  String.fromCharCode(dado.replace("&#","").replace(";","")));
	}
	return t;
}

function getFlashVar(){
		var variaveis=document.URL.split("?");
		var quebra = variaveis[1].split("=");
		return quebra[1];
	}


function mostrar(id){
	document.getElementById(id).style.display="block";										
}function esconder(id){
	document.getElementById(id).style.display="none";
}
function getCoreWnd() {
	wnd = new Array();
	wnd[0] = 'lb-lock';
	wnd[1] = 'lb-sm';
	return wnd;
}

function clearWindow(){
	wnd = getCoreWnd();
	// -------------------------
	// Limpa as janelas basicas
	// -------------------------
	for(i=0;i<wnd.length;i++)
		$(wnd[i]).style.display = "none";
	// ------------------
	// Show/Hide selects
	// ------------------
	flip();
}

function flip(){
	selects = document.getElementsByTagName("select");
	for (i=0; i!=selects.length;i++)
		selects[i].style.visibility = (selects[i].style.visibility == "hidden") ? "visible" : "hidden";
}


function callWindow(obj, overlayClick){
	// --------------------------
	// Pega resolucao do browser
	// --------------------------
	arrayPageSize = getPageSize();
	// ------------
	// Cria janela
	// ------------
	
	http.open("GET", "../Scripts/lightbox/templates/" + obj + '.htm', true);
		http.onreadystatechange = function() {
            if (http.readyState == 4) {
				$('lb-sm').innerHTML = http.responseText;
								
								
					if(document.URL.indexOf("?")!=-1 && obj == "sms"){
						varFlash = getFlashVar();
						document.getElementById("smsFrame").src="../Scripts/lightbox/templates/frame.html?var="+varFlash
					}
				
				// ------------------
				// Show/Hide selects
				// ------------------
				flip();	
				$(obj).style.zIndex = 1000;
				$(obj).style.display = "block";
				$('lb-sm').style.display = "block";
				lock = $('lb-lock');
				lock.style.height 	= arrayPageSize[1] + 'px';
				lock.style.width 	= arrayPageSize[0] + 'px';
				lock.style.display 	= "block";
				lock.onclick = (overlayClick) ? clearWindow : '';
			}
    
		}
		http.send(null);
}

function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function getHTTPObject() {
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
var http = getHTTPObject();

function getPageSize(){		
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.availWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function AbrePopupIndique(){
	alert("abre pop up indique");
}function AbrePopupLogin(){
	alert("abre pop up login");
}