
function toggle(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'block') { e.style.display = 'none'; }
	else { e.style.display = 'block'; }
}
function clearSearching(){
	var dq = document.gobu.q.value;
	if(dq=='Buscar...'){ document.gobu.q.value = ''; }
	else {
		if(dq.length==0){ document.gobu.q.value = 'Buscar...'; }
	}
}


function getList(pag){//obtenemos el listado
		goTo("container");	
		var url = "/content/list/?pag="+pag;
		ajax('list',url);
	}


function order(campo){//manda la ordenacion
		verListado();
		campo=campo.split(",");
		var url = "/content/list/?campo="+campo[0]+"&orden="+campo[1];
		ajax('list',url);
	}

function verListado(){//pasa del mapa al listado
		hide('map');
		//GUnload();
		show('list');
	}

function verMapa(){//ver el mapa en el listado
		hide('list');
		show('map');
		load();
	}

function buscar(){//busqueda del formulario

		if (document.getElementById('tipo').value=="hotel"){//busqueda hotels
				llegada=document.getElementById("arrival").value;
				salida=document.getElementById("departure").value;
				var city="-372490";
				
				var listaLL = llegada.split ("/");		
					var dLL = listaLL[0];
					var mLL = listaLL[1];
					var yLL = listaLL[2];
				var listaS = salida.split ("/");		
					var dS = listaS[0];
					var mS = listaS[1];
					var yS = listaS[2];

				url="http://hotels.barcelona-home.com/searchresults.html?aid=307125&class=3&class_interval=5&order=price&do_availability_check=1&city="+city+"&checkin_monthday="+dLL+"&checkin_year_month="+yLL+"-"+mLL+"&checkout_monthday="+dS+"&checkout_year_month="+yS+"-"+mS+"&arrival="+llegada+"&departure="+salida+"&tipo=hotel";
		}
		else {
			arrival=document.getElementById('arrival').value.replace("/","").replace("/","");
			departure=document.getElementById('departure').value.replace("/","").replace("/","");
			url="/search/list-p/type-"+document.getElementById('tipo').value+"/city-"+document.getElementById('city').value+"/px-"+document.getElementById('px').value+"/arrival-"+arrival+"/departure-"+departure+"/";
			
		}
				
		//alert(url);
		//loading();
		window.location=url;
	}

function hoteleros(stars){
	llegada = document.getElementById('arrival').value;
	salida = document.getElementById('departure').value;
	var city = '-372490';
	var listaLL = llegada.split('/');		
	var dLL = listaLL[0];
	var mLL = listaLL[1];
	var yLL = listaLL[2];
	var listaS = salida.split('/');		
	var dS = listaS[0];
	var mS = listaS[1];
	var yS = listaS[2];
	url = 'http://hotels.barcelona-home.com/searchresults.html?aid=307125&class='+stars+'&class_interval=5&order=price&do_availability_check=1&city='+city+'&checkin_monthday='+dLL+'&checkin_year_month='+yLL+'-'+mLL+'&checkout_monthday='+dS+'&checkout_year_month='+yS+'-'+mS+'&arrival='+llegada+'&departure='+salida+'&tipo=hotel';
	window.location=url;
}
	
function buscarIntranet(){//busqueda del formulario
		arrival=document.getElementById('arrival').value.replace("/","").replace("/","");
		departure=document.getElementById('departure').value.replace("/","").replace("/","");
		url="/intranet/search/list-p/type-"+document.getElementById('tipo').value+"/city-"+document.getElementById('city').value+"/px-"+document.getElementById('px').value+"/arrival-"+arrival+"/departure-"+departure+"/";
		//alert(url);
		//loading();
		window.location=url;
	}
	
function rebuscar(){//busqueda del calendario
		arrival=document.getElementById('llegadacal').value.replace("/","").replace("/","");
		departure=document.getElementById('salidacal').value.replace("/","").replace("/","");
		url="/"+document.getElementById('tipo').value+"/id-"+document.getElementById('id').value+"/name-"+document.getElementById('nombre').value+"/px-"+document.getElementById('px').value+"/arrival-"+arrival+"/departure-"+departure+"/";
		window.location=url;
	}

function rebuscarCal(){//busqueda del calendario
		arrival=document.getElementById('llegadacal').value.replace("/","").replace("/","");
		departure=document.getElementById('salidacal').value.replace("/","").replace("/","");
		url="/"+document.getElementById('tipo').value+"/id-"+document.getElementById('id').value+"/name-"+document.getElementById('nombre').value+"/px-"+document.getElementById('pers').value+"/arrival-"+arrival+"/departure-"+departure+"/";
		window.location=url;
	}


function recalcular(){//recalcular inmueble
		arrival=document.getElementById('arrival2').value.replace("/","").replace("/","");
		departure=document.getElementById('departure2').value.replace("/","").replace("/","");
		url="/"+document.getElementById('tipo2').value+"/id-"+document.getElementById('id').value+"/name-"+document.getElementById('nombre').value+"/px-"+document.getElementById('pers').value+"/arrival-"+arrival+"/departure-"+departure+"/";
		//alert(url);
		//loading();
		window.location=url;
	}
	
var clicks=0;//contador de clicks global

function setDateCalendar(fecha){
		if (clicks==0){//1r click
			clicks++;
			ocultarImgFecha();
			document.getElementById("llegadacal").value=fecha;
			document.getElementById(fecha).src='/content/media/img/iconos/icon_calendar_select.gif';
		}
		else if (clicks==1) {//2º click
			clicks=0;
			if (showToSelected(fecha)==true){
				//alert(showToSelected(fecha));
				document.getElementById("salidacal").value=fecha;
				document.getElementById(fecha).src='/content/media/img/iconos/icon_calendar_select.gif';
				show("rebuscar");	
			}
			else {
				alert("Error check out date");
				ocultarImgFecha();
			}
		}
	}
	
function ocultarImgFecha(){// hide all images
			var numImg=document.images.length;
			//alert(numImg);
			var ruta;
			for (f=0; f<numImg; f++){
				//alert(document.images[f].src);
				ruta=document.images[f].src;
				if (ruta.indexOf("icon_calendar_select.gif")>-1) {
					document.images[f].src='/content/media/img/iconos/icon_calendar_on.gif';	
				}
			/*else if(ruta.indexOf("icon_calendar_oferta.gif")>-1) {
					document.images[f].src='/content/media/img/iconos/icon_calendar_on.gif';	
				}*/
			}
	}

function showToSelected(fecha){//seleccion de imagenes
			var show=true;
			var numImg=document.images.length;
			var f,ruta,chiv;
			chiv=0;
			f=0;
			
			while(f<numImg&&show==true){
				//alert(document.images[f].src);
				ruta=document.images[f].src;
				if (ruta.indexOf("icon_calendar_select.gif")>-1) 	chiv=1;//si es la llegada imprimimos lo que viene
				if (document.images[f].id==fecha) 	chiv=0;//cuando se llega a la salida ya no se cambia la imagen
				
				if (chiv==1&&(ruta.indexOf("icon_calendar_on.gif")>-1||ruta.indexOf("icon_calendar_oferta.gif")>-1)) {//se pone el icono de para la busqueda cuando es vacio
					document.images[f].src='/content/media/img/iconos/icon_calendar_select.gif'
				}
				else if(chiv==1&&ruta.indexOf("icon_calendar_off.gif")>-1){//entre medio hay dias no vacios
					chiv=false;
					show=false;
				}
				f++;
			}
		return show;
	}



function calcula(){
		var total=0;

		for (var i=0;i < document.getElementById('form').elements.length;i++){
			var elemento = document.getElementById('form').elements[i];	
			if (elemento.getAttribute("accion")== "suma")
				{
					total = total + parseFloat(elemento.value);
					//alert(elemento.value);
				}
		}
		document.getElementById("total").value=total;
	}


function dateCheck(be,en) {
	var t=' 1:00:00 AM';
	var b,e;
	b = Date.parse(be + t);
	e = Date.parse(en + t);
	if(b<e) { return true; }
	return false;
}

function zumbador(){
	var url='';
	llegada=document.getElementById('arrival').value;
	salida=document.getElementById('departure').value;
	var city="-372490";
	var listaLL = llegada.split ('/');		
	var dLL = listaLL[0];
	var mLL = listaLL[1];
	var yLL = listaLL[2];
	var listaS = salida.split ('/');		
	var dS = listaS[0];
	var mS = listaS[1];
	var yS = listaS[2];
	var be = mLL + '/' + dLL + '/' + yLL;
	var en = mS + '/' + dS + '/' + yS;
	if(document.getElementById('tipo').value=='-') {
		alert('You must select the type of accommodation');
	}
	else if (document.getElementById('tipo').value=='hotel'){
		url='http://hotels.barcelona-home.com/searchresults.html?aid=307125&class=3&class_interval=5&order=price&do_availability_check=1&city='+city+'&checkin_monthday='+dLL+'&checkin_year_month='+yLL+'-'+mLL+'&checkout_monthday='+dS+'&checkout_year_month='+yS+'-'+mS+'&arrival='+llegada+'&departure='+salida+'&tipo=hotel';
		location.href=url;
	}
	else {
		if(dateCheck(be,en)){
			arrival=document.getElementById('arrival').value.replace('/','').replace('/','');
			departure=document.getElementById('departure').value.replace('/','').replace('/','');
			url='/search/list-p/type-'+document.getElementById('tipo').value+'/city-Barcelona/px-'+document.getElementById('px').value+'/arrival-'+arrival+'/departure-'+departure+'/';
			location.href=url;
		}
		else{
			alert('Departure date can not be greater than the Arrival date!');
		}
	}
}

function addOptionPx(num) {
	var elOptNew = document.createElement('option');
	elOptNew.text = num;
	elOptNew.value = num;
	var elSel = document.getElementById('px');
	try { elSel.add(elOptNew, null); }
	catch(ex) { elSel.add(elOptNew); }
}

function removeOptionPx() {
	var elSel = document.getElementById('px');
	if (elSel.length > 0) { elSel.remove(elSel.length - 1); }
}

function controlSearchSelect() {
	if(document.getElementById('tipo').value!='-') {
		if(document.getElementById('tipo').value=='flat') {
			document.getElementById('px').length = 0;
			for(var x = 1;x<12;x++) {
				addOptionPx(x);
			}
		}
		else {
			document.getElementById('px').length = 0;
			addOptionPx(1);
			addOptionPx(2);
		}
	}
}

function shm(divId,divStyle) { document.getElementById(divId).style.display=divStyle; }
function gebc(node,searchClass,tag) {
	var classElements = new Array();
	var els = node.getElementsByTagName(tag);
	var pattern = new RegExp('\\b'+searchClass+'\\b');
	for (var i = 0; i < els.length; i++) {
		if (pattern.test(els[i].className)) { classElements[classElements.length] = els[i]; }
	}
	return classElements;
}
function menuOO(liId) {
	var alls = gebc(document,liId,'li');
	for (var i = 0; i <= alls.length; i++) {
		try {
			var v = alls[i].id;
			var a = document.getElementById(v);
			a.onmouseover = function() {
				this.className='a'+liId;
				if((this.id=='i5')||(this.id=='i6')) { shm(this.id+'0','block'); }
			};
			a.onmouseout = function() {
				this.className=liId;
				if((this.id=='i5')||(this.id=='i6')) { shm(this.id+'0','none'); }
			};
		}
		catch(e) {}
	}
}
menuOO('normal');
menuOO('moral');
var simplxModal = '<div id="popupModal">';
simplxModal +='<div id="modalBg"></div>';
simplxModal +='<div id="loaderCenter"></div>';
simplxModal +='<div id="modalPopup">';
simplxModal +='<div id="popupClose">';
simplxModal +='<table width="100%" height="100%">';
simplxModal +='<tr>';
simplxModal +='<td id="modalTitle"></td>';
simplxModal +='<td id="modalTextClose"><a href="#" onclick="closePopup();return false;" title="cerrar">cerrar</a></td>';
simplxModal +='</tr>';
simplxModal +='</tr>';
simplxModal +='<td colspan="2" id="popupContent"></td>';
simplxModal +='</tr>';
simplxModal +='</table>';
simplxModal +='</div>';
simplxModal +='</div>';
simplxModal +='</div>';
var defaultBodyBg = document.body.style.backgroundColor;
var ievs = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
function showPopup(a,b) { 
	document.getElementById('modalTitle').innerHTML=b;
	document.body.style.overflow='hidden'; 
/*	if(ievs){ document.getElementById('wrap').style.display='none'; } */
	setTimeout("pageScroll()", 100); 
	setTimeout("mainPopup()",500);
	setTimeout("completePopup('"+a+"')",1000);
}

function completePopup(a) {
	var pc = document.getElementById('popupContent');
	if(pc.innerHTML=='') {
		pc.innerHTML='<iframe src="'+a+'" name="form100" id="form100" style="width:100%;height:100%;" scrolling="auto" frameborder="0"></iframe>';
	}
}

function closePopup() { 
	document.body.style.backgroundColor=defaultBodyBg; 
	document.getElementById('popupModal').style.display='none'; 
	document.getElementById('modalPopup').style.display='none'; 
	document.getElementById('popupContent').innerHTML=''; 
	document.body.style.overflow='auto';
/*	if(ievs){ document.getElementById('wrap').style.display='block'; } */
}

function mainPopup() { 
	document.getElementById('modalPopup').style.display='block'; 
	document.getElementById('loaderCenter').style.display='none'; 
}

function pageScroll() { 

document.getElementById('popupModal').style.top = Math.round((document.documentElement.scrollTop-document.documentElement.clientHeight)+(document.documentElement.clientHeight))+'px';
document.getElementById('popupModal').style.display='block'; 
document.getElementById('loaderCenter').style.display='block';
}
document.write(simplxModal);
function docHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
};
function emailMe() {
	document.write('<a href="/contact/barcelona-home/" style="text-decoration:none;">info@barcelona-home.com</a>');
}

function putHeight() {
	var heightFooter = 40;

	var dh = docHeight();

	var eld = document.getElementById('footer-container');
	eld.style.display = 'block';

	var hd = document.getElementById('docHeight').innerHTML;

	if(hd=='') {hd=0;}

	if(dh<hd) {
		eld.style.top = parseInt(dh+heightFooter)+'px';
		document.getElementById('docHeight').innerHTML = dh;
		alert('aca');
	}
	else {
		if(hd==0) {
			eld.style.top = parseInt((dh+heightFooter)+heightFooter)+'px';
			document.getElementById('docHeight').innerHTML = parseInt((dh+heightFooter)+heightFooter);
		}
		else {
			var eldTop = eld.style.top;
			var topEld = eldTop.replace('px','');
			if(parseInt(topEld)<dh) {
				eld.style.top = parseInt(dh+heightFooter)+'px';
				document.getElementById('docHeight').innerHTML = parseInt(dh+heightFooter);
			}
		}
	}

};
function buscaGoogle() {
	document.forms['gobu'].submit();
}
function isNumeric(value) { return !isNaN(value); }
window.onerror = function() { return true; };


function cambiarIdioma(newLang,idioma) {
	var sla='',nla='';
	switch (idioma) {
	case "eng":
		sla="en";
		break;
	case "s":
		sla="sv";
		break;
	case "po":
		sla="pt";
		break;
	case "d":
		sla="de";
		break;
	case "dk":
		sla="da";
		break;
	default:
		sla=idioma;
	}
	switch (newLang) {
	case "eng":
		nla="en";
		break;
	case "s":
		nla="sv";
		break;
	case "po":
		nla="pt";
		break;
	case "d":
		nla="de";
		break;
	case "dk":
		nla="da";
		break;
	default:
		nla=newLang;
	}
	if(nla!=sla) {
		var url=window.location.href, nurl=url;
		if(url.indexOf('http://barcelona-home.com')>-1){
			nurl=url.replace('http://','http://'+nla+'.');
		}
		else if(url.indexOf('http://www.barcelona-home.com')>-1){
			nurl=url.replace('http://www.','http://'+nla+'.');
		}
		else{
			nurl=url.replace('http://'+sla+'.','http://'+nla+'.');
		}
		window.location=nurl;
	}
}


function addFavorites(a,b) {
	var c = b.replace('-','_');
	document.getElementById('fav'+a).innerHTML='<a href="#" onclick="clearFavorites(\''+a+'\');return false;">&nbsp;Quitar de favoritos<img src="/img/favoritos/remove.png" border="0" alt="Quitar de favoritos" title="Quitar de favoritos" /></a>';
	document.getElementById('msgUsers'+a).innerHTML='Has agregado a favoritos el piso REF: <b>'+a+'</b>';
	document.getElementById('msgUsers'+a).style.display='block';
	setTimeout("document.getElementById('msgUsers"+a+"').style.display='none'",2000);
	document.getElementById('rowState'+a).style.backgroundColor='#FFFACD';
	simplx.pushSome('simplxDiv','/source/cart/?view=&id='+a+'&nn='+c);

}
function clearFavorites(a) {
	document.getElementById('rowState'+a).style.backgroundColor='#F4F4F4';
	simplx.pushSome('simplxDiv','/source/cart/?view=&id='+a+'&dd=1');
}

function addFavoritesInmueble(a,b) {
	addFavorites(a,b);
	setTimeout("goBack()()",2000);
}
function clearFavoritesInmueble(a) {
	clearFavorites(a);
	setTimeout("goBack()()",2000);
}
function goBack() {
	top.location.href='/search/list-f/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/';
}
function removeState(a) {
	if(confirm('Seguro que desea eliminar este inmueble de su busqueda?')) {
		simplx.pushSome('simplxDiv','/source/cart/rem/?view=&id='+a);
		setTimeout("FadeOut('rowState"+a+"')",1000);
		var dhtml = document.getElementById('rowState'+a).innerHTML;
		document.getElementById('rowState'+a).innerHTML = dhtml + cloudsBye();

	}
}
function cloudsBye() {
	var res = '<div style="position:absolute;left:50%;top:40%;z-index:100;">';
	res += '<div style="text-align:center;margin:auto;">';
	res += '<img src="/img/favoritos/clouds.gif" border="0" />';
	res += '</div>';
	res += '</div>';
	return res;
}
function showListPages() {
	topUrl('/search/list-f/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/');
}
function hideState(a,b) {
	document.getElementById(a).style.display=b;
}
function adicionarState(a) {
	simplx.pushSome('simplxDiv','/source/cart/rem/?dd=0&id='+a);
	setTimeout("FadeOut('rowState"+a+"')",1000);
	var dhtml = document.getElementById('rowState'+a).innerHTML;
	document.getElementById('rowState'+a).innerHTML = dhtml + cloudsBye();
}
function showFavorites() {
	topUrl('/search/list-f/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/view-favs/');
}
function showDeletes() {
	topUrl('/search/list-f/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/view-dele/');
}
function xcal(u) {
	return '<iframe src="'+u+'" name="ko_cal" id="ko_cal" style="width:100%;height:500px;" scrolling="no" frameborder="0"></iframe>';
}
function zone(z) {
	return '<iframe src="/content/zone/small/?z='+z+'" name="ko_ifZone" id="ko_ifZone" style="width:100%;height:650px;" scrolling="no" frameborder="0"></iframe>';
}
function gmaps(z) {
	return '<iframe src="/map/inmus/?id='+z+'&amp;h=410" name="ko_ifMap" id="ko_ifMap" style="width:100%;height:410px;" scrolling="no" frameborder="0"></iframe>';
}
var loaderImg = '<div style="text-align:center"><img src="/img/lb/ph_loading.gif" /></div>';
function simplxSource(a,b) {var ih=document.getElementById(a).innerHTML;if(ih.length<2){simplx.pushSource(a,loaderImg);simplx.pushSource(a,b);}}
function simplxLoad(a,b) {var ih=document.getElementById(a).innerHTML;if(ih.length<2){simplx.pushSome('simplxDiv',b);}}
function ToggleDiv(odiv) {
	if (document.getElementById(odiv).style.display == 'none') {
		setOpac(odiv,100);
		document.getElementById(odiv).style.display = 'block';
	}
	else {
		document.getElementById(odiv).style.display = 'none';
	}
}
function FadeToggleDiv(odiv) {
	if (document.getElementById(odiv).style.display == 'none') {
		FadeIn(odiv);
	}
	else {
		FadeOut(odiv);
	}
}
function FadeIn(odiv) {
	setOpac(odiv,0);
	document.getElementById(odiv).style.display = 'block';
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpac(\''+odiv+'\',' + i + ')' , 8 * i );
	}
}
function FadeOut(odiv) {
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpac(\''+odiv+'\',' + (100 - i) + ')' , 8 * i );
	}
	setTimeout('ToggleDiv(\''+odiv+'\')', 8 * i);
	setOpac(odiv,100);
}
function setOpac(odiv, value) {
	document.getElementById(odiv).style.opacity = value / 100;
	document.getElementById(odiv).style.filter = 'alpha(opacity=' + value + ')';
}
function ToggleVert(odiv, minh, maxh) {
	var curh = parseInt(document.getElementById(odiv).style.height);
	if (curh < (maxh - 10)) {
		VertScale(odiv,maxh);
	}
	else {
		VertScale(odiv,minh);
	}
}
function VertScale(odiv, endh) {
	var starth = parseInt(document.getElementById(odiv).style.height);
	document.getElementById(odiv).style.display = 'block';
	document.getElementById(odiv).style.overflow = 'hidden';
	for( var i = 0 ; i <= 50 ; i++ ) {
		curh = (starth - (((starth - endh) / 50) * (i-1)));
		setTimeout('setHeight(\''+odiv+'\',' + curh + ')' , 8 * i );
	}
	if (endh == 0) {
		setTimeout('ToggleDiv(\''+odiv+'\')', 8 * i);
	}
}
function setHeight(odiv,value) {
	document.getElementById(odiv).style.height = parseInt(value) + 'px';
}
function myList(){
	topUrl('/search/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/p-1/');
}
function orderSearch(a) {
	var b = a.split(',');
	goUrl('/search/type-flat/city-barcelona/px-1/arrival-01082010/departure-02082010/p-1/campo-'+b[0]+'/orden-'+b[1]+'/');
}
function myMap(){
	hide('list');
	show('map');
	document.getElementById('map').innerHTML='<iframe src="/source/include/maps.htm" name="ko_map" id="ko_map" style="width:100%;height:100%;" scrolling="no" frameborder="0"></iframe>';
}
function show(a) {document.getElementById(a).style.display='block';}
function hide(a) {document.getElementById(a).style.display='none';}
function goUrl(u) {
	location.href=u;
}
function topUrl(u) {
	top.location.href=u;
}


function chat() {
	 window.open('/contact/chat/', 'chat', 'width=300, height=300, status=0, toolbar=0, location=0, menubar=0, directories=0, resizeable=0, scrollbars=0');return false;
}

function mover(a) {
	var d = scrollDetect();
	for (var i = a; i <= d; i++) {
		setTimeout("window.scrollTo(0, "+parseInt((d-(d-(d-i)))+a)+")", 100);
	}
}
function scrollDetect() {
	var a='';
	if (navigator.appName == "Microsoft Internet Explorer") { a = document.body.scrollTop; }
	else{ a = window.pageYOffset; }
	return a;
}
function centerPopUp(u,w,h,n,s){
	var l = (screen.width-w)/2;
	var t = (screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+s+',toolbar=no';
	var w=window.open(u,n,settings);
	if(parseInt(navigator.appVersion) >= 4){w.window.focus();}
}


function tog(o) {var e=document.getElementById(o);if((e.style.display=='')||(e.style.display=='block')){e.style.display='none';}else{e.style.display='block';}}
function shareLinks() { }

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1909718-1']);
_gaq.push(['_setDomainName', 'www.inmo6d2.com']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();

