// JavaScript Document

$(document).ready(function(){			 

	// ----TAB INIT -----
 
	$('.pTab').addClass('formatTab');	
	$('.pTab').eq(0).addClass('activeTab').css('margin-left', '4em');
	

	$('.tabContent').css('margin-top', '2.4em');
	$('.tabContent').css('margin-left', '0em');
	$('.tabContent').addClass('formatTabContent');
	$('.tabContent').eq(0).addClass('activeContent');
	$('.tabContent').eq(1).find('ul').css('margin-top', '4em');

	$('.tabContent').find('li').eq(0).css('margin-top', '1.7em');
	
	//----BROWSER CHANGES ----------------------------------
	
	theApp = navigator.appVersion;
	
	var webKit = new RegExp('AppleWebKit');
	
	var result = theApp.match(webKit);
	
	if(result == 'AppleWebKit'){ //Safari Fix
		
		$('.formatTab').css('margin-top', 1);
	
		
	}
	
	var msie6 = new RegExp('MSIE 6.0');
	
	var result = theApp.match(msie6);
	
	if(result == 'MSIE 6.0'){
		
		$('.tabUL').css('width', '53em');
		
	}
	
	//----SET INITIAL HEIGHT -------------------------------
	
	var firstContents = $('.partDesc').children().eq(1).text();
	
	var approxHeight = (firstContents.length)*.25; //aproximate relationship between string characters and height

	$('.product_container').height(approxHeight + 658);
	
	//-------------------------------------------
	
	$('.pTab').bind('click', tabHandler);
	
	function tabHandler() {
		
		if($(this).hasClass('activeTab')){}
		
		else {

			$('.pTab').removeClass('activeTab');
			$(this).addClass('activeTab');
			
			$('.tabContent').removeClass('activeContent');
			$(this).next().addClass('activeContent');
			
			activeHeight = $('.activeContent').height();

			$('.product_container').height(activeHeight + 658);
			
		} //end if/else
	}
	
	//-------FORMATS PAGE FOR EXTRA LONG TABS ------------------
	
	

						   
});
