
function sharetotwitter()
{
	window.open('http://twitter.com/home?status=Me encanta Pilares '+encodeURIComponent( location.href )+'&t='+encodeURIComponent( document.title ),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;

}

function sharetofacebook()
{
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent( location.href )+'&t='+encodeURIComponent( document.title ),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}



projectmap = false;
projectmap2 = false;

function showMapProjects() {

	if ( projectmap  )
		return false;
	projectmap = true;

	if (GBrowserIsCompatible())
	{
        var map = new GMap2(document.getElementById("map_canvas"), {  size:new GSize(615,385)  });
        map.setCenter(new GLatLng( '-33.42536' , '-70.566466' ), 10, G_HYBRID_MAP  );
        map.setUIToDefault();

        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(44, 60);
        baseIcon.shadowSize = new GSize(61, 60);
        baseIcon.iconAnchor = new GPoint(20, 60);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {

          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);

          letteredIcon.image = "http://www.pilares.cl/assets/images/"+ picon ;

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "mouseup", function() {
            marker.openInfoWindowHtml(   "<a href='/proyecto.html/proyecto.index/" + mprojects[index].ID  + "/"+ mprojects[index].NOMBRE_AMIGABLE  +"?p="+ mprojects[index].ESTADO__PRY_LINK  +"' target='_blank'><b>" + mprojects[index].NOMBRE   +"</b>" + "<br/>" + mprojects[index].PIEZAS + (mprojects[index].DESDE ? " desde UF " + mprojects[index].DESDE : "")  +"</a>"        );
          });
          return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i <  mprojects.length ; i++)
	{
		var latlng = new GLatLng( mprojects[ i ].LATITUD ,  mprojects[i].LONGITUD  );
		map.addOverlay(createMarker(latlng, i));
        }
	map.checkResize();
      }
}
function showMapProjects_mini() {

	if ( projectmap2  )
		return false;
	projectmap2 = true;

	if (GBrowserIsCompatible())
	{
        var map2 = new GMap2(document.getElementById("map_canvas2"), {  size:new GSize(210,300)  });
        map2.setCenter(new GLatLng( '-33.42536' , '-70.566466' ), 10, G_HYBRID_MAP  );
        map2.setUIToDefault();

        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(44, 60);
        baseIcon.shadowSize = new GSize(61, 60);
        baseIcon.iconAnchor = new GPoint(20, 60);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {

          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);

          letteredIcon.image = "http://www.pilares.cl/assets/images/"+ picon ;

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "mouseup", function() {
            marker.openInfoWindowHtml(   "<a href='/proyecto.html/proyecto.index/" + mprojects_mini[index].ID  + "/"+ mprojects_mini[index].NOMBRE_AMIGABLE  +"?p="+ mprojects_mini[index].ESTADO__PRY_LINK  +"' target='_blank'><b>" + mprojects_mini[index].NOMBRE   +"</b>" + "<br/>" + mprojects_mini[index].PIEZAS + (mprojects_mini[index].DESDE ? " desde UF " + mprojects_mini[index].DESDE : "")  +"</a>"        );
          });
          return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map2.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i <  mprojects_mini.length ; i++)
	{
		var latlng = new GLatLng( mprojects_mini[ i ].LATITUD ,  mprojects_mini[i].LONGITUD  );
		map2.addOverlay(createMarker(latlng, i));
        }
	map2.checkResize();
      }
}


function showMapProject() {

	if ( projectmap  )
		return false;
	projectmap = true;

	if (GBrowserIsCompatible())
	{
        var map = new GMap(document.getElementById("map_canvas"), {  size:new GSize(615,385)  });
        map.setCenter(new GLatLng( platitud , plongitud  ), 15, G_HYBRID_MAP );
        map.setUIToDefault();

        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	/*
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
	*/
        baseIcon.iconSize = new GSize(44, 60);
        baseIcon.shadowSize = new GSize(61, 60);
        baseIcon.iconAnchor = new GPoint(20, 60);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {

          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);

          letteredIcon.image = "http://www.pilares.cl/assets/images/"+ picon ;

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml( pname );
          });
          return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i < 1; i++) {
          var latlng = new GLatLng( platitud, plongitud );
          map.addOverlay(createMarker(latlng, i));
        }
	map.checkResize();
      }
}

window.projectplantas = false;


function showDetailProject( detail )
{
	$('a[href="' + detail + '"]').parents('#menu-proyecto').children('ul').children().children().removeClass('selected');
	$('a[href="' + detail + '"]').parents('li').children().addClass('selected');
	$("#ventana_caracteristicas , #ventana_entorno, #ventana_ubicacion , #ventana_galeria , #ventana_plantas, #ventana_video").css("display","none");	
	$(detail).css("display","block");
	if ( detail == "#ventana_ubicacion" && $('#ubicacion_tab_plano').css('display') != 'none' )
		showMapProject();

	if ( detail == "#ventana_plantas"  )
	{
		if ( window.projectplantas  )
			return false;
		window.projectplantas = true;
		if ( window.projectplantas  )
		{	
			try {
				$('#photos').galleryView({
					panel_width: 450,
					panel_height: 335,
					frame_width: 80,
					frame_height: 82
						
				});
			} catch(e) {
				if(typeof(console) != 'undefined') {
					console.debug(e);
				}
			}
		}
	}

	return false;
}

function showDetailModel( detail, idmodelo )
{
		$('a[href="' + detail + '"]').parents('#tabs-modelo').parent().find('ul').children().children().removeClass('selected');
		$('a[href="' + detail + '"]').parents('li').children().addClass('selected');
		$("#modelo_tab_caracteristicas , #modelo_tab_plantas").css("display","none");	
		$(detail).css("display","block");

		plantaUrl = "/modelo-print.html/modelo-print.index/" + idmodelo;

		if ( detail == "#modelo_tab_plantas"  )
		{
			plantaUrl = "/planta.html/modelo-planta.index/" + idmodelo + "/modelo-planta.planta/1";
			/* FIXME: swfobject */
			var plantaImage;
			plantaImage = $('#plantaimg').html();
			plantaImage = plantaImage.replace(/^[ \n\r\t]*(.*)[ \n\r\t]*$/, '$1');
			var flashvars = {};
			flashvars.imgSrc = "/includes/thumbnailer.php/1024/1024/" + plantaImage;
				
			var params = {};  
			params.scale = "noScale";
			params.salign = "center";
			swfobject.embedSWF("/assets/swf/flexiZoomer.swf", "flashContent", "580", "390", "4.0.0","/assets/swf/expressInstall.swf", flashvars, params);
			//$('#modelo-boton-cotizar').hide();
		} else {
			$('#modelo-boton-cotizar').show();
		}
		$('#modelo-imprimir').attr('href', plantaUrl);

	return false;
}

function showDetailUbicacion( detail )
{
	$('a[href="' + detail + '"]').parents('#menu-ubicacion').find('ul').children().children().removeClass('selected');
	$('a[href="' + detail + '"]').parents('li').children().addClass('selected');
	$("#ubicacion_tab_acceso , #ubicacion_tab_plano").css("display","none");	
	$(detail).css("display","block");

	if ( detail == "#ubicacion_tab_plano" )
		showMapProject();

	return false;
}




function showProjects( ptype  )
{
	$(".btn_realizados, .btn_ventas, .btn_proximos").removeClass("active");
	$(".btn_realizados").removeClass("btn_realizados_active");
	$(".btn_ventas").removeClass("btn_ventas_active");
	$(".btn_proximos").removeClass("btn_proximos_active");
	if ( ptype == "R"  )
	{
		$(".btn_realizados").addClass("active").addClass("btn_realizados_active");
		// $(".btn_realizados").css("background","url(/assets/images/proyectos-realizados.jpg) no-repeat 0px -37px");

	}
	if ( ptype == "V"  )
		$(".btn_ventas").addClass("active").addClass("btn_ventas_active");
	if ( ptype == "P"  )
		$(".btn_proximos").addClass("active").addClass("btn_proximos_active");

	$(".carrusel-proyectos-home").html("<div align='center'><img src='/assets/images/loading.gif' width='128' height='15'  /></div>");

	$.ajax(	{
		url: "/inicio-proyectos.json/inicio-proyectos.tipo/depto/inicio-proyectos.estado/" + ptype , 
		dataType: "html" ,
		data: { "action" : "showProjects", "type" : ptype   , "n" : Math.random()  } ,
		success: function( rsp )
		{
			$(".carrusel-proyectos-home").empty();
			$(".carrusel-proyectos-home").html( rsp  );
			$('.inicio-proyectos-carouseldepto').jcarousel();
		}
	});		
	$.ajax(	{
		url: "/inicio-proyectos.json/inicio-proyectos.tipo/casa/inicio-proyectos.estado/" + ptype , 
		dataType: "html" ,
		data: { "action" : "showProjects", "type" : ptype   , "n" : Math.random()  } ,
		success: function( rsp )
		{
			$(".carrusel-proyectos-casas-home").empty();
			$(".carrusel-proyectos-casas-home").html( rsp  );
			$('.inicio-proyectos-carouselcasa').jcarousel();
		}
	});
	if(ptype == "V") {
		jQuery('div.mod-derecho div.proyectos-home').animate({'height': '620px'}, 1000);
	} else {
		jQuery('div.mod-derecho div.proyectos-home').animate({'height': '340px'}, 1000);
	}

}

function newsletterRegister()
{
	if (  $("#newsletter_mail").val()   )
	{
		$.ajax(	{
		url: "/json.php" , 
		dataType: "json" ,
		data: { "email" :  $("#newsletter_mail").val() , "n" : Math.random() , "option" : "newsletterRegister"  } ,
		success: function( rsp )
		{
			try {
				if ( rsp.status  )
				{
					
					/* Esto no puede ser un div */
					// $("#form-newsletter-thx").fadeIn(200);
					// $("#form-newsletter").fadeOut(200, function(){  $("#form-newsletter-thx").fadeIn(200)    }  );
					/* Esto no puede ser un alert */
					// alert("Gracias por inscribirte!");
					$("#form-newsletter-thx").fadeIn(200);
					//$("#form-newsletter").fadeOut(200, function(){  $("#form-newsletter-thx").fadeIn(200)    }  );

					setCookieLT("newsletterRegister", "1" , (3600/6)   , "/" );
				}
				else
				{
					alert( rsp.message );
				}
			} catch(e) {
				alert(e);
			}
		}
		});		
	}
}
function closeNewsletterRegister()
{
	$("#form-newsletter-thx").fadeOut(200);
	return false;
}







$(function(){
	
	//Anything Slider
	$('#sliderHome').anythingSlider({
		// Appearance
		width               : 648,      // Override the default CSS width
		height              : 354,      // Override the default CSS height
		resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
		tooltipClass        : 'tooltip', // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
		theme               : 'default', // Theme name
		themeDirectory      : 'css/theme-{themeName}.css', // Theme directory & filename {themeName} is replaced by the theme value above

		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : true,      // Should links change the hashtag in the URL?
		enableKeyboard      : true,      // if false, keyboard arrow keys will not work for the current panel.
		buildArrows         : true,      // If true, builds the forwards and backwards buttons
		toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
		buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
		enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
		toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
		appendControlsTo    : null,      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		forwardText         : "»", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		backText            : "«", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		// Slideshow options
		enablePlay          : true,      // if false, the play/stop button will still be visible, but not clickable.
		autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video is complete
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		playRtl             : false,     // If true, the slideshow will move right-to-left
		startText           : "Start",   // Start button text
		stopText            : "Stop",    // Stop button text
		delay               : 4000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		easing              : "swing",   // Anything other than "linear" or "swing" requires the easing plugin

		// Misc options
		addWmodeToObject    : "opaque", // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
		maxOverallWidth     : 32766     // Max width (in pixels) of combined sliders (side-to-side); set to 32766 to prevent problems with Opera
	});
	
	//Anything Slider
	$('#sliderGaleria').anythingSlider({
		// Appearance
		width               : 600,      // Override the default CSS width
		height              : 386,      // Override the default CSS height
		resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport
		tooltipClass        : 'tooltip', // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
		theme               : 'default', // Theme name
		themeDirectory      : 'css/theme-{themeName}.css', // Theme directory & filename {themeName} is replaced by the theme value above

		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : true,      // Should links change the hashtag in the URL?
		enableKeyboard      : true,      // if false, keyboard arrow keys will not work for the current panel.
		buildArrows         : true,      // If true, builds the forwards and backwards buttons
		toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
		buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
		enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
		toggleControls      : true,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
		appendControlsTo    : null,      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		forwardText         : "forwardText", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		backText            : "backText", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		// Slideshow options
		enablePlay          : true,      // if false, the play/stop button will still be visible, but not clickable.
		autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video is complete
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		playRtl             : false,     // If true, the slideshow will move right-to-left
		startText           : "Start",   // Start button text
		stopText            : "Stop",    // Stop button text
		delay               : 3000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		easing              : "swing",   // Anything other than "linear" or "swing" requires the easing plugin

		// Callbacks
		onBeforeInitialize  : null,      // Callback before the plugin initializes
		onInitialized       : null,      // Callback when the plugin finished initializing
		onShowStart         : null,      // Callback on slideshow start
		onShowStop          : null,      // Callback after slideshow stops
		onShowPause         : null,      // Callback when slideshow pauses
		onShowUnpause       : null,      // Callback when slideshow unpauses - may not trigger properly if user clicks on any controls
		onSlideInit         : null,      // Callback when slide initiates, before control animation
		onSlideBegin        : null,      // Callback before slide animates
		onSlideComplete     : null,      // Callback when slide completes

		// Interactivity
		clickArrows         : "click",         // Event used to activate arrow functionality (e.g. "click" or "mouseenter")
		clickControls       : "click focusin", // Events used to activate navigation control functionality
		clickSlideshow      : "click",         // Event used to activate slideshow play/stop button

		// Misc options
		addWmodeToObject    : "opaque", // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
		maxOverallWidth     : 32766     // Max width (in pixels) of combined sliders (side-to-side); set to 32766 to prevent problems with Opera
	});
	
	//Anything Slider
	$('#sliderProyecto').anythingSlider({
		// Appearance
		width               : 648,      // Override the default CSS width
		height              : 315,      // Override the default CSS height
		resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
		tooltipClass        : 'tooltip', // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
		theme               : 'default', // Theme name
		themeDirectory      : 'css/theme-{themeName}.css', // Theme directory & filename {themeName} is replaced by the theme value above

		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : true,      // Should links change the hashtag in the URL?
		enableKeyboard      : true,      // if false, keyboard arrow keys will not work for the current panel.
		buildArrows         : true,      // If true, builds the forwards and backwards buttons
		toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
		buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
		enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
		toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
		appendControlsTo    : null,      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		forwardText         : "»", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		backText            : "«", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		// Slideshow options
		enablePlay          : true,      // if false, the play/stop button will still be visible, but not clickable.
		autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video is complete
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		playRtl             : false,     // If true, the slideshow will move right-to-left
		startText           : "Start",   // Start button text
		stopText            : "Stop",    // Stop button text
		delay               : 4000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		easing              : "swing",   // Anything other than "linear" or "swing" requires the easing plugin

		// Misc options
		addWmodeToObject    : "opaque", // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
		maxOverallWidth     : 32766     // Max width (in pixels) of combined sliders (side-to-side); set to 32766 to prevent problems with Opera
	});
	
	//Anything Slider
	$('#sliderGaleria2').anythingSlider({
		// Appearance
		width               : 618,      // Override the default CSS width
		height              : 267,      // Override the default CSS height
		resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport
		tooltipClass        : 'tooltip', // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
		theme               : 'default', // Theme name
		themeDirectory      : 'css/theme-{themeName}.css', // Theme directory & filename {themeName} is replaced by the theme value above

		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : true,      // Should links change the hashtag in the URL?
		enableKeyboard      : true,      // if false, keyboard arrow keys will not work for the current panel.
		buildArrows         : true,      // If true, builds the forwards and backwards buttons
		toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
		buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
		enableNavigation    : true,      // if false, navigation links will still be visible, but not clickable.
		toggleControls      : true,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
		appendControlsTo    : null,      // A HTML element (jQuery Object, selector or HTMLNode) to which the controls will be appended if not null
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		forwardText         : "forwardText", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		backText            : "backText", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		// Slideshow options
		enablePlay          : false,      // if false, the play/stop button will still be visible, but not clickable.
		autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : false,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : false,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video is complete
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page

		playRtl             : false,     // If true, the slideshow will move right-to-left
		startText           : "Start",   // Start button text
		stopText            : "Stop",    // Stop button text
		delay               : 3000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		easing              : "swing"
	});
	//Colorbox
	try {
		$(".galeria-modelo a").colorbox({
			width:"675px", 
			height:"760px",
			onComplete: function() {
				/* Grrr */
				/*
				var plantaImage = $('#plantaimg').html().trim();
				var flashvars = {};
				flashvars.imgSrc = "/includes/thumbnailer.php/1024/1024/" + plantaImage;
					
				var params = {};  
				params.scale = "noScale";
				params.salign = "center";
				swfobject.embedSWF("/assets/swf/flexiZoomer.swf", "flashContent", "580", "390", "4.0.0","/assets/swf/expressInstall.swf", flashvars, params);
				*/
			}
		});
		$(".modelos-box").colorbox({
			width:"675px", 
			height:"775px"
		});
		$(".modelos-planta-box").colorbox({
			width:"675px", 
			height:"775px",
			onComplete: function() {
				/* FIXME: swfobject */
				var plantaImage;
				plantaImage = $('#plantaimg').html();
				plantaImage = plantaImage.replace(/^[ \n\r\t]*(.*)[ \n\r\t]*$/, '$1');
				var flashvars = {};
				flashvars.imgSrc = "/includes/thumbnailer.php/1024/1024/" + plantaImage;
					
				var params = {};  
				params.scale = "noScale";
				params.salign = "center";
				swfobject.embedSWF("/assets/swf/flexiZoomer.swf", "flashContent", "580", "390", "4.0.0","/assets/swf/expressInstall.swf", flashvars, params);
			}
		});
		$(".contacto-box").colorbox({
			width:"675px", 
			height:"775px"
		});

		$(".lightbox-ahorra").colorbox({
			width:"675px", 
			height:"775px",
			onComplete: function() {
				var a = $('#texto-container-lightbox').html();
				if(a == null) {
					return;
				}
				if(a.match(/<hr/i)) {
					$('#texto-container-lightbox').hrsep({
					'width': 618,
					'height': 'auto'
					});
					$('.hrsep .hrsep-message').hide();
				}
			}
		});
		$(".lightbox-nuestra-empresa").colorbox({
			width:"675px", 
			height:"775px",
			onComplete: function() {
				var a = $('#texto-container-lightbox').html();
				if(a == null) {
					return;
				}
				if(a.match(/<hr/i)) {
					$('#texto-container-lightbox').hrsep({
					'width': 583,
					'height': 'auto'
					});
					$('.hrsep .hrsep-message').hide();
				}
			}
		});
		$(".lightbox-subsidio").colorbox({
			width:"675px", 
			height:"775px",
			onComplete: function() {
				var a = $('#texto-container-lightbox').html();
				if(a == null) {
					return;
				}
				if(a.match(/<hr/i)) {
					var sal = false;
					var qqq = $('#texto-container-lightbox').html();
					if(qqq.match(/subsidio/i)) {
						sal = true;
					}
					$('#texto-container-lightbox').hrsep({
					'width': 618,
					'height': 'auto'
					});
					if(sal) {
						$('.hrsep .hrsep-message').show().html('Solicitar asesoría').click(function() {
							$(this).parent().parent().find('.hrsep-goto').eq(3).click();
						});
					}
				}
			}
		});


	
	
	
	
	//Acordion Home
		jQuery('.inicio-proyectos-carousel').jcarousel();

	$( "#slider-precioTotal" ).slider({
			range: true,
			min: glb_precios_min,
			max: glb_precios_max,
			values: [ glb_precios_min , glb_precios_max ],
			slide: function( event, ui ) {
				var escala = (ui.values[0]-glb_precios_min)/(glb_precios_max-glb_precios_min);
				escala = escala*escala;
				ui.values[0] = Math.round(escala*(glb_precios_max-glb_precios_min) + glb_precios_min);
				escala = (ui.values[1]-glb_precios_min)/(glb_precios_max-glb_precios_min);
				escala = escala*escala;
				ui.values[1] = Math.round(escala*(glb_precios_max-glb_precios_min) + glb_precios_min);



				$( "#amount" ).val( "UF " + ui.values[ 0 ] + " - UF " + ui.values[ 1 ] );
				$("#precio-total").val( $( "#slider-precioTotal" ).slider( "values", 0 )+","+$( "#slider-precioTotal" ).slider( "values", 1 )   );
			}
		});
		
	    $( "#slider-dividendos" ).slider({
			range: true,
			min: dminimo,
			max: dmaximo,
			values: [ dminimo, dmaximo ],
			slide: function( event, ui ) {
				var escala = (ui.values[0]-dminimo)/(dmaximo-dminimo);
				escala = escala*escala;
				ui.values[0] = Math.round(escala*(dmaximo-dminimo) + dminimo);
				escala = (ui.values[1]-dminimo)/(dmaximo-dminimo);
				escala = escala*escala;
				ui.values[1] = Math.round(escala*(dmaximo-dminimo) + dminimo);
				$( "#amount2" ).val( "$ " + ui.values[ 0 ] + " - $ " + ui.values[ 1 ] );
				$("#precio-dividendo").val( $( "#slider-dividendos" ).slider( "values", 0 ) + "," + $( "#slider-dividendos" ).slider( "values", 1 )  );
			}
		});
		$( "#amount" ).val( "UF " + $( "#slider-precioTotal" ).slider( "values", 0 ) +
			" - UF " + $( "#slider-precioTotal" ).slider( "values", 1 ) );

		$("#precio-total").val( $( "#slider-precioTotal" ).slider( "values", 0 )+","+$( "#slider-precioTotal" ).slider( "values", 1 )   );

		$( "#amount2" ).val( "$ " + $( "#slider-dividendos" ).slider( "values", 0 ) +
		" - $ " + $( "#slider-dividendos" ).slider( "values", 1 ) );
		
		$("#precio-dividendo").val( $( "#slider-dividendos" ).slider( "values", 0 ) + "," + $( "#slider-dividendos" ).slider( "values", 1 )  );

		showProjects('V');
	} catch(e) {
	}
});


function open_posventa()
{
	if (document.Form1.acepto.checked)  {
		$.colorbox({
			width:"675px", 
			height:"775px",
			href:'formulario-posventa.html'
		});
		// return document.MM_returnValue;
	} else {
		alert('Por favor acepte las condiciones antes de ir al formulario.');
	}
	return false;
}




$(document).ready(function(){
$(".titulo-pestana:first").addClass("actived");
$(".tab_info_mini:first").fadeIn("fast");
$(".titulo-pestana").click( function(){
	$(".titulo-pestana").removeClass("actived");
	$(this).addClass("actived");
	var idtab = $(this).attr("id");
	$(".tab_info_mini").hide();
	$("#tab_content"+idtab).fadeIn("fast");
	
});	

if ( typeof getCookie != 'undefined' && getCookie("newsletterRegister")  )
{
	//$("#form-newsletter-thx").html("Ya estas registrado!");
	//$("#form-newsletter").fadeOut(200, function(){  $("#form-newsletter-thx").fadeIn(200)    }  );
}

});





