/*
var SESSIONURL = "";
var SECURITYTOKEN = "guest";
var IMGDIR_MISC = "images/misc";
var vb_disable_ajax = parseInt("0", 10);
*/

var username;
var imagen_galeria;
var imagenes_total_post;
MAXWIDTH = 560; // ancho maximo de imagenes
function r_imagen_swf(div_id,url_img,url_img_ag,var_username,userid){ // carga imagenes a swf

//alert(div_id + "\n" +url_img+ "\n" +url_img_ag)
	ide_imagen =document.getElementById("img_"+div_id) ;
	width = ide_imagen.width;
	height = ide_imagen.height;
	ide_imagen.style.display = 'none';
//alert(width + "\n" +height)
	original_width = ide_imagen.width;
	original_height = ide_imagen.height;
	resized = "no";
	if(width> MAXWIDTH) { // si el tamaño excede el máximo permitido hacer un resise
		resized = "si";
		height = (MAXWIDTH / width) * height;
		width = MAXWIDTH;
	}

	if(width<=151){
		document.getElementById(div_id).style.display = 'none';
		ide_imagen.style.display = 'block';
		ide_imagen.style.position = 'relative';
		ide_imagen.style.top = '0px';
	}else{

var soWD = new SWFObject("http://aguantexu.com.ar/imagenes/visor-imagenes-post/imagenes-maximizar/imagenes-maximizar-v1.swf?version=2", div_id, width, height, "7", "#000000");
		soWD.addParam("allowFullScreen", "true");
		soWD.addVariable("imagen_galeria", imagen_galeria);
	
		soWD.addParam("wmode", "transparent");
		soWD.addVariable("diagrama_url", url_img);
		soWD.addVariable("f_height", height);
		soWD.addVariable("f_width", width);
		soWD.addVariable("original_f_height", original_height);
		soWD.addVariable("original_f_width", original_width);
		soWD.addVariable("resized", resized);
		soWD.addVariable("username", var_username);
		soWD.addVariable("userid", userid);
		soWD.addVariable("url_img_ag", url_img_ag);
		soWD.addVariable("imagenes_total_post", imagenes_total_post);
		soWD.write(div_id);
	}
}

function r_imagen_swf_error(div_id,url_img_ag){ // carga imagenes a swf
	document.getElementById(div_id).innerHTML = '<fieldset style="width:350px"><div align="center" style="font-size:14px; background:#fd9595">Error: no se puede mostrar la imagen<div style="font-size:10px">'+url_img_ag+'</div></div></fieldset>';
}


/* Agregar pagina a favoritos */
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url=location.href; 
      var titulo=document.title;
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
}

/* Establecer sitio como pagina de inicio */
function inicio(){
	document.getElementById('hp').setHomepage('http://aguantexu.com.ar/');
}

/* Cerrar sesion desde flash (header) */
flashlogout = function() {
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm('¿Confirmas finalizar la sesión en aguante Xu! ?')){
		window.location= HTTPHOST+"foro/login.php?do=logout&logouthash="+logouthash;
	}else{
		ht[0].style.filter = "";
		return;
	}
}


function home_collapse(tabla,texpires){
		if(document.getElementById(tabla).style.display == 'none'){
			document.getElementById(tabla).style.display = '';
			document.getElementById(tabla+'_img').src = HTTPHOST+'imagenes/collapse_tcat-bl.gif';
			document.cookie= tabla+" = false; expires = "+texpires+" 100000; "; 
		}else{
			document.getElementById(tabla).style.display = 'none';
			document.getElementById(tabla+'_img').src = HTTPHOST+'imagenes/collapse_tcat_collapsed-bl.gif';
			document.cookie= tabla+" = true; expires = "+texpires+" 100000; ";
		}
}


function savecookie(name,opcion,texpires){
	document.cookie= name+" = "+opcion+"; expires = "+texpires+" 100000; "; 
}

/* Recargar Estadisticas del Sitio */
function reloadOnline(nocache){
	cargaDIVXML('divUserOnline','divUserOnline','actualizando estadisticas en tiempo real...','NO','');
	cargaXML(BASEURL+'aguantexu-stats-new.php?reload=true&stats=NO&nocache='+nocache);
}


function rewriteswf(name){
	colapsechange(name);
	soAN.write(name);
}


function Ventana(URL,Nombre,Flags) { 
  if(Flags=="rangos"){
  	Flags="status=0,toolbar=0,menubar=0,resizable=1,scrollbars=yes,location=0,width=460,height=150";
  }
  if(Flags=="general"){
  	Flags="status=0,toolbar=0,menubar=0,resizable=1,scrollbars=yes,location=0,width=500,height=300";
  }
  window.open(URL,Nombre,Flags);
}


window_onload = false;

window.onload=function(){
	window_onload = true;
	if(username=="Matias"){
		cargaDIVXML('div_complementos','div_complementos','cargando','NO','');
		cargaXML(HTTPHOST+'aguantexu-complementos/menu.php');
		//aguantexu_complementos();
	}
}
/*
document.onload=function(){
	window_onload = true;
	if(username=="Matias"){
		cargaDIVXML('div_complementos','div_complementos','cargando','NO','');
		cargaXML(HTTPHOST+'aguantexu-complementos/menu.php');
		//aguantexu_complementos();
	}
}*/
function pagina_load(){
	if(window_onload==true){
		return "true";
	}else{
		return "false";
	}
}


function colapsechange(objetoid){
	 $(document.getElementById(objetoid)).slideToggle(1500) 
}


// redirecciona avatares no existentes
function avatar_tamano(imagen_id){ 
	if( document.getElementById(imagen_id).fileSize < 200){
 		document.getElementById(imagen_id).src="http://aguantexu.com.ar/imagenes/no-avatar.gif";
	}
} 
