

	function addToVisit(id){
		
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "addToVisit="+id,
			dataType: "xml",
			success: function(data){
				
				$("shops", data).each(function() {
					count = $("count",this).text();
					id = $("id",this).text();
					name = $("name",this).text();
					level = $("level",this).text();
					type = $("type",this).text();
					phone = $("phone",this).text();
					hours = $("hours",this).text();
				});
				
				var plural = (count == 1) ? '':'s';
				
				
				$('#all_header_right_top strong:first').text(count+' place'+plural);
				
			}, error: function(data){
					alert('an error occurred adding this location to MyVisit.');
			}
		});
	}






$(document).ready(function(){

	
	$('a.linker').click(function(e){
		//alert($($(this).attr('href')).length);
		if ($($(this).attr('href')).length != 0){
			$('#tenantListing').scrollTo($(this).attr('href'));
		}
		return false;
	});
	

	
/*
	$('.linker').hover(function(){
		//alert($($(this).attr('href')).length);
		if ($($(this).attr('href')).length != 0){
			$('#tenantListing').scrollTo($(this).attr('href'));
		}
	
	},function(){
	
	
	});
	
*/
	
	
	
/*
	$('#all_content_description_text em').each(function(e){
		if (e > 0){
			$(this).before('</div>');
		}
		$(this).after('<div>');
	});
*/
	
	$('#all_content_description_text .directionsText').hide();
	
	
	$('.directionsHeader').click(function(){
	
		$(this).nextAll('.directionsText:first').slideToggle('fast');
	});
	




	//add an item to your visits
	$('.addToVisit').click(function(){
	
		var id = $(this).attr('id').substr(5);
		
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "addToVisit="+id,
			dataType: "xml",
			success: function(data){
			
				//alert(data);
				
				$('#shop_'+id).attr('src','/assets/img/content_top_added_to_visit.gif');
			
			
				$("shops", data).each(function() {
					count = $("count",this).text();
					id = $("id",this).text();
					name = $("name",this).text();
					level = $("level",this).text();
					type = $("type",this).text();
					phone = $("phone",this).text();
					hours = $("hours",this).text();
				});
				
				var plural = (count == 1) ? '':'s';
				
				//alert(count);
				
				$('#all_header_right_top strong:first').text(count+' place'+plural);
				
			}, error: function(data){
					alert('an error occurred adding this location to MyVisit.');
			}
		});
		
		
		
	});
	
	
	
	
	
	$('.removeFromVisit').click(function(){
		var id = $(this).attr('id').substr(7);
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "removeFromVisit="+id,
			dataType: "xml",
			success: function(data){
			
				$("shops", data).each(function() {
					count = $("count",this).text();
				});
			
				$('#shop_'+id).fadeOut('slow').remove();
				
				
				$('.floorVisitContainer').each(function(e){
					

					var stops = $(this).children('.floorVisitDetails').length;
					var plural = (stops == 1) ? '':'s';
					
					//alert(stops);
					
					$(this).children('.floorVisitFloor').children('span:first').text(stops+' stop'+plural+' on this floor');
				
					if (stops == 0){
						$(this).hide().remove();
					}
				});
				
				
				if ($('.floorVisitContainer').length == 1){
					$('#emptyList').show();
				}

				var plural = (count == 1) ? '':'s';
				$('#all_header_right_top strong:first').text(count+' place'+plural);
				
			}, error: function(data){
					
			}
		});	
	});


	$('.addToVisit,.sendToFriend,.printOptions button').mouseup(function(){
		$(this).css('opacity','1');
	}).mousedown(function(){
		$(this).css('opacity','.70');
	});
	
	$('.addToVisit,.sendToFriend,.printOptions button').mouseout(function(){
		$(this).css('opacity','1');
	});


	//reload image

	$('.captcha').livequery('click', function(){
		$(this).attr('src','/apps/captcha/captcha.php?'+Math.random());
	});


	

	//nicer forms overlay text etc
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('keyup', function(){
		$(this).removeClass('error');
		$(this).css('color','#000');
	});
	$('.sendForm input[@type="text"], .sendForm textarea').each(function(){							
		$(this).val($(this).attr('title')).css('color','#777');
	});
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('focus', function(){
		if ($(this).val() == $(this).attr('title')){
			$(this).val('').css('color','#000');
		}
	});
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('blur', function(){
		if ($(this).val() == ''){
			$(this).val($(this).attr('title')).css('color','#777');
		}
	});
		
	
	
	
	
	//send to friend
	$('#sendToFriendForm').livequery('submit', function(){
		var captcha = ($('#captchaText').val() != '' || $('#captchaText').val() != undefined) ? $('#captchaText').val() : '';
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "captcha="+captcha,
			dataType: "html",
			success: function(data){
				//alert(data);
				if (data[0] == 1){
				
					var formdata = $('#sendToFriendForm').serialize();
					//alert(formdata);
					
					$.ajax({
						url: "/assets/tools.ajax.php",
						type: "POST",
						data: "sendToFriend=1&url="+$('#sendToFriendURL').val()+"&"+formdata,
						dataType: "html",
						success: function(msg){
							
							$('#sendToFriend').slideUp('fast');
							
							//alert(msg);
							
						}
					});
							
				} else {
					$('#captchaText').val('Incorrect Word. Try another.').focus().select().addClass('error');
					$('.captcha').attr('src','/apps/captcha/captcha.php?'+Math.random());
				}

			}, error: function(data){
					
			}
		});
		return false;
	});
	
	
	
	
	//share with a friend
	$('#shareWithFriendForm').livequery('submit', function(){
		var captcha = ($('#captchaText').val() != '' || $('#captchaText').val() != undefined) ? $('#captchaText').val() : '';
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "captcha="+captcha,
			dataType: "html",
			success: function(data){
				//alert(data);
				if (data[0] == 1){
				
					var formdata = $('#shareWithFriendForm').serialize();
					//alert(formdata);
					
					$.ajax({
						url: "/assets/tools.ajax.php",
						type: "POST",
						data: "shareWithFriend=1&"+formdata,
						dataType: "html",
						success: function(msg){
							$('#shareWithFriend').slideUp('fast');
							
							$('body').append('<div class="successAdd" style="display:none; left:500px; color:#666; font-family:Georgia; font-size:14px; background:white; border:2px solid #b0cbd8; -moz-border-radius:8px; position:absolute; top:200px; padding:10px;"><img src="/admin/images/success.png" height="32" width="32" style="vertical-align:middle; padding-right:12px; margin-right:8px; border-right:1px solid #ddd;" />Your Visit Was Sent!</div>');
							
							
							
 							$('.successAdd').css('opacity','0').show().animate({opacity:1, marginLeft: 100},300).animate({opacity:1, marginLeft: 110},1600).animate({opacity:0, marginLeft: 210},300,function(){$('.successAdd').fadeOut('fast',function(){$('.successAdd').remove();});});
							
						}
					});
							
				} else {
					$('#captchaText').val('Incorrect Word. Try another.').focus().select().addClass('error');
					$('.captcha').attr('src','/apps/captcha/captcha.php?'+Math.random());
				}

			}, error: function(data){
					
			}
		});
		return false;
	});
	
	
	
	
	
	
	$('.sendToFriend').click(function(){
		
		$('#all_content_retail_top_logo_rt').append('<div id="sendToFriend" class="sendForm"><div class="innerContainer"><h4>close</h4><div class="content"><form id="sendToFriendForm"><label><input type="text" name="friendname" title="Friend\'s Name" /></label><label><input type="text" name="friendemail" title="Friend\'s Email" /></label><hr size="2" color="#d4e2eb" /><label><input type="text" name="yourname" title="Your Name" /></label><label><input type="text" name="youremail" title="Your Email" /></label><textarea name="message" title="Your Message"></textarea><hr size="2" color="#d4e2eb" /><label><input type="text" id="captchaText" title="Type the Word Below" /></label><div style="clear:both;"></div><img src="" alt="Security" class="captcha" width="200" height="50" /><button type="submit">Send</button></form></div></div></div>');
	
		
			$('.sendForm input[@type="text"], .sendForm textarea').each(function(){							
				$(this).val($(this).attr('title')).css('color','#777');
			});

	
		$('#sendToFriend').slideToggle('fast',function(){
			if ($(this).is(':visible')){
				 $('.captcha').attr('src','/apps/captcha/captcha.php?'+Math.random());
			}
		});
	});
	
	//closer
	$('.sendForm .innerContainer h4').livequery('click', function(){
		$(this).parent().parent().slideUp('fast');
	});


	
	
	
		$('.printOptions button').click(function(){
			if ($(this).attr('id') == 'download'){
				
				var sessionId = ($("#sessionId").val() != '') ? 'id='+$("#sessionId").val():'id=0';
				var specials = ($("input[@name='specials']:checked").val() == 1) ? '&specials':'';
				var events = ($("input[@name='events']:checked").val() == 1) ? '&events':'';
				var directions = ($("input[@name='directions']:checked").val() == 1) ? '&directions':'';
				
				var stores = '&stores='+$("#sessionStores").val();

	/*
			alert(specials);
				alert(events);
				alert(directions);
*/

				
				
				window.open('/assets/tcpdf/my.php?'+sessionId+stores+specials+events+directions,'_blank');
			}
			
			if ($(this).attr('id') == 'print'){
				window.print();
			}
			
			if ($(this).attr('id') == 'share'){

				$('#shareBox').append('<div id="shareWithFriend" class="sendForm"><div class="innerContainer"><h4>close</h4><div class="content"><form id="shareWithFriendForm"><label><input type="text" name="friendname" title="Friend\'s Name" /></label><label><input type="text" name="friendemail" title="Friend\'s Email" /></label><hr size="2" color="#d4e2eb" /><label><input type="text" name="yourname" title="Your Name" /></label><label><input type="text" name="youremail" title="Your Email" /></label><textarea name="message" title="Your Message"></textarea><hr size="2" color="#d4e2eb" /><label><input type="text" id="captchaText" title="Type the Word Below" /></label><div style="clear:both;"></div><img src="" alt="Security" class="captcha" width="200" height="50" /><button type="submit">Send</button></form></div></div></div>');
				
				
			
				
					$('.sendForm input[@type="text"], .sendForm textarea').each(function(){							
						$(this).val($(this).attr('title')).css('color','#777');
					});
		
			
				$('#shareWithFriend').slideToggle('fast',function(){
					if ($(this).is(':visible')){
						 $('.captcha').attr('src','/apps/captcha/captcha.php?'+Math.random());
					}
				});
			}
		}); //print options button click
	
	
	

	//image pong thingy
	$('.retail_image_small').click(function(e){
	
		if ($(this).attr('src') != "/userimages/tenant_images/blank_thumbnail.gif"){
			$('#imagePong').show().animate({left: $(this).position().left + 'px'},200);
			$('#all_content_retail_right_col_img').append('<img class="newImage" src="'+$(this).attr('src')+'" style="position:absolute; top:6px; left:6px; display:none;" />');
			
			$('.newImage').fadeIn('slow',function(){
				$('#all_content_retail_right_col_img img:first').attr('src',$(this).attr('src'));
			
			});
		}
	});
	
	$('.retail_image_small').css('opacity',.80);
	
	$('.retail_image_small').hover(function(e){
		//alert($(this).position().left);
	
		if ($(this).attr('src') != "/userimages/tenant_images/blank_thumbnail.gif"){	
			$(this).animate({opacity: 1},120);
		}
			},function(){
		if ($(this).attr('src') != "/userimages/tenant_images/blank_thumbnail.gif"){
			$('.retail_image_small').animate({opacity: .80},120);
		}
			});

}); //document on ready































