﻿

//for projector
var CurrentImage = 0;
var ct;
var Btnnext;
var text;
var count = 0;
var Targetdiv;

function projector() {
    var sliderImagesContentWidth = 650 * propertiesForProjector;
    jQuery("#sliderImagesContent").css('width', sliderImagesContentWidth);
    MoveToImage(CurrentImage, jQuery("div[rel=Img0]"));




}
function MoveToImage(ImageNum, Btn) {
    CurrentImage = ImageNum;
    jQuery("#DisplayText").text("");
    clearTimeout(ct);
    var leftPos = -(ImageNum * 650);
    $("#sliderImagesContent").stop().animate({
        left: leftPos
    }, 1000, function() {
        // Animation complete.
    });
    jQuery(".sliderButtonHover").removeClass("sliderButtonHover").addClass("sliderButton");
    jQuery(Btn).removeClass("sliderButton");
    jQuery(Btn).addClass("sliderButtonHover");



    Typeit(jQuery("#Txt" + CurrentImage).text(), jQuery("#DisplayText"));



}
function Typeit(TextToType, DivToType) {
    text = TextToType;

    count = 0;
    type(DivToType);
}
function character(start, end, text) {
    return text.substring(start, end);

}
function type(DivToType) {




    jQuery(DivToType).append(character(count, count + 1, text));
    count++;

    if (count == text.length) {

        CurrentImage = CurrentImage + 1;

        if (CurrentImage == propertiesForProjector) {
            CurrentImage = 0;
        }
        Btnnext = jQuery("div[rel=Img" + CurrentImage + "]");

        setTimeout(function() { jQuery(DivToType).text(""); MoveToImage(CurrentImage, Btnnext); }, 3000);


    } else {
        ct = setTimeout(function() { type(DivToType); }, 70);
    }
}
function ResizeProjectImage(MaxHeight, MaxWidth, Image1) {

    var max_height = MaxHeight;
    var max_width = MaxWidth;

    if (jQuery(Image1).height() > jQuery(Image1).width()) {
      
        var h = max_height;
        var w = Math.ceil(jQuery(Image1).width() / jQuery(Image1).height() * max_height);
        if (w > max_width) {

            h = Math.ceil(h / w * max_width);
            w = max_width;
        }
    } else {
 
        var w = max_width;
        var h = Math.ceil(jQuery(Image1).height() / jQuery(Image1).width() * max_width);
        if (h > max_height){

            w = Math.ceil(w / h * max_height);
            h = max_height;
        }
    }
    jQuery(Image1).css({ height: h, width: w });



}
function ShowSlide(EstateID) {
    jQuery("a[rel='SlideShow" + EstateID + "']").colorbox();
    
}
function pageLoad() {
    jQuery(".DivProperty").hover(function() {
        var imageJQObject = jQuery(this).find("img[rel='MainImage']");
$("img[rel='MainImage']")


        if (imageJQObject.length > 0) {

            var ImageWidth = jQuery(this).find("img[rel='MainImage']").width();
            var ImageHeight = jQuery(this).find("img[rel='MainImage']").height();
            if (ImageWidth < 215 && ImageWidth > 50 && ImageHeight < 215) {
                jQuery.data(this, 'ImageWidth', ImageWidth);
                jQuery.data(this, 'ImageHeight', ImageHeight);
                jQuery(".DivProperty").stop(true, true);
                var newWidth = parseInt(ImageWidth + 0.3 * ImageWidth);
                var newHeight = parseInt(ImageHeight + 0.3 * ImageHeight);

                jQuery(this).find(".PropertyImageDiv").stop(true, true).animate({ marginTop: '-110px', /* The next 4 lines will vertically align this image */
                marginTop: '-20px',
                marginBottom: '-20px',
                marginRight: '-20px',
                marginLeft: '-20px',
                    top: '-10px',
                    left: '-20px'
                }, 200);
                jQuery(this).find("img[rel='MainImage']").stop(true, true).animate({

                    width: newWidth, /* Set new width */
                    height: newHeight /* Set new height */

                }, 200);
            } 
        }

    }, function() {


        jQuery(this).find(".PropertyImageDiv").stop(true, true).animate({ marginTop: '0', /* The next 4 lines will vertically align this image */
        marginTop: '5px',
        marginBottom: '5px',
        marginRight: '5px',
        marginLeft: '5px',
            top: '10px',
            left: '0px'
        }, 200);
        jQuery(this).find("img[rel='MainImage']").stop(true, true).animate({
            width: jQuery.data(this, 'ImageWidth'), /* Set width back to default */
            height: jQuery.data(this, 'ImageHeight') /* Set height back to default */
        }, 400);
    });
}

			


