jQuery(document).ready(function(){	

	// map mouseover effects
	jQuery('.click-here').mouseover(function(){
		$this = jQuery(this);
		if (!jQuery('#insert').hasClass('active')) {
			$this.children().show().css('opacity', .40);
			$this.parent().css('border-color', '#666');
		}	
	}).mouseout(function(){
		$this.children().css('opacity', 0);
		$this.parent().css('border-color', '#aaa');
	});
	
	// flippin ie crap
	if (jQuery.browser.msie) {
		jQuery('img.map').mouseover(function(){
			$this = jQuery(this);
			if (!jQuery('#insert').hasClass('active')) {
				jQuery(this).parent().children('.click-here').children('span').show().css('opacity', .40);
				jQuery(this).parent().css('border-color', '#666');	
			}
		}).mouseout(function(){
			$this.parent().children('.click-here').children('span').show().css('opacity', 0);
			$this.parent().css('border-color', '#aaa');
		});
	}
	
	// bind the click to the close button here, now it exists
	jQuery('#close-insert').live('click', function(){
		jQuery('#insert').removeClass('active').fadeOut(100, function(){
			jQuery('iframe').remove();
			jQuery('#address').empty();
			jQuery('#overlay').fadeOut(100);
			jQuery('#this-map-link').attr('href', '#');
		});
		return false; // if google iframe hijacks js, reload page should work
	});

	// show/hide the lightboxy larger maps
	jQuery(".click-here").click(function(){	
		if (!jQuery('#insert').hasClass('active')) {
			jQuery('#insert').addClass('active');
			jQuery('.click-here span').css('opacity', 0);		
			var border = 11 * 2;
			var divheight = 550 + border;
			var divwidth = 	800 + border;	
			var thisid = jQuery(this).attr('id');
			var address = jQuery(this).parent().parent().parent().children('h3').text();
			var dheight = jQuery(document).height();
						var dwidth = jQuery(document).width();
						var wheight = jQuery(window).height();
						var insertleft = (dwidth / 2) - (divwidth / 2);
						var inserttop = ((wheight - divheight) / 2) + jQuery(window).scrollTop();
						jQuery(maps[thisid]).prependTo('#insert');	
						jQuery('#address').text(address);
						jQuery('#this-map-link').attr('href', links[thisid]);
						jQuery('#overlay').css({
							opacity: 0,
							display: 'block',
							height: dheight,
							width: '100%'
						}).animate({opacity: .8}, 100, 'swing', function(){
							jQuery('#insert').fadeIn().css({
								left: insertleft,
								top: inserttop
							});
						});
		}
	});
});

// google map embed codes + links
var maps = new Object();
var links = new Object();

/* all homes link */
links['all'] = 'http://maps.google.com/maps/ms?ie=UTF8&msa=0&msid=111790389182776104747.00046463185f62d3b25f1&ll=35.161249,-80.833282&spn=0.240541,0.275002&z=12';

/* 4017 Alexandra Alley Drive, 28210 */
maps['map-4017a'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;s=AARTsJpssAUMj7B_BlWY4F3aDEWZzORXJA&amp;msa=0&amp;msid=109302938582766853174.00046464226a94c8415b2&amp;ll=35.130035,-80.839527&amp;spn=0.003949,0.007832&amp;z=15&amp;output=embed"></iframe><br />';
links['map-4017a'] = 'http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=109302938582766853174.00046464226a94c8415b2&ll=35.13005,-80.839339&spn=0.064932,0.074072&z=14';

/* 537 Sedgewood Lake Drive, 28211 */
maps['map-537s'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=537+Sedgewood+Lake+Dr+28211&amp;oe=utf-8&amp;client=firefox-a&amp;ie=UTF8&amp;split=0&amp;gl=us&amp;ei=tjixSaabE5CV-ga91oz7Ag&amp;s=AARTsJqFrEhw4mRBmTMkDIyJ7Ov1X1p3mw&amp;ll=35.195765,-80.807877&amp;spn=0.032264,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-537s'] = 'http://maps.google.com/maps?q=537+Sedgewood+Lake+Dr+28211&oe=utf-8&client=firefox-a&ie=UTF8&split=0&gl=us&ei=tjixSaabE5CV-ga91oz7Ag&ll=35.185454,-80.809765&spn=0.059346,0.075617&z=14';

/* 2306 Beverly Drive, 28207 */
maps['map-2306b'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=2306+Beverly+Drive,+28207&amp;sll=35.185454,-80.809765&amp;sspn=0.059346,0.075617&amp;gl=us&amp;ie=UTF8&amp;s=AARTsJr-9d0F4a-ky10l5M58CrIV9w_7Kw&amp;ll=35.197308,-80.819035&amp;spn=0.032264,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-2306b'] = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=2306+Beverly+Drive,+28207&sll=35.185454,-80.809765&sspn=0.059346,0.075617&gl=us&ie=UTF8&ll=35.186927,-80.82324&spn=0.029672,0.037808&z=15&iwloc=addr';

/* 3806 Olivia View Court, 28210 */
maps['map-3806o'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;s=AARTsJpYnnwm1Ru9QTzNq9B7YJojdWzBZQ&amp;msa=0&amp;msid=110212813013353919602.00046475b074857b61e4f&amp;ll=35.12993,-80.839248&amp;spn=0.008073,0.015836&amp;z=15&amp;output=embed"></iframe>';
links['map-3806o'] = 'http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&ll=35.12993,-80.839258&spn=0.028851,0.037808&z=15&msid=110212813013353919602.00046475b074857b61e4f';

/* 2108 Dickinson Place, 28207 */
maps['map-2108d'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=2108+Dickinson+Place,+28207&amp;sll=35.12993,-80.839258&amp;sspn=0.028851,0.037808&amp;ie=UTF8&amp;s=AARTsJrDmRLwgDsGQOFMB5XZeaE_vbLDtA&amp;ll=35.196256,-80.833712&amp;spn=0.032264,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-2108d'] = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=2108+Dickinson+Place,+28207&sll=35.12993,-80.839258&sspn=0.028851,0.037808&ie=UTF8&ll=35.185845,-80.837946&spn=0.029673,0.037808&z=15';

/* 3029 Hanson Drive, 28207 */
maps['map-3029h'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=3029+Hanson+Drive,+28207&amp;sll=35.185845,-80.837946&amp;sspn=0.118691,0.151234&amp;ie=UTF8&amp;s=AARTsJrMFOgYmxFZjFHFoGvEQGBoMAFnHw&amp;ll=35.194643,-80.818777&amp;spn=0.032265,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-3029h'] = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=3029+Hanson+Drive,+28207&sll=35.185845,-80.837946&sspn=0.118691,0.151234&ie=UTF8&ll=35.184296,-80.822983&spn=0.029673,0.037808&z=15&iwloc=addr';

/* 2200 Hastings Drive, 28207 */
maps['map-2200h'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=2200+Hastings+Drive,+28207&amp;sll=35.184296,-80.822983&amp;sspn=0.118693,0.151234&amp;ie=UTF8&amp;s=AARTsJrkWmMNN-qZdG9H05DUkcJyW9ANWA&amp;ll=35.196607,-80.831566&amp;spn=0.032264,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-2200h'] = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=2200+Hastings+Drive,+28207&sll=35.184296,-80.822983&sspn=0.118693,0.151234&ie=UTF8&ll=35.186225,-80.835729&spn=0.029673,0.037808&z=15&iwloc=addr';

/* 1200 Coddington Place, 28211 */
maps['map-1200h'] = '<iframe width="738" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=1200+Coddington+Place,+28211&amp;sll=35.186225,-80.835729&amp;sspn=0.118691,0.151234&amp;ie=UTF8&amp;s=AARTsJobG_XvHyWtXiUEtxjvGnEB5gpJ_w&amp;ll=35.192609,-80.804701&amp;spn=0.032266,0.063343&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe>';
links['map-1200h'] = 'http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=1200+Coddington+Place,+28211&sll=35.186225,-80.835729&sspn=0.118691,0.151234&ie=UTF8&ll=35.182227,-80.808907&spn=0.029674,0.037808&z=15&iwloc=addr';

/* 3810 Stoney Ridge Trail, Lot 3, 28210 */
maps['map-3810s'] = '<iframe width="739" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;s=AARTsJrlPy5Nas_NImPuFhS85oImQJTL7w&amp;msa=0&amp;msid=116778658007351813945.000464763fa29db11cec3&amp;ll=35.12749,-80.860062&amp;spn=0.129166,0.253716&amp;z=14&amp;output=embed"></iframe>';
links['map-3810s'] = 'http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&ll=35.127683,-80.851961&spn=0.029694,0.037808&z=15&msid=116778658007351813945.000464763fa29db11cec3';

/* 3800 Stoney Ridge Trail, Lot 4, 28210 */
maps['map-3800s'] = '<iframe width="739" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;s=AARTsJrlPy5Nas_NImPuFhS85oImQJTL7w&amp;msa=0&amp;msid=116778658007351813945.000464763fa29db11cec3&amp;ll=35.12749,-80.860062&amp;spn=0.129166,0.253716&amp;z=14&amp;output=embed"></iframe>';
links['map-3800s'] = 'http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&ll=35.127683,-80.851961&spn=0.029694,0.037808&z=15&msid=116778658007351813945.000464763fa29db11cec3';

/* 2815 Stoney Ridge Trail, Lot 5 28210 */
maps['map-2815s'] = '<iframe width="739" height="460" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;s=AARTsJrlPy5Nas_NImPuFhS85oImQJTL7w&amp;msa=0&amp;msid=116778658007351813945.000464763fa29db11cec3&amp;ll=35.12749,-80.860062&amp;spn=0.129166,0.253716&amp;z=14&amp;output=embed"></iframe>';
links['map-2815s'] = 'http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&ll=35.127683,-80.851961&spn=0.029694,0.037808&z=15&msid=116778658007351813945.000464763fa29db11cec3';












