// Funciones que realizan ajax
//document.write('<script src="../Library/IngeomapsIniJS.js" type="text/javascript"></script);

//Funcion ajaxLoadImage: 
function ajaxLoadImage(urlajax,dataajax,div,iframe){
	
	if($("#RulerInfo").css("visibility")=="visible"){
		CleanDiv("#RulerInfo");
		ExecuteFile("Load/AjaxCleanDistanceValue.php","");
	}
	//Limpiamos el resultado del info si el usuario realizo el evento info
	if($("#divInfo").css("visibility")=="visible"){
		CleanDiv("#divInfo");
	}
	
	$.ajax({
		type: "GET",
		url: urlajax,
		data: dataajax,
		dataType: "html",
		cache: false,
		beforeSend: function(html){
			
			var htmlWait = "<table width='638' height='196'><!--DWLayoutTable--><tr><td width='145' height='184'>&nbsp;</td><td width='324'>&nbsp;</td><td width='147'>&nbsp;</td></tr><tr><td height='72'>&nbsp;</td><td align='center' valign='middle'><input type='image' id='map' name='map'  src='../../Images/Map/Loading/MapLoad.gif' /><p class='titulo3verde16' align='center'> Cargando...</p><td>&nbsp;</td></tr><tr><td height='128'>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
						
			var objDiv = selectDivIframe(div);//Seeleccionamos el div
			objDiv.html(htmlWait);// asignamos la imagen al div
										
		},
		success: function(html){
			
			if(html != "SessionRefresh")
			{
				if(iframe){//TRUE: si se desea cargar la imagen llamando la funcion fuera del iframe
					var objDiv = selectDivIframe(div);//Seeleccionamos el div
					objDiv.html(html); // asignamos la imagen al div
					
					getReferenceImage('Load/AjaxReferenceImage.php');
										
				}
				else{//FALSE: Si se desea cargar la imagen llamando la funcion dentro del iframe
					
					$(div).html(html);
				}
			}
			else{
				window.open('CloseIngeoMaps.php','_parent','','true');
			}
		}
	})
}


//Funcion ajaxLoadData:
function ajaxLoadData(urlajax,dataajax,div){

	$.ajax({
		type: "GET",
		url: urlajax,
		data: dataajax,
		dataType: "html",
		cache: false,
		beforeSend: function(html){
							
			var htmlWait = "<table id='map' width='638' height='196'><!--DWLayoutTable--><tr><td width='145' height='184'>&nbsp;</td><td width='324'>&nbsp;</td><td width='147'>&nbsp;</td></tr><tr><td height='72'>&nbsp;</td><td align='center' valign='middle'><img src='../../Images/Map/Loading/InfoLoading2.gif' /><p class='titulo3verde16' align='center'> Cargando...</p><td>&nbsp;</td></tr><tr><td height='128'>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
			
			var objDiv = $(div);//Seeleccionamos el div
	
			objDiv.html(htmlWait);// asignamos la imagen al div	
		},
		success: function(html){
			if(html != "SessionRefresh")
			{
				var objDiv = $(div);//Seeleccionamos el div
				
				objDiv.html(html); // asignamos la imagen al div	
			}
			else{
				window.open('CloseIngeoMaps.php','_parent','','true');
			}
		}
	})
}

//Funcion ajaxLoadData:
function ajaxLoadDataReference(urlajax,div){

	$.ajax({
		type: "GET",
		url: urlajax,
		dataType: "html",
		cache: false,
		success: function(html){
			var objDiv = $(div);//Seeleccionamos el div
			objDiv.html(html); // asignamos la imagen al div	
				
		}
	})
}
//Funcion ajaxLoadImageDrag:
function ajaxLoadImageDrag(urlajax,dataajax,div){

	$.ajax({
		type: "GET",
		url: urlajax,
		data: dataajax,
		dataType: "html",
		async: false, // este parametro esta configurado como false para que se realice primero y luego continue ejecutando otro codigo que este por debajo de este.
		cache: false,
		success: function(html){
			
			if(html != "SessionRefresh")
			{
				var objDiv = $(div);//Seeleccionamos el div
				
				objDiv.html(html); // asignamos la imagen al div
				parent.getReferenceImage('Load/AjaxReferenceImage.php');
			}
			else{
				window.open('../CloseIngeoMaps.php','_parent','','true');
			}	
		}
	})
}



//Funcion ajaxLoadInfo:
function ajaxLoadInfo(urlajax,dataajax,divInfo,formInfo,idtxtInfo){

	$.ajax({
		type: "GET",
		url: urlajax,
		data: dataajax,
		dataType: "html",
		cache: false,
		beforeSend: function(html){
														
			var htmlWait = "<p class='titulo2verde11' align='left'><img src='../Images/Map/Loading/InfoLoading.gif'/> Cargando...</p>";
			$(idtxtInfo).html(htmlWait);
			$("#FLinfo").css({"display":"none"}); 
			$("#FLinfo").toggle();
		},
		success: function(html){
			
			if (html!="SessionRefresh"){
				var objDiv = $(divInfo);//Seleccionamos el div
				
				objDiv.html(formInfo); // asignamos la imagen al div	
				//alert(html);
				$(idtxtInfo).html(html);
				$("#FLinfo").css({"display":"none"}); 
				$("#FLinfo").toggle();
			}
			else{
				window.open('CloseIngeoMaps.php','_parent','','true');
			}
		}
	})
}


function ExecuteFile(urlajax,dataajax){

	$.ajax({
		type: "GET",
		url: urlajax,
		data: dataajax,
		dataType: "html",
		async: true
	})
}