

$(document).ready(function(){ 
	
	
	$('a[href*="video.php"]').fancybox({
				'width'				: 640,
				'height'			: 480,
				'autoDimensions'	: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
			
	$('.lightbox').fancybox();
	
	$('a[href*=".jpg"]').fancybox();
	$('a[href*="/webdemo/"]').fancybox({
				'width'				: 960,
				'height'			: 561,
				'autoDimensions'	: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
	
	$('#featured_clients li li').wrapInner('<div class="featured_client-highlight" />');
	
	$('.featured_client-highlight > a').each(function(){
		$(this).clone().prependTo($(this).parent().parent());
	});
	
	$('.featured_client-highlight > img').each(function(){
		$(this).clone().prependTo($(this).parent().parent());
	});
	
	$('#top_nav li:has(ul)').addClass('parent');

	$('#billboards a').each(function(){
		$(this).parent().addClass('billboard_link');
	});

	$('.tab').each(function(){
		$('#content > .callout').clone().prependTo(this);
	});

	$('.featured_client-highlight').append('<div class="highlight_tail"></div>');
	
	$('#featured_clients > ul li li').each(function(){
		$(this).children('div').css('left',(-(248-$(this).width())/2));
	});
	
	$('#featured_clients > ul li li').hover(
		function(){
			$(this).children('div').show();
		},
		function(){
			$(this).children('div').hide();
		});
	
/*	$('#top_nav > .current-menu-item > ul > li:first-child').addClass('current-menu-item');
	$('.current-menu-ancestor:first > ul, #top_nav > .current-menu-item > ul').clone().appendTo('#sub_nav');
*/	

$('#menu-top-nav > li > a').each(function(){
       $(this).replaceWith('<h3>' + $(this).html() + '</h3>');
    });

	if(paramExists('tab')){
		tabToShow = ':eq(' + getParameterByName('tab') + ')';
		$("#content.tabbed").semantictabs({
		  panel:'.tab',                //-- Selector of individual panel body
          head:'h3',               //-- Selector of element containing panel head
			active:tabToShow
			});
	} else {
		$("#content.tabbed").semantictabs({
          panel:'.tab',                //-- Selector of individual panel body
          head:'h3'                    //-- Selector of element containing panel head
          
        });
	}



/*		$('#content .tab').equalHeights();
*/
	
	$('ul#top_nav ul').css('display', 'none');

	$('ul#top_nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(125);
		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(250);			
		}
	);
	
	
$('#billboards li').each(function(){
	var link = $(this).find('a').attr('href');
	$(this).children().each(function(){
		$(this).click(function(){
		window.location = link;
	});
	});
});

$('#features img').not('#featured_clients img, .highlight img').each(function(){
	var imgWidth = $(this).width();
	if(imgWidth < 90) {
		$(this).addClass('alignleft');	
	} else {
		$(this).removeClass('alignleft');	
	}
});




	$('#s').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
				$(this).css('font-style', 'normal');
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
				$(this).css('font-style', 'italic');
			}
		});
	});
	
$('.rotating > ul:not(.features_nav_numbers)').each(function(){
    var p = this.parentNode;
    $(this).cycle({

        fx:      'fade',
		speed:	 300,
        timeout:  0,
		nowrap:  0,
        next: $('a.next', p),
		prev: $('a.prev', p),
        pager:   $('.features_nav_numbers', p),
        pagerAnchorBuilder: pagerFactory
    });
});

	$('#latest_news ul').cycle({
		speed:	 300,
        timeout:  5000,
		nowrap:  0,
	    prev:    '#latest_news_prev',
        next:    '#latest_news_next',
		cleartypeNoBg: true
    });

	$('#billboards').cycle({
        fx:      'fade',
		speed:	 1000,
        timeout:  6000,
		pause:    1,
        pager:   '#billboard_nav',
        pagerAnchorBuilder: billboardPagerFactory,
		pauseOnPagerHover: true
    });

    function pagerFactory(idx, slide) {
		var s = idx > 7 ? ' style="display:none"' : "";
        return '<li' + s + '><a href="#">'+(idx+1)+'</a></li>';
    };
	
    function billboardPagerFactory(idx, slide) {
        var s = idx;
		var linkText = $(slide).find('h2').text();
		var linkId = $(slide).attr('class');
        return '<li id="'+linkId+'"><a href="#">'+linkText+'</a></li>';
    };
	
	
	$('#forescout_solutions_by h3').click(function(){
		$('#forescout_solutions_by h3').each(function(){
			$(this).parent().removeClass('current').find('ul').hide();
		});
		$(this).parent().addClass('current').find('ul').show();
	});
	
	$('#features div *, #billboard *').css('visibility','visible');
	
	$('#footer .solutions-by-industry, #footer .solutions-by-purpose').each(function(){
		$(this).prependTo($(this).parent().parent().parent());
	});
	
	$('#footer .solutions').hide();
	
		 $('a[href*="lead_form.php"], a[href*="request_info_form.php"]').each(function(){
               $(this).fancybox();
          }); 
		  
	$('#fat-dropdown-solutions').prependTo('#top_nav .solutions > .sub-menu');
	$('#fat-dropdown-product').prependTo('#top_nav .product > .sub-menu');
	$('#fat-dropdown-partners').prependTo('#top_nav .partners > .sub-menu');
	$('#fat-dropdown-support').prependTo('#top_nav .support > .sub-menu');
	$('#fat-dropdown-news').prependTo('#top_nav .news > .sub-menu');
	$('#fat-dropdown-company').prependTo('#top_nav .company > .sub-menu');

$('#top_nav .fat-dropdown-list').each(function(){
	menuHeight=$(this).parent().height();
	$(this).height(menuHeight-25);
});

$('#top_nav ul.sub-menu').has('li.fat-dropdown-list').addClass('fat');

	
});

function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

function paramExists(param){
	var url = window.location.href;
	if(url.indexOf('?' + param + '=') != -1)
		return true;
	else if(url.indexOf('&' + param + '=') != -1)
		return true;
	return false;
}





