var Dyn_DivLoad = "divLoad"
var Dyn_DivResultadoOperacion = "divLblResultadoDeOperacion"
var Dyn_Pag = "rn_casas_de_foto.asp"
var Dyn_Id	= 0
var IdDeSucursal = 0
var IdLocalidadDeSucursal = 0
var IdNivelPub = 0
var IdLocalidad = 0
var CambiaPassword = false
var esNuevo = "N"
var esSucu = "N"
var Dyn_root = ''
var Dyn_item = 0
var Dyn_SolapaNueva = false
var Dyn_Iframe = "iu_uploadImagenModif.asp"
var Dyn_VectorSucursales = new Array()

function fncInicio() {	
	if (esSucu == 'N') {
		Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboFechasDias",'','selFechaNacimientoUsuarioCasaFotoDias','divFechaNacimientoUsuarioCasaFotoDias','fncDiasCargados')		
	}
	if (esNuevo == "S" || esSucu == 'S') {					
		Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboProvincias",'',"selProvinciasSucursal", "divSelProvinciasSucursal",'fncDatosSucursal')
	}
}

function fncDiasCargados() {
	Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboFechasMeses",'','selFechaNacimientoUsuarioCasaFotoMeses','divFechaNacimientoUsuarioCasaFotoMeses','fncMesesCargados')		
}

function fncMesesCargados() {
	if (esNuevo == "S") {
		Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboFechasAnios",'','selFechaNacimientoUsuarioCasaFotoAnios','divFechaNacimientoUsuarioCasaFotoAnios','fncCargaOrigenes')	
	}
	else {
		Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboFechasAnios",'','selFechaNacimientoUsuarioCasaFotoAnios','divFechaNacimientoUsuarioCasaFotoAnios','fncAniosCargados')	
	}
}

function fncAniosCargados() {	
	if (esNuevo == "N") {
		Dyn_fncEnviarTraerDatos(Dyn_Pag,2,"DatosCasaFoto",'','',Dyn_DivLoad,'fncCargarDatosCasaFoto')			
	}
}

function fncCargaOrigenes() {
	Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboOrigenes",'',"selOrigenes", "divSelOrigenes",'fncAniosCargados')
}

function fncDatosSucursal() {		
	Dyn_fncEnviarTraerDatos(Dyn_Pag,2,"DatosSucursal",'','',Dyn_DivLoad,'fncCargarDatosSucursal')	

}

function fncCargarDatosCasaFoto(root) {
	var ImagenLogo = ''
	var texto = ''
	
	if (root.getElementsByTagName('CasaFoto')[0].childNodes.length > 0) {
		nodos = root.getElementsByTagName('CasaFoto')[0]				
		try{document.getElementById("txtCantPositivo").value						= nodos.getElementsByTagName('CantPositivoDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}
		try{document.getElementById("txtCantNeutro").value							= nodos.getElementsByTagName('CantNeutroDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}
		try{document.getElementById("txtCantNegativo").value						= nodos.getElementsByTagName('CantNegativoDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}
		try{document.getElementById("txtNombreCasaFoto").value						= nodos.getElementsByTagName('NombreDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}		
		try{document.getElementById("txtMailCasaFoto").value						= nodos.getElementsByTagName('MailDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}		
		try{texto = nodos.getElementsByTagName('DescripcionDeCasaFoto')[0].childNodes.item(0).data;
		    texto = texto.replace(/###/g,"\n");
		    document.getElementById("txtDescripcionCasaFoto").value = texto
		} catch(e) {}		
		try{document.getElementById("txtNombreUsuarioCasaFoto").value				= nodos.getElementsByTagName('NombreUsuarioDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}		
		try{document.getElementById("txtApellidoUsuarioCasaFoto").value				= nodos.getElementsByTagName('ApellidoUsuarioDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}		
		try{document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").value	= nodos.getElementsByTagName('FechaNacimientoUsuarioDeCasaFotoDia')[0].childNodes.item(0).data} catch(e) {}
		try{document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").value	= nodos.getElementsByTagName('FechaNacimientoUsuarioDeCasaFotoMes')[0].childNodes.item(0).data} catch(e) {}
		try{document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").value	= nodos.getElementsByTagName('FechaNacimientoUsuarioDeCasaFotoAnio')[0].childNodes.item(0).data} catch(e) {}		
		try{ImagenLogo															= nodos.getElementsByTagName('LogoDeCasaFoto')[0].childNodes.item(0).data} catch(e) {}				
		if (ImagenLogo != '') {			
			var ImagenLogo = "<img src='" + ImagenLogo + "' height=18 width=128>"
			document.getElementById("divLogo").innerHTML = ImagenLogo
			document.getElementById("btnQuitarLogo").style.display = ""
		}
		if (nodos.getElementsByTagName('SexoUsuarioDeCasaFoto')[0].childNodes.item(0).data == 'F')
			document.getElementById("optSexoF").checked = true
		else
			document.getElementById("optSexoM").checked = true
	}		
}
	
function fncCargarDatosSucursal(root) {	
	var ImagenLocal = ''			
	if (root.getElementsByTagName('Sucursales')[0].childNodes.length > 0) {
		lista_sucursales = root.getElementsByTagName('Sucursal')	
		if (lista_sucursales[0].childNodes.length > 0) {						
			nodos = lista_sucursales[0]	
			agrega_solapa('tablita',nodos.getElementsByTagName('NombreDeSucursal')[0].childNodes.item(0).data)
			try{IdDeSucursal											= nodos.getElementsByTagName('IdDeSucursal')[0].childNodes.item(0).data} catch(e) {}		
			try{document.getElementById("txtNombreSucursal").value		= nodos.getElementsByTagName('NombreDeSucursal')[0].childNodes.item(0).data} catch(e) {}		
			try{document.getElementById("selProvinciasSucursal").value	= nodos.getElementsByTagName('IdDeProvincia')[0].childNodes.item(0).data} catch(e) {}		
			try{document.getElementById("txtLocalidadSucursal").value	= nodos.getElementsByTagName('LocalidadDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{IdLocalidadDeSucursal									= nodos.getElementsByTagName('IdDeLocalidad')[0].childNodes.item(0).data} catch(e) {}
			if (nodos.getElementsByTagName('IdDeLocalidad')[0].childNodes.length <= 0 && document.getElementById("txtLocalidadSucursal").value != '') {
				try{IdLocalidadDeSucursal = 'Otra'} catch(e) {}
				document.getElementById("txtTextoLocalidadSucursal").style.display = ""
				document.getElementById("txtTextoLocalidadSucursal2").style.display = ""
			}	
			try{document.getElementById("txtTelefonoSucursal").value	= nodos.getElementsByTagName('TelefonoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtCalleSucursal").value		= nodos.getElementsByTagName('CalleDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtNumeroSucursal").value		= nodos.getElementsByTagName('NumeroDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{
				if (nodos.getElementsByTagName('PisoDeSucursal')[0].childNodes.item(0).data == 0) {
					try{document.getElementById("txtPisoSucursal").value		= ""} catch(e) {}
				}
				else{
					try{document.getElementById("txtPisoSucursal").value		= nodos.getElementsByTagName('PisoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
				}
			} catch(e) {}
			try{
				if (nodos.getElementsByTagName('DeptoDeSucursal')[0].childNodes.item(0).data == 0) {
					try{document.getElementById("txtDeptoSucursal").value		= ""} catch(e) {}
				}
				else {
					try{document.getElementById("txtDeptoSucursal").value		= nodos.getElementsByTagName('DeptoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
				}
			} catch(e) {}
			try{document.getElementById("txtCpSucursal").value			= nodos.getElementsByTagName('CpDeSucursal')[0].childNodes.item(0).data} catch(e) {}													
			try{document.getElementById("selPublicaSucursal").value		= nodos.getElementsByTagName('NivelPubDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			IdNivelPub = nodos.getElementsByTagName('NivelPubDeSucursal')[0].childNodes.item(0).data
			try{ImagenLocal												= nodos.getElementsByTagName('ImagenLocalDeSucursal')[0].childNodes.item(0).data} catch(e) {}								
			if (ImagenLocal != '') {			
				var ImagenLocal = "<img id='ImagenLocal' src='" + ImagenLocal + "' height=150 width=250>"
				document.getElementById("divImagenLocal").innerHTML = ImagenLocal
				document.getElementById("btnQuitarImagen").style.display = ""
			}		
			Dyn_VectorSucursales[Dyn_VectorSucursales.length] = IdDeSucursal		
			fncSelSucu()		
			Dyn_root = root		
			Dyn_item = 1
			fncTraerLocalidades('selProvinciasSucursal','fncCompletarLocalidadSucursal')	
		}
	}
}

function fncSeguirCargandoDatosSucursal() {	
	var ImagenLocal = ''		
	lista_sucursales = Dyn_root.getElementsByTagName('Sucursal')	
	if (Dyn_item<lista_sucursales.length) {		
		if (lista_sucursales[Dyn_item].childNodes.length > 0) {						
			nodos = lista_sucursales[Dyn_item]	
			
			agrega_solapa('tablita',nodos.getElementsByTagName('NombreDeSucursal')[0].childNodes.item(0).data)
			
			try{IdDeSucursal											= nodos.getElementsByTagName('IdDeSucursal')[0].childNodes.item(0).data} catch(e) {}		
			try{document.getElementById("txtNombreSucursal").value		= nodos.getElementsByTagName('NombreDeSucursal')[0].childNodes.item(0).data} catch(e) {}		
			try{document.getElementById("selProvinciasSucursal").value	= nodos.getElementsByTagName('IdDeProvincia')[0].childNodes.item(0).data} catch(e) {}		
			try{IdLocalidadDeSucursal									= nodos.getElementsByTagName('IdDeLocalidad')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtLocalidadSucursal").value	= nodos.getElementsByTagName('LocalidadDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtTelefonoSucursal").value	= nodos.getElementsByTagName('TelefonoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtCalleSucursal").value		= nodos.getElementsByTagName('CalleDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{document.getElementById("txtNumeroSucursal").value		= nodos.getElementsByTagName('NumeroDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			try{
				if (nodos.getElementsByTagName('PisoDeSucursal')[0].childNodes.item(0).data == 0) {
					try{document.getElementById("txtPisoSucursal").value		= ""} catch(e) {}
				}
				else{
					try{document.getElementById("txtPisoSucursal").value		= nodos.getElementsByTagName('PisoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
				}
			} catch(e) {}
			try{
				if (nodos.getElementsByTagName('DeptoDeSucursal')[0].childNodes.item(0).data == 0) {
					try{document.getElementById("txtDeptoSucursal").value		= ""} catch(e) {}
				}
				else {
					try{document.getElementById("txtDeptoSucursal").value		= nodos.getElementsByTagName('DeptoDeSucursal')[0].childNodes.item(0).data} catch(e) {}
				}
			} catch(e) {}
			try{document.getElementById("txtCpSucursal").value			= nodos.getElementsByTagName('CpDeSucursal')[0].childNodes.item(0).data} catch(e) {}													
			try{document.getElementById("selPublicaSucursal").value		= nodos.getElementsByTagName('NivelPubDeSucursal')[0].childNodes.item(0).data} catch(e) {}
			IdNivelPub = nodos.getElementsByTagName('NivelPubDeSucursal')[0].childNodes.item(0).data
			try{ImagenLocal												= nodos.getElementsByTagName('ImagenLocalDeSucursal')[0].childNodes.item(0).data} catch(e) {}								
			if (ImagenLocal != '') {			
				var ImagenLocal = "<img id='ImagenLocal' src='" + ImagenLocal + "' height=150 width=250>"
				document.getElementById("divImagenLocal").innerHTML = ImagenLocal
				document.getElementById("btnQuitarImagen").style.display = ""
			}
			Dyn_VectorSucursales[Dyn_VectorSucursales.length] = IdDeSucursal			
			fncSelSucu()
			Dyn_item++		
			fncTraerLocalidades('selProvinciasSucursal','fncCompletarLocalidadSucursal')	
		}
	}
	else {
		Dyn_SolapaNueva=true
		Dyn_Iframe = "iu_uploadImagenNuevaSuc.asp"
	}	
}

function fncCompletarLocalidadSucursal() {
	document.getElementById("selLocalidadesSucursal").value	= IdLocalidadDeSucursal
	document.getElementById("selPublicaSucursal").value	= IdNivelPub
	fncSeguirCargandoDatosSucursal()
}


function fncOtraLocalidad (obj) {
	var cp = document.getElementById("selLocalidadesSucursal").options[document.getElementById("selLocalidadesSucursal").selectedIndex].attributes.getNamedItem("cp").value
	if (document.getElementById("selLocalidadesSucursal").value == "Otra") {		
		
		document.getElementById("txtTextoLocalidadSucursal").style.display = ""
		document.getElementById("txtTextoLocalidadSucursal2").style.display = ""
		document.getElementById("txtCpSucursal").value = ""
		document.getElementById("txtCpSucursal").disabled	= false
	}
	else {
		document.getElementById("txtLocalidadSucursal").value		= ""
		document.getElementById("txtTextoLocalidadSucursal").style.display = "none"
		document.getElementById("txtTextoLocalidadSucursal2").style.display = "none"
		if (cp != 1 && cp != '') {
			document.getElementById("txtCpSucursal").value = cp
			document.getElementById("txtCpSucursal").disabled = true
		}
		else {
			document.getElementById("txtCpSucursal").value = ""
			document.getElementById("txtCpSucursal").disabled = false
		}
	}
}

function fncValidarDatosGrabar() {
	formatoA = "<table id='toppage' width='100%' border='0' cellpadding='0' cellspacing='0'>"
	formatoA = formatoA + "<tr><td id='tdMensaje' height='20' style='background-Image:url(images/fondo_error.gif)' class='textoMensajeError'><IMG align='absmiddle' src='images/error_icon.gif'>&nbsp;"
	formatoD = "</td></tr></table>"
	//Valida datos
	//Ini****************************************	
	if (CambiaPassword) {		
		if (document.getElementById("txtPassword").value == '') {
			 document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar su Contraseña Actual" + formatoD;
			 document.getElementById("txtPassword").className = "contenidoCamposWarning";
			 return false}
		else{
			document.getElementById("txtPassword").className = "inputLogin";}				
			
		if (document.getElementById("txtPasswordNuevo").value == '') {
			document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar una Nueva Contraseña" + formatoD;
			document.getElementById("txtPasswordNuevo").className = "contenidoCamposWarning";
			return false}
		else{
			document.getElementById("txtPasswordNuevo").className = "inputLogin";}				
				
		if (document.getElementById("txtPasswordNuevo").value != document.getElementById("txtReingresePassword").value) {
			document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "La Contraseña nueva y la Contraseña reingresada son diferentes" + formatoD; 
			document.getElementById("txtPasswordNuevo").className = "contenidoCamposWarning";
			return false}
		else{
			document.getElementById("txtPasswordNuevo").className = "inputLogin";}				
				
	
	}
	else {
		if (esSucu == "N") {
			if (IsMail(document.getElementById("txtMailCasaFoto").value)) {
				document.getElementById("txtMailCasaFoto").className = "inputLogin";}				
			else{
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar un dirección de mail válida" + formatoD; 
				document.getElementById("txtMailCasaFoto").className = "contenidoCamposWarning";
				return false
				}				
				
			if (esNuevo == "S") {			
				if (document.getElementById("txtPassword").value == '') {
					document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar una Contraseña" + formatoD; 
					document.getElementById("txtPassword").className = "contenidoCamposWarning";
					return false}
				else{
					document.getElementById("txtPassword").className = "inputLogin";}				
				
				if (document.getElementById("txtPassword").value != document.getElementById("txtReingresePassword").value) {
					document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Las Contraseñas ingresadas son diferentes" + formatoD; 
					document.getElementById("txtReingresePassword").className = "contenidoCamposWarning";
					return false}
				else{
					document.getElementById("txtReingresePassword").className = "inputLogin";}				
	
			}	
						
			if (document.getElementById("txtNombreUsuarioCasaFoto").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar Nombre  y Apellido" + formatoD; 
				document.getElementById("txtNombreUsuarioCasaFoto").className = "contenidoCamposWarning";
				return false}		
			else{
				document.getElementById("txtNombreUsuarioCasaFoto").className = "inputLogin";}					
				
			if (document.getElementById("txtApellidoUsuarioCasaFoto").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar Nombre  y Apellido" + formatoD; 
				document.getElementById("txtApellidoUsuarioCasaFoto").className = "contenidoCamposWarning";
				return false}				
			else{
				document.getElementById("txtApellidoUsuarioCasaFoto").className = "inputLogin";}						

			if (document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").value == '0' || document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").value == '0' || document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").value == '0') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe seleccionar una fecha de nacimiento" + formatoD; 
				document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").className = "contenidoCamposWarning";
				document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").className = "contenidoCamposWarning";
				document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").className = "contenidoCamposWarning";
				return false
			}			
			else {
				document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").className = "inputLogin";
				document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").className = "inputLogin";
				document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").className = "inputLogin";
			}	
			
			if (document.getElementById("txtNombreCasaFoto").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar el Nombre de la Casa de Fotos" + formatoD; 
				document.getElementById("txtNombreCasaFoto").className = "contenidoCamposWarning";
				return false}		
			else{
				document.getElementById("txtNombreCasaFoto").className = "inputLogin";}							
					
		}		
		if (esNuevo == "S" || esSucu == "S") {			
			if (document.getElementById("txtNombreSucursal").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar el Nombre de la Sucursal" + formatoD; 
				document.getElementById("txtNombreSucursal").className = "contenidoCamposWarning";
				return false}				
			else{
				document.getElementById("txtNombreSucursal").className = "inputLogin";}							
				
			if (document.getElementById("selProvinciasSucursal").value == '0') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe seleccionar una provincia" + formatoD; 
				document.getElementById("selProvinciasSucursal").className = "contenidoCamposWarning";
				return false}	
			else{
				document.getElementById("selProvinciasSucursal").className = "inputLogin";}								

			if (document.getElementById("selLocalidadesSucursal").value == '0') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe seleccionar una localidad" + formatoD; 
				document.getElementById("selLocalidadesSucursal").className = "contenidoCamposWarning";
				return false}	
			else{
				document.getElementById("selLocalidadesSucursal").className = "inputLogin";}									
			
			if (document.getElementById("selLocalidadesSucursal").value == 'Otra') {
				if (document.getElementById("txtLocalidadSucursal").value == '') {
					document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar una localidad" + formatoD; 
					document.getElementById("txtLocalidadSucursal").className = "contenidoCamposWarning";
					return false
				}
				else {
					document.getElementById("txtLocalidadSucursal").className = "inputLogin";
				}
			}
			else {
				document.getElementById("txtLocalidadSucursal").className = "inputLogin";
			}
			
			if (document.getElementById("txtTelefonoSucursal").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar un número de teléfono" + formatoD; 
				document.getElementById("txtTelefonoSucursal").className = "contenidoCamposWarning";
				return false}	
			else{
				document.getElementById("txtTelefonoSucursal").className = "inputLogin";}										
			
			if (document.getElementById("txtCalleSucursal").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar el nombre de la calle" + formatoD; 
				document.getElementById("txtCalleSucursal").className = "contenidoCamposWarning";
				return false}					
			else{
				document.getElementById("txtCalleSucursal").className = "inputLogin";}											
			
			if (!Dyn_fncEsNumeroEntero(document.getElementById("txtNumeroSucursal").value)) {
				document.getElementById("divLblResultadoDeOperacion").innerHTML = formatoA + "El número de calle debe ser un número válido" + formatoD; 
				document.getElementById("txtNumeroSucursal").className = "contenidoCamposWarning";
				return false}
			else{
				document.getElementById("txtNumeroSucursal").className = "inputLogin";}												
			
			if (document.getElementById("txtPisoSucursal").value != '' && !Dyn_fncEsNumeroEntero(document.getElementById("txtPisoSucursal").value)) {
				document.getElementById("divLblResultadoDeOperacion").innerHTML = formatoA + "El Piso debe ser un número válido" + formatoD; 
				document.getElementById("txtPisoSucursal").className = "contenidoCamposWarning";
				return false}
			else{
				document.getElementById("txtPisoSucursal").className = "inputLogin";}											
			
			if (document.getElementById("txtCpSucursal").value == '') {
				document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formatoA + "Debe ingresar un Cp" + formatoD; 
				document.getElementById("txtCpSucursal").className = "contenidoCamposWarning";
				return false}			
			else{
				document.getElementById("txtCpSucursal").className = "inputLogin";}												
		}
	}
	//Fin****************************************	
	location.href="#toppage"
	return true	
}

function fncCambiaPassword(bol) {		
	CambiaPassword = bol
}

function fncArmarXmlGrabar() {
	//Arma xml
	var xml = ''
	var texto = ''
	
	//Ini****************************************
	xml += "<CasaFoto>"
	xml += "<EsNuevo>" + esNuevo + "</EsNuevo>"
	xml += "<EsSucursal>" + esSucu + "</EsSucursal>"
	if (CambiaPassword) {		
		xml += "<CambiaPassword>S</CambiaPassword>"
		xml += "<PasswordDeCasaFoto>"				+ document.getElementById("txtPassword").value + "</PasswordDeCasaFoto>"
		xml += "<PasswordNuevaDeCasaFoto>"			+ document.getElementById("txtPasswordNuevo").value + "</PasswordNuevaDeCasaFoto>"
	}
	else {		
		if (esSucu == "N") {
			if (esNuevo	== "S") {	
				xml += "<PasswordDeCasaFoto>"			+ document.getElementById("txtPassword").value + "</PasswordDeCasaFoto>"
			}
			
			var fechaNacim = document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").value + '-' + document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").value + '-' + document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").value
			
			xml += "<CambiaPassword>N</CambiaPassword>"			
			xml += "<NombreDeCasaFoto>"					+ document.getElementById("txtNombreCasaFoto").value + "</NombreDeCasaFoto>"		
			xml += "<NombreUsuarioDeCasaFoto>"			+ document.getElementById("txtNombreUsuarioCasaFoto").value + "</NombreUsuarioDeCasaFoto>"
			xml += "<ApellidoUsuarioDeCasaFoto>"		+ document.getElementById("txtApellidoUsuarioCasaFoto").value + "</ApellidoUsuarioDeCasaFoto>"		
			xml += "<FechaNacimientoUsuarioDeCasaFoto>"	+ fechaNacim + "</FechaNacimientoUsuarioDeCasaFoto>"		
			xml += "<IdDeOrigen>"						+ document.getElementById("selOrigenes").value + "</IdDeOrigen>"
		
			xml += "<MailDeCasaFoto>"					+ document.getElementById("txtMailCasaFoto").value + "</MailDeCasaFoto>"		
			if (document.getElementById("optSexoF").checked)
				xml += "<SexoUsuarioDeCasaFoto>F</SexoUsuarioDeCasaFoto>"
			else
				xml += "<SexoUsuarioDeCasaFoto>M</SexoUsuarioDeCasaFoto>"
			
			texto = document.getElementById("txtDescripcionCasaFoto").value
			texto = texto.replace(/\n/g,"###")
			
			xml += "<DescripcionDeCasaFoto>" + texto + "</DescripcionDeCasaFoto>"
		}
				
		if (esNuevo == "S" || esSucu == "S") {
			TerminarCargarDatosSolapaSel()
			
			xml += "<Sucursales>"
				//borra								
				for (var j=0; j<Dyn_VectorSucursales.length; j++) {
					var esta = false
					for (var i=1; i<=SolapasCant; i++) {							
						if (Dyn_VectorSucursales[j] == SolapaVector[i][0]) {
							esta = true
						}
					}
					if (esta == false) {
						xml += "<Sucursal>"	
						xml += "<NuevaSucursal>B</NuevaSucursal>"
						xml += "<IdDeSucursal>"	+ Dyn_VectorSucursales[j] + "</IdDeSucursal>"
						xml += "</Sucursal>"	
					}
				}
				if (esNuevo == "S") {
					xml += "<Sucursal>"	
						xml += "<NuevaSucursal>S</NuevaSucursal>"
						xml += "<ImagenLocalDeSucursal></ImagenLocalDeSucursal>"
						xml += "<IdDeSucursal>0</IdDeSucursal>"
						xml += "<IdDeProvincia>"		+ document.getElementById("selProvinciasSucursal").value + "</IdDeProvincia>"
						xml += "<IdDeLocalidad>"		+ document.getElementById("selLocalidadesSucursal").value + "</IdDeLocalidad>"
						xml += "<NombreDeSucursal>"		+ document.getElementById("txtNombreSucursal").value + "</NombreDeSucursal>"
						xml += "<TelefonoDeSucursal>"	+ document.getElementById("txtTelefonoSucursal").value + "</TelefonoDeSucursal>"
						xml += "<CalleDeSucursal>"		+ document.getElementById("txtCalleSucursal").value + "</CalleDeSucursal>"
						xml += "<NumeroDeSucursal>"		+ document.getElementById("txtNumeroSucursal").value + "</NumeroDeSucursal>"				
						xml += "<PisoDeSucursal>"		+ document.getElementById("txtPisoSucursal").value + "</PisoDeSucursal>"				
						xml += "<DeptoDeSucursal>"		+ document.getElementById("txtDeptoSucursal").value + "</DeptoDeSucursal>"
						xml += "<LocalidadDeSucursal>"	+ document.getElementById("txtLocalidadSucursal").value + "</LocalidadDeSucursal>"
						xml += "<CpDeSucursal>"			+ document.getElementById("txtCpSucursal").value + "</CpDeSucursal>"								
						xml += "<NivelPubDeSucursal>"	+ document.getElementById("selPublicaSucursal").value + "</NivelPubDeSucursal>"
					xml += "</Sucursal>"
				}
				else {				
					//modifica u agrega
					for (var i=1; i<SolapaVector.length; i++) {							
						var FueBorrada = false
						for (l=0; l<SolapasBorradas.length; l++) {
							if (SolapasBorradas[l] == i) {
								FueBorrada = true
							}
						}
						if (FueBorrada == false) {							
							xml += "<Sucursal>"	
								if (SolapaVector[i][15]==true) {xml += "<NuevaSucursal>S</NuevaSucursal>"}
								else {xml += "<NuevaSucursal>N</NuevaSucursal>"}
								xml += "<ImagenLocalDeSucursal></ImagenLocalDeSucursal>"
								xml += "<IdDeSucursal>"			+ SolapaVector[i][0] + "</IdDeSucursal>"
								xml += "<IdDeProvincia>"		+ SolapaVector[i][2] + "</IdDeProvincia>"
								xml += "<IdDeLocalidad>"		+ SolapaVector[i][4] + "</IdDeLocalidad>"
								xml += "<NombreDeSucursal>"		+ SolapaVector[i][5] + "</NombreDeSucursal>"
								xml += "<TelefonoDeSucursal>"	+ SolapaVector[i][6] + "</TelefonoDeSucursal>"
								xml += "<CalleDeSucursal>"		+ SolapaVector[i][7] + "</CalleDeSucursal>"
								xml += "<NumeroDeSucursal>"		+ SolapaVector[i][8] + "</NumeroDeSucursal>"				
								xml += "<DeptoDeSucursal>"		+ SolapaVector[i][9] + "</DeptoDeSucursal>"
								xml += "<PisoDeSucursal>"		+ SolapaVector[i][10] + "</PisoDeSucursal>"				
								xml += "<LocalidadDeSucursal>"	+ SolapaVector[i][11] + "</LocalidadDeSucursal>"
								xml += "<CpDeSucursal>"			+ SolapaVector[i][12] + "</CpDeSucursal>"								
								xml += "<NivelPubDeSucursal>"	+ SolapaVector[i][17] + "</NivelPubDeSucursal>"
							xml += "</Sucursal>"
						}
					}
				}
			xml += "</Sucursales>"						
		}
	}		
	xml += "</CasaFoto>"
	//Fin****************************************
	return xml	
}

function fncResultadoOperacionLocal(numError,resultado,formatoA,formatoD) {
	mensaje = "Error en la operacion. Numero de error: " + numError
	if (resultado == "OK") {
		mensaje = "Operación efectuada con éxito"
		formato = formatoA + mensaje + formatoD
		Dyn_fncCancelar()
		if (esNuevo	== "S") {
			setTimeout(function(){document.location.href ='iu_adm_casa_marco.asp'},3000);
		}
		else {
			Dyn_fncOcultarMensaje(Dyn_DivResultadoOperacion)
		}
	}
	else {
		switch (numError) {
		case "x":
			mensaje = "";
			break;
		}
		formato = formatoA + mensaje + formatoD
	}	
	document.getElementById(Dyn_DivResultadoOperacion).innerHTML = formato
}


function fncLimpiarCampos() {
	//Ini****************************************
	if (CambiaPassword) {			
		document.getElementById("txtPassword").value = ""
		document.getElementById("txtPasswordNuevo").value = ""
		document.getElementById("txtReingresePassword").value = ""	
	}
	else {
		if (esNuevo	== "S") {
			document.getElementById("txtMailCasaFoto").value = ""
			document.getElementById("txtPassword").value = ""
			document.getElementById("txtReingresePassword").value = ""
			document.getElementById("txtNombreUsuarioCasaFoto").value = ""
			document.getElementById("txtApellidoUsuarioCasaFoto").value = ""
			document.getElementById("selFechaNacimientoUsuarioCasaFotoAnios").selectedIndex = 0
			document.getElementById("selFechaNacimientoUsuarioCasaFotoMeses").selectedIndex = 0
			document.getElementById("selFechaNacimientoUsuarioCasaFotoDias").selectedIndex = 0
			document.getElementById("txtNombreCasaFoto").value = ""
			document.getElementById("txtNombreSucursal").value = ""
			document.getElementById("txtDescripcionCasaFoto").value = ""
			document.getElementById("selProvinciasSucursal").selectedIndex = 0
			document.getElementById("selLocalidadesSucursal").selectedIndex = 0
			document.getElementById("txtLocalidadSucursal").value = ""
			document.getElementById("txtTelefonoSucursal").value = ""
			document.getElementById("txtCalleSucursal").value = ""
			document.getElementById("txtNumeroSucursal").value = ""
			document.getElementById("txtPisoSucursal").value = ""
			document.getElementById("txtDeptoSucursal").value = ""
			document.getElementById("txtCpSucursal").value = ""
			document.getElementById("selPublicaSucursal").selectedIndex = 0
		}
	}
	//Fin****************************************
}

function fncTraerLocalidades(id,fun) {
	if (id == 'selProvincias') {		
		var xml = fncArmarXmlLocalidades()
		Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboLocalidades",xml,"selLocalidades","divSelLocalidades",fun)		
	}
	if (id == 'selProvinciasSucursal') {		
		var xml = fncArmarXmlLocalidadesSucursal()
		if (fun == '') {
			Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboLocalidades",xml,"selLocalidadesSucursal","divSelLocalidadesSucursal","fncTraerNivelPubNoSigue")
		}
		else {
			Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboLocalidades",xml,"selLocalidadesSucursal","divSelLocalidadesSucursal","fncTraerNivelPub")		
		}		
	}
}

function fncTraerNivelPub() {
	var xml = fncArmarXmlLocalidadesSucursal()
	Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboNivelPublica",xml,"selPublicaSucursal","divSelPublicaSucursal","fncCompletarLocalidadSucursal")		
}

function fncTraerNivelPubNoSigue() {
	var xml = fncArmarXmlLocalidadesSucursal()
	Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"ComboNivelPublica",xml,"selPublicaSucursal","divSelPublicaSucursal","fncReseteaNivelPub")		
}

function fncReseteaNivelPub () {
	document.getElementById("selPublicaSucursal").selectedIndex = 0
}

function fncArmarXmlLocalidades() {
	//Arma xml
	var xml = ''
	
	//Ini****************************************	
	xml += "<Localidad>"
		xml += "<IdDeProvincia>"	+ document.getElementById("selProvincias").value + "</IdDeProvincia>"		
	xml += "</Localidad>"
	//Fin****************************************	
	
	return xml	
}


function fncArmarXmlLocalidadesSucursal() {
	//Arma xml
	var xml = ''
	
	//Ini****************************************	
	xml += "<Localidad>"
		xml += "<IdDeProvincia>"	+ document.getElementById("selProvinciasSucursal").value + "</IdDeProvincia>"		
	xml += "</Localidad>"
	//Fin****************************************	
	
	return xml	
}


function fncTermClick() {
	if (document.getElementById("chkTerm").checked) {
		document.getElementById("btnRegistrarme").onmouseover = new Function("this.src='images/registrarme-N.jpg'")
		document.getElementById("btnRegistrarme").onmouseout = new Function("this.src='images/registrarme-A.jpg'")
		document.getElementById("btnRegistrarme").onmousedown = new Function("javascript:fncCambiaPassword(false);Dyn_fncGrabar()")
		document.getElementById("btnRegistrarme").src = "images/registrarme-A.jpg"		
	}
	else {
		document.getElementById("btnRegistrarme").onmouseover = ""
		document.getElementById("btnRegistrarme").onmouseout = ""
		document.getElementById("btnRegistrarme").onmousedown = ""
		document.getElementById("btnRegistrarme").src = "images/registrarme-G.jpg"		
	}}

function fncNuevoCasa() {esNuevo = "S"}
function fncEsSucu() {esSucu = "S"}


function fncQuitarLogo(opcion) {
	if (opcion==1) {		
		Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'QuitarLogoTemp','','',Dyn_DivLoad,'fncSeQuitoLogo')
	}
	else {
		Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'QuitarLogo','','',Dyn_DivLoad,'fncSeQuitoLogo')		
	}
}
function fncSeQuitoLogo() {		
	document.getElementById("divLogo").innerHTML = ''
	document.getElementById("btnQuitarLogo").style.display = "none"
}

function fncQuitarImagenLocal(opcion) {
	if (opcion==1) {	
		Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'QuitarImagenLocalTemp','',Dyn_DivLoad,Dyn_DivLoad,'fncSeQuitoImagen')		
	}
	else {
		if (SolapasEsNueva == false) {
			Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'QuitarImagenLocal','',Dyn_DivLoad,Dyn_DivLoad,'fncSeQuitoImagen')		
		}
		else {
			var xml =''
			xml += "<Cant>" + SolapasSel + "</Cant>"						
			Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'QuitarImagenLocalSucNueva',xml,Dyn_DivLoad,Dyn_DivLoad,'fncSeQuitoImagen')		
		}			
	}
}

function fncSeQuitoImagen() {	
	document.getElementById("divImagenLocal").innerHTML = ''
	document.getElementById("btnQuitarImagen").style.display = "none"
}


function fncFinUpload(tipo,arch,actualiza) {		
	if (tipo == 'Logo_') {				
		var ImagenLogo = "<img src='" + arch + "' height=18 width=128>"		
		document.getElementById("divLogo").innerHTML = ImagenLogo		
		if (esNuevo == "S")
			document.getElementById("ifrmUploadLogo").src = 'iu_uploadLogo.asp'
		else
			document.getElementById("ifrmUploadLogo").src = 'iu_uploadLogoModif.asp'				
		document.getElementById("btnQuitarLogo").style.display = ""				
		if (actualiza=="S") {
			Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'ActualizarLogo','',Dyn_DivLoad,Dyn_DivLoad,'')		
		}			
	}
	if (tipo == 'Imagen_') {
		var ImagenLocal = "<img id='ImagenLocal' src='" + arch + "' height=150 width=250>"
		document.getElementById("divImagenLocal").innerHTML = ImagenLocal
		if (esNuevo == "S")
			document.getElementById("ifrmUploadImagen").src = 'iu_uploadImagen.asp'
		else
			document.getElementById("ifrmUploadImagen").src = 'iu_uploadImagenModif.asp'		
		document.getElementById("btnQuitarImagen").style.display = ""
		if (actualiza=="S") {			
			Dyn_fncEnviarTraerDatos(Dyn_Pag,2,'ActualizarImagenLocal','',Dyn_DivLoad,Dyn_DivLoad,'')		
		}
	}
	if (tipo == 'ImagenNuevaSuc_') {		
		var ImagenLocal = "<img id='ImagenLocal' src='" + arch + "' height=150 width=250>"
		document.getElementById("divImagenLocal").innerHTML = ImagenLocal
		document.getElementById("ifrmUploadImagen").src = 'iu_uploadImagenNuevaSuc.asp'		
		document.getElementById("btnQuitarImagen").style.display = ""		
	}		
	
}


function fncSelSucu () { 
	var xml = ''		
	xml += '<IdDeSucursal>' + IdDeSucursal + '</IdDeSucursal>'	
	Dyn_fncEnviarTraerDatos(Dyn_Pag,2,"SelSucu",xml,'',Dyn_DivLoad,'')
}


//solapas
//---------------------------------------------------------------------
var SolapaCols= 0
var SolapaVector = new Array()
var SolapaColAnt = 1
var SolapaObjAnt = ''
var SolapaColorIzq = "images/solapa_izq_rojo.gif"
var SolapaColorFondo = "images/solapa_fondo_rojo.gif"
var SolapaColorDer = "images/solapa_der_rojo.gif"
var SolapaColorNoSel = "#FFFFFF"
var SolapasCant = 0
var SolapasEsNueva = false
var SolapasSel = 0
var SolapasBorradas = new Array()

function agrega_solapa(id,nombre){		
	var tipoNavegador = Dyn_fncTipoNavegador()	
	if (tipoNavegador == "IE") {		
		SolapasCant++; 
			SolapaCols++;
			var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
   		      var row = tbody.getElementsByTagName("TR")[0];
			     var td = document.createElement('<TD style="cursor:pointer" onclick="clickEnSolapa(this,'+SolapaCols+')">')
				   var tabla = document.createElement('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 width=100%>')
				     var tablabody = document.createElement('<TBODY>')
					   var tr2 = document.createElement('<TR>')
					      var fila1Tabla = document.createElement('<TD>')
		                     fila1Tabla.appendChild(document.createElement('<IMG src='+SolapaColorIzq+'>'))
				          var fila2Tabla = document.createElement('<TD id=centro class=adminTitulo2 background='+SolapaColorFondo+' nowrap>')
		            		 if (nombre=='') fila2Tabla.appendChild(document.createTextNode('Sucursal ')) 
		            		 else fila2Tabla.appendChild(document.createTextNode(nombre+' ')) 
					         fila2Tabla.appendChild(document.createElement('<img onmouseover=MM_swapImage("cerrar'+SolapaCols+'","","images/close_over.gif",1) onmouseout=MM_swapImgRestore() id="cerrar'+SolapaCols+'" src="images/close.gif" onclick="cerrar(this.parentNode.parentNode.parentNode.parentNode.parentNode,'+SolapaCols+')" align="absmiddle">')) 
				          var fila3Tabla = document.createElement('<TD>')
		                      fila3Tabla.appendChild(document.createElement('<IMG src='+SolapaColorDer+'>'))
						tr2.appendChild(fila1Tabla)
						tr2.appendChild(fila2Tabla)
						tr2.appendChild(fila3Tabla)
					tablabody.appendChild(tr2)
				  tabla.appendChild(tablabody)				
				td.appendChild(tabla)
			   row.appendChild(td)
		    tbody.appendChild(row);
		td.click()
	}	
	if (tipoNavegador == "NIE") {
		SolapasCant++; 
			SolapaCols++;
			var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
			  var row = tbody.getElementsByTagName("TR")[0];			
				var td = document.createElement('<TD>')
				td.style.cursor = 'pointer'			
				td.setAttribute('onmousedown','clickEnSolapa(this,'+SolapaCols+')'); 
					var tabla = document.createElement('<TABLE>')
					tabla.setAttribute('border','0')
					tabla.setAttribute('cellspacing','0')
					tabla.setAttribute('cellpadding','0')
					tabla.setAttribute('width','100%')
					
					var tablabody = document.createElement('<TBODY>')
						var tr2 = document.createElement('<TR>')
						
						var fila1Tabla = document.createElement('<TD>')						
		                    var im = document.createElement('<IMG>')
		                    im.src = SolapaColorIzq	                    
		                    fila1Tabla.appendChild(im)	                    					
						
						var fila2Tabla = document.createElement('<TD>')
							fila2Tabla.id = 'centro'
							fila2Tabla.className = 'adminTitulo2'
							fila2Tabla.setAttribute('background',SolapaColorFondo)
							if (nombre=='') {							
								var textAux = document.createTextNode('Sucursal ')
								fila2Tabla.appendChild(textAux)  
							}
		            		else {	         	            			
		            			var textAux = document.createTextNode(nombre+' ')	            			
		            			fila2Tabla.appendChild(textAux) 
		            		}	            		
		            		var im = document.createElement('<img>')
		            			im.setAttribute('onmouseover','MM_swapImage("cerrar'+SolapaCols+'","","images/close_over.gif",1)')
		            			im.setAttribute('onmouseout','MM_swapImgRestore()')
		            			im.setAttribute('id','cerrar'+SolapaCols)
		            			im.setAttribute('src','images/close.gif')
		            			im.setAttribute('onmousedown','cerrar(this.parentNode.parentNode.parentNode.parentNode.parentNode,'+SolapaCols+')')
		            			im.setAttribute('align','absmiddle')
					        fila2Tabla.appendChild(im)
					        				        
						var fila3Tabla = document.createElement('<TD>')										
							var im = document.createElement('<IMG>')
							im.setAttribute('src',SolapaColorDer)
							fila3Tabla.appendChild(im)
						tr2.appendChild(fila1Tabla)
						tr2.appendChild(fila2Tabla)
						tr2.appendChild(fila3Tabla)
					tablabody.appendChild(tr2)
				  tabla.appendChild(tablabody)				
				td.appendChild(tabla)			
			   row.appendChild(td)
		    tbody.appendChild(row);	
		td.onmousedown()
	}
}

function TerminarCargarDatosSolapaSel() {
	SolapaVector[SolapasSel] = new Array
	(
	IdDeSucursal,
	document.getElementById("divSelProvinciasSucursal").innerHTML,				
	document.getElementById("selProvinciasSucursal").value,
	document.getElementById("divSelLocalidadesSucursal").innerHTML,
	document.getElementById("selLocalidadesSucursal").value,
	document.getElementById("txtNombreSucursal").value,
	document.getElementById("txtTelefonoSucursal").value,
	document.getElementById("txtCalleSucursal").value,
	document.getElementById("txtNumeroSucursal").value,
	document.getElementById("txtDeptoSucursal").value,
	document.getElementById("txtPisoSucursal").value,
	document.getElementById("txtLocalidadSucursal").value,
	document.getElementById("txtCpSucursal").value,	
	document.getElementById("divImagenLocal").innerHTML,
	document.getElementById("ifrmUploadImagen").src,
	SolapasEsNueva,
	document.getElementById("btnQuitarImagen").style.display,
	document.getElementById("selPublicaSucursal").value,
	document.getElementById("divSelPublicaSucursal").innerHTML
	)
}

function cerrar(obj,item) {		
	var tipoNavegador = Dyn_fncTipoNavegador()
	if (tipoNavegador == "IE") {
		if (SolapasCant>1) {
			SolapasCant-- 
			if (obj.getElementsByTagName("TD")[1].background == SolapaColorFondo) {
			   var nodoInicio = obj.parentNode.getElementsByTagName("TABLE")[0]
			}
			var nodo = obj.parentNode
			nodo.removeChild(obj)
			try{nodoInicio.parentNode.click()}catch(e){}
		}
	}
	if (tipoNavegador == "NIE") {
		if (SolapasCant>1) {
			SolapasCant-- 
			if (obj.getElementsByTagName("TD")[1].getAttribute('background') == SolapaColorFondo) {
			   var nodoInicio = obj.parentNode.getElementsByTagName("TABLE")[0]
			}
			var nodo = obj.parentNode
			nodo.removeChild(obj)
			try{nodoInicio.parentNode.onmousedown()}catch(e){}
		}
	}	
	SolapaVector[item][0] = 0
	SolapasBorradas[SolapasBorradas.length] = item
}

function clickEnSolapa(obj,col) {	
	SolapasSel = col
	var tipoNavegador = Dyn_fncTipoNavegador()
	if (tipoNavegador == "IE") {
		try {SolapaObjAnt.getElementsByTagName("TD")[1].background = "images/solapa_fondo_gris.gif"}catch(e){}
		try {SolapaObjAnt.getElementsByTagName("IMG")[0].src = "images/solapa_izq_gris.gif"}catch(e){}
		try {SolapaObjAnt.getElementsByTagName("IMG")[2].src = "images/solapa_der_gris.gif"}catch(e){}
		obj.getElementsByTagName("TD")[1].background = SolapaColorFondo
		obj.getElementsByTagName("IMG")[0].src = SolapaColorIzq
		obj.getElementsByTagName("IMG")[2].src = SolapaColorDer	
	}
	if (tipoNavegador == "NIE") {
		try {SolapaObjAnt.getElementsByTagName("TD")[1].setAttribute('background','images/solapa_fondo_gris.gif') }catch(e){}
		try {SolapaObjAnt.getElementsByTagName("IMG")[0].src = "images/solapa_izq_gris.gif"}catch(e){}
		try {SolapaObjAnt.getElementsByTagName("IMG")[2].src = "images/solapa_der_gris.gif"}catch(e){}
		obj.getElementsByTagName("TD")[1].setAttribute('background',SolapaColorFondo)
		obj.getElementsByTagName("IMG")[0].src = SolapaColorIzq
		obj.getElementsByTagName("IMG")[2].src = SolapaColorDer
	}	
	if (SolapaColAnt != col) {			
		SolapaVector[SolapaColAnt] = new Array
				(
				IdDeSucursal,
				document.getElementById("divSelProvinciasSucursal").innerHTML,
				document.getElementById("selProvinciasSucursal").value,
				document.getElementById("divSelLocalidadesSucursal").innerHTML,
				document.getElementById("selLocalidadesSucursal").value,
				document.getElementById("txtNombreSucursal").value,
				document.getElementById("txtTelefonoSucursal").value,
				document.getElementById("txtCalleSucursal").value,
				document.getElementById("txtNumeroSucursal").value,
				document.getElementById("txtDeptoSucursal").value,
				document.getElementById("txtPisoSucursal").value,
				document.getElementById("txtLocalidadSucursal").value,
				document.getElementById("txtCpSucursal").value,
				document.getElementById("divImagenLocal").innerHTML,
				document.getElementById("ifrmUploadImagen").src,
				SolapasEsNueva,
				document.getElementById("btnQuitarImagen").style.display,
				document.getElementById("selPublicaSucursal").value,
				document.getElementById("divSelPublicaSucursal").innerHTML
				)

		try {						
			IdDeSucursal													= SolapaVector[col][0]
			document.getElementById("divSelProvinciasSucursal").innerHTML	= SolapaVector[col][1]	
			document.getElementById("selProvinciasSucursal").value			= SolapaVector[col][2]
			document.getElementById("divSelLocalidadesSucursal").innerHTML	= SolapaVector[col][3]
			document.getElementById("selLocalidadesSucursal").value			= SolapaVector[col][4]
			document.getElementById("txtNombreSucursal").value				= SolapaVector[col][5]
			document.getElementById("txtTelefonoSucursal").value			= SolapaVector[col][6]
			document.getElementById("txtCalleSucursal").value				= SolapaVector[col][7]
			document.getElementById("txtNumeroSucursal").value				= SolapaVector[col][8]									 
			document.getElementById("txtDeptoSucursal").value				= SolapaVector[col][9]
			document.getElementById("txtPisoSucursal").value				= SolapaVector[col][10]
			document.getElementById("txtLocalidadSucursal").value			= SolapaVector[col][11]
			document.getElementById("txtCpSucursal").value					= SolapaVector[col][12]
			document.getElementById("divImagenLocal").innerHTML				= SolapaVector[col][13]
			document.getElementById("ifrmUploadImagen").src					= SolapaVector[col][14]
			SolapasEsNueva													= SolapaVector[col][15]
			document.getElementById("btnQuitarImagen").style.display		= SolapaVector[col][16]
			document.getElementById("divSelPublicaSucursal").innerHTML		= SolapaVector[col][18]
			document.getElementById("selPublicaSucursal").value				= SolapaVector[col][17]

		} catch(e) {			
			//Nueva solapa			
			IdDeSucursal = col			
			document.getElementById("selProvinciasSucursal").selectedIndex = 0
			document.getElementById("selLocalidadesSucursal").selectedIndex = 0
			document.getElementById("txtNombreSucursal").value = ""
			document.getElementById("txtTelefonoSucursal").value = ""
			document.getElementById("txtCalleSucursal").value = ""
			document.getElementById("txtNumeroSucursal").value = ""
			document.getElementById("txtDeptoSucursal").value = ""
			document.getElementById("txtPisoSucursal").value = ""
			document.getElementById("txtLocalidadSucursal").value = ""
			document.getElementById("txtCpSucursal").value = ""	
			document.getElementById("divImagenLocal").innerHTML = ""
			document.getElementById("ifrmUploadImagen").src = Dyn_Iframe + "?cant="+SolapasCant
			SolapasEsNueva = Dyn_SolapaNueva,
			document.getElementById("btnQuitarImagen").style.display = "none",
			document.getElementById("selPublicaSucursal").selectedIndex = 0	
		}
	}		
	SolapaColAnt = col
	SolapaObjAnt = obj	
}

function fncVerComentarios(id) {
	window.open ("comentarios.asp?pag='rn_casas_de_foto.asp'&ped=","","height=500,width=630,scrollbars=yes,status=0,unadorned=yes")
}


function fncVerInterconsultas() {
	//Arma xml
	document.getElementById("txtComentario").value = ""
	IdDeUsuario = 0
	var xml = ''
	xml += "<Interconsulta>"
	xml += "</Interconsulta>"
	Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"Interconsultas",xml,"tblConsultas","divInterconsultas",'')	
}

function fncGrabaInterconsulta() {
	//Arma xml
	if (IdDeUsuario > 0) {
		if (document.getElementById("txtComentario").value != '') {
			var xml = ''
			xml += "<Interconsulta>"
				xml += "<IdDeUsuario>"	+ IdDeUsuario + "</IdDeUsuario>"		
				xml += "<IdDeSucursal>"	+ IdDeSucursal + "</IdDeSucursal>"		
				xml += "<IdDeInterconsulta>" + IdDeInterconsulta + "</IdDeInterconsulta>"
				xml += "<NombreDeUsuario>" + NombreDeUsuario + "</NombreDeUsuario>"
				xml += "<MailDeUsuario>" + MailDeUsuario + "</MailDeUsuario>"
				xml += "<NombreDeCasaFoto>" + NombreDeCasaFoto + "</NombreDeCasaFoto>"
				  texto = document.getElementById("txtComentario").value
				  texto = texto.replace(/\n/g,"###")
				xml += "<ConsultaDeInterconsulta>"	+ texto + "</ConsultaDeInterconsulta>"
			xml += "</Interconsulta>"
			Dyn_fncEnviarTraerDatos(Dyn_Pag,1,"GrabarInterconsultas",xml,"","",'fncVerInterconsultas()')			
		}
		else {
			alert("Debe ingresar una respuesta")
		}
	}
	else {
		alert("Debe seleccionar una consulta")
	}
}


function fncClickEnFila(root,id) {	
	if (id == "tblConsultas") {
		try{IdDeInterconsulta = root.getElementsByTagName('Campo')[0].childNodes.item(0).data} catch(e) {}		
		try{IdDeUsuario = root.getElementsByTagName('Campo')[1].childNodes.item(0).data} catch(e) {}
		try{IdDeSucursal = root.getElementsByTagName('Campo')[2].childNodes.item(0).data} catch(e) {}
		try{NombreDeUsuario = root.getElementsByTagName('Campo')[3].childNodes.item(0).data} catch(e) {}
		try{MailDeUsuario = root.getElementsByTagName('Campo')[4].childNodes.item(0).data} catch(e) {}
		try{NombreDeCasaFoto = root.getElementsByTagName('Campo')[5].childNodes.item(0).data} catch(e) {}
	}
	setTimeout(function(){document.getElementById("txtComentario").focus()},300);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
	
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function IsMail(YourMail)
{
var Template = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i //Formato de direccion de correo electronico
return (Template.test(YourMail)) ? 1 : 0 //Compara "YourMail" con el formato "Template" y si coincidevuelve verdadero si no devuelve falso
}
//---------------------------------------------------------------------
