// written by nick-stone.com
// for onestopwebplans.com

/*
contains:
1. email obfuscation
2. portfolio page functions
3. png fix


*/



$(document).ready(function()
{
	////////////////////////////////////
	// CONTACT Pg Functions
	
	// prevent multiple lookups
	var email_address=$('#email-address');
	var mast_email_address=$('#mast-email-address');
	
	if ($('#email-address').length || $('#mast-email-address').length )
	{
		obfuscate_email();
	}
	
	
	// WRITE EMAIL ADDRESS (hide from crawlers)
	function obfuscate_email()
	{
	
		var e_name='nf';
		e_name+= String.fromCharCode((55*2)+1)  ;
		e_name=String.fromCharCode((55*2)- 5) + e_name;
		//console.log(e_name);
		var e_domain='onestopwebplans.com';
		var e_add=e_name + '@' + e_domain;
		var e_subject_query='?subject=';
		var e_subject ='OneStop Email Inquiry';
		var e_mailto=e_add + e_subject_query + e_subject;
		
		// build  EMAIL link for CONTACT Pg Sidepanel
		$('#email-address')
		.html('<a href="mailto:' + e_mailto + '">' + e_add + '</a>')
		.css('font-size','smaller');
		$('#email-address a').css('margin-left',0);
		
		// build  EMAIL link for MAST
		$('#mast-email-address')
		.html('<a href="mailto:' + e_mailto + '"></a>');
		
		
		
	}


	
	//////////////////////////////


	// PORTFOLIO Pg Functions
	
	if ($('#portfolio-thumbs').length)
	{
	init_screenshots();
	}
	// Show Screenshot by clicking thumb

	// Show SCREENSHOT from Thumbs on Portfolio Page

	// TEST-03 uses an object defined by NS ... hotdog!
	// and inserts object creation into the loop
	// and encloses arguments in doc.ready so they won't get used
	//... before they are created in the loop

	function init_screenshots(){
	
	//hide screeenshot table
	$('#portfolio-screenshots').css('display','none');
	

	// set var to avoid repetitive jquery lookups
	// ps= portfolio sidepanel
	var ps_screenshot_img= $('#portfolio-sidepanel-screenshot img');
	var ps_screenshot_a= $('#portfolio-sidepanel-screenshot a');


	// new sitelink object will hold 2 args
	function sitelink(){
	this.href= '';
	this.lnktxt= '';
	};

	// img object to hold third arg
	var shot=[];




	 $('#portfolio-thumbs img')
		.each(function(imgIndex)
			{
			// instance
			sitelink[imgIndex]=new sitelink();
			// instance
			shot[imgIndex]=new Image(272,221);

				$(this).bind('click',
					function()
						{
							//console.log(sitelink[imgIndex].lnktxt);
							$(ps_screenshot_img.attr('src',shot[imgIndex].src));
							
							$(ps_screenshot_a.attr(
							{
							'href': sitelink[imgIndex].href,
							'innerHTML': sitelink[imgIndex].lnktxt
							}
							
							)); // end 'a'.attr(     end $(ps_screenshot_a
							
							
						}
					); // end bind	
			}  // end function(imgIndex)

		); // end .each




	if ( $('#portfolio-thumbs img').length>-1  )
	{
	shot[0].src='../img/screenshots/100930-charlottesville-seo-web-development-272x221.jpg';
	sitelink[0].href='http://www.nick-stone.com/';
	sitelink[0].lnktxt ='Charlottesville SEO Web Development';


	shot[1].src='../img/screenshots/100930-shulman-creative-272x221.jpg';
	sitelink[1].href='http://www.shulmancreative.com/';
	sitelink[1].lnktxt ='Shulman Creative';


	shot[2].src='../img/screenshots/100930-charlottesville-wellness-272x221.jpg';
	sitelink[2].href='http://www.cwcfp.com/';
	sitelink[2].lnktxt='Charlottesville Wellness';

	shot[3].src='../img/screenshots/100930-wesley-woods-272x221.jpg';
	sitelink[3].href='http://www.wesleywoodsnewnan.com/';
	sitelink[3].lnktxt='Wesley Woods';




	shot[4].src='../img/screenshots/100930-lucy-corr-272x221.jpg';
	sitelink[4].href='http://www.lucycorrvillage.com/';
	sitelink[4].lnktxt='Lucy Corr';

	shot[5].src='../img/screenshots/100930-ivanoff-272x221.jpg';
	sitelink[5].href='http://www.ivanofflaw.com/';
	sitelink[5].lnktxt='Ivanoff Law';

	shot[6].src='../img/screenshots/100930-solution-advisors-272x221.jpg';
	sitelink[6].href='http://www.solutions-advisors.com/';
	sitelink[6].lnktxt='Solution Advisors';

	shot[7].src='../img/screenshots/101004-central-va-feldenkrais-272x221.jpg';
	sitelink[7].href='http://www.centralvirginiafeldenkrais.com';
	sitelink[7].lnktxt='Central Virginia Feldenkrais';
	}

	} // end init_screenshots()

	}  // end document.(ready)







); // end document(ready)

// the app modifies 3 object properties
// I used image.title property to hold onto anchor text
// instead, I could have created anchor objects, 
// ... then used their target property to hold this anchor text








// Fix png for IE6
$(document).ready(function()
{
//note: best practices suggest $.support is preferable to $.browser for browser sniffing
// but I haven't found an IE6 ONLY test that uses $.support
	
	if($.browser.msie  && $.browser.version<7 && $('body').filters)
	{
		var pings=$('img.alpha');
		for(var i=0;i<pings.length;i++)
		{
		pings[i].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + this.src + '", sizingMethod="scale")';
		alert('Test for MSIE 6 = True');
		}
		
	}
	else
	{
	//alert($.browser.Safari + $.browser.version);
	}
});

// OR TO USE SUPERSLEIGHT & optimize performance
//provide images requiring pngfix to:
// supersleight.limitTo()




// transition requested by Patti in early June 2010
// kill the transition per Patti June 15,2010
/*
$('document').ready(function()
{
	fade_out($('#traffic'),4000);
	
	function fade_out(fade_obj,speed)
		{
			// ...stop the current animation, and fade it to 1 from current position
			fade_obj.stop().fadeTo(speed, 0);
		}
});		
*/
