
(function($){
 
	//Add in resizer elements
	
	 


 



	$.myplugin = (function(my){     

                my.repositionImages = function(){
 	
			var MyPos=10;
		for (var u=0; u<pos; u++){
			 MyPos+=-20-ImagesArray[u].width();
			}
			
			for (var i=0; i<ImagesArray.length; i++){
			ImagesArray[i].stop();
	 ImagesArray[i].animate({"left": MyPos}, "fast");
	// ImagesArray[i].css('left', MyPos);
	 
	 MyPos+= ImagesArray[i].width()+20;
	 }


                };
                return my;      
            })({});
			
			

			
			
	//Resize image on ready or resize
	$.resizer = function( options ) {
	
		var element = $('#TOTALCONTIndex');		//resizer container
		
		$(document).ready(function() {
			resizenow();
			repositionImages();
		});

		
		$(window).load(function(){
			resizenow();
			repositionImages();
		
		});			
		


		$(window).resize(function(){
    		resizenow();	
			repositionImages();
		
		});
		
		function repositionImages(){
		var MyPos=10;
		for (var u=0; u<pos; u++){
			 MyPos+=-20-ImagesArray[u].width();
			}
			
			for (var i=0; i<ImagesArray.length; i++){
   //  $(this).animate({"left": MyPos}, "slow");
	 ImagesArray[i].css('left', MyPos);
	 MyPos+= ImagesArray[i].width()+20;

	 }
	 
	
		}
		
		
		function CheckVisible(){
		for (var i=0; i<ImagesArray.length; i++){
		var position = ImagesArray[i].position();
	
	  if (position.left+ImagesArray[i].width()>element.width()){
	ImagesArray[i].hide();
	 
	  }else{
	  ImagesArray[i].show();
	  }
	  }
		}
		
		
		jQuery.fn.center = function () {
	
    this.css("position","absolute");
   // this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

jQuery.fn.centerY = function () {
	
    this.css("position","absolute");
    this.css("top", ((this.outerHeight()) / 2)-$(this).height()/2+200 + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

jQuery.fn.centerY2 = function () {
	
    this.css("position","absolute");
    this.css("top", ((this.outerHeight()) / 2)-$(this).height()/2+200 + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}
		
		//Adjust image size
		function resizenow() {
			$("#TOTALCONTIndex").width($(window).width()-160);
			$("#TOTALCONTIndex").height($(window).height()-140);
			
			$("#TOTALCONT").width($(window).width()-220);
			//$("#TOTALCONT").height($(window).height()-140);
			
			$("#LongDetails").height($(window).height()-120);
			
			if($(window).height()<$("#videoContInner").height()+311){
			$("#videoCont").height($("#videoContInner").height()+333);
		
			}else{
			$("#videoCont").height($(window).height());
			}
				//$("#videoCont").css('top',250);
			
				$("#videoContInner").centerY2();
				$("#VideoprojectTitle").center();
				
			//	$("#VideoprojectTitle").center();
		
			
		var browserheight=0;
	
		
			return element.each(function() {
		
		  		var t = $('img', element);
	
		  		//Resize each image seperately
		  		$(t).each(function(){
		  			
					var ratio = ($(this).height()/$(this).width()).toFixed(2);	//Define image ratio
				
					var browserwidth = Math.ceil(element.width());
						browserheight = Math.ceil(element.height()-10);
				
					
					/**Resize image to proper ratio**/	
					$(this).height(browserheight);
					
			/* 	if ($("#TOTALCONT").width()>$("#TOTALCONT").height()){
					thisSlide.height(browserheight).width(browserheight/ratio);
					}else{
					if (thisSlide.height()>	thisSlide.width()){
					thisSlide.height(browserheight).width(browserheight/ratio);
					}else{
					thisSlide.width(browserwidth).height(ratio*browserwidth);
					}
					} */
					//thisSlide.width(ratio*browserheight);
				//	thisSlide.css("width", browserwidth); // Set new width
				//thisSlide.css("height", browserheight ); 
				});
				
			//	return false;
			});
			
		
	
		};
			
	};
	
	
	
	
	
	   
		
})(jQuery);


