function getViewportSize(){
    var size = [0, 0];
    if (typeof window.innerWidth != 'undefined')
    {
		size = [ window.innerWidth, window.innerHeight ];
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
    {
		size = [ document.documentElement.clientWidth, document.documentElement.clientHeight ];
    }
    else
    {
		size = [ document.getElementsByTagName('body')[0].clientWidth,
				 document.getElementsByTagName('body')[0].clientHeight ];
    }
    return size;    
}

function newsslider_resize(){
	anchura_noticia = 200;
	anchura_bloque = 560;
	anchura_pagina = 960;
	size = getViewportSize();
	
	jQuery(".news_slider").accessNews({
		newsHeadline: "Noticias recientes",
		newsSpeed: "slow",
		easing: "BounceEaseOut",
		slide: 1
	});
				
	if(size[0]<1003) {
		jQuery('.news_items').css('width', 290 + 'px');
		jQuery('#desplegable').css('width', 240 + 'px');
		jQuery('#desplegable').css('float', 'left');
		jQuery('.news_slider').css('width', 330 + 'px');
		jQuery('.news_slider .next').css('right', 3 + 'px');
		jQuery('#slidercontainer').css('width', 330 + 'px');
		/* NEWS SLIDER */

	}
	else {
		jQuery('.news_items').css('width', anchura_bloque + 'px');
		jQuery('#desplegable').css('width', '100%');
		jQuery('.news_slider').css('width', 600 + 'px');
		jQuery('.news_slider .next').css('right', 10 + 'px');
		jQuery('#slidercontainer').css('width', 600 + 'px');
		
	}
	
	
	var IE6=false/*@cc_on||@_jscript_version<5.7@*/;
	if(IE6) {
		jQuery('.news_slider .prev').css('display','block');
	}
	
}

/* Scroll To */
function InitScrollto() {
	if ( jQuery("#skiptocontent a").length ) {
		jQuery('#skiptocontent a').click(function(e){
			jQuery.scrollTo( jQuery('#skiptocontent a').attr('href'), {speed:750, easing: 'linear'} );
			return false;
		});
	}
	if ( jQuery("#backtotop a").length ) {
		jQuery('#backtotop a').click(function(e){
			jQuery.scrollTo( jQuery('#backtotop a').attr('href'), {speed:750, easing: 'linear'} );
			return false;
		});
	}
}


/* Tooltips */	  
function InitTooltips(){

    jQuery('.tooltip').tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    showBody: " - ", 
	    extraClass: "pretty", 
	    fixPNG: true, 
	    left: -120 
	});
	
}


function Iniciar() {
	InitScrollto();
	newsslider_resize();

	if ( jQuery("p#showmailform a").length) {
		jQuery("#form-index").css('display', 'none');
		jQuery("p#showmailform a").click(function () {
			jQuery("#form-index").fadeIn();
			return false;
		});
		output = '<a class="close-form fir" href="#" title="Hide this form">Hide this form<span>&nbsp;</span></a>';
		jQuery("#form-index").append(output);
		jQuery("a.close-form").click(function () {
			jQuery("#form-index").fadeOut();
			return false;
		});
	}
	
	if ( jQuery("#showmailform2 a").length) {
		jQuery("#form-services").css('display', 'none');
		jQuery("#showmailform2 a").click(function () {
			jQuery("#form-services").fadeIn();
			return false;
		});
		output = '<a class="close-form fir" href="#" title="Hide this form">Hide this form<span>&nbsp;</span></a>';
		jQuery("#form-services").append(output);
		jQuery("a.close-form").click(function () {
			jQuery("#form-services").fadeOut();
			return false;
		});
	}

	if ( jQuery('.col,#row1col1, #row1col2, #row2col1, #row2col2, #row2col3, #row3col1, #row3col2, #row4col1, #row4col2,#footercol1, #footercolmid, #footercol2, #nov-col-dcha,#fcontact, #fskype, #faddress').length ) {
		jQuery("#row1col1, #row1col2").equalizeCols();
		jQuery("#row2col1, #row2col2, #row2col3").equalizeCols();
		jQuery("#row3col1, #row3col2, #row4col1, #row4col2").equalizeCols();
		jQuery("#row4col1, #row4col2").equalizeCols();
		jQuery("#footercol1, #footercolmid, #footercol2").equalizeCols();
		//jQuery("#fcontact, #fskype, #faddress").equalizeCols();			
	}



	/* PAGER */
	if ( jQuery(".paged").length ) {
		jQuery('.paged').pager('p', {
			navId: 'pagednav',
			height: ''
		});
	}

	/* Ability */
	if ( jQuery("#accessibility").length ) {
			/* Print */
		if ( jQuery('#accessibility').length ) {
			jQuery('#accessibility').addPrintLink('Print');
		}
		
	}

	/* Add Flash */
	if(jQuery('#add_flash').length) {
		jQuery('#add_flash').flash(
			{ src: pathToTheme+'/images/flash.swf' }, 
			{ expressInstall: true }
		);
	}
	
	if ( jQuery('#geomap').length ) {
		if (GBrowserIsCompatible())	{ 
			map = new GMap2(document.getElementById("geomap"),'G_MAP_TYPE');
			map.addControl(new GLargeMapControl());
			geocoder = new GClientGeocoder();
			pintar_mi_globito(mi_latitud, mi_longitud);
			pintar_otros_globitos(latitudes, longitudes);
		}
	}

	/* Validate */
	/*
	if ( jQuery('#cformsform').length ) {
		jQuery("#cformsform").validate({
			errorElement: "span",
			success: "valid",
	
			rules: {
				cf_field_2: {
					required: true
				},
				cf_field_3: {
					required: true,
					email: true
				},
				cf_field_8: {
					required: true
				}
			},

			messages: {
				cf_field_2: "Please enter your name",
				cf_field_3: "Please enter a valid email address",
				cf_field_8: "Please enter a message"
			}		
		});
	}
*/

	/* Validate */
	/*
	if ( jQuery('#cforms2form').length ) {
		jQuery("#cforms2form").validate({
			errorElement: "span",
			success: "valid",
	
			rules: {
				cf2_field_2: {
					required: true
				},
				cf2_field_5: {
					required: true,
					email: true
				}
			},

			messages: {
				cf_field_2: "Please enter your name",
				cf_field_3: "Please enter a valid email address"
			}		
		});
	}
*/

	/* Plegable */
	if ( jQuery('#plegable').length ) {
		jQuery('#plegable').hide();
		jQuery('a#plegable_a').click(function() {
			jQuery('#plegable').toggle(400);
			return false;
		});
	}

	/* Animate */
	if ( jQuery('#go').length ) {
		jQuery("#go").click(function(){
		  jQuery("#block").animate({ 
			width: "90%", 
			fontSize: "7em",
			backgroundColor: '#FF3300'
		  }, 1000 ); 
		});
	}
	
	if ( jQuery('#form_appointments').length ) {
		jQuery("#form_appointments ul").hide();
		jQuery("#form_appointments a").click(function(){
		 yo = jQuery(this);
		 jQuery("#form_appointments ul").hide();
		  jQuery(this).parent().find("ul").not(jQuery(this)).toggle(
				function(){
				yo.animate(500);
				}
			);
		  return false;
		}).focus();
	}
	
//	/* PNG Fix */
//	if ( jQuery("img[@srcjQuery=png]").length ) {
//		jQuery.ifixpng(pathToTheme + '/images/pixel.gif');
//		jQuery("img[@srcjQuery=png]").ifixpng();
//	}

	/*Carousel */
	if ( jQuery("#mycarousel").length ) {
		jQuery('#mycarousel').jcarousel({
			easing: 'BounceEaseOut',
			animation: 1000
		});
	}

	/* ZEBRA */
	/*jQuery("table.data").each(function(){
  		jQuery("tr:odd", this).addClass("odd");
	});*/
	
	if ( jQuery("table").length ) {
		jQuery("table").each(function(){
			jQuery("tr:odd", this).addClass("odd");
		});
	}
	
	//COOKIE SORT
	jQuery('#myTable th').click(function() {
  
  if(jQuery.cookie("sort") == this.cellIndex)
  {
  	
  	if(jQuery.cookie("ad") == 0)
  	{
  		jQuery.cookie("ad", 1);
  	}
  	else
  	{
  		jQuery.cookie("ad", 0);
  	}
  }
  else
  {
  	jQuery.cookie("sort", this.cellIndex);
  	jQuery.cookie("ad", 0);
  }
  
  //alert(jQuery.cookie("sort"));
  //alert(jQuery.cookie("ad"));
  //alert(jQuery.cookie("sort").length);
});
	
		
		
	// TABLE SORTER
//	if ( jQuery("#myTable").length ) {
//		jQuery(document).ready(function(){        
//			jQuery("#myTable").tableSorter();
//			     
//		} ); 
//	}
	if ( jQuery("#myTable").length ) {
	jQuery(document).ready(function() 
    { 	
    	
    		if(jQuery.cookie("sort"))
    		{
       		jQuery("#myTable").tablesorter({sortList: [[jQuery.cookie("sort"),jQuery.cookie("ad")]]}); 
     		}
     		else
     		{
     			jQuery("#myTable").tablesorter({sortList: [[0,0]]}); 
     		}
     		
        
    }
    
		);}
	
	//REMOVE FORM LINK	
	jQuery(document).ready(function() 
    { 	

    		jQuery("#ll").remove();
     		
    });	
	jQuery(window).load(function() 
    { 	
		jQuery('#long_term_rental_map').css('display', 'block');
     		
    });
	
	
	

	/* SCROLL TO */
	if ( jQuery("#scrollToID").length ) {
		jQuery('#scrollToID').click(function(e){
			jQuery.scrollTo( jQuery('#news'), {speed:2500} );
			return false;
		});
	}


	/* Acordion */
	if ( jQuery(".list1").length ) {
		jQuery('.list1').Accordion({
			active: false // By default the first child element is displayed. Set active to false and no child element is displayed.
		});

		// set global defaults for all following Accordions, will be valid for #list1, #list2 
		jQuery.Accordion.setDefaults({
			showSpeed: 1000,
			hideSpeed: 150
		});
	}
		
	// bind to change event of select to control first and seconds accordion
	// similar to tab's plugin triggerTab(), without an extra method
	if ( jQuery("#switch select").length ) {
		jQuery('#switch select').change(function() {
			jQuery('.list1').activate( this.selectedIndex-1 );
		});
	}



	jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	};
}

			jQuery(document).ready(function(){
				jQuery('#cf3_field_12-1').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_12-2').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_12-3').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_12-4').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_12-5').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_15-1').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_15-2').addClass('styled').css('display', 'none');	
				jQuery('#cf3_field_16-1').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_16-2').addClass('styled').css('display', 'none');	
				jQuery('#cf3_field_17-1').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_17-2').addClass('styled').css('display', 'none');	
				jQuery('#cf3_field_18-1').addClass('styled').css('display', 'none');
				jQuery('#cf3_field_18-2').addClass('styled').css('display', 'none');
				jQuery('#ENQUIRY-TYPE').attr('class', '');
				jQuery('#ENQUIRY-TYPE').attr('class', 'styled');
				jQuery('#sendbutton3').attr('value', '');
				jQuery('#sendbutton3').attr('style', '');
				jQuery('#your_name_val').click(function(){
					jQuery('#your_name_val').css('display', 'none');
					setTimeout(function(){jQuery('#your_name').focus();},10);
					
				});
				jQuery('#your_email_val').click(function(){
					jQuery('#your_email_val').css('display', 'none');
					setTimeout(function(){jQuery('#your_email').focus();},10);
				});
				jQuery('#your_name').focus(function(){
					jQuery('#your_name_val').css('display', 'none');
				});
				jQuery('#your_email').focus(function(){
					jQuery('#your_email_val').css('display', 'none');
				});
				jQuery('#your_name').blur(function(){
					var your_name = jQuery('#your_name').val();
					if(your_name.length == 0)
						jQuery('#your_name_val').css('display', 'block');
				});
				jQuery('#your_email').blur(function(){
					var your_name = jQuery('#your_email').val();
					if(your_name.length == 0)
						jQuery('#your_email_val').css('display', 'block');
				});
			});


addEvent_before(window, 'DOMContentLoaded', Iniciar);	
window.onresize = newsslider_resize;

//css map style patch
jQuery(document).ready(function(){
	
	jQuery('#multi_map_js_link_36844').click(function(){
		
		jQuery('#lightbox-imageBox').css("border","none");
		jQuery('#lightbox #lightbox-imageBox').css("min-width","946px");
		jQuery('#lightbox-image').css("height","775px");
		jQuery('#lightbox-image').css("width","1000px");
		jQuery('#lightbox-imageBox').css("height","775px");
		jQuery('#lightbox-infoBox').remove();
		
		});
	
	});
