/* Devuelve la cookie*/ function getCookie(name) {    var start = document.cookie.indexOf(name+"=");    var len = start+name.length+1;    var cookie_col = "00000000000000CPREesGPR52000000000000";    if ((!start) && (name != document.cookie.substring(0,name.length)))			 return null;    if (start == -1) {			/*alert("noa hay cookie");*/			return null;		}    var end = document.cookie.indexOf(";",len);    if (end == -1)	end = document.cookie.length;	cookie_col = unescape(document.cookie.substring(len,end));		return cookie_col;    }/* Devuelve CPRE, AHOG, etc...*/function getSegmentoCookie() {			var cookie = getCookie('COL');	if (cookie != null) {		return cookie.substring(14,18);	} else {		return 'AHOG';	}		}/* Devuelve es, ca*/function getIdiomaCookie() {			var cookie = getCookie('COL');		if (cookie != null) {	      //	return cookie.substring(18,20);	      return 'es';	} else {		return 'es';	}		}/*	Coge el segmento de los parámetros pasados a la URL*/function getSegmentoURL() {	/*		Espera el parámetro v_segmento y v_idioma.	*/		var v_segmento;	var v_idioma;	var url;		var idx = top.document.URL.indexOf('?');		var params = new Array();		if (idx != -1) {	  var pairs = top.document.URL.substring(idx+1, top.document.URL.length).split('&');	  for (var i=0; i<pairs.length; i++) {	   nameVal = pairs[i].split('=');	   params[nameVal[0]] = unescape(nameVal[1]);	  }	}		if (params['v_segmento'] == null) {		v_segmento = 'NINGUNO';	 		} else {		v_segmento = params['v_segmento'];	}		// Adaptamos el segmento tipo QX al de ON	switch (v_segmento) {		case "86870": 			v_segmento = 'AHOG';			break;		case "86871":				v_segmento = 'APRO';			break;		case "180840":			v_segmento = 'AOPN';			break;		case "2":			v_segmento = 'EMPR';			break;		case "86872":					if (esSeguro()) {				v_segmento = 'CHOG';			} else { 				v_semgento = 'AHOG';			}				break;		case "306981":			if (esSeguro()) {				v_segmento = 'CPRE';			} else {				v_segmento = 'AHOG';			}				break;		case "86873":			if (esSeguro()) {				v_segmento = 'CPRO';			} else {				v_segmento = 'APRO';			}				break;		case "1161699":			if (esSeguro()) {				v_segmento = 'CGCP';			} else {				v_segmento = 'APRO';			}				break;		case "86875":			if (esSeguro()) {				v_segmento = 'PYME';			} else {				v_segmento = 'EMPR';			}				break;		case "86876":			if (esSeguro()) {				v_segmento = 'GCLI';			} else {				v_segmento = 'EMPR';			}			break;		case "201955": 			if (esSeguro()) {				v_segmento = 'COPN';			} else {				v_segmento = 'AOPN';			}				break;					}		return v_segmento;}/*	Devuelve el protocolo*/function esSeguro() {	var url;	var idx = top.document.URL.indexOf("https");	if ( idx != -1) {		return true;	} else {		return false;	}	}/*	Coge el idioma de los parámetros pasados a la URL*/function getIdiomaURL() {	/*		Espera el parámetro v_segmento y v_idioma.	*/		var v_segmento;	var v_idioma;	var url;		var idx = top.document.URL.indexOf('?');	var params = new Array();		if (idx != -1) {	  var pairs = top.document.URL.substring(idx+1, top.document.URL.length).split('&');	  for (var i=0; i<pairs.length; i++) {	   nameVal = pairs[i].split('=');	   params[nameVal[0]] = unescape(nameVal[1]);	  }	}			if (params['v_idioma'] == null) {		v_idioma = 'NINGUNO';	} else {		v_idioma = params['v_idioma'];		}						// Adaptamos el idioma de QX	switch (v_idioma) {		case "1":			v_idioma = 'es';			break;		case "2":			v_idioma = 'ca';				break;	}				// return v_idioma;	return 'es';}function getSegmento() {		if (getSegmentoURL() == 'NINGUNO') {				return getSegmentoCookie();	} else {				return getSegmentoURL();	}		}function getIdioma() {		if (getIdiomaURL() == 'NINGUNO') {		return getIdiomaCookie();	} else {		return getIdiomaURL();	}		}
