// JavaScript Document

//*********************************************************
// moves the home page content to center another panel
// each div.expansive holds a row.  Each div.content-panel holds content
// col & row are the relative locations of the panel desired.
// panel is the id of the panel desired.  tab is the numerical 
// id part of the tab graphic that matches this panel.

function shift_content(col, row, panel, tab)
{
	var content_pad = 26;  	// account for bottom padding in content-main
	var row_pad = 0;  			// account for padding in row heigth
	var pos = String(-968 * (col - 1)) + 'px';
	var pageid = "#cpanel" + panel;
	var tabid = "#tab" + tab;
	var newheight = ($(pageid).height() - content_pad) + 'px';
	var rowheight = 0;
	
	$("#exp1 > div").each(function() {
		if(($(this).height() - row_pad) > rowheight)
			rowheight = ($(this).height() - row_pad);
	});
	
	rowheight = rowheight * (row - 1);
	
	$("[id*='cpanel']").animate({left:pos}, {duration:800});
	$("#condiv").animate({height:newheight}, {duration:800});		
	
	$("#exp1").animate({top:"-" + rowheight + "px"}, {duration:800});
	$("#exp2").animate({top:"-" + rowheight + "px"}, {duration:800});		

	$("[id*='tab']").removeClass('nav-tab-selected');
	$(tabid).addClass('nav-tab-selected');
}

// retrieves GET varibles from page URL
// usage: var var1 = $_GET('var1');
function $_GET(q,s) {
    s = (s) ? s : window.location.search;
    var re = new RegExp('&amp;'+q+'=([^&amp;]*)','i');
    return (s=s.replace(/^\?/,'&amp;').match(re)) ?s=s[1] :s='';
}

$(function() {
	var page_id = $_GET('page');
	
	if (page_id != "") {
		var ids = page_id.split(',');
		shift_content(parseInt(ids[0]), parseInt(ids[1]), parseInt(ids[2]), parseInt(ids[3]));
	}
	else
		$("#tab1").addClass('nav-tab-selected');
});	


