var URL_BASE = 'http://componentes.cedrofinances.com.br';
var authContent = new Array();
var authCountContent = 0;

function initSession(){
	var rem = document.createElement("div");
	rem.innerHTML = '<iframe id="cedro" style="display:none" src="' + URL_BASE + '/CreateSession" name="rpc"></iframe>';
	document.body.appendChild(rem);
	
	setTimeout("initAllAuthContent();", 200);
}

function initAllAuthContent(){
	var i = 0;
	for (i = 0; i < authContent.length; i++)
		setTimeout("initAuthContent('"+authContent[i][0]+"', '"+authContent[i][1]+"', '"+authContent[i][2]+"', '"+authContent[i][3]+"', '"+authContent[i][4]+"');", 100);
}

function addAuthContent(frame, iData, aTime, kKey, cType) {
	authContent[authCountContent] = new Array();
	authContent[authCountContent][0] = frame;
	authContent[authCountContent][1] = iData;
	authContent[authCountContent][2] = aTime;
	authContent[authCountContent][3] = kKey;
	authContent[authCountContent][4] = cType;
	authCountContent = authCountContent + 1;
}

function initAuthContent(frame, iData, aTime, kKey, cType) {
	changeIframeSrc(frame, URL_BASE + "/GetComponent?source="
					+ iData + "&key=" + (aTime < 10 ? "0" + aTime : aTime)
					+ kKey +"&target=" + cType);
}

function changeIframeSrc(id, url) {
	if (!document.getElementById) {
		alert("document.getElementById == null");
	}
	var el = document.getElementById(id);
	if (el) {
		el.src = url;
		return false;
	} else {
		return true;
	}
}

