﻿
//for projector
var CurrentImage = 0;
var ct;
var Btnnext;
var text;
var count = 0;
var Targetdiv;

function projector() {
    var sliderImagesContentWidth = 620 * 5;
    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 * 620);
    $("#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 == 5) {
            CurrentImage = 0;
        }
        Btnnext = jQuery("div[rel=Img" + CurrentImage + "]");

        setTimeout(function() { jQuery(DivToType).text(""); MoveToImage(CurrentImage, Btnnext); }, 3000);


    } else {
        ct = setTimeout(function() { type(DivToType); }, 100);
    }
}
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 });



}
