$(document).ready(function(){


	/* globNav Menus */
	$('#globNav li').hover(function(){
		$('ul',$(this)).show();
		$('ul',$(this)).css('left', $(this).offset().left);
		$('ul',$(this)).css('top', $(this).offset().top+32);
	}, function(){
		$('ul',$(this)).hide();
	});

});

function minHeight(objectID, minHeight) {	
	if (document.getElementById) {
		var c_height = document.getElementById(objectID).offsetHeight;
		
		if (c_height < minHeight) {
			document.getElementById(objectID).style.height = minHeight + 'px';
		}
	}
}
function setHeights() {
	//var l = document.getElementById("left").offsetHeight;
	//var r = document.getElementById("right").offsetHeight;

	//if (l > r) minHeight("content", (l - 160));
	//else if (r > l) minHeight("left", r);
}
function openProductPhotoGallery() {
	var rows = document.getElementById("photoBox").getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].style.display == "none") rows[i].style.display = "block";
	}
	document.getElementById("photoLink").innerHTML = '<a href="#" onclick="closeProductPhotoGallery();return false;">close</a>';	
	setHeights();
}
function closeProductPhotoGallery() {
	var rows = document.getElementById("photoBox").getElementsByTagName("tr");
	for(i = 0; i < rows.length; i++) {
		if (rows[i].className == "photoThumb") rows[i].style.display = "none";
	}
	document.getElementById("photoLink").innerHTML = '<a href="#" onclick="openProductPhotoGallery();return false;">view all photos</a>';	
	setHeights();
}
function openProductTabs(f, t) {
	var a = document.getElementById("product-tabs-list").getElementsByTagName("a");
	for(i = 0; i < a.length; i++) {
		a[i].className = (a[i] == t ? 'product-tab-selected' : 'product-tab');	
	}
	var d = document.getElementById("product-tabs-content").getElementsByTagName("div");
	for(i = 0; i < d.length; i++) {
		d[i].style.display = (d[i].id == 'tab-' + f ? '' : 'none');	
	}
}

function openNavDropdown(p) { 
	var divs = document.getElementById("top-nav").getElementsByTagName("div");
	for(i = 0; i < divs.length; i++) {
		if (divs[i].className == 'nav-dropdown' && divs[i].id != 'dropdown-' + p) {
			divs[i].style.display = 'none';	
		}
	}
	if (document.getElementById("dropdown-" + p)) document.getElementById("dropdown-" + p).style.display = 'block';
}
function manualBlogSwitch(b) {
	blogRotater = 0;
	blogSwitch(b);
}
function blogSwitch(b) {
	var d = document.getElementById("latest-news").getElementsByTagName("div");
	for(i = 0; i < d.length; i++) {
		d[i].style.display = (d[i].id == 'blurb-' + b ? 'block' : 'none'); 	
	}
	var a = document.getElementById("latest-news").getElementsByTagName("a");
	for(i = 0; i < a.length; i++) {
		if (a[i].className == 'blog-numbers' || a[i].className == 'blog-numbers-selected') {
			a[i].className = (a[i].id == 'blurb-link-' + b ? 'blog-numbers-selected' : 'blog-numbers');	
		}
	}
}
function rotateBlogItems(i) {
	if (blogRotater == 1) {
		blogSwitch(i);
		i++;
		if (i >= numBlogs) i = 0;
		setTimeout('rotateBlogItems(' + i + ')', 5000);
	}
}

function forgotPassword() {
	document.getElementById("password-forgot").style.display = 'none';
	document.getElementById("password-forgot-msg").style.display = 'block';
	xajax_forgotPassword(document.getElementById("username").value);
}
