/**
 * Sets two divs to the same height.
 * 
 * Sets two divs to the same height using possibly enclosed divs.
 *
 * @param div1
 *   the id of the first div tag.
 * @param div2
 *   the id of the second div tag.
 * @param space1
 *   the id for the spacing div tag associated with the first div tag.
 * @param space2
 *   the id for the spacing div tag associated with the second div tag.
 * @param correction1
 *   any corrections that need to be applied to the spacing for div1
 * @param correction2
 *   any corrections that need to be applied to the spacing for div2
 * @param mode
 *   0 is to add the difference to an extra space element
 *   1 is to match the two main divs in height
 *
 * @return
 *    none
 */
function setHeight(div1, div2, space1, space2, correction1, correction2, $mode) {

	/** div1 calculations **/
	//height
	var height_div1 = (document.getElementById(div1).offsetHeight);
	//total
	var total_div1 = height_div1 + correction1;
	
	/** div2 calculations **/
	//height
	var height_div2 = (document.getElementById(div2).offsetHeight);
	//total
	var total_div2 = height_div2 + correction2;
	
	/** set spacing **/
	var extra_space = Math.abs(total_div1-total_div2) + 'px';
	if ( total_div1 > total_div2 ) {
		//div1 > div2 -> give space to div2
		if ($mode) {
			document.getElementById(space2).style.height = total_div1 + 'px';
		} else {
			document.getElementById(space2).style.height = extra_space;
		}
	} else {
		//div1 < div2 -> give space to div1
		if ($mode) {
			document.getElementById(space1).style.height = total_div2 + 'px';
		} else {
			document.getElementById(space1).style.height = extra_space;
		}
	}
}

function findX(obj, menu) { 
	var x = -6; 
	var y = 25;
	while (obj) { 
		x += obj.offsetLeft;
		y += obj.offsetTop;
		obj = obj.offsetParent;
	} 
	hp = document.getElementById(menu); 
	hp.style.top = y + "px"; 
	hp.style.left = x + "px"; 
}

$(document).ready(function () {
	//top menu
	var id;
	var menu = new Array();
	menu[0] = "solutions";
	menu[1] = "partners";
	menu[2] = "customers";
	menu[3] = "news";
	menu[4] = "resource";
	menu[5] = "dev";
	menu[6] = "support";
	menu[7] = "about";
	menu[8] = "contact";
	for ( var i in menu) {
		$("#"+menu[i]+"Tab").bind("mouseenter", function () {
			$(this).addClass("active");
			id = $(this).attr("id");
			$("div[class*="+id+"]").addClass("active");
		}).bind("mouseleave", function () {
			$(this).removeClass("active");
			id = $(this).attr("id");
			$("div[class*="+id+"]").removeClass("active");
		});
		$("#"+menu[i]+"Nav").bind("mouseenter", function () {
			$(this).addClass("active");
			$("#"+menu+"Tab").addClass("active");
		}).bind("mouseleave", function () {
			$(this).removeClass("active");
			$("#"+menu+"Tab").removeClass("active");
		});
	}
	
	var path = window.location.pathname;
	
	if ( path == '/' ) {
		$('.slideshow').cycle({
			fx: 'fade',
			pause: 'true'
		});
	}
	
	//quicklinks
	/*
	$('#quickLinks').bind("mouseenter", function() {
		$('#quickMenu').addClass("active");
	}).bind("mouseleave", function () {
		$('#quickMenu').removeClass("active");
	});
	$('#quickMenu').bind("mouseenter", function() {
		$(this).addClass("active");
	}).bind("mouseleave", function () {
		$(this).removeClass("active");
	});
	*/
});