// Look for more js in the includes folder mainNav.php


// Zoom text based on Remy Sharps take down of the Big Snapper spy effect .... Swivel Productions

(function ($) {
    
$.fn.zoom = function (limit, interval) {
    limit = limit || 1;
    interval = interval || 7000;
	
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = 50;
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
       // $list.wrap('<div class="txtZoomWrapper" />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function txtZoom() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 0, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000)
						.animate( { fontSize:"1px", opacity:0, letterSpacing:"0px"}, 0)
					 .animate( { fontSize:"28px", opacity: .3, letterSpacing:"5px" }, 3000 )
					 .animate( { letterSpacing:"17px", opacity:0}, 3000);                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
            
            setTimeout(txtZoom, interval)
        }
        
        txtZoom();
    });
};
    
})(jQuery);



// Rotate testimonials based on Remy Sharps take down of the Big Snapper spy effect .... Swivel Productions

(function ($) {
    
$.fn.rotate = function (limit, interval) {
    limit = limit || 1;
    interval = interval || 17000;
	
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
			heights = [],
            currentItem = limit,
            total = 0, // initialise later on
            height = 0;
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>'); 
        });
        // capture the cache
        $list.find('> li').each(function () {
            heights.push($(this).height());
        });
        total = items.length;
                
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function txtRotate() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 0, function () {																		 
                // finally fade the first item in 
                $insert.animate({ height : heights[currentItem] }, 500)
						.animate( {opacity :1}, 2000);                
                    //  remove the last)
                    $(this).remove();
					
		var getWrapper = $("#wrapper").height();
			if(heights[currentItem]>260){$("#wrapper").height(getWrapper+(heights[currentItem]-260)+50)};         
			
			// });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
	
			
            
            setTimeout(txtRotate, interval)
        }
	 

			
        txtRotate();
    });
};
    
})(jQuery);


// add google map

  function initialize() {
    var latlng = new google.maps.LatLng(28.4668, -81.413);
    var myOptions = {
      zoom: 15,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var infowindow = new google.maps.InfoWindow(
    { content: '<b>designers\' press</b><br>6305 Chancellor Drive<br>Orlando, Florida 32809',
      size: new google.maps.Size(200,60)
    });

	
	var beachMarker = new google.maps.Marker({
      position: latlng,
      map: map,
	  title: "designers' press"
  });
    google.maps.event.addListener(beachMarker, 'click', function() {
    infowindow.open(map,beachMarker);
    });	
  }


	
$(document).ready(function() {

// force content to open last div
						   
		var myNones = 	$("#accordion div").length;
		var myActive = myNones -1;
						   
// Add accordion events						    
						   
		$("#accordion").accordion({
		event: "click",
		navigation: "true",
		active: myActive,
		animated: 'bounceslide',
		autoHeight: false
		}		

		);		
		

		$(".ui-accordion-content").css({'padding-bottom' : '30px'});
		
		
		
							

	



// Add diolog to a page

					$(function() {
                        $("#dialog").dialog({
                                autoOpen: false,
                                bgiframe: true,
                                resizable: false,
                                width: 325,
                                modal: true,
                                overlay: {
                                backgroundColor: '#000',
                                opacity: 0.8
                                }
                               /* , buttons: {
                                         'Logout': function() {
                                                document.location = 'modules/logout.php';
                                          },
                                        'Cancel': function() {
                                                $(this).dialog('close');
                                        }
                                }
								*/
								
                        });

                $('.link-logout, #promoIN').click(function() {
                        $('#dialog').dialog('open');
						  $("#loginBar").animate({width:"166px" }, 150 ); 
						  $("#logBar").animate({width:"191px" }, 150 ); 
						  $("#loginBar").slideUp("slow");
						  $("#logBar").html("<img src='images/loginBar.png'>");
                        });
        }); 
					
// end diolog


   // Hide address and sales rep when send sample checkbox is selected

					

 $('.hideAddress').hide();
 $('.hideSales').hide();

 
$('#reqSamples').click(function(){
var checked_status = this.checked;
if(checked_status == true) {
 $('.hideAddress').show();
 $('.ui-accordion-content-active').animate({height : "460px"});

 
						   }
if(checked_status == false) {
 $('.hideAddress').hide();
 //$('.ui-accordion-content-active').animate({height : "390px"});

						   }
}); 

$('#txtSalesRep').click(function(){
var checked_status = this.checked;
if(checked_status == true) {
 $('.hideSales').show();
						   }
if(checked_status == false) {
 $('.hideSales').hide();
						   }
}); 

});  // end ready



