
// add google map

  function initialize() {
    var latlng = new google.maps.LatLng(28.758339, -81.265891);
    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>Sunstate Awning</b><br>50 Keyes Court <br>Sanford, Florida 32773',
      size: new google.maps.Size(200,100)
    });

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




// Main JavaScript Document for Sunstate Awning inc all rights reserved
$(document).ready(function () {
							
							
// Make the main navs active when we enter the page

$("#mainNav a").each(function() {
var hreflink = $(this).attr("href");
var currentURL = window.location.toString().split("/");

if (hreflink.toLowerCase() == currentURL[currentURL.length-1]
.toLowerCase()) {
	$(this).addClass("selected");
}
});

// end active function



							
// Run the main page effect to roll out roll in

$('#mainIMG').cycle({ 
	fx:    'turnUp', 
	timeout:6000,
	delay: -3000				
				  });

$('#mainIMG2').cycle({ 
		fx:    'scrollRight', 
		timeout:5000,
		delay: -4000				
		              });
					  
$('#mainIMG3').cycle({ 
		fx:    'scrollLeft', 
		timeout:5000,
		delay: -4000				
		              });	

// end rolls  
							
					
// make the thumbnails IMG to background-images

var items = [];

$('#gallery').find('img').each(function () {
items.push($(this).attr('src'));
$('#gallery img').remove();
return items;
});


$('#gallery a').each(function(i) {
$(this).css({'background-image' : 'url(\''+items[i]+'\')' });
// $('this').addClass('image'+i)
 });					
// end thumbnails BG	

// add hover state to thumbnails
    $("#gallery a").hover(
      function () {
        $(this).animate( { opacity:".5" }, { queue:false, duration:300 } );
        

      }, 
      function () {
        $(this).animate( { opacity:"1" }, { queue:false, duration:300 } );
      }
    );


// end hover TN

// .............. sub nav for product catagories li from MYSQL

  $('#galCatNavBar li a.allIMG').addClass('catSelect'); // add hilight to "all" link
  

// capture arr of all catagories
var catLink = [];
$('#galCatNavBar li a:not(.allIMG)').each(function() {
catLink.push($(this).attr('class'));
return catLink

}); // end capture
// add event handlers for catagory navs for bothe galleries
// sat intinal state to rid last span pipe
$('#galCatNavBar li span:last').hide();

$('#galCatNavBar li a:not(.allIMG)').each(function(i) {
  $(this).click(function () {
      $('#gallery a').hide();
      $('#gallery a.'+catLink[i]).show();
	  $(this).addClass('catSelect');
	  $('#gallery a.'+catLink[i]).attr({rel : "prettyPhoto[gallery]"});
	  
// select only the shown gallery for the lightbox
$('#gallery a:not(.'+catLink[i]+')').each(function(){
					if($(this).attr('rel') == "prettyPhoto[gallery]") {							
			$(this).attr({rel : "notYet"});
			             }
});
	  
// select the link based on the catsSelect class
$('#galCatNavBar a:not(.'+catLink[i]+')').each(function(){
	if($(this).is('.catSelect')){
            $(this).removeClass('catSelect');
						}
					          });
    
      return false;
    });							  
 });	

// all catagory images  click handlers
$('#galCatNavBar li a.allIMG').each(function(i) {
  $(this).click(function () {
$('#gallery a').show();
$('#gallery a').attr({rel : "prettyPhoto[gallery]"});


  $(this).addClass('catSelect');
  
// select the link based on the catsSelect class
	  $('#galCatNavBar a:not(.allIMG)').each(function(){
	if($(this).is('.catSelect')){
            $(this).removeClass('catSelect');
						}
					          });

return false;
    });							  
 });




// end event handlers

// pretty Photo interation
$("#gallery a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded'});

	           //$("a[rel^='prettyPhoto']").prettyPhoto({
				// animationSpeed: 'normal', /* fast/slow/normal */
				// padding: 40, /* padding for each side of the picture */
				// opacity: 0.35, /* Value betwee 0 and 1 */
				// showTitle: true, /* true/false */				
				//theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
				// allowresize: false /* true/false */
				// counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				//hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
				//modal: false, /* If set to true, only the close button will close the window */
				//changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
				//callback: function(){} /* Called when prettyPhoto is closed */
			      //});

// end pretty	



// add to mainWrapper as gallery grows 

var galleryHeight = $('#gallery').height();

if(galleryHeight>880){
	var galleryHeight = galleryHeight +250;
	$('#mainWrapper').height(galleryHeight);
}

  
  
 // draw round corners and shadows for all  

//$('#mainWrapper, #galleryInfo, #mainQuickLink').corners("bottom 15px");
//$('body:not(#mainWrapper)').removeShadow();

//$('#mainWrapper').dropShadow({ left: -8, top: 8, opacity: 0.2, blur: 3 });

// Start accordion for the FAQ page only  using if statment

if(window.location == 'http://sunstateawning.net/questions.php' || window.location == 'http://www.sunstateawning.net/questions.php' || window.location == 'http://sunstateawning.com/questions.php' || window.location == 'http://www.sunstateawning.com/questions.php') {
	$("#accordion").accordion({
			autoHeight: false
		});
	}
	//var $accordionHT = $('#accordion').height();
	//$('#mainWrapper').height($accordionHT+220);
	// end accordion

// add hover state to the design page sub navs

$('#mainQuickLink td img').hover(function () {

$(this).animate({opacity: .6 }, 200);

}, 
      function () {
$(this).animate({opacity: 1 }, 200);
      }

);

// add width to the li for windows design page

var subCatWT = [];
$('#designCatNavBar li').each(function() {
subCatWT.push($(this).width());
return subCatWT;
});

$('#designCatNavBar li').each(function(i) {

$(this).width(subCatWT[i]+2);

});

// end add window shit

// extend the height if galCatNavBar when more catagories are added
var galCatNavHT = 5 + $('#galCatNavBar li').height();
$('#galCatNavBar').height(galCatNavHT);
	  

// set initial state for sub navs
$('#designCatNavBar li').hide();
$('#designCatNavBar li.cat10').show();
$('#desPDF li').hide();
$('#desPDF li.cat10').show();
// hide last span tab to rid the pipe
$('#designCatNavBar li.cat10 span:last').hide();

// add click handler for design sub navs 
$('#mainQuickLink td:first-child').each( function() {
var tdCat = $(this).attr('class');
$('#mainQuickLink td img').css({'border' : 'solid 2px #EBEBD3'});
$('#mainQuickLink td.10 img').css({'border' : 'solid 2px orange'});

$('#mainQuickLink td.'+tdCat).click( function() {
$('#designCatNavBar li').hide();
$('#designCatNavBar li.cat'+tdCat).show();
// hide last span tab to rid the pipe
$('#designCatNavBar li.cat'+tdCat+' span:last').hide();
$('#desPDF li').hide();
$('#desPDF li.cat'+tdCat).show();
$('#mainQuickLink td img').css({'border' : 'solid 2px #EBEBD3'});
$('#mainQuickLink td.'+tdCat+' img').css({'border' : 'solid 2px orange'});
var desCatNavHT = $('#designCatNavBar ul').height();
if(desCatNavHT<40) {$('#designCatNavBar').height(35)} else{$('#designCatNavBar').height(desCatNavHT)};
});
});
// add click event for pdf from sub navs on design page

var subNavLink = [];
$('#designCatNavBar li').each(function() {
subNavLink.push($(this).attr('class'));
return subNavLink;
});

$('#designCatNavBar li').each(function(i) {
    $(this).click( function() {
        $('#desPDF li').hide();
        var splitSubNavLink = subNavLink[i].split(" ");
        $('#desPDF li.'+splitSubNavLink[0]+'.'+splitSubNavLink[1]).show();



});

});


// add height to contact and about mainWrapper for extra content
contactHT = $('#mainInfo').height();
if(contactHT != null) {
	if(contactHT<400){
	$('#mainWrapper').height(950);
		} else {	
		$('#mainWrapper').height(250 +contactHT);
                }
      }
		



});



