/*------------------------------------------
|   Author: Andre Franco, Smart Lab
|   Release: v1.2
|   May 1, 2009
/*------------------------------------------*/

// reads var main_css_path;

var d=document;
var safari = navigator.userAgent.match(/safari/i);
var firefox = navigator.userAgent.match(/firefox/i);
var ie = d.all;
d.body.id = "tbar_body";

// getElementById SHORTCUT
function $$(id) {
	return document.getElementById(id);
}

if (parent!=window) go = function(path,id_page){
	call="tbox.go('" + path + "'" + (id_page ? ",'" + id_page +"'" : "") + ")";
	proxy_call_parent(base_url2, call);
}
else go = function(path) {
	location.href = path;
}

function resize_modal(){
	try {
		var ly_error = $$("errors");
		if (ly_error && ly_error.innerHTML.match(/\w/)) {
			ly_error.style.display = "block"; // show the error layer
			extra_height = ly_error.scrollHeight;
		}
		if (window!=parent) {
			setTimeout('proxy_call_parent(base_url2, "tbox.prepare_resize_modal(\''+ modal_size +'\', '+ extra_height +', '+ d.body.scrollWidth +','+ d.body.scrollHeight +')")', 100);
		}
	}
	catch(e){};
}

// Open Popup

/*
 * PARAMETERS
 * - url (URL of the popup)
 * - name (Name of the popup)
 * - w (Width)
 * - h (Height)
 * - scrolling (no = 0 / yes = 1)
 */
function openPopup(url,name,w,h,scrolling) {
	var leftPosition = (screen.width) ? (screen.width-w)/2 : 0,
		topPosition = (screen.height) ? (screen.height-h)/2 : 0,
		settings = "height="+h+",width="+w+",top="+topPosition+",left="+leftPosition+",scrollbars="+scrolling+",resizable=0";
	return window.open(url,name,settings);
}
