jQuery(document).ready(function(){
		
		// jquery plugin to make sidebar and main content area the same height...
		jQuery('#equalheight').equalHeights();
		
		// store list of shops in 'listShops' variable
		var listShops = jQuery('#spit-shop-names').html();
		
		// on store page, replace text in sidebar explaining how to use....
		jQuery('#map_sidebar .text_below_map').html(listShops);
		
		
		
		// 
		jQuery('#map_sidebar .text_below_map a').click(function() {
			
			// grab store phone number and store it in 'storeNo' variable
			var storeNo = jQuery(this).children().html();
			
			// grab the stores PDF menu and store it in 'pdfmenu' variable
			var pdfmenu = jQuery(this).siblings("span").html();

            // grab store address for popups
            var storeAddress = jQuery(this).siblings("em").html();

            
            		
			// find out which links have an empty href
			 if(jQuery(this).attr("href") == "") {
				
				// if empty apply colorbox plugin to link
				jQuery(this).attr('rel', 'pop');
				
				// popuplate popup paragraph with store number
				jQuery('#addinNo').html(storeNo);

                // populate the popup with store address...
                jQuery('#addinAddress').html(storeAddress);
                				
				// belfast south
				if((storeNo) == "028 906 62999") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				// belfast west
				if((storeNo) == "028 906 05333") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				
				// dun lao...
				if((storeNo) == "01 284 3629") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				// naas
				if((storeNo) == "045 881700") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				// sandyford
				if((storeNo) == "01 295 7255") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				// tallaght
				if((storeNo) == "01 451 0047") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				// drogheda...
				if((storeNo) == "041 987 2755") {
					jQuery('#menuLink').attr('href', pdfmenu);
				}
				
				// newtownabbey
				if((storeNo) == "028 908 54949") {
					jQuery('#menuLink').css('display', 'none');
				}				
				// churtown...
				if((storeNo) == "01 2988 688") {
					jQuery('#menuLink').css('display', 'none');
				}
				
				// instigate colorbox plugin....
				jQuery("a[rel='pop']").colorbox({
					onOpen:function(){ jQuery('#inline').removeClass('hide'); },
					inline:true, 
					href:"#inline",
					rel: 'nofollow',
					width: "300px", 
					height: "250px",
					onClosed:function(){ jQuery('#inline').addClass('hide'); }
				});
								
			}
		});
		
		// if user is on a apple mobile device, switch flash code...
		if( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)){
			jQuery("#slideshow-section").html("<iframe frameborder='0'  width='323' height='470' name='vidly-frame' src='http://s.vid.ly/embeded.html?link=7y4a8f&autoplay=false'><a target='_blank' href='http://vid.ly/7y4a8f'><img src='http://cf.cdn.vid.ly/7y4a8f/poster.jpg' /></a></iframe>");
		}

		// if user is on a apple mobile device, switch flash code...
		if( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)){
			jQuery("#flashy-sign").html("<img src='/wp-content/themes/fourstarpizza/images/order-now-off.gif' /><img src='/wp-content/themes/fourstarpizza/images/order-now.gif' id='pulse' />");
		}

		// pulse effect on 'order now' sign on homepage
		jQuery('#pulse').effect("pulsate", { times: 999 }, 400);
		
		
		/* show map on store pages
		 not working in ie8/9
		jQuery("a#btnMap").click(function(){
			
			jQuery("#revealMap").fadeToggle(2000);
			
			return true;
		});
		*/
		// show map on store pages
		var mapCode = jQuery("#showMap").html();
			
		jQuery("#revealMap").hide();
			
		jQuery("a#btnMap").click(function(){  
		      
			jQuery("#revealMap").html(mapCode);
		    jQuery("#revealMap").fadeToggle();
		      
		});
						
});

