//
// Creates an xml/http object for ajax functions to use
//
function getXmlHttpObject() {
	var objXmlHttp = null;

	try {
		// Firefox, Opera 8.0+, Safari
		objXmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			objXmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e) {
			try {
				objXmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}

	return objXmlHttp;
}

function showHelp() {
	window.open('/help/');
	
}

//
// Hides the navigation area
//
function hideNav() {
	// Check to see if we're on the set live edit page
	var objSetImage = document.getElementById('divImage');

	if (objSetImage) {
		objSetImage.style.width = '695px';
	}

	document.getElementById('leftNavControl').src = '/img/show_nav.gif';
	document.getElementById('leftNavControl').onclick = showNav;
	document.getElementById('leftNavControl').onmouseover = new Function("Tip('Show navigation pane')");
	document.getElementById('leftNav').className = 'leftNavHidden';
}


//
// Unhides the navigation area
//
function showNav() {
	var objSetImage = document.getElementById('divImage');

	if (objSetImage) {
		objSetImage.style.width = '460px';
	}

	document.getElementById('leftNavControl').src = '/img/hide_nav.gif';
	document.getElementById('leftNavControl').onclick = hideNav;
	document.getElementById('leftNavControl').onmouseover = new Function("Tip('Hide navigation pane')");
	document.getElementById('leftNav').className = 'leftNavVisible';
}


//
// Displays account selector (below order wizard image)
//
function changeAccount() {
	objXmlHttp = getXmlHttpObject();

	if (objXmlHttp == null) { return; }

	objXmlHttp.onreadystatechange = function() {
		if (objXmlHttp.readyState == 4) {
			document.getElementById("nav_account_selector").innerHTML = objXmlHttp.responseText;
		}
	}

	objXmlHttp.open('GET', '/ajax/get_account_selector.php', true);
	objXmlHttp.send(null);
}

// Applies the jquery CSS fix
$(document).ready(function(){
	$("*").not("font,h1,h2,h3,h4,h5,h6,strong").addClass("common_font");
});
