jQuery(document).ready(function ($) {
	// select current page nav button
	imagePath = "/wp-content/themes/lmfunding/images/interface/l1-" + sSelectedButton + "-r.gif";
	$("#" + sSelectedButton + "Btn img").attr("src",imagePath);
	
	// assign styles on page load
	$("#homeContact input[type='text']").css({width: '241px', height: '14px', display: 'block', border: 'none', background: 'transparent url(/wp-content/themes/lmfunding/images/home/bg-home-field.gif) top left no-repeat'});
	$("#homeContact label[for='yourName']").css({background: 'transparent url(/wp-content/themes/lmfunding/images/home/label-name.png) top left no-repeat'});
	$("#homeContact label[for='company']").css({background: 'transparent url(/wp-content/themes/lmfunding/images/home/label-company.png) top left no-repeat'});
	$("#homeContact label[for='your-email']").css({background: 'transparent url(/wp-content/themes/lmfunding/images/home/label-email.png) top left no-repeat'});
	$("#homeContact label[for='phone']").css({background: 'transparent url(/wp-content/themes/lmfunding/images/home/label-phone.png) top left no-repeat'});
	$("#homeContact input[type='submit']").css({display: 'block', width: '142px', height: '30px', position: 'absolute', top: '194px', left: '126px', textIndent: '-9999px', border: 'none', background: 'transparent url(/wp-content/themes/lmfunding/images/interface/btn-submit.png) top left no-repeat', cursor: 'pointer'});
	$("#newsShortenedList p:gt(3)").css("display","none");
	if (sSelectedButton != "contact" && sSelectedButton != "resources")
	{
		$("#tab1Content").jScrollPane();
	}
	
	// store URL variables
	getUrlVars();
	var tabShow = getUrlVars()["tabShow"];
	if (typeof tabShow != 'undefined') {
		showTheTab(tabShow);
	}
	if (sSelectedButton == "about")
	{
		initalizeColorBoxes();
	}
	if (sSelectedButton == "resources")
	{
		initalizeAnalyzerResults();
	}
	if (sSelectedButton != "home")
	{
		setupContactLightbox();		
	}
	if (sSelectedButton == "home")
	{
		showQuote();
	}
});

var btnLevel1 = new Array();
btnLevel1 = ["home", "about", "approach", "success-stories", "resources", "contact"];
for (var i = 0; i < btnLevel1.length; i++) { 
	eval("A" + i + "on = new Image();"); eval("A" + i + "off = new Image();");
	eval("A" + i + "on.src = '/wp-content/themes/lmfunding/images/interface/l1-" + btnLevel1[i] + "-r.gif';");
	eval("A" + i + "off.src = '/wp-content/themes/lmfunding/images/interface/l1-" + btnLevel1[i] + "-0.gif';");
	if (sSelectedButton == btnLevel1[i]) {
		eval("A" + i + "off.src = '/wp-content/themes/lmfunding/images/interface/l1-" + btnLevel1[i] + "-r.gif';");
	}
}

var btnLevel2 = new Array();
switch(sSelectedButton)
{
case "about":
	btnLevel2 = ["overview", "people", "news"];
	break;
case "approach":
	btnLevel2 = ["howitworks", "faqs", "fineprint"];
	break;
case "resources":
	btnLevel2 = ["analyzer", "statutes"];
	break;
}

if (btnLevel2.length > 0)
{
	for (var i = 0; i < btnLevel2.length; i++) { 
		eval("B" + i + "on = new Image();"); eval("B" + i + "off = new Image();");
		eval("B" + i + "on.src = '/wp-content/themes/lmfunding/images/interface/tab-" + btnLevel2[i] + "-1.png';");
		eval("B" + i + "off.src = '/wp-content/themes/lmfunding/images/interface/tab-" + btnLevel2[i] + "-0.png';");
	}
}

if (sSelectedButton == "success-stories")
{
	for (var i = 1; i < 4; i++) { 
		eval("success" + i + "= new Image();");
		eval("success" + i + ".src = '/wp-content/themes/lmfunding/images/content-design/photo-success-stories" + i + ".jpg';");
	}
}

function changeImages() 
{
  if (document.getElementById) {
    for (var i = 0; i < changeImages.arguments.length; i += 2) { 
  		document.getElementById(changeImages.arguments[i]).src = eval(changeImages.arguments[i + 1] + ".src"); 
	}
  }
}

function contentSwap(whichOne)
{
	jQuery(document).ready(function($) {
		$("#contentTabs li").attr("id","");
		$("#contentTabs .tab" + whichOne).attr("id","tab" + whichOne + "Selected");
		$(".tabContent").css("display","none");
		$(".quote").css("display","none");
		$("#tab" + whichOne + "Content").css("display","block");
		$("#tab" + whichOne + "Content").jScrollPane();
		$("#quote" + whichOne).css("display","block");
		trackVirtualPageviews(whichOne);
		if (sSelectedButton == "success-stories")
		{
			$("#centralPhoto").attr("src","/wp-content/themes/lmfunding/images/content-design/photo-success-stories" + whichOne + ".jpg");
		}
	});	
}

function trackVirtualPageviews(whichOne)
{
	switch(sSelectedButton)
	{
	case "about":
		if(whichOne == 2) {
			_gaq.push(['_trackPageview', '/about/people']);
		} else if(whichOne == 3) {
			_gaq.push(['_trackPageview', '/about/news']);
		} else {
			_gaq.push(['_trackPageview', '/about']);
		}
		break;
	case "approach":
		if(whichOne == 2) {
			_gaq.push(['_trackPageview', '/our-approach/faqs']);
		} else if(whichOne == 3) {
			_gaq.push(['_trackPageview', '/our-approach/the-fine-print']);
		} else {
			_gaq.push(['_trackPageview', '/our-approach']);
		}
		break;
	case "success-stories":
		if(whichOne == 2) {
			_gaq.push(['_trackPageview', '/success-stories/bermuda-dunes']);
		} else if(whichOne == 3) {
			_gaq.push(['_trackPageview', '/success-stories/village-at-town-park']);
		} else {
			_gaq.push(['_trackPageview', '/success-stories']);
		}
		break;
	case "resources":
		if(whichOne == 2) {
			_gaq.push(['_trackPageview', '/resources/florida-statutes']);
		} else {
			_gaq.push(['_trackPageview', '/resources']);
		}
		break;
	}
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

// use this function to make a content tab show up selected by default
function showTheTab(tabShow)
{
	contentSwap(tabShow);
}

function initalizeColorBoxes()
{
	jQuery(document).ready(function($) {
		$(".showSilcoxBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showGouldBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showGalarisBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showCulumberBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showDicksonBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showGordonBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showVentoBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showTouzanBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showKoopBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showEvansBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showPoulosBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showBrunoBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showKennedyBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showSampleBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showBillupsBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showMcDonaldBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showTelferBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showPoffenbargerBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showAlmaBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showOlsonBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
		$(".showMcKownBio").colorbox({width:"483px", inline:true, opacity:0.85, speed:350, scrolling:false});
	});
}

function setupContactLightbox()
{
	jQuery(document).ready(function($) {
		//initialize lightbox
		$(".openContact").colorbox({width:"536px", height: "291px", inline:true, opacity:0.85, speed:350, scrolling:false});
		// contact form lightbox styles
		$("#theContactForm input[name='your-name']").css({width: '156px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/input-name.gif) top left no-repeat'});
		$("#theContactForm label[for='your-name']").css({width: '37px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/label-name.gif) top left no-repeat'});
		$("#theContactForm input[name='company']").css({width: '277px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/input-company.gif) top left no-repeat'});
		$("#theContactForm label[for='company']").css({width: '147px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/label-company.gif) top left no-repeat'});
		$("#theContactForm input[name='your-email']").css({width: '228px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/input-email.gif) top left no-repeat'});
		$("#theContactForm label[for='your-email']").css({width: '39px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/label-email.gif) top left no-repeat'});
		$("#theContactForm input[name='phone']").css({width: '149px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/input-phone.gif) top left no-repeat'});
		$("#theContactForm label[for='phone']").css({width: '94px', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/label-phone.gif) top left no-repeat'});
		$("#theContactForm .formRow:eq(0)").css({position: 'absolute', top: '89px', left: '32px'});
		$("#theContactForm .formRow:eq(1)").css({position: 'absolute', top: '89px', left: '206px'});
		$("#theContactForm .formRow:eq(2)").css({position: 'absolute', top: '147px', left: '32px'});
		$("#theContactForm .formRow:eq(3)").css({position: 'absolute', top: '147px', left: '274px'});
		$("#theContactForm input[type='submit']").css({display: 'block', width: '160px', height: '39px', position: 'absolute', top: '247px', left: '331px', zIndex: '9', textIndent: '-9999px', border: 'none', background: 'transparent url(/wp-content/themes/lmfunding/images/content-design/btn-submit-lightbox.png) top left no-repeat', cursor: 'pointer'});
	});
}

function showQuote()
{
	jQuery(document).ready(function($) {
		var numberOfQuotes;
		numberOfQuotes = document.getElementById("proofItWorks").getElementsByTagName("div").length;
		var randomNumber = Math.floor(Math.random()*(numberOfQuotes+1));
		if (randomNumber == 0)
		{
			randomNumber = 1;
		}
		$("#proofItWorks #quote" + randomNumber).css({display: 'block'});
	});
}


