
DynWeb = {		

	getHTTPObject: function()
	{
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
		   try {
		      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		   } catch (e) {
		      try {
		         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		      } catch (E) { xmlhttp = false; }
		   }
		@else
		xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		   try {
		      xmlhttp = new XMLHttpRequest();
		   } catch (e) { xmlhttp = false; }
		}
		return xmlhttp;
	},
	
	compiler: function(http,url,params){
		if (http) {
			http.open("post", url, true);
			http.onreadystatechange = function (){										
				if (http.readyState == 4) {		
					if (http.status == 200) {	
						if (http.responseText.indexOf('invalid') == -1) {							
							returnCode=http.responseText;														
							eval(returnCode);
						}
					}
				}
			};			
			http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			http.setRequestHeader("HTTP_DynWeb","application/x-www-form-urlencoded");			
			http.send("ms=" + new Date().getTime() + "&" + params);
		}
		return true;
	},
	
	isIE6: function()
	{
		return (typeof document.body.style.maxHeight == "undefined");
	},
	
	screen:
	{
		show: function(iWidth,iHeight,sContent)
		{			
			var oScreen = document.getElementById('screen');
			var oBackScreen = document.getElementById('backScreen');
			var oTopScreen = document.getElementById('topScreen');		
			var oScreenContent = document.getElementById('screenContent');							
			
			if (!!DynWeb.isIE6())
			{
				oScreen.style.position='absolute';
				document.body.style.overflow='hidden';	
			}
				
			oTopScreen.style.width = iWidth + 'px';
			oTopScreen.style.height = iHeight + 'px';												
						
			oScreenContent.innerHTML = sContent;
						
			setTimeout(function(){DynWeb.screen.fadeIn(oScreen,oBackScreen,oTopScreen,0);},10);
									
		},
		
		fadeIn:function(oScreen,oBackScreen,oTopScreen,iOpacity)
		{

			if (!!oBackScreen.filters)
			{											
				oBackScreen.style.filter='alpha(opacity=' + iOpacity + ')';																				
			}else{				
				oBackScreen.style.opacity = (iOpacity/100);
				oBackScreen.style.MozOpacity = (iOpacity/100);
			}
			
			if (iOpacity==50)
			{
				oTopScreen.style.display = 'block';
			}else{
				oScreen.style.display = 'block';
				setTimeout(function(){DynWeb.screen.fadeIn(oScreen,oBackScreen,oTopScreen,(iOpacity+5));},10);
			}
		},
		
		hide: function()
		{
			var oScreen = document.getElementById('screen');						
			var oBackScreen = document.getElementById('backScreen');
			var oTopScreen = document.getElementById('topScreen');		
			
			if (!!DynWeb.isIE6())
			{
				document.body.style.overflow='visible';
			}
			
			oTopScreen.style.display = 'none';
			
			setTimeout(function(){DynWeb.screen.fadeOut(oScreen,oBackScreen,oTopScreen,50);},10);
		},
		
		fadeOut:function(oScreen,oBackScreen,oTopScreen,iOpacity)
		{
			if (!!oBackScreen.filters)
			{											
				oBackScreen.style.filter='alpha(opacity=' + iOpacity + ')';																				
			}else{				
				oBackScreen.style.opacity = (iOpacity/100);
				oBackScreen.style.MozOpacity = (iOpacity/100);
			}
			
			if (iOpacity==0)
			{
				oScreen.style.display = 'none';				
			}else{
				setTimeout(function(){DynWeb.screen.fadeOut(oScreen,oBackScreen,oTopScreen,(iOpacity-5));},10);
			}
		}
				
	},			
	
	functions:
	{			
		
		toggleCondiciones: function() {
			oTitle = document.getElementById("condiciones_title");
			oTitle2 = document.getElementById("condiciones_title2");
			oContent = document.getElementById("condiciones_content");
			
			if (oContent.style.display == 'none')
			{				
				oContent.style.display = 'block';
				oTitle2.style.display = 'none';
			}else{				
				oContent.style.display = 'none';
				oTitle2.style.display = 'inline';
			}
			
		}
		,
		
    	initializeMap: function(pLong , pLat) {
		  if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"),{size: new GSize(550,200)}); 

		    map.setCenter(new GLatLng(pLong, pLat), 16);
		    map.addControl(new GSmallMapControl());
		map.setMapType(G_HYBRID_MAP);

		map.addOverlay(new GMarker(new GLatLng(pLong, pLat)));
		  }

		},

		map: function(sTitle,sSubTitle,pLong,pLat)
		{
			var sContent ='';
			sContent+='<div class="titulo">Lugar de dictado: '+ sTitle +'</div>';
			sContent+='<div class="subtitulo">'+ sSubTitle +'</div>';
			sContent+='	<br/>';
			sContent+='	<div id="map_canvas" style="border:solid 1px #d5d4cd;overflow:hidden;width: 550px; height: 200px"></div>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cerrar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(600,360,sContent);			
			DynWeb.functions.initializeMap(pLong,pLat);
		},

		addFavorite: function(sTitle , sUrl)
		{
			if (window.sidebar){
				window.sidebar.addPanel(sTitle, sUrl,'');
			}else if( window.external ){
				window.external.AddFavorite(sUrl, sTitle);
			}else if(window.opera && window.print) {
				return true; 
			}
		},
		
		contact: function()
		{
			sContact = 'info'
			sDomain = 'escueladenegocios.edu.ar'
			document.getElementById('FRM_contact').src='mailto:' + sContact + '@' + sDomain;
		},
		
		showMenu: function(sMenu)
		{
			var oMenus = document.getElementById('menu').getElementsByTagName('DIV');			
			for(i=0;i<oMenus.length;i++)
			{				
				oMenus[i].className = '';
				var oMenuItems = document.getElementById('menuItems_' + oMenus[i].id.replace('menu_',''));
				oMenuItems.style.display = 'none';
			}
			
			var oMenu = document.getElementById('menu_' + sMenu);
			oMenu.className = 'selected';

			var oMenuItem = document.getElementById('menuItems_' + sMenu);			
			oMenuItem.style.display = 'block';
		},						
		
		shareCurso: function(sTitle,sLink)
		{
			var sContent ='';
			sContent+='<div class="titulo">Envíar el curso a un colega</div>';
			sContent+='<div class="subtitulo">'+ sTitle +'</div>';
			sContent+='	<br/>';
			sContent+='	Ingrese su nombre y apellido';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_emisor" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';			
			sContent+='	Ingrese su correo electrónico';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_emisor_correo" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	Ingrese el nombre y apellido de su colega';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_receptor" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	Ingrese el correo electrónico de su colega';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_receptor_correo" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Enviar" class="button" onclick="DynWeb.functions.shareCursoSend(\'' + escape(sTitle) + '\',\'' + escape(sLink) + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},
		
		shareCursoSend: function(sTitle,sLink)
		{
			var sUrl = document.location.href.toLowerCase().replace('/cursos/','/enviar_cursos/');
			var sParams ='';
			sParams += 'emisor=' + escape(document.getElementById('enviar_colega_emisor').value);			
			sParams += '&emisor_correo=' +  escape(document.getElementById('enviar_colega_emisor_correo').value);
			sParams += '&receptor=' +  escape(document.getElementById('enviar_colega_receptor').value);
			sParams += '&receptor_correo=' +  escape(document.getElementById('enviar_colega_receptor_correo').value);
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
			
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		joinCurso: function(sTitle,sId,sRestante)
		{
			var sContent ='';
			sContent+='<div class="titulo">Inscribirse al curso</div>';
			sContent+='<div class="subtitulo">'+ sTitle +'</div>';
			sContent+='	<br/>';
			sContent+='	Por favor confirme la inscripción al curso.';									
			sContent+='	<br/>';
			sContent+='	<br/>';			
			sContent+='	<span id="error" style="color:#ff0000;font-weight:bold;">'
			if (sRestante != '')
				sContent+='	Tiene disponible(s) ' + sRestante + ' inscripciones PRESENCIALES.'
			sContent+='	</span>';			
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Confirmar" class="button" onclick="DynWeb.functions.joinCursoSend(\'' + escape(sTitle) + '\',\'' + escape(sId) + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},

		joinCursoSend: function(sTitle,sId)
		{
			var sUrl = document.location.href.toLowerCase().replace('/cursos/','/inscripcion_cursos/');
			var sParams ='';			
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
			
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},

		joinCursoOnline: function(sTitle,sId,sRestante)
		{
			var sContent ='';
			sContent+='<div class="titulo">Inscribirse al curso</div>';
			sContent+='<div class="subtitulo">'+ sTitle +'</div>';
			sContent+='	<br/>';
			sContent+='	Por favor confirme la inscripción al curso.';									
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<span id="error" style="color:#ff0000;font-weight:bold;">'
			if (sRestante != '')
				sContent+='	Tiene disponible(s) ' + sRestante + ' inscripciones ONLINE.'
			sContent+='	</span>';									
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Confirmar" class="button" onclick="DynWeb.functions.joinCursoOnlineSend(\'' + escape(sTitle) + '\',\'' + escape(sId) + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},

		joinCursoOnlineSend: function(sTitle,sId)
		{
			var sUrl = document.location.href.toLowerCase().replace('/cursos_online/','/inscripcion_cursos_online/');
			var sParams ='';			
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
			
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		login: function(sSite)
		{
			var sContent ='';
			sContent+='<div class="titulo">Identifíquese en el sistema</div>';
			sContent+='<div class="subtitulo">Ingrese su usuario y contraseña</div>';
			sContent+='	<br/>';
			sContent+='	Usuario';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="usuario" value="" maxlength="20" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';			
			sContent+='	Contraseña';
			sContent+='	<br/>';
			sContent+='	<input type="password" class="input" id="clave" value="" maxlength="20" size="60"/>';			
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Identificarse" class="button" onclick="DynWeb.functions.loginSend(\'' + sSite + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},

		loginSend2: function(sSite)
		{
			var sUrl = sSite + 'identificarse';			
			var sParams ='';			
			sParams += 'usuario=' +  escape(document.getElementById('usuario').value);
			sParams += '&clave=' +  escape(document.getElementById('clave').value);
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
		
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		loginSend: function(sSite)
		{
			var sUrl = sSite + 'identificarse';			
			var sParams ='';			
			sParams += 'usuario=' +  escape(document.getElementById('usuario').value);
			sParams += '&clave=' +  escape(document.getElementById('clave').value);
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
		
			document.getElementById('enviar_colega_login').disabled = true;			
		},

		forget: function(sSite)
		{
			var sContent ='';
			sContent+='<div class="titulo">Recupere su contraseña</div>';
			sContent+='<div class="subtitulo">Ingrese su usuario</div>';
			sContent+='	<br/>';
			sContent+='	Usuario';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="forget_user" value="" maxlength="50" size="60"/>';
			/*
			sContent+='	<br/>';
			sContent+='	Correo electrónico';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="forget_mail" value="" maxlength="50" size="60"/>';
			*/
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Recuperar" class="button" onclick="DynWeb.functions.forgetSend(\'' + sSite + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},
		
		forgetSend: function(sSite)
		{
			var sUrl = sSite + 'recuperar';			
			var sParams ='';			
			sParams += 'user=' +  escape(document.getElementById('forget_user').value);
			/*
			sParams += '&mail=' +  escape(document.getElementById('forget_mail').value);
			*/
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
		
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		activate: function(sSite)
		{
			var sContent ='';
			sContent+='<div class="titulo">Correo electrónico de confirmación</div>';
			sContent+='<div class="subtitulo">Ingrese su correo electrónico</div>';
			sContent+='	<br/>';
			sContent+='	Correo electrónico';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="mail" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Solicitar envío" class="button" onclick="DynWeb.functions.activateSend(\'' + sSite + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},
		
		activateSend: function(sSite)
		{			
			var sUrl = sSite + 'activacion2';			
			var sParams ='';			
			sParams += 'mail=' +  escape(document.getElementById('mail').value);			
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
		
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		logout: function(sSite)
		{
			var sContent ='';
			sContent+='<div class="titulo">Salir del sistema</div>';
			sContent+='<div class="subtitulo">Confirme su salida</div>';
			sContent+='	<br/>';
			sContent+='	Por favor confirme la salida del sistema.';									
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Salir" class="button" onclick="DynWeb.functions.logoutSend(\'' + sSite + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},
		
		logoutSend: function(sSite)
		{
			var sUrl = sSite + 'salir';			
			var sParams ='';						
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
			
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},				

		shareCursoOnline: function(sTitle,sLink)
		{
			var sContent ='';
			sContent+='<div class="titulo">Envíar el curso a un colega</div>';
			sContent+='<div class="subtitulo">'+ sTitle +'</div>';
			sContent+='	<br/>';
			sContent+='	Ingrese su nombre y apellido';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_emisor" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';			
			sContent+='	Ingrese su correo electrónico';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_emisor_correo" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	Ingrese el nombre y apellido de su colega';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_receptor" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	Ingrese el correo electrónico de su colega';
			sContent+='	<br/>';
			sContent+='	<input type="text" class="input" id="enviar_colega_receptor_correo" value="" maxlength="50" size="60"/>';
			sContent+='	<br/>';
			sContent+='	<br/>';
			sContent+='	<input type="button" name="enviar" id="enviar_colega_enviar" value="Enviar" class="button" onclick="DynWeb.functions.shareCursoOnlineSend(\'' + escape(sTitle) + '\',\'' + escape(sLink) + '\');"/>';
			sContent+='	<input type="button" name="cancelar" id="enviar_colega_cancelar" value="Cancelar" class="button2" onclick="DynWeb.screen.hide();"/>';			
			DynWeb.screen.show(400,360,sContent);			
		},
		
		shareCursoOnlineSend: function(sTitle,sLink)
		{
			var sUrl = document.location.href.toLowerCase().replace('/cursos_online/','/enviar_cursos_online/');
			var sParams ='';
			sParams += 'emisor=' + escape(document.getElementById('enviar_colega_emisor').value);			
			sParams += '&emisor_correo=' +  escape(document.getElementById('enviar_colega_emisor_correo').value);
			sParams += '&receptor=' +  escape(document.getElementById('enviar_colega_receptor').value);
			sParams += '&receptor_correo=' +  escape(document.getElementById('enviar_colega_receptor_correo').value);
			var httpWindow = DynWeb.getHTTPObject();
			DynWeb.compiler(httpWindow,sUrl,sParams);						
			
			document.getElementById('enviar_colega_enviar').style.display = 'none';			
		},
		
		navigate: function(sLink,sParams)
		{
			var oBody = document.body;
			var oForm = document.createElement('FORM');				
				oForm.setAttribute('action',sLink);
				oForm.setAttribute('method','post');				
				
				var sTempInnerHTML = sParams;
				sTempInnerHTML = sTempInnerHTML.replace('=','" VALUE="');
				sTempInnerHTML = sTempInnerHTML.replace('&','"/><input TYPE="hidden" name="');
				
				var sInnerHTML = '<input TYPE="hidden" name="' + sTempInnerHTML + '"/>';												
								
				oForm.innerHTML = sInnerHTML;												
				oResult = oBody.appendChild(oForm);	
				/*
				oEl = document.createElement('input');
				oEl.type='hidden';
				oEl.name='c';
				oEl.value='cac';				
				oResult.appendChild(oEl);
				*/
				//alert(oResult.getElementsByTagName('input')[0].value);
				//alert(oResult.innerHTML);
				oResult.submit();
		},
		
		changeLocalidadParticular: function(oThis)
		{			
			if (oThis.value=='Buenos Aires')
			{
				document.getElementById('localidad_particular_texto').style.display='none';
				document.getElementById('localidad_particular_combo').style.display='block';
			}else{
				document.getElementById('localidad_particular_texto').style.display='block';
				document.getElementById('localidad_particular_combo').style.display='none';
			}
		},
		
		changeLocalidadLaboral: function(oThis)
		{			
			if (oThis.value=='Buenos Aires')
			{
				document.getElementById('localidad_laboral_texto').style.display='none';
				document.getElementById('localidad_laboral_combo').style.display='block';
			}else{
				document.getElementById('localidad_laboral_texto').style.display='block';
				document.getElementById('localidad_laboral_combo').style.display='none';
			}
		}
		
	}		
}


