var seccion = window.location.pathname.split('/')[1];
var pagina  = window.location.pathname.split('/')[2].split('.')[0];


switch(seccion) {
	case 'inmuebles':
		switch(pagina) {
			case 'busqueda':
				var operacion_v 		= window.location.href.split('=');
				var tipo_inmueble_v 	= operacion_v[2];
				
				//if(operacion_v[1]){
					//operacion_v = operacion_v[1].split('&')[0];
					
					//if(tipo_inmueble_v){
						//tipo_inmueble_v = tipo_inmueble_v.split('&')[0];
										
						//if(operacion_v == 'venta' && (tipo_inmueble_v == 'casas_v' || tipo_inmueble_v == 'departamentos_condominios_v')){					
							var OAS_listpos	 = 'Middle,Middle2,Bottom3,Frame1,x01,x02,x03,x04,x05,x06';
						//}
						//else{
							//var OAS_listpos	 = 'Bottom3,Frame1,x01,x02,x03,x04,x05,x06';
						//}
					//}
				//}				
				break;
			case '':
			case 'index':
				var OAS_listpos	 = 'Frame1,Bottom3,x01,x02,x03,x04,x05,x06';
				break;
			default:
				break;
		}
		break;
	case 'vehiculos':
			switch(pagina) {
				case 'busqueda':
					var operacion_v = window.location.href.split('=');
					if(operacion_v[1]){
						operacion_v = operacion_v[1].split('&')[0];
						if(operacion_v == 'venta_autos'){
							var OAS_listpos	 = 'Middle,Middle2,Middle3,Bottom3,Frame1,x01,x02,x03,x04,x05,x06';
						} else {
							var OAS_listpos	 = 'Frame2,Middle';
						}
					}
					break;
				case '':
				
				case 'index':
					//var OAS_listpos	  = 'Frame1,Bottom3,Top';
					var OAS_listpos	 = 'Bottom3,Top,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,Frame1,Frame2';
				break;
				
				case 'detalles':
					var OAS_listpos	 = 'Frame1';
				break;
				
				default:
				break;
			}
		break;
	case 'empleos':
		switch(pagina) {
			case 'busqueda':
				var OAS_listpos	 = 'Middle,Middle2,Bottom3,Frame1,x01,x02,x03,x04,x05';
				break;
			case '':
			case 'index':
				var OAS_listpos	 = 'Frame1,Bottom3,Right';
				break;
			default:
				break;
		}
		break;
	case 'varios':
		switch(pagina) {
			case 'busqueda':
				var OAS_listpos	 = 'Middle,Middle2,Bottom3,Frame1,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12';
				break;
			case '':
			case 'index':
				var OAS_listpos	 = 'Frame1,Bottom3,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12';
				break;
			default:
				break;
		}
		break;
	case 'anunciate':
		switch(pagina) {
			case '':
			case 'index':
				var OAS_listpos	 = 'Frame1,Bottom3,x01,x02,x03,x04,x05,x06';
				break;
			default:
				break;
		}
		break;
	case 'home':
		var OAS_listpos	 = 'Middle,Middle2,Bottom3,Frame1,x01,x02,x03,x04,x05';
		break;
}

// adaptacion a AD Stream
switch(seccion){
	case 'vehiculos':
		seccion = 'autos'; break;
}
switch(pagina) {
	case 'busqueda':
		pagina = 'resultados'; break;
	case '':
	case 'undefined':
		pagina = 'home'; break;
}

if ( (navigator.userAgent.indexOf('Mozilla/3') != -1) || (navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1) ) {
	var OAS_version = 10;
} else {
	var OAS_version	= 11;
}

var OAS_url		 = 'http://ads.eluniversal.com.mx/RealMedia/ads/';
var OAS_target	 = '_top';
var OAS_query	 = '';
var OAS_rn		 = new String(Math.random()); 
var OAS_rns		 = OAS_rn.substring (2, 11);
if(seccion == 'home') {
	var OAS_sitepage = 'www.ao.com.mx/'+pagina;
} else {
	var OAS_sitepage = 'www.ao.com.mx/'+seccion+'/'+pagina;
	if(queryString('categoria') == 'adultos') OAS_sitepage+= '/adultos';
}

function OAS_AD(pos) {
	try {
		if (OAS_version >= 11) {
			OAS_RICH  (pos);
		} else {
			OAS_NORMAL(pos);
		}
	} catch(e) {
		OAS_NORMAL(pos);
	}
}

function OAS_NORMAL(pos) {
	document.write('<a href="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" target=' + OAS_target + '><img src="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" ></a>');
}

if (OAS_version >= 11) {
	document.write('<scr' + 'ipt type="text/javascript" language="JavaScript1.1" src="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/script>');
}

//Elimina estilo en los banners cuando no hay publicidad
$('div.publicidad.horizontal:first').ready(function() {
	
	// Cuando el div con las clases "publicidad" y "horizontal" estan vacios
	$('.publicidad.horizontal:empty').remove();
	
	var publiObj = $('.publicidad.horizontal object');
	var publiEnl = $('.publicidad.horizontal a:first');
	
	if(publiEnl.length !=0){
		var hrefText      = publiEnl.attr('href');
		if(hrefText.indexOf('empty') != -1 && publiObj.length == 0){
			$('.publicidad.horizontal').remove();
		}
	}
	
	var objHijos = $('.publicidad.horizontal object').length;
	var imgHijos = $('.publicidad.horizontal img').length;
	var enlHijos = $('.publicidad.horizontal a').length;
	
	if( imgHijos == 0 && enlHijos == 0 && objHijos == 0){
		$('.publicidad.horizontal').remove();
	}/**/
});/**/
