//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: pais.map.dashboard.js
// Created: 2017-01-01
// Updates: 2017-01-01
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
var xmlHttp11;
var xmlHttpStream11;
//NOTE: geographic center of the US
var lon = -98.583333;
var lat = 39.833333;
var zoom = 5;
var map;
var blueMarble, us_base;
var colleges, highways, cities, water;
//-------------------------------------------------------//
window.onload = function(){
	window.resizeTo(1024,750);
	getUserCajaDepartamento();
	getUserFunctions();
	init();
}
//-------------------------------------------------------//
// LEVEL 1
function getUserCajaDepartamento(){
    var URL     = "/cgi-bin/RTM_v30/pl/user.caja.departamento.get.pl?appid=RTM_v30&lan=es";
    xmlHttp11	= GetXmlHttpObject(getUserCajaDepartamentoSC);
    xmlHttp11.open("GET",URL,true) ;
    xmlHttp11.send(null);
}
function getUserCajaDepartamentoSC(){
    if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
        xmlHttpStream11=xmlHttp11.responseText;

    }
}
function getUserFunctions(){
	var cid		= "bsws";
	var clase	= "inmueble"
	var oid		= "3002"
    var URL     = "/cgi-bin/"+appid+"/pl/get_user_option_functions.pl?appid="+appid+"&lan="+lan+"&clase="+clase+"&cid="+cid+"&oid="+oid;
    xmlHttp12	= GetXmlHttpObject(getUserFunctionsSC);
    xmlHttp12.open("GET",URL,true) ;
    xmlHttp12.send(null);
}
function getUserFunctionsSC(){
    if (xmlHttp12.readyState==4 || xmlHttp12.readyState=="complete"){ 
        xmlHttpStream12=xmlHttp12.responseText;

    }
}
function init(){
	map 	= new OpenLayers.Map( $('map' ) );
	us_base = new OpenLayers.Layer.WMS("US","http://localhost/cgi-bin/mapserver/apps/wms.exe?",{layers:'municipios',format:'image/png',transparent:true,styles:'us_states'},{isBaseLayer:true} );
	map.addLayer(us_base);
	blueMarble = new OpenLayers.Layer.WMS("Blue Marble","http://wms.jpl.nasa.gov/wms.cgi?",{layers:'BMNG',format:'image/png' },{isBaseLayer:true});
	map.addLayer(blueMarble);
	colleges = new OpenLayers.Layer.WMS("Colleges","http://localhost:8888/geoserver/wms?",{layers:'g4wd:college',format:'image/png',transparent:true,styles:'colleges'},{isBaseLayer:false, opacity:0.5});
	map.addLayer(colleges);
	highways = new OpenLayers.Layer.WMS("Highways","http://localhost:8888/geoserver/wms?",{layers:'g4wd:co_highway',format:'image/png',transparent: true},{isBaseLayer:false,opacity:0.5});
	map.addLayer(highways);
	cities = new OpenLayers.Layer.WMS("Cities","http://localhost:8888/geoserver/wms?",{layers:'g4wd:co_city',format:'image/png',transparent:true,style:'city'},{isBaseLayer:false,opacity:0.5});
	map.addLayer(cities);
	water = new OpenLayers.Layer.WMS("Water","http://localhost:8888/geoserver/wms?",{layers: 'g4wd:co_lake',format:'image/png',transparent:true},{isBaseLayer:false, opacity:0.5} );
	map.addLayer(water);
	map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
	map.addControl( new OpenLayers.Control.LayerSwitcher() );
}
//--------------------------------------------------------//
// LEVEL 2
function openView(wid,cmp,cls,fol,tb,sb,mb,rz,lo,st,typ){
    var winame 		= cmp+"_"+wid;
	var id_field	= document.form.id_field.value;
	var id			= eval("document.form."+id_field+".value");
    if (!OpenWindows[winame] || OpenWindows[winame].closed){
		var win ="window.open('/cgi-bin/"+appid+"/"+fol+"/"+cmp+"."+typ+"?lan="+lan+"&appid="+appid+"&clase="+cls+"&id="+id+"','"+cmp+"_"+wid+"','left=20,top=20,width=20,height=20,scrollbars="+sb+",toolbar="+tb+",menubar="+mb+",resizable="+rz+",location="+lo+",status="+st+"')";
		OpenWindows[winame]=eval(win);
    }else{OpenWindows[winame].focus()}
}
//--------------------------------------------------------//
// LEVEL 3

//-------------------------------------------------------//
// AUXILIAR
if (window.ActiveXObject){
	var Propietarios = new ActiveXObject("Microsoft.XMLDOM");
	Propietarios.async=false;
	Propietarios.loadXML(Prop);
}else if (document.implementation && document.implementation.createDocument){
	var Propietarias = document.implementation.createDocument("","",null);
	Propietarios= document.implementation.createDocument("","",null);
	//Propietarios.loadXML(Prop);
}else{
	alert('Your browser cannot handle this script');
}