//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: inmueble.cnr.p.js
// Created: 2018-06-06
// Updates: 2018-06-06
//-------------------------------------------------------//
//-------------------------------------------------------//
var xmlHttp;
var xmlHttpStream;
//-------------------------------------------------------//
window.onload = function(){

}
//-------------------------------------------------------//
function GetXmlHttpObject(handler){
	var objXmlHttp=null;	
	if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler; 		
	}
	if(window.ActiveXObject){// code for IE6, IE5
		objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		objXmlHttp.onreadystatechange=handler;
	}
	if(objXmlHttp==null){alert("Your Browser Does Not Suppport AJAX")}
	return objXmlHttp;
}
function saveVinculacion(){
    var appid	= document.getElementById('appid').value;
    var lan 	= document.getElementById('lan').value;
	var clase	= document.getElementById('clase').value;
	var sid		= document.getElementById('sid').value;
	var pid		= document.getElementById('pid').value;
	var id		= document.getElementById('i8_inmueble_id').value;
	
	var str		= "&appid="+appid+"&lan="+lan+"&clase="+clase+"&sid="+sid+"&pid="+pid+"&id="+id;
    var URL     = "/cgi-bin/"+appid+"/pl/inmueble.cnr.s.pl";	
    xmlHttp		= GetXmlHttpObject(stateChangedSave);
    xmlHttp.open("POST",URL,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(str);
}
function stateChangedSave(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream=xmlHttp.responseText;
        if (xmlHttpStream==="SUCCESS"){
			var lon	= document.getElementById('lon').value;
			var lat	= document.getElementById('lat').value;
			var zoom= document.getElementById('zoom').value;
			window.opener.location.reload();
			setTimeout(function(){
				opener.Recargar(lon,lat,zoom);
				window.close();
			}, 1000);
        }else{
			alert(xmlHttpStream);
		}
    } 
}