// JavaScript Document
function startover() {										 
	if ($(this).is(".active")) {  //If it's already active, then...
		return false; // Don't click through
	} else {
		$(".startover").hide();
		$(".services_list li").show();		
		$("#service_box2 ul, #service_box2 p, #service_box3 p").hide();
		var descId = $(".services_list li:nth-child(1) a").attr("name");	
		//$("p#"+descId+"_desc").show();
		$("#service_box3 img").show();
		//$("img#"+descId+"_img").show();	
		$(".services_list li a, .subservice_list li a").removeClass("active").removeClass("curr");
		//$(".services_list li a.active").parent().show();
	}
} 


$(function() { 
	startover();
	var $title = $("#page_title h2").html();
	if($title==null) { 
		 document.title = "Welcome to Technology2Reality.com";
	} else {
		 document.title = "Welcome to Technology2Reality.com  - " + $title;
	}
	
	
	$(".startover").click( function() {	startover(); });
	$(".services_list li a").hover( function() {
		//if ($(this).is(".active") || $(this).is(".curr") || $(".services_list li a").is(".curr")) {  //If it's already active, then...
		/*if ($(".services_list li a").is(".curr") || $(".services_list li a").is(".active")) {  //If it's any of one already active, then...
				return false; // Don't click through
		} else {*/
			$("#service_box2 ul, #service_box2 p, #service_box3 p").hide();
			var descId = $(this).attr("name");	
			$("p#"+descId+"_desc").show();
			//$("img#"+descId+"_img").show();
		//}
	}, function() {
		$active = $(".services_list li a.active");
		$activeId = $active.attr("name");
		var descId = $(this).attr("name");
		$("p#"+descId+"_desc").hide();
		$("#"+$activeId).show();
	});
	
	$(".services_list li a").click( function() {
		var descId = $(this).attr("name");
		$(".services_list li a").removeClass("curr").removeClass("active");
		$(this).addClass("curr");
		if ($("ul#"+descId).length) { // implies *not* zero
			//$("#service_box2 ul, #service_box2 p, #service_box3 img, #service_box3 p, ul.services_list > li").hide();
			$("#service_box2 ul, #service_box2 p, #service_box3 img, #service_box3 p").hide();
			//$(".startover").show();
			$("ul#"+descId).show();		
			$(".services_list li a.curr").addClass("active").parent().show();
			$(".subservice_list li a").removeClass("active");
			var subdescId = $("ul#"+descId+" li:nth-child(1) a").attr("name");	
			//$("ul#"+descId+" li a").removeClass("active");
			//$("ul#"+descId+" li:nth-child(1) a").addClass("active");
			//$("p#"+subdescId+"_desc").show();		
		} else {
			$("#service_box2 ul, #service_box2 p, #service_box3 p").hide();
			$(".services_list li a.curr").addClass("active");
			//$(".startover").show();
			$("p#"+descId).show();
		}		
	});
	
	$(".subservice_list li a").hover( function() {
		$(".subservice_list li a").removeClass("curr");
		/*if ($(".subservice_list li a").is(".curr") || $(".subservice_list li a").is(".active")) {  //If it's already active, then...
				return false; // Don't click through
		} else {*/
			$(this).addClass("curr");
			$("#service_box3 img, #service_box3 p").hide();
			var descId = $(this).attr("name");	
			$("p#"+descId+"_desc").show();
		//}
	}, function() {		
		$active = $(".services_list li a.active");
		$activeId = $active.attr("name");
		$subactive = $(".subservice_list li a.active");
		$subactiveId = $subactive.attr("name");
		var descId = $(this).attr("name");
		$("#"+$activeId).show();
		$("p#"+descId+"_desc").hide();
		$("#"+$subactiveId+"_price").show();
	});	
	
	$(".subservice_list li a").click( function() {
		if ($(this).is(".active")) {  //If it's already active, then...
				return false; // Don't click through
		} else {
			$(".subservice_list li a").removeClass("active");
			$(this).addClass("active");
			$("#service_box3 img, #service_box3 p").hide();
			var descId = $(this).attr("name");	
			$("p#"+descId+"_price").show();
		}
	});	
});



/*function megaHoverOver(){
	//$(this).find(".sub").stop().fadeTo('fast', 1).show();
	$(this).find(".sub").stop().slideDown();
		
	//Calculate width of all ul's
	(function($) { 
		jQuery.fn.calcSubWidth = function() {
			rowWidth = 0;
			//Calculate row
			$(this).find("ul").each(function() {					
				rowWidth += $(this).width(); 
			});	
		};
	})(jQuery); 
	
	if ( $(this).find(".row").length > 0 ) { //If row exists...
		var biggestRow = 0;	
		//Calculate each row
		$(this).find(".row").each(function() {							   
			$(this).calcSubWidth();
			//Find biggest row
			if(rowWidth > biggestRow) {
				biggestRow = rowWidth;
			}
		});
		//Set width
		$(this).find(".sub").css({'width' :biggestRow});
		$(this).find(".row:last").css({'margin':'0'});
		
	} else { //If row does not exist...
		
		$(this).calcSubWidth();
		//Set Width
		$(this).find(".sub").css({'width' : rowWidth});		
	}
	
}

function megaHoverOut(){ 
 /* $(this).find(".sub").stop().fadeTo('fast', 0, function() {
	  $(this).hide(); 
  });/
  $(this).find(".sub").stop().slideUp();
}*/

