jQuery.noConflict();  
jQuery(document).ready(function(){ 

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}


	jQuery("#portfolio_tab").click(function () {
		jQuery("#portfolio_pane").css("display","block");
		jQuery("#li_portfolio").css("background","#4d93d4");
		jQuery("#li_search").css("background","#f0f0f0");
		jQuery("#search_pane").css("display","none");
		jQuery("#search_tab").css("color","#336699");
		jQuery("#portfolio_tab").css("color","#ffffff");
		// load the first portfolio on initial page load
		if (jQuery('.portfolio_list').length > 0) {
			var urls = jQuery("#portfolio_urls0").val().split(',');
			HH.fn.reload_chart(urls);
		}
	});

	jQuery("#search_tab").click(function () {
		jQuery("#portfolio_pane").css("display","none");
		jQuery("#li_portfolio").css("background","#f0f0f0");
		jQuery("#li_search").css("background","#4d93d4");
		jQuery("#search_pane").css("display","block");
		jQuery("#portfolio_tab").css("color","#336699");
		jQuery("#search_tab").css("color","#ffffff");
	});


	// preload images
	//jQuery.preloadCssImages();

	var heardableGrade = 0;
	var componentCounter = 0;
	var sit = '';


	// handle portfolio click on dashboard.php
	// ideally, this first grabs results from db. 
	// if db has recent results, display that only.
	// if results are dated, do a non-deep scan and schedule a deepscan to follow.
	jQuery(".portfolio_list").click(function() {
	
		// reset views 
		resetViews();

		url = ""; url2 = ""; url3 = ""; url4 = ""; url5 = ""; 
		id = ""; id2 = ""; id3 = ""; id4 = ""; id5 = ""; 
		is_quickscan_button = this.id;
		if (is_quickscan_button == "quickscan_button")
		{
			// quick scan fields, put urls in array
			var urlArray = [];
			if (jQuery("#url_1").val().length != 0)
			urlArray.push(jQuery("#url_1").val());
			if (jQuery("#url_2").val().length != 0)
			urlArray.push(jQuery("#url_2").val());
			if (jQuery("#url_3").val().length != 0)
			urlArray.push(jQuery("#url_3").val());
			if (jQuery("#url_4").val().length != 0)
			urlArray.push(jQuery("#url_4").val());
			if (jQuery("#url_5").val().length != 0)
			urlArray.push(jQuery("#url_5").val());

			if (urlArray.length == 0)
			return false;

		}
		else
		{	// put urls in array
			urlString = jQuery("#portfolio_urls" + this.id).val();
			urlArray = urlString.split(",");
		}

		// clean each domain and get it's site id
		var a_url = [];
		var a_id = [];
		multiscan_count = 0;
		for (i=0;i<5;i++)
		{
			if (i < urlArray.length) {
				a_url[i] = cleanedDomain(urlArray[i]); // clean domain
				a_id[i] = getSiteID(a_url[i]); // get a site id
				multiscan_count++;
			}
			else {
				a_url[i] = ''; a_id[i] = '';
			}
		}
		
		// If on portfolio page
		
		if (is_quickscan_button != "quickscan_button")
		{
		initializeBarChart(multiscan_count);
		}
		url1 = a_url[0]; url2 = a_url[1]; url3 = a_url[2]; url4 = a_url[3]; url5 = a_url[4];
		id1 = a_id[0]; id2 = a_id[1]; id3 = a_id[2]; id4 = a_id[3]; id5 = a_id[4];


		// See if "Save to portfolio" option is checked
		save_portfolio = 0;
		portfolio_name = '';
		if (jQuery("#saveInPortfolio").is(':checked') && jQuery("#portfolio_name").val() != '' && this.id == "quickscan_button")
		{
			save_portfolio = 1;		
			portfolio_name =  jQuery("#portfolio_name").val();
		}
 

		hasBeenScanned = 0;
		jQuery.ajax({
			type: "POST",
			url: "/ajax_stats_rev.php",
			async: "false",
			data: "id=" + id1 + "&id2=" + id2 + "&id3=" + id3 + "&id4=" + id4 + "&id5=" + id5,
			success: function(msg){

				// alert(url1 + id1 + url2 + id2 + url3 + id3 + url4 + id4 + url5 + id5);
				rescan = 0;


				// find out if any sites need to be scanned
	 
				if (id1.length > 0 && jQuery("site1_rescan", msg).text() == "score") {
					rescan = 1;
				}
				if (id2.length > 0 &&  jQuery("site2_rescan", msg).text() =="score") {
					rescan = 1; 
				}
				if (id3.length > 0 && jQuery("site3_rescan", msg).text() =="score") {
					rescan = 1; 
				}
				if (id4.length > 0 && jQuery("site4_rescan", msg).text() == "score") { 
					rescan = 1; 
				}
				if (id5.length > 0 && jQuery("site5_rescan", msg).text() == "score") {
					rescan = 1; 
				}
	 

				if (rescan == 0){ 

					// if site has recent data, poll db
					if (is_quickscan_button == "quickscan_button"){
						progress_interal = setInterval('getProgress(id1, id2, id3, id4, id5)',5000);
						
					}
					//jQuery('html, body').animate({scrollTop: jQuery("#endresults").offset().top}, 2000);
					//getComparison(url1, id1, url2, id2, url3, id3, url4, id4, url5, id5, "poll");
					getComparison(url1, id1, url2, id2, url3, id3, url4, id4, url5, id5, "poll", save_portfolio, portfolio_name);
			
			
					
					//jQuery("#multisearch_resultbox").html(); 					
					// else run scanner and poll db
					//alert("poll");
				}
				// else it has not been scanned. run comparison scan and poll db. 
				else
				{

 
					// begin crawl should start here

					// start polling for results
					if (is_quickscan_button == "quickscan_button")
					progress_interal = setInterval('getProgress(id1, id2, id3, id4, id5)',5000);

					// run scoring 
					getComparison(url1, id1, url2, id2, url3, id3, url4, id4, url5, id5, "score", save_portfolio, portfolio_name);
					
					//jQuery("#multisearch_resultbox").html(); 					

				}
			} 
		});
		
		// reload_chart will create the chart if necessary, otherwise it will update with new data
		if (is_quickscan_button != "quickscan_button")
		{HH.fn.reload_chart(urlArray);}
		

		return false;

	});

 

	function getComparison(url1, id1, url2, id2, url3, id3, url4, id4, url5, id5, action, save_portfolio, portfolio_name) {

		jQuery.ajax({
			type: "POST",
			url: "/ajax_comparison_rev5.php",
			async: "false",
			data: "id1=" + id1 + "&id2=" + id2 + "&id3=" + id3 + "&id4=" + id4 + "&id5=" + id5 + "&url1=" + url1 + "&url2=" + url2 + "&url3=" + url3 + "&url4=" + url4 + "&url5=" + url5 + "&action=" + action+ "&save_portfolio=" + save_portfolio+ "&portfolio_name=" + portfolio_name,
			success: function(xml){


				// get social info
				jQuery(xml).find("xml").each(function()
				{

					jQuery(this).find("portable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#scanProgress" + class_id).html("");
						//jQuery("#multisearch_resultbox").html(); 
						jQuery("#detailView" + class_id + " .portableResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .portableResults").append('<div class="subscore_achievements"></div>');
						
						jQuery("#detailView" + class_id + " .portableResults .subscore_achievements").append(jQuery(this).find("page_inc_results").text() );
						
						
	 

						jQuery("#detailView" + class_id + " .portableResults").append('<a href="/blogs.php?user_id=7&blogentry_id=65" class="improveScore" >IMPROVE THIS SCORE</a>');

						mobilePlatformsSupported = 0;

					});

					jQuery(this).find("sociable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#detailView" + class_id + " .socialResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .socialResults").append('<div class="subscore_achievements"></div>');

						jQuery("#detailView" + class_id + " .socialResults .subscore_achievements").append(jQuery(this).find("result").text() );
						jQuery("#detailView" + class_id + " .socialResults").append('<a href="/blogs.php?user_id=7&blogentry_id=67" class="improveScore" >IMPROVE THIS SCORE</a>');

					});

					jQuery(this).find("shareable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#detailView" + class_id + " .shareableResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .shareableResults").append('<div class="subscore_achievements"></div>');
						jQuery("#detailView" + class_id + " .shareableResults .subscore_achievements").append(jQuery(this).find("result").text() );
						jQuery("#detailView" + class_id + " .shareableResults").append('<a href="/blogs.php?user_id=7&blogentry_id=62" class="improveScore" >IMPROVE THIS SCORE</a>');

					});

					jQuery(this).find("measurable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#detailView" + class_id + " .measurableResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .measurableResults").append('<div class="subscore_achievements"></div>');
						jQuery("#detailView" + class_id + " .measurableResults .subscore_achievements").append(jQuery(this).find("result").text() );
						jQuery("#detailView" + class_id + " .measurableResults").append('<a href="/blogs.php?user_id=7&blogentry_id=64" class="improveScore" >IMPROVE THIS SCORE</a>');

					});

					jQuery(this).find("searchable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#detailView" + class_id + " .searchableResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .searchableResults").append('<div class="subscore_achievements"></div>');
						jQuery("#detailView" + class_id + " .searchableResults .subscore_achievements").append(jQuery(this).find("result").text() );
						jQuery("#detailView" + class_id + " .searchableResults").append('<a href="/blogs.php?user_id=7&blogentry_id=63" class="improveScore" >IMPROVE THIS SCORE</a>');

					});


					jQuery(this).find("actionable").each(function()
					{

						// keep things in order
						if (jQuery(this).find("domain_id").text() == id1)
						class_id = 1;
						if (jQuery(this).find("domain_id").text() == id2)
						class_id = 2;
						if (jQuery(this).find("domain_id").text() == id3)
						class_id = 3;
						if (jQuery(this).find("domain_id").text() == id4)
						class_id = 4;
						if (jQuery(this).find("domain_id").text() == id5)
						class_id = 5;

						jQuery("#detailView" + class_id + " .actionableResults").html('<div class="subscore">&nbsp;&nbsp;+ ' + jQuery(this).find("points").text() + '&nbsp;&nbsp;</div>');
						jQuery("#detailView" + class_id + " .actionableResults").append('<div class="subscore_achievements"></div>');
						jQuery("#detailView" + class_id + " .actionableResults .subscore_achievements").append(jQuery(this).find("result").text() );
						jQuery("#detailView" + class_id + " .actionableResults").append('<a href="/blogs.php?user_id=7&blogentry_id=66" class="improveScore" >IMPROVE THIS SCORE</a>');

					});

				});

			}
		});


	}

 

	function getSiteID (siteurl){
		jQuery.ajax({
			type: "POST",
			url: "/ajax_initialize_rev.php",
			data: "url=" + siteurl,
			async: false,
			success: function(xml){
				if (jQuery("siteid", xml).text().length > 0){
					sit = jQuery("siteid", xml).text();
				}
			}
		});
		return sit;
	}


	function updateMsg() {
		jQuery("#socialProgress").html("Updated<br/>");
	}

	String.prototype.trim = function() {
		// Strip leading and trailing white-space
		return this.replace(/^\s*|\s*jQuery/g, "");
	}

	// getStats
	function getStats() {

		jQuery.post("/ajax_stats_rev.php", {id: sit }, function(xml) {
			// format and output result
			if (jQuery("page_crawl_count", xml).text().length > 0)
			jQuery(".lastpagecrawled").html( jQuery("page_crawl_count", xml).text() 	);	 

		});

	}
	// /getStats



	//start crawl
	function crawl(){

		jQuery.ajax({
			type: "POST",
			url: "/ajax_proxy.php",
			async: "false",
			data: "url=" + siteurl + "&id=" + sit,
			success: function(msg){

				// debug code
				jQuery("#debug").html("<strong>Debug</strong><br/><span  style='color:#666666;width:450px; word-wrap:break-word'>" +  msg + "</span>");
				jQuery("#debug").append("url=http://www." + siteurl + "&id=" + sit);

				getSingleScanData();

				// Update results 
				jQuery("#page_crawl_count").html("Crawl complete");
				jQuery("#searchableProgressBar").css( "background", "url()" );
				jQuery('#searchableResultsButtonCont').show();
				jQuery("#actionableProgressBar").css( "background", "url()" );
				jQuery('#actionableResultsButtonCont').show();
				jQuery("#shareableProgressBar").css( "background", "url()" );

				// stop polling
				clearInterval(stats_interval);

			}
		});

	}
	// /crawl

	var randomnumber=Math.floor(Math.random()*1100)

	//formats domain name for screen
	function cleanedDomain(domainname) {
		if (domainname == undefined){
			return domainname;
		}
		else {
			searchstring = domainname.split(".");

			if (searchstring.length ==3)
				if (searchstring[0] == "www")
					cleanedstring = searchstring[1] + '.' + searchstring[2];
				else
					cleanedstring = searchstring[0] + '.' + searchstring[1] + '.' + searchstring[2];
			else
			cleanedstring = domainname;
			return cleanedstring;
		}
	}

	jQuery("#saveInPortfolio").click(function () {
		//jQuery("#saveInPortfolio.p").css("display","block");
		jQuery('p').toggle(); 
	});
	
	jQuery("#contactbox").click(function () {
		//jQuery("#saveInPortfolio.p").css("display","block");
		//jQuery('#otherfields').toggle(); 
		jQuery("#otherfields").css( "display", "block" );
		jQuery("#contactbox").css("height","150px");
		if ( jQuery("#contactbox").val() == "Send us comments, bug reports, love letters, etc.")
			jQuery("#contactbox").val(''); 
 

	});



	jQuery(".resetform").click(function () {
		document.forms[0].reset();

		//clearInterval(stats_interval2);
		
		jQuery("#multisearch_resultbox").html(''); 		

		jQuery(".siteTitleLine").html("");
		jQuery(".siteTitleLine2").html(""); 

		jQuery("#siteDetails1").fadeOut("slow");
		var s = setTimeout('jQuery("#siteDetails1").css("display","none")',500);
		jQuery("#pageCrawl1").html("");	
		jQuery("#scanProgress1").html("");	
 

		jQuery("#siteDetails2").fadeOut("slow");
		setTimeout('jQuery("#siteDetails2").css("display","none")',500);		
		jQuery("#scanProgress2").html("");
		jQuery("#pageCrawl2").html("");
 

		jQuery("#siteDetails3").fadeOut("slow");
		setTimeout('jQuery("#siteDetails3").css("display","none")',500);	
		jQuery("#scanProgress3").html("");
		jQuery("#pageCrawl3").html("");	
 

		jQuery("#siteDetails4").fadeOut("slow");
		setTimeout('jQuery("#siteDetails4").css("display","none")',500);
		jQuery("#scanProgress4").html("");
		jQuery("#pageCrawl4").html("");	
 

		jQuery("#siteDetails5").fadeOut("slow");
		setTimeout('jQuery("#siteDetails5").css("display","none")',500);
		jQuery("#scanProgres5").html("");
		jQuery("#pageCrawl5").html("");	
 
	});

});


// SUPPORTING FUNCTIONS BELOW //

var portTitle = "";
var heardableGrade = 0;
var componentCounter = 0;
var sit = '';

function getProgress(id1, id2, id3, id4, id5) {
 
	jQuery.post("/ajax_stats_rev.php", {id: id1, id2: id2, id3: id3, id4: id4, id5: id5 }, function(xml) {
		// format and output result

		if (parseFloat( jQuery("site1_total_points", xml).text()) > 0 ){
			jQuery("#pageCrawl1").html( jQuery("page_crawl_count", xml).text() + " pages crawled"	);	
			jQuery("#siteDetails1").fadeIn("slow");
			if (url1.length > 0) {			
				searchstring = url1.split(".");
		 
				if (searchstring.length ==3){
					jQuery("#siteTitle1_1").html(searchstring[0] );
					jQuery("#siteTitle1_2").html("." + searchstring[1] + '.' + searchstring[2]);
				}
				else {
					jQuery("#siteTitle1_1").html(searchstring[0] );
					jQuery("#siteTitle1_2").html("." + searchstring[1] );
				}	
			}

			updateBarChart(1, jQuery("site1_portable_points", xml).text(), jQuery("site1_shareable_points", xml).text(), jQuery("site1_measurable_points", xml).text(), jQuery("site1_actionable_points", xml).text(), jQuery("site1_sociable_points", xml).text(), jQuery("site1_searchable_points", xml).text(), jQuery("site1_total_points", xml).text() ) ;
		}
		if (parseFloat( jQuery("site2_total_points", xml).text()) > 0 ){
			jQuery("#siteDetails2").fadeIn("slow");
			if (url2.length > 0) {			
				searchstring = url2.split(".");
		 
				if (searchstring.length ==3){
					jQuery("#siteTitle2_1").html(searchstring[0] );
					jQuery("#siteTitle2_2").html("." + searchstring[1] + '.' + searchstring[2]);
				}
				else {
					jQuery("#siteTitle2_1").html(searchstring[0] );
					jQuery("#siteTitle2_2").html("." + searchstring[1] );
				}	
			}
			
			jQuery("#pageCrawl2").html(  jQuery("page_crawl_count2", xml).text() + " pages crawled");	

			updateBarChart(2, jQuery("site2_portable_points", xml).text(), jQuery("site2_shareable_points", xml).text(), jQuery("site2_measurable_points", xml).text(), jQuery("site2_actionable_points", xml).text(), jQuery("site2_sociable_points", xml).text(), jQuery("site2_searchable_points", xml).text(), jQuery("site2_total_points", xml).text() ) ;
		}
		if (parseFloat( jQuery("site3_total_points", xml).text()) > 0 ){
			jQuery("#siteDetails3").fadeIn("slow");
			if (url3.length > 0) {			
				searchstring = url3.split(".");
				if (searchstring.length ==3){
					jQuery("#siteTitle3_1").html(searchstring[0] );
					jQuery("#siteTitle3_2").html("." + searchstring[1] + '.' + searchstring[2]);
				}
				else {
					jQuery("#siteTitle3_1").html(searchstring[0] );
					jQuery("#siteTitle3_2").html("." + searchstring[1] );
				}	
			}
			
			jQuery("#pageCrawl3").html( jQuery("page_crawl_count3", xml).text() + " pages crawled");	

			updateBarChart(3, jQuery("site3_portable_points", xml).text(), jQuery("site3_shareable_points", xml).text(), jQuery("site3_measurable_points", xml).text(), jQuery("site3_actionable_points", xml).text(), jQuery("site3_sociable_points", xml).text(), jQuery("site3_searchable_points", xml).text(), jQuery("site3_total_points", xml).text() ) ;
		}
		if (parseFloat( jQuery("site4_total_points", xml).text()) > 0 ){
			jQuery("#siteDetails4").fadeIn("slow");
			if (url4.length > 0) {			
				searchstring = url4.split(".");
				if (searchstring.length ==3){
					jQuery("#siteTitle4_1").html(searchstring[0] );
					jQuery("#siteTitle4_2").html("." + searchstring[1] + '.' + searchstring[2]);
				}
				else {
					jQuery("#siteTitle4_1").html(searchstring[0] );
					jQuery("#siteTitle4_2").html("." + searchstring[1] );
				}	
			}
			
			jQuery("#pageCrawl4").html(  jQuery("page_crawl_count4", xml).text() + " pages crawled"	);	

			updateBarChart(4, jQuery("site4_portable_points", xml).text(), jQuery("site4_shareable_points", xml).text(), jQuery("site4_measurable_points", xml).text(), jQuery("site4_actionable_points", xml).text(), jQuery("site4_sociable_points", xml).text(), jQuery("site4_searchable_points", xml).text(), jQuery("site4_total_points", xml).text() ) ;
		}
		if (parseFloat( jQuery("site5_total_points", xml).text()) > 0 ){
			jQuery("#siteDetails5").fadeIn("slow"); 
			if (url5.length > 0) {			
				searchstring = url5.split(".");
				if (searchstring.length ==3){
					jQuery("#siteTitle5_1").html(searchstring[0] );
					jQuery("#siteTitle5_2").html("." + searchstring[1] + '.' + searchstring[2]);
				}
				else {
					jQuery("#siteTitle5_1").html(searchstring[0] );
					jQuery("#siteTitle5_2").html("." + searchstring[1] );
				}	
			}
			jQuery("#pageCrawl5").html(  jQuery("page_crawl_count5", xml).text() + " pages crawled");	

			updateBarChart(5, jQuery("site5_portable_points", xml).text(), jQuery("site5_shareable_points", xml).text(), jQuery("site5_measurable_points", xml).text(), jQuery("site5_actionable_points", xml).text(), jQuery("site5_sociable_points", xml).text(), jQuery("site5_searchable_points", xml).text(), jQuery("site5_total_points", xml).text() ) ;
		}
		
		if (parseFloat( jQuery("site5_total_points", xml).text()) > 0 || parseFloat( jQuery("site4_total_points", xml).text()) > 0 || parseFloat( jQuery("site3_total_points", xml).text()) > 0 || parseFloat( jQuery("site2_total_points", xml).text()) > 0 || parseFloat( jQuery("site1_total_points", xml).text()) > 0){
			jQuery("#multisearch_resultbox").html(""); 
		}
		
	});



}

function initializeBarChart(scan_count) {

	for (classId=1; classId <= scan_count;  classId++) {

		jQuery("#scorebar" + classId +"  .portable_bar").css( "width",  "2px"	);	
		jQuery("#scorebar" + classId +"  .shareable_bar").css( "width",  "2px"	);	
		jQuery("#scorebar" + classId +"  .measurable_bar").css( "width",  "2px"	);	
		jQuery("#scorebar" + classId +"  .actionable_bar").css( "width",  "2px"	);	
		jQuery("#scorebar" + classId +"  .sociable_bar").css( "width",  "2px"	);	
		jQuery("#scorebar" + classId +"  .searchable_bar").css( "width",  "2px"	);	
		jQuery('#scorebar' + classId +'  .portable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Portable: 0' ,offset: [-55, -70]  });
		jQuery('#scorebar' + classId +'  .shareable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Shareable: 0' ,offset: [-55, -70]  });
		jQuery('#scorebar' + classId +'  .measurable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Measurable: 0' ,offset: [-55, -70]  });
		jQuery('#scorebar' + classId +'  .actionable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Actionable: 0',offset: [-55, -70]  });
		jQuery('#scorebar' + classId +'  .sociable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Sociable: 0',offset: [-55, -70]  });
		jQuery('#scorebar' + classId +'  .searchable_bar a').simpletip({ fixed: false, position: 'top' , content: 'Searchable: 0',offset: [-55, -70]  });
	}
}
function updateBarChart(classId, portable_points, shareable_points, measurable_points, actionable_points, sociable_points, searchable_points, total_points ) {

	// display each score length within its appropriate space. 
	// max actionable points = 200. this represents 1/5 of 600 pixel wide score bar. which is 120 pixels. 
	// ( actionable score / 200 ) * 120 = width
	// ( shareable score / 150 ) * 90 = width
	// ( Searchable score / 150 ) * 90 = width
	// ( Sociable score / 200 ) * 120 = width
	// ( Portable score / 200 ) * 120 = width
	// ( Measurable score / 100 ) * 60 = width

	// only update if there is a value. 
	//if (parseFloat(portable_points) > 0 || parseFloat(shareable_points) > 0 || parseFloat(measurable_points) > 0 || parseFloat(actionable_points) > 0 || parseFloat(sociable_points) > 0 || parseFloat(searchable_points) > 0){

		if (parseFloat(portable_points) > 0 ){
			jQuery("#scorebar" + classId +"  .portable_bar").css( "width",  (((parseFloat(portable_points) / 200) * 120)+2) + "px"	);	
			jQuery('#scorebar' + classId +'  .portable_bar a').simpletip(); // Access the API of a previously initatied simpletip 
			var api = jQuery('#scorebar' + classId +'  .portable_bar a').eq(0).simpletip(); // Perform a simple API call to update tooltip contents
			api.update('Portable: ' + portable_points);
		}

		if (parseFloat(shareable_points) > 0 ){
			jQuery("#scorebar" + classId +"  .shareable_bar").css( "width", (((parseFloat(shareable_points) / 150) * 90) + 2) + "px"	);	
			jQuery('#scorebar' + classId +'  .shareable_bar a').simpletip(); 
			var api = jQuery('#scorebar' + classId +'  .shareable_bar a').eq(0).simpletip(); 
			api.update('Shareable: ' + shareable_points);
		}

		if (parseFloat(measurable_points) > 0 ){

			jQuery("#scorebar" + classId +"  .measurable_bar").css( "width", (((parseFloat(measurable_points) / 100) * 60) + 2) + "px"	);	
			jQuery('#scorebar' + classId +'  .measurable_bar a').simpletip();
			var api = jQuery('#scorebar' + classId +'  .measurable_bar a').eq(0).simpletip();
			api.update('Measurable: ' + measurable_points);

		}

		if (parseFloat(actionable_points) > 0 ){
			jQuery("#scorebar" + classId +"  .actionable_bar").css( "width", (((parseFloat(actionable_points) / 200) * 120) + 2) + "px"	);
			jQuery('#scorebar' + classId +'  .actionable_bar a').simpletip();
			var api = jQuery('#scorebar' + classId +'  .actionable_bar a').eq(0).simpletip();
			api.update('Actionable: ' + actionable_points);
		}

		if (parseFloat(sociable_points) > 0 ){
			jQuery("#scorebar" + classId +"  .sociable_bar").css( "width", (((parseFloat(sociable_points) / 200) * 120) + 2) + "px"	);
			jQuery('#scorebar' + classId +'  .sociable_bar a').simpletip();
			var api = jQuery('#scorebar' + classId +'  .sociable_bar a').eq(0).simpletip();
			api.update('Sociable: ' + sociable_points);
		}

		if (parseFloat(searchable_points) > 0 ){
			jQuery("#scorebar" + classId +"  .searchable_bar").css( "width", (((parseFloat(searchable_points) / 150) * 90) + 2) + "px"	);
			jQuery('#scorebar' + classId +'  .searchable_bar a').simpletip();
			var api = jQuery('#scorebar' + classId +'  .searchable_bar a').eq(0).simpletip();
			api.update('Searchable: ' + searchable_points);
		}

		if (parseFloat(total_points) > 0 ){
			jQuery("#points" + classId).html(total_points  );
		}
		
		//}


	}

	// clear out any old results if any
	function resetViews() {

		jQuery("#siteDetails1").css("display", "none");
		jQuery("#siteDetails2").css("display", "none");
		jQuery("#siteDetails3").css("display", "none");
		jQuery("#siteDetails4").css("display", "none");
		jQuery("#siteDetails5").css("display", "none");

		jQuery(".portable_bar").css("width", "0");
		jQuery(".shareable_bar").css("width", "0");
		jQuery(".measurable_bar").css("width", "0");
		jQuery(".actionable_bar").css("width", "0");
		jQuery(".searchable_bar").css("width", "0");
		jQuery(".sociable_bar").css("width", "0");

		for (var classid=1; classid <=5; classid++) {

			jQuery("#detailView" + classid + " .portableResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');
			jQuery("#detailView" + classid + " .shareableResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');
			jQuery("#detailView" + classid + " .measurableResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');
			jQuery("#detailView" + classid + " .actionableResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');
			jQuery("#detailView" + classid + " .socialResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');
			jQuery("#detailView" + classid + " .searchableResults").html('<img src="/dev/images/refresh-animated.gif"/> Updating data...');

			jQuery(".points_wrapper" + classid + " #points1").html('0');
			jQuery(".points_wrapper" + classid + " #points2").html('0');
			jQuery(".points_wrapper" + classid + " #points3").html('0');
			jQuery(".points_wrapper" + classid + " #points4").html('0');
			jQuery(".points_wrapper" + classid + " #points5").html('0');
		}

		jQuery('#detailView1').fadeOut('slow');
		jQuery('#detailView2').fadeOut('slow');
		jQuery('#detailView3').fadeOut('slow');
		jQuery('#detailView4').fadeOut('slow');
		jQuery('#detailView5').fadeOut('slow');
		
		jQuery("#multisearch_resultbox").html('Calculating Heardable Scores...   <img src="/dev/images/refresh-animated.gif" /> '); 		
		
	}


