
function fileBrowserCallBack(field_name, url, type, win) {
	var connector = "../../../file_manager.php";

	my_field = field_name;
	my_win = win;

	/*switch (type) {
		case "image":
			connector += "?type=img";
			break;
		case "media":
			connector += "?type=media";
			break;
		case "flash": //for older versions of tinymce
			connector += "?type=media";
			break;
		case "file":
			connector += "?type=files";
			break;
	}*/
	popup(connector+"?type=files",450,600,'fm');
	//window.open(connector, "file_manager", "modal,width=450,height=600,scrollbars=1");
}
		
		
		
function menu_section(id) {
	var d = document.getElementById(id);
	if (d.style.display=='block') d.style.display='none';
	else d.style.display='block';
}

function cmenuitems(val) {
	advAJAX.get({
		url: "../admin/index.php",
		parameters : {
			"module" : "js_utils",
			"action" : "cmenuitems",
			"params" : val	  	  
		},
		onSuccess : function(obj) { document.getElementById("menu_parent").innerHTML = obj.responseText; },
		onLoading : function(obj) { 
			document.getElementById("menu_parent").innerHTML = "<img src='./templates/admin_default/images/loading.gif' border='0' height='12' width='12' alt='...'>";  },
		onError : function(obj) { document.getElementById("menu_parent").innerHTML = obj.status;  }
	});	
}

function toggle_activity(id,mod) {
	advAJAX.get({
		url: "../admin/index.php",
		parameters : {
			"module" : "js_utils",
			"action" : mod,
			"params" : id	  	  
		},
		onSuccess : function(obj) { document.getElementById("act_"+id).innerHTML = obj.responseText; },
		onLoading : function(obj) { 
			document.getElementById("act_"+id).innerHTML = "<img src='./templates/admin_default/images/loading.gif' border='0' height='12' width='12' alt='...'>";  },
		onError : function(obj) { document.getElementById("act_"+id).innerHTML = obj.status;  }
	});
}

function popup(src,pop_w,pop_h,n) {
	//if (document.all || document.layers) {
	   w = screen.width;
	   h = screen.height;
	//}
	var left_pos = (w-pop_w)/2, top_pos = (h-pop_h)/2;
	window.open(src,n,'toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width='+pop_w+',height='+pop_h+',top='+top_pos+',left='+left_pos);
}

function openGallery(id) {
	popup('/galeria.php?id='+id,1000,700,'galeria');
}

function get_random(lbound, ubound) {
	return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function get_password(length) {
	//var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var chars = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
	var ret = "";
	if (length > 0)
		for (var i = 0; i < length; i++) {
			ret = ret + chars.charAt(get_random(0, chars.length));
		}
	return ret;
}

function browser(){
	var is_major=parseInt(navigator.appVersion);
	this.nver=is_major;
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera=window.opera?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.opera)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera)?1:0;
	this.ie4=(document.all&&!this.dom&&!this.opera)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;
	this.ie3=(this.ver.indexOf("MSIE")&&(is_major<4));
	this.hotjava=(this.agent.toLowerCase().indexOf('hotjava')!=-1)?1:0;
	this.ns4=(document.layers&&!this.dom&&!this.hotjava)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera);
	this.ver3=(this.hotjava||this.ie3);
	this.opera7=((this.agent.toLowerCase().indexOf('opera 7')>-1) || (this.agent.toLowerCase().indexOf('opera/7')>-1));
	this.operaOld=this.opera&&!this.opera7;
	return this;
};


