var slideSpeed = 500;
var tabEffect = "fade";
var url = window.location.pathname;
var $j=jQuery.noConflict();
var alertText = "FIRSTBase is our content, lead and application management platform.<br />To schedule a demo please <a href=\"/contact-us.html\">contact us</a>.";

$j(document).ready( function() {

	productTabs();
	
	if (url.indexOf("portfolio") != -1) {
		$j("body").attr("id", "portfolio");
	};
	
	if( $j('#productTabs').length > 0 ){
		$j('#productTabs dt').css("display", "block");
	}
	
	if( $j('.jsCheck').length > 0 ){
		$j('#contentInner').removeClass('jsCheck');
	}
	
	$j("#ultraTopNav a:contains('FIRSTBase')").click( function() {						   
		if (!confirmAlert($j(this).attr('href'))){
			return false;			
		}
	}); 

}); // END doc ready

function productTabs(){
	if( $j('#productTabs').length > 0 ){
		var offset = 20;
		var minHeight = 130;
		var newMinHeight = parseInt($j('#product').attr('class'));
		if( newMinHeight > minHeight )
			minHeight = newMinHeight;
		$j('#productTabs dt').addClass('label');
		$j('#productTabs dt:eq(0)').addClass('selected');
		$j('#productTabs dd').addClass('pane tabs').hide();
		$j('#productTabs dd:eq(0)').show();
		var tempHeight = $j('#productTabs dd:eq(0)').height();
		if( tempHeight < minHeight ) tempHeight = minHeight;
		$j('#product').css('height', tempHeight + offset);
		
		var newHeight = 0;
		$j('#productTabs dt').click( function(){
			var holdThis = $j(this);
			if( !holdThis.hasClass('selected') ){
				$j('#productTabs dt').removeClass('selected');
				holdThis.addClass('selected');
				newHeight = holdThis.next().height() + offset;
				if( newHeight < minHeight ) newHeight = minHeight;
				if(tabEffect == "slide"){
					$j('#productTabs dd').slideUp(slideSpeed);
					$j('#product').animate({ height : newHeight }, slideSpeed, function(){
						holdThis.next().slideDown(slideSpeed);									 
					});
				}
				else{
					$j('#productTabs dd').fadeOut(slideSpeed);
					$j('#product').animate({ height : newHeight }, slideSpeed, function(){
						holdThis.next().fadeIn(slideSpeed);									 
					});
				}
			}
		});
	}
}

function confirmAlert(url){
			jConfirm(alertText, "Confirm", function(r) {
				if( r ){
					window.open(url);
				} else {
					return false;
			}
		});
		return false;
}