// Vizible Javascript 
// created 2008 v0.1

function vizible_init()
{
	modifyLinks();
}

/*
This function simulates what server side code would do by setting any <a> tags that point to the current page
as class="current" and also removes their HREF so they can't be clicked
*/
function modifyLinks()
{
	var currentUrl=document.location.href;
	var split=currentUrl.split("/");
	var currentLocation=split[split.length-1];
	var linkString = "a[href='"+currentLocation.split("?")[0]+"']";
	var navLocation = linkString;
//	alert(currentLocation.indexOf("about"));
	if (currentLocation.indexOf("about")>=0) 
	{
		navLocation = "a[href='about.html']";
	}
	else if (currentLocation.indexOf("careers")>=0) 
	{
		navLocation = "a[href='careers.html']";
	}

	if((currentLocation != "index.html"))
	{
		if ($(navLocation+" img").attr("src"))
		{
			$(navLocation+" img").attr("src",$(navLocation+" img").attr("src").replace(/off/,"on"));
		}
	}
	$(linkString).attr("id","current");
	$("a[href='"+currentLocation+"']").click(function () { javascript:return false; });
	$("a[href='"+currentLocation+"']").attr("href","#");
}

function show (on)
{
	var onobj = $(on);
//	onobj.css("top","0px");
	$(onobj).fadeIn('slow');
	return false;
}


function centerOn(selector)
{
	var mywidth = 0;
	var myheight = 0;
	var horizontalScroll = 0;
	var verticalScroll = 0;

	if (!jQuery.browser.opera)
	{
		mywidth = $(window).width();
		myheight = $(window).height();
	}
	else
	{
		mywidth = window.innerWidth;
		myheight = window.innerHeight;
	}
	if (jQuery.browser.msie)
	{
		horizontalScroll = document.documentElement.scrollLeft;
		verticalScroll = document.documentElement.scrollTop;
	}
	else 
	{
		horizontalScroll = window.pageXOffset;
		verticalScroll = window.pageYOffset;
	}
	var centerleft = ((mywidth/2) - parseInt($(selector).width()/2))+"px";
	var centertop = (((myheight/2) - parseInt($(selector).height()/2)) + verticalScroll) +"px";

	//alert(mywidth  + " | " +  myheight   + " | " +   $(selector).width()  + " | " +  $(selector).height() + " | " + centerleft + " | " +  centertop + " | " + verticalScroll);
	$(selector).css("left", centerleft);
	$(selector).css("top", centertop);
	
	return false;
}


/*
 * This function parses ampersand-separated name=value argument pairs from
 * the query string of the URL. It stores the name=value pairs in 
 * properties of an object and returns that object. Use it like this:
 * 
 * var args = getArgs();  // Parse args from URL
 * var q = args.q || "";  // Use argument, if defined, or a default value
 * var n = args.n ? parseInt(args.n) : 10; 
 */
function getArgs()
{
	var args = {};
	var query = location.search.substring(1);     // Get query string
	var pairs = query.split("&");                 // Break at ampersand
	for(var i = 0; i < pairs.length; i++)
	{
		var pos = pairs[i].indexOf('=');          // Look for "name=value"
		if (pos == -1)
		{
			continue;                  // If not found, skip
		}
		var argname = pairs[i].substring(0,pos);  // Extract the name
		var value = pairs[i].substring(pos+1);    // Extract the value
		value = decodeURIComponent(value);        // Decode it, if needed
		args[argname] = value;                    // Store as a property
	}
	return args;                                  // Return the object
}

// 	window.onload=vizible_init;
$(document).ready(function() {
	vizible_init();
	$(".fade").fadeIn(1982, function () { $(".fadebold").css("font-weight", "bold"); });
}); // end doc.ready








