jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};
//$(".rentalproperty").css("border","3px solid red");							  
	//$("#realEstate_VL>.rightArrows_VL").css("border","3px solid red");
	
/*
$('#showAllVacationRentals').css({display: 'block', visibility: 'visible'});
$('#showAllHomesForSale').css({display: 'block', visibility: 'visible'});
$('#showAllRealEstate').css({display: 'block', visibility: 'visible'});
$('#showAllBusinesses').css({display: 'block', visibility: 'visible'});
*/	
$( document ).ready( function(){

	$('#principalContent_VL').supersleight({shim: '/style/x.gif'});
							  
	//$('#bannerads> a').removeClass("firstAd");							  

	//Gets all childs div of vacationRentalContent and hides them except the first one
	var vacationRentalsContent = $('#vacationRentalContent');
	vacationRentalsContent.css({display: 'inline'});
    var divsVacationRentals = vacationRentalsContent.find( '> div' );       
	
        
    if( divsVacationRentals.size( ) > 0 ){
		
		var title = divsVacationRentals.eq(0).find('> h3');
		var texto = title.find('> a').text();
		
        if (divsVacationRentals.size( ) != 1){
			
			if (texto.substring(0, 27) == 'Million Dollar View (Sa ...'){
				divsVacationRentals.eq( 0 ).remove();
			}
			divsVacationRentals = vacationRentalsContent.find( '> div' );
			//alert(divsVacationRentals.size());
			
			for (i = 0; i < divsVacationRentals.size( ); i++){
			  
				divsVacationRentals.eq( i + 1 ).hide();                                        
			}
		}
    }
	
	if (divsVacationRentals.size( ) > 1)
	{
		$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	
	//Vacation Rentals arrow actions code
	var j = 0; //index for vacation rental Elements
	$("#vacationRentals_VL>.rightArrows_VL").click(function(){
		
		j++;
		//alert(j);
		

		if ( ( divsVacationRentals.size() > 0) && (j == divsVacationRentals.size()-1) ){
			$("#vacationRentals_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( j >= 0 ) && ( j < divsVacationRentals.size() ) ){

			$('#vacationRentalContent').children().hide("normal").eq(j).slideDown("slow");
			$("#vacationRentals_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
			//$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.png) no-repeat 0 50%'});
		}
		
		if (j >= divsVacationRentals.size()){
			j= divsVacationRentals.size() - 1;
		}
		
	});
	
	$("#vacationRentals_VL>.leftArrows_VL").click(function(){
		


		j--;
		//alert(j);
		if ( (j == 0) && (divsVacationRentals.size() > 0) ){
			$("#vacationRentals_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( j >= 0 ) && ( j < divsVacationRentals.size() ) ){

			$('#vacationRentalContent').children().hide("normal").eq(j).slideDown("slow");
			$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (j < 0){
			j= 0;
		}
		
	});
	
	//Gets all childs div of homesForSaleContent and hides them except the first one
	var homesForSaleContent = $("#forSale_VL>.middleContent>#homesForSaleContentParent");
    var divsHomesForSale = homesForSaleContent.find( '> div' );       

    if( divsHomesForSale.size( ) > 0 ){
		for (i = 0; i < divsHomesForSale.size( ); i++){
			divsHomesForSale.eq( i + 1 ).hide();                                        
		}		
    }
	
	
	if (divsHomesForSale.size( ) > 1)
	{
		$("#forSale_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	
	var rentalIndex = 0; //index for vacation rental Elements
	$("#forSale_VL>.rightArrows_VL").click(function(){
		
		rentalIndex++;
		//alert(rentalIndex);
		

		if ( ( divsHomesForSale.size() > 0) && (rentalIndex == divsHomesForSale.size()-1) ){
			$("#forSale_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#forSale_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( rentalIndex >= 0 ) && ( rentalIndex < divsHomesForSale.size() ) ){

			$('#homesForSaleContentParent').children().hide("normal").eq(rentalIndex).slideDown("slow");
			$("#forSale_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
			//$("#vacationRentals_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.png) no-repeat 0 50%'});
		}
		
		if (rentalIndex >= divsHomesForSale.size()){
			rentalIndex= divsHomesForSale.size() - 1;
		}
		
	});
	
	$("#forSale_VL>.leftArrows_VL").click(function(){
		

		rentalIndex--;
		//alert(rentalIndex);
		if ( (rentalIndex == 0) && (divsHomesForSale.size() > 0) ){
			$("#forSale_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#forSale_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( rentalIndex >= 0 ) && ( rentalIndex < divsHomesForSale.size() ) ){

			$('#homesForSaleContentParent').children().hide("normal").eq(rentalIndex).slideDown("slow");
			$("#forSale_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (rentalIndex < 0){
			rentalIndex= 0;
		}
		
	});
	
	
	/****************/

	//Gets all <li> from <ud id="RealEstateList"> and hides them except the first one
	var realEstateContent = $('#RealEstateList');
	var RealEstateLi = realEstateContent.find( '> li' );
	if( RealEstateLi.size( ) > 0 ){
        
		for (i = 0; i < RealEstateLi.size( ); i++){
		  
			RealEstateLi.eq( i + 1 ).hide();                                        
			
		}
    }
	
	if (RealEstateLi.size( ) > 1)
	{
		$("#realEstate_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	
	//Real Estate Arrows action code
	var k = 0; //index for Real Estate Elements
	$("#realEstate_VL>.rightArrows_VL").click(function(){
		
		k++;
		//alert(j);
		if ((RealEstateLi.size() > 0) && (k == RealEstateLi.size( )-1))
		{
			$("#realEstate_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#realEstate_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( k >= 0 ) && ( k < RealEstateLi.size() ) ){

			$('#RealEstateList').children().hide("normal").eq(k).slideDown("slow");
			$("#realEstate_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
		}
		
		if (k >= RealEstateLi.size()){
			k= RealEstateLi.size() - 1;
		}
		
	});
	
	$("#realEstate_VL>.leftArrows_VL").click(function(){
		
		k--;
		//alert(j);
		
		if ( (k == 0) && (divsVacationRentals.size() > 0) ){
			$("#realEstate_VL>.leftArrows_VL").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#realEstate_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( k >= 0 ) && ( k < RealEstateLi.size() ) ){

			$('#RealEstateList').children().hide("normal").eq(k).slideDown("slow");
			$("#realEstate_VL>.rightArrows_VL").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (k < 0){
			k= 0;
		}
		
	});
	
	/*
		$('#genericamenitiesSectionBusiness')
		$('#eatingSectionBusiness')
		$('#attractionSectionBusiness')
		$('#boataccessSectionBusiness')
	*/
	
	
	
	
	//Gets all <div class="amenity"> generiBusiness and hides them except the first one
	var genericamenitiesHasInfo= 0;
	var eatingHasInfo= 0;
	var attractionHasInfo= 0;
	var boataccessHasInfo= 0;
	
	
	var businessGeneri = $('#generiBusiness');
	var genericamenities = businessGeneri.find( '> div' );
	if( genericamenities.size( ) > 0 ){
        
		for (i = 0; i < genericamenities.size( ); i++){
		  
			genericamenities.eq( i + 1 ).hide();                                        
			
		}
		
		genericamenitiesHasInfo = 1;
    }
	
	if (genericamenities.size( ) > 1)
	{
		$("#rightArrowGeneriBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	//alert(genericamenities.size());
	//generiBusiness arrows action code
	var g = 0; //index for Business-Restaurant elements
	$('#rightArrowGeneriBusiness').click(function(){
		
		g++;
		//alert(b);
		if ( ( genericamenities.size() > 0) && (g == genericamenities.size()-1) ){
			$("#leftArrowGeneriBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#rightArrowGeneriBusiness").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( g >= 0 ) && ( g < genericamenities.size() ) ){

			businessGeneri.children().hide("normal").eq(g).slideDown("slow");
			$("#leftArrowGeneriBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
		}
		
		if (g >= genericamenities.size()){
			g= genericamenities.size() - 1;
		}
		
	});
	
	$('#leftArrowGeneriBusiness').click(function(){
		
		g--;
//		alert(b);
		if ( (g == 0) && (genericamenities.size() > 0) ){
			$("#leftArrowGeneriBusiness").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#rightArrowGeneriBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( g >= 0 ) && ( g < genericamenities.size() ) ){

			businessGeneri.children().hide("normal").eq(g).slideDown("slow");
			$("#rightArrowGeneriBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (g < 0){
			g= 0;
		}
		
	});
	
	//Gets all <div class="amenity"> Restaurants-Business and hides them except the first one
	var businessRestaurants = $('#businessRestaurants');
	var restaurants = businessRestaurants.find( '> div' );
	if( restaurants.size( ) > 0 ){
        
		for (i = 0; i < restaurants.size( ); i++){
		  
			restaurants.eq( i + 1 ).hide();                                        
			
		}
		
		eatingHasInfo = 1;
    }
	
	if (restaurants.size() > 1)
	{
		$("#rightArrowRestBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	
	//Business-Restaurant arrows action code
	var b = 0; //index for Business-Restaurant elements
	$('#rightArrowRestBusiness').click(function(){
		
		b++;
		//alert(b);
		
		if ( ( restaurants.size() > 0) && (b == restaurants.size()-1) ){
			$("#leftArrowRestBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#rightArrowRestBusiness").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( b >= 0 ) && ( b < restaurants.size() ) ){

			businessRestaurants.children().hide("normal").eq(b).slideDown("slow");
			$("#leftArrowRestBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
		}
		
		if (b >= restaurants.size()){
			b= restaurants.size() - 1;
		}
		
	});
	
	$('#leftArrowRestBusiness').click(function(){
		
		b--;
//		alert(b);
		if ( (b == 0) && (restaurants.size() > 0) ){
			$("#leftArrowRestBusiness").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#rightArrowRestBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( b >= 0 ) && ( b < restaurants.size() ) ){

			businessRestaurants.children().hide("normal").eq(b).slideDown("slow");
			$("#rightArrowRestBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (b < 0){
			b= 0;
		}
		
	});
	
	
	//Gets all <div class="amenity"> businessAtraction and hides them except the first one
	var businessAtractions = $('#businessAtraction');
	var atractions = businessAtractions.find( '> div' );
	if( atractions.size( ) > 0 ){
        
		for (i = 0; i < atractions.size( ); i++){
		  
			atractions.eq( i + 1 ).hide();                                        
			
		}
		
		attractionHasInfo = 1;
    }
	
	if (atractions.size( ) > 1)
	{
		$("#rightArrowAtractionBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	//alert(atractions.size());
	//businessAtraction arrows action code
	var a = 0; //index for Business-Restaurant elements
	$('#rightArrowAtractionBusiness').click(function(){
		
		a++;
		//alert(b);
		if ( ( atractions.size() > 0) && (a == atractions.size()-1) ){
			$("#leftArrowAtractionBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#rightArrowAtractionBusiness").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( a >= 0 ) && ( a < atractions.size() ) ){

			businessAtractions.children().hide("normal").eq(a).slideDown("slow");
			$("#leftArrowAtractionBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
		}
		
		if (a >= atractions.size()){
			a= atractions.size() - 1;
		}
		
	});
	
	$('#leftArrowAtractionBusiness').click(function(){
		
		a--;
//		alert(b);
		if ( (a == 0) && (atractions.size() > 0) ){
			$("#leftArrowAtractionBusiness").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#rightArrowAtractionBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( a >= 0 ) && ( a < atractions.size() ) ){

			businessAtractions.children().hide("normal").eq(a).slideDown("slow");
			$("#rightArrowAtractionBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (a < 0){
			a= 0;
		}
		
	});
	
	//Gets all <div class="amenity"> businessBoat and hides them except the first one
	var businessBoats = $('#businessBoat');
	var boats = businessBoats.find( '> div' );
	if( boats.size( ) > 0 ){
        
		for (i = 0; i < boats.size( ); i++){
		  
			boats.eq( i + 1 ).hide();                                        
			
		}
		boataccessHasInfo = 1;
    }
	
	if (boats.size( ) > 1)
	{
		$("#rightArrowBoatBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});	
	}
	//	alert(boats.size());
	//businessBoat arrows action code
	var boat = 0; //index for Business-Restaurant elements
	$('#rightArrowBoatBusiness').click(function(){
		
		boat++;
		//alert(b);
		if ( ( boats.size() > 0) && (boat == boats.size()-1) ){
			$("#leftArrowBoatBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});	
			$("#rightArrowBoatBusiness").css({background: 'url(../style/Arrow_right.gif) no-repeat 0 50%'});			
		}
		
		if ( ( boat >= 0 ) && ( boat < boats.size() ) ){

			businessBoats.children().hide("normal").eq(boat).slideDown("slow");
			$("#leftArrowBoatBusiness").css({background: 'url(../style/Arrow_leftActive.gif) no-repeat 0 50%'});
		}
		
		if (boat >= boats.size()){
			boat= boats.size() - 1;
		}
		
	});
	
	$('#leftArrowBoatBusiness').click(function(){
		
		boat--;
		if ( (boat == 0) && (boats.size() > 0) ){
			$("#leftArrowBoatBusiness").css({background: 'url(../style/Arrow_left.gif) no-repeat 0 50%'});
			$("#rightArrowBoatBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if ( ( boat >= 0 ) && ( boat < boats.size() ) ){

			businessBoats.children().hide("normal").eq(boat).slideDown("slow");
			$("#rightArrowBoatBusiness").css({background: 'url(../style/Arrow_rightActive.gif) no-repeat 0 50%'});
		}
		
		if (boat < 0){
			boat= 0;
		}
		
	});
	
	var randomnumber= Math.floor(Math.random()*4);
	
	var continuar= 1;
	while (	continuar != 0 )
	{
		if ( (randomnumber == 0) && (genericamenitiesHasInfo == 0) ){
			randomnumber= Math.floor(Math.random()*4);
		}
		else{
			continuar = 0;
		}
		
		if ( (randomnumber == 1) && (eatingHasInfo == 0) ){
			randomnumber= Math.floor(Math.random()*4);
		}
		else{
			continuar = 0;
		}
		
		if ( (randomnumber == 2) && (attractionHasInfo == 0) ){
			randomnumber= Math.floor(Math.random()*4);
		}
		else{
			continuar = 0;
		}
		
		if ( (randomnumber == 3) && (boataccessHasInfo == 0) ){
			randomnumber= Math.floor(Math.random()*4);
		}
		else{
			continuar = 0;
		}
		
	}

	
	switch (randomnumber){
		
		case 0:
		//alert (randomnumber);
			$( '#genericamenitiesSectionBusiness' ).css({display: 'block', visibility: 'visible'});
		break;
		
		case 1:
		//alert (randomnumber);
			$( '#eatingSectionBusiness' ).css({display: 'block', visibility: 'visible'});
		break;
		
		case 2:
		//alert (randomnumber);
			$( '#attractionSectionBusiness').css({display: 'block', visibility: 'visible'});
		break;
		
		case 3:
		//alert (randomnumber);
			$( '#boataccessSectionBusiness' ).css({display: 'block', visibility: 'visible'});
		break;
	}
	
	/*/Mouse Over efect for arrows
	$( ".leftArrows_VL").mouseover(
	    function () {
            $(this).css({background: 'url(../style/Arrow_leftActive.png) no-repeat 0 50%'});
        }).mouseout(function(){
            $(this).css({background: 'url(../style/Arrow_left.png) no-repeat 0 50%'});
    });
	
	$( ".rightArrows_VL").mouseover(
        function () {
            $(this).css({background: 'url(../style/Arrow_rightActive.png) no-repeat 0 50%'});
        }).mouseout(function(){
            $(this).css({background: 'url(../style/Arrow_right.png) no-repeat 0 50%'});
    });*/
	
});