// -----------------------------------------------------------------------------------
// Constructor de Ventana															  
// -----------------------------------------------------------------------------------
// Objeto: GenFunc
// Comentario: Aqui se encuentran todas las funciones genericas que se utilizan
// -----------------------------------------------------------------------------------


var GenFunc={
	$: function(id){
		return document.getElementById(id);
	},
	
	frame_opacity:{
		show: function(){
			var div = document.createElement("DIV");
			div.id = "element_container";
			div.style.position = "absolute";
			div.style.left = "0";
			div.style.top = "0";
			div.style.width = "100%";
			div.style.height = "100%";
			div.style.background = Window.configure.wallpaper.background_color;
			div.style.zIndex=200;
			div.innerHTML = " ";
			GenFunc.set_opacity(div, Window.configure.wallpaper.opacity);
			document.body.style.overflow="hidden";
			document.body.appendChild(div);			
		},
		hidden: function(){
			e = GenFunc.$("element_container");
			padre = e.parentNode;
			padre.removeChild(e);
		}
	},

	set_opacity: function(o, val) {
		if( o.filters ) {  //For IE
			val = parseInt(val)*10;
			if( val>100 ) val=100;
						
			try {
				o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = val;
			} catch (e) { 
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				if( val==100 ) o.style.filter = '';
				else o.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+val+')';
			}
		} else {
			val = parseInt(val)*0.1;
			if( val >1 ) val=1;
			o.style.opacity = val;
			o.style.MozOpacity = val;  //This is for older Mozilla Browsers
		}
	},
		
	disabled_selection: function(id){
		div = GenFunc.$(id);
		if( document.all ){
			div.onselectstart=new Function ("return false");
		}else{
			if( window.sidebar ) { 
			   div.onmousedown = function() {return false}
			   div.onclick = function() {return true}
			} 
		}				
	},
	
	Ajax: {	
		XMLHttp: false,
		create_instance_ajax: function(){
			this.XMLHttp=false;
			
			if( window.XMLHttpRequest ){
				return new XMLHttpRequest();
			}
			else if( window.ActiveXObject ){
				var versiones = ["Msxml2.XMLHTTP.7.0","Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
				
				for(var i=0;i<versiones.length;i++){
					try {
						XMLHttp = new ActiveXObject(versiones[i]);
						if( XMLHttp ){
							return XMLHttp;
							break;
						}
					} catch(e){}
				}
			}
		},
	
		changing_state_ajax: function(id){
			if( GenFunc.Ajax.XMLHttp.readyState==4 ){			
				if( GenFunc.Ajax.XMLHttp.status==200 ){
					Window.show_skin(id, GenFunc.Ajax.XMLHttp.responseText);

				}else{
					alert("Error al recibir respuesta "+GenFunc.Ajax.XMLHttp.statusText);
				}
			}
		}
	},	

	get_browser_height: function(){
		if( window.innerHeight ) return window.innerHeight;
		else if( document.documentElement && document.documentElement.clientHeight != 0 ) return document.documentElement.clientHeight+15;
		else if( document.body ) return document.body.clientHeight;
		return 0
	},

	get_browser_width: function(){
		if( window.innerWidth ) return window.innerWidth;
		else if( document.documentElement && document.documentElement.clientWidth != 0 ) return document.documentElement.clientWidth;
		else if( document.body ) return document.body.clientWidth;
		return 0;
	},

	remove_element: function(obj){
		if( obj ){
			nodePadre = obj.parentNode;
			nodePadre.removeChild(obj);
		}
	}
}