$(document).ready(function(){
	/* Detects if iPhone or iPod is being used */
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { 
	   if (document.cookie.indexOf("iphone_redirect=false") == -1) {
	   		
	   		/* Main Nav slider */
	   		$('#mainNav ul').addClass('navList');
	   			   		
	   		$('<ul><li class="phoneMenu"><a><span class="hidden" id="mobileMenuHide">Hide</span> Menu</a></li><ul>').insertBefore($('#mainNav ul'));
	   		
	   		$('<li class="amenities"><a href="inn-spa-amenities.html">Amenities</a></li>').insertAfter($('.reservations'));
	   		
	   		$('<li class="press"><a href="intercourse-pa-inn-press.html">Press</a></li>').insertAfter($('.reservations'));
	   		
	   		$('<li class="blog"><a href="inn-spa-blog.html">Blog</a></li>').insertAfter($('.reservations'));
	   		
	   		$('<li class="Gift Certificates"><a href="gift-certificates.html">Gift Certificates</a></li>').insertAfter($('.reservations'));
	   		
	   		$('.navList').hide();
	   		
	   		$('.phoneMenu').click(function() {
	   			$('.navList').slideToggle('slow', function(){
	   				$('#mobileMenuHide').toggleClass('hidden');
	   			});
   	        });
   	        
   	        /* footer links */
   	        $('<div id="phoneFooter"> <a href="http://www.facebook.com/amishcountryinns"><img height="67" width="67" id="phoneFacebookLink" alt="Facebook Link" src="images/facebook.png" /></a> <a href="tel:18006640949"> <img height="67" width="67" id="phonePhoneLink" alt="Phone Link" src="images/telephone-blue.png" /></a></div><p class="phoneAddress">The Inn &amp; Spa at Intercourse Village</p><p class="phoneNumber">Phone: 1-800-664-0949</p> <p class="phoneAddress">3542 Old Philadelphia Pike</p> <p class="phoneAddress">P.O. Box 598</p> <p class="phoneAddress">Intercourse, PA 17534</p><p class="copyrightHome">&copy; The Inn & Spa at Intercourse Village</p> </div> <a class="redLink" href="#container">Back to Top</a>').insertBefore($('#footerFullWidth'));
	   		
	   		/* replaces main site header logo with smaller one */
	   		$("#logoBanner img").replaceWith('<img height="79" width="309" alt="The Inn and Spa at Intercourse Village" src="images/mobile-header-logo309x79.png" />');
	   		
	   		/* replaces home page label with smaller page label */
	   		$("#pageLabel.homePage").replaceWith('<img class="homePage shrink" id="pageLabel" alt="Relaxtion and Romance at the Inn and Spa at Intercourse" src="images/mobile-home-page-label361x72.png">');
	   		
	   		/* moves home page packages image link to after first paragraph */
	   		$('.firstParagraph').after($('.homePgPkgImg'));
	   		
	   		/* replaces rooms page label with smaller page label */
	   		$("#pageLabel.roomsPage").replaceWith('<img height="107" width="296" class="roomsPage" id="pageLabel" alt="Relax and Romance at Inn and Spa at Intercourse" src="images/mobile-rooms-pg-label296x107.png" />');
	   		
	   		/* moves chef image to before chef image label */	   		
	   		$('#breakfastPage .breakfastChefDesc').before($('#breakfastPage #homepgFeatureImg'));
	   		
	   		
	       /* replaces breakfast.html page label img */
	       $("#breakfastPage #pageLabel").replaceWith('<img height="109" id="pageLabel" width="270" alt="Begin Your Day with Breakfast at the Inn &amp; Spa" src="images/mobile-breakfast-page-label270x109.png" />');	       
	       
	       /* replaces packages.html page label img */
	       $("#packagesPage #pageLabel").replaceWith('<img id="pageLabel"  alt="Indulge with a Package at the Inn &amp; Spa" class="shrink" src="images/mobile-package-page-label345x77.png" />');
	       
	       /* moves packageTitle to before the package image */
	       $('.serenity .packageTitle').insertBefore($('.serenityImg'));
	       
	       $('.romance .packageTitle').insertBefore($('.romanceImg'));
	       
	       $('.babymoon .packageTitle').insertBefore($('.babymoonImg'));
	       
	       $('.loveYou .packageTitle').insertBefore($('.loveYouImg'));
	       
	       $('.girls .packageTitle').insertBefore($('.girlsImg')); 
	       
	       $('.fallin .packageTitle').insertBefore($('.fallInImg'));
	       
	        /* replaces plan.html page label img */
	       $("#planPage #pageLabel").replaceWith('<img id="pageLabel"  alt="Explore the Village of Intercourse, PA" src="images/mobile-plan-page-label256x77.png" />'); 
	       
	       /* replaces plan.html "you decide" phrase image with a smaller one */
	       $("#planPage #planDecide").replaceWith('<img class="shrink" alt="As a guest in our lively village, you decide which story you like best" src="images/mobile-plan-you-decide-phrase280x51.png" />');  
	       
	       /* takes out id that is being used for fancybox */ 
	       $('#planActivitiesLink').replaceWith('<a class="redLink" href="http://www.padutchcountry.com/">Lancaster County Activities</a>');
	      	      
	       
	       /* for using alt tag content rather than image */
	       var altText = $('#spaPhrase').attr('alt');
	       $('#spaPhrase').hide();
	       $('<p class="spaPhraseInsert">'+altText+'</p>').insertAfter($('.spaPage .spaShowImg'));
	       
	       /* spa.html - to make 'Menu of Services' into accordian navigation */
	       $('#tabs').removeClass('tabbed').addClass('notTabbed');
	       	       
	       $('#tabs a').removeAttr('href');
	       $('#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5, #tabs-6').hide();
	       
	       /* moves spa services content divs to be after their list item */
	       $('#tabs-1').insertAfter($('li.spaBody'));
	       $('#tabs-2').insertAfter($('li.spaPackages'));
	       $('#tabs-3').insertAfter($('li.spaFacials'));
	       $('#tabs-4').insertAfter($('li.spaManis'));
	       $('#tabs-5').insertAfter($('li.spaMassage'));
	       $('#tabs-6').insertAfter($('li.spaWaxing'));
	       
	       /* does a slide toggle for the menu of services on the spa page */
	       $('.spaBody a').click(function(){
	       		$('#tabs-1').slideToggle('slow', function(){
	       			//$('.hideService').toggleClass('hidden');
	       		});
	       });
	       
	       $('.spaPackages a').click(function(){
	       		$('#tabs-2').slideToggle('slow', function(){
	       			
	       		});
	       });
	       
	       $('.spaFacials a').click(function(){
	       		$('#tabs-3').slideToggle('slow', function(){
	       			//$('.hideService').toggleClass('hidden');
	       		});
	       });
	       
	       $('.spaManis a').click(function(){
	       		$('#tabs-4').slideToggle('slow', function(){
	       			//$('.hideService').toggleClass('hidden');
	       		});
	       });
	       
	       $('.spaMassage a').click(function(){
	       		$('#tabs-5').slideToggle('slow', function(){
	       			//$('.hideService').toggleClass('hidden');
	       		});
	       });
	       
	       $('.spaWaxing a').click(function(){
	       		$('#tabs-6').slideToggle('slow', function(){
	       			//$('.hideService').toggleClass('hidden');
	       		});
	       });
	       
	       /* weddings page replace page label */
	       $(".weddingPage #pageLabel").replaceWith('<img id="pageLabel" class="shrink" alt="Your Romantic Journey Begins at the Inn &amp; Spa..." src="images/mobile-wedding-page-label298x121.png" />');
	       
	       $('.wedGarden').removeAttr('height');
	       $('.wedGarden').addClass('shrink');
	       
	       $('.wedJacuzzie').removeAttr('height');
	       $('.wedJacuzzie').addClass('shrink');
	       
	       
	       var wedAltText = $('.wedPhraseBottom').attr('alt');
	       $('.wedPhraseBottom').hide();
	       $('<p class="wedPhraseReplace">'+wedAltText+'</p>').insertAfter($('.wedFireplace'));
	       
	       /* maps page */
	       $('#mapZoom').removeClass('zooming');
	       
	       $('#formInput').addClass('hideForm'); 
	       $('#map_canvas').removeClass('mapWithForm').addClass('mapFullWidth');
	       
	       /* gift-certificate page */
	       $('#giftCertPage #pageLabel').replaceWith('<img id="pageLabel" class="shrink" alt="Indulge Their Senses with a Gift Certificate" src="images/mobile-gift-cert-page-label322x70.png" />');
	       
	       $('.giftCertDeck').removeAttr('height').addClass('shrink');
	       
	       /* blog page */
	       $('#blogPage #pageLabel').removeAttr('height').addClass('shrink');
	       
	       /* press page */
	        $('#pressPage #pageLabel').replaceWith('<img id="pageLabel" class="shrink" alt="Press and Media featuring the Inn and Spa" src="images/mobile-press-page-label296x83.png" />');
	        
	        /* reservations page */
	        $('#mainContentContainer.resPage #pageLabel').removeAttr('height').addClass('shrink');
	        
	       
	  }
	}
});
