/// <reference path="jquery-1.6.3.min.js" />


/*===================================================================*/
/*===================  START $(document).ready()  ===================*/
/*===================================================================*/
$('document').ready(function ()
{


	/*--Get Current Page from Address bar to manipulate Top and Left Navigations--*/
	var getURLPath = window.location.pathname.split('/');
	var currentPage = getURLPath[getURLPath.length - 1];
	if (currentPage != '')
	{
		//--Make Top Nav Category Selected (blue tab) when a page within that category is loaded--//
		$('ul#tabs li a[href="' + currentPage + '"]').parents('li[id]').toggleClass('jsCurrentCategory');
		//--Show Level 2 Sub-nav when of loaded page--//
		$('li a[href="' + currentPage + '"]').parents('li.jsSubNav-Hide').toggleClass('jsSubNav-Hide');
	}
	/*----END----*/



	/*--Check if Homepage URL is a redirect from the Request a Quote form--*/
	if ($('.requestQuote').length > 0 || $('.scheduleDemo').length > 0)
	{

		var getParamValues = window.location.href.split('=');

		if (getParamValues[getParamValues.length - 1] == 'Received')
		{
			$('.requestQuote').removeClass('jsRequestReceived').addClass('jsRequestReceived').html('<p>Thank you <br /> for your request.</p> <a href="default.htm">Start New Request >></a>');
			$('.scheduleDemo').removeClass('jsRequestReceived').addClass('jsRequestReceived').html('<p>Thank you <br /> for your request.</p> <a href="' + currentPage + '">Start New Request >></a>');
		}

	}
	/*----END----*/



	/*--Run rotating client logo script--*/
	if ($("#ourClientsLogosDisplayer").length > 0)
	{
		pickLogos(4);
		$('#ourClientsLogosDisplayer p').first().css('border', 'none');
	}
	/*----END----*/



	/*--Schedule a Demo form -- Add 'jsNoDemoForm' to div.sideContainer when the Scheduling a Demo form is not present--*/
	if ($('.scheduleDemo').length == 0)
	{
		$('.sideContent').addClass('jsNoDemoForm');
	}
	/*----END----*/



	/*--Schedule a Demo form -- Popluate the 'Current_Page' input with current page URI--*/
	$('input#currentPage').val(currentPage);
	/*----END----*/



	/*--Schedule a Demo form -- Disable 'State' dropdown if the U.S. is not selected--*/
	$('#ddCountry').change(function ()
	{
		if ($(this).val() != 'US')
		{
			$('#ddStates').attr('disabled', 'disabled').val('N/A');
		}
		else
		{
			$('#ddStates').removeAttr('disabled').val('');
		}
	});
	/*----END----*/



	/*--Tabbed Container functionality [Current Implementations:  Thought Leadership page]--*/
	if ($('#tabbedContainer').length > 0)
	{
		//--Change background color on the even row listings--//
		$('.row:odd').addClass('even'); //Remember, Arrays are Zero-based

		//--Change Tab color and show selected tabContent--//

		//var currentTab;

		$('ul.tabbedTitle li').click(function ()
		{

			$('ul.tabbedTitle li').removeClass('selected');
			$(this).toggleClass('selected');

			currentTab = $(this).attr('title')

			$('div.tabbedContent').removeClass('selected');
			$('#' + currentTab).toggleClass('selected');

		});
	}
	/*----END----*/



	/*--Request a Quote Form :: Add and Show Language Pairs Script--*/
	if ($('#RequestQuoteForm').length > 0)
	{
		$('#ddTargetLang').change(function ()
		{
			var selSourceLang = $('#ddSourceLang option:selected');
			var selTargetLang = $('#ddTargetLang option:selected');

			$('#showLangPairs').append('<div id="' + $(selTargetLang).val() + '" rel="' + selSourceLang.val() + '"><span onclick="removeLangPair(this);">X</span> ' + selSourceLang.text() + ' to ' + $(selTargetLang).text() + '</div>');

		});


		$('#ddHearAbout').change(function ()
		{
			if ($(this).val() == 'Other')
			{
				$('label[for="txtHearAboutOther"]').addClass('required');
			}
			else
			{
				$('label[for="txtHearAboutOther"]').removeClass('required');
			}
		});

		$('#referrerPage').val(document.referrer.replace('%2D', '-').replace('%20', ' '));
		
	}
	/*----END----*/






});
/*=================================================================*/
/*===================  END $(document).ready()  ===================*/
/*=================================================================*/








/*=================================================================*/
/*====  Request a Quote Form Functionality Supporting Scripts  ====*/
/*=================================================================*/


/*--Set Source Language--*/
function setSourceLang()
{
	$('#txtSourceLang').val('');

	var getSourcetIDs = [];
	$('#showLangPairs div').each(function (i)
	{
		getSourcetIDs[i] = $(this).attr('rel');
	});

	$('#txtSourceLang').val(getSourcetIDs);

}
/*----END----*/



/*--Set Target Language--*/
function setTargetLang()
{
	$('#txtTargetLang').val('');

	var getTargetIDs = [];
	$('#showLangPairs div').each(function (i)
	{
		getTargetIDs[i] = $(this).attr('id');
	});

	$('#txtTargetLang').val(getTargetIDs);

}
/*----END----*/


/*--Run Language Setters--*/
function runLangSetters()
{
	$(setSourceLang);
	$(setTargetLang);
}
/*----END----*/


/*--Remove Displayed Language Pairs--*/
function removeLangPair(elem)
{
	//--- Remove DIV of Clicked Language Pair ---//
	$(elem).closest('div').remove();
}
/*----END----*/



/*============  END Request a Quote Form  =============*/
/*=====================================================*/











//==== START $(window).load() ====//
$(window).load(function ()
{


	//====  Home page Focus Image Sliding rotation feature  ====//
	if ($('#slider'))
	{
		$('#slider').nivoSlider({
			effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
			animSpeed: 500, // Slide transition speed
			pauseTime: 6000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: true, // Next & Prev navigation
			directionNavHide: false, // Only show on hover
			controlNav: true, // 1,2,3... navigation
			controlNavThumbs: false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel: false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav: true, // Use left & right arrows
			pauseOnHover: true, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			captionOpacity: 0.8, // Universal caption opacity
			prevText: 'Prev', // Prev directionNav text
			nextText: 'Next', // Next directionNav text
			beforeChange: function () { }, // Triggers before a slide transition
			afterChange: function () { }, // Triggers after a slide transition
			slideshowEnd: function () { }, // Triggers after all slides have been shown
			lastSlide: function () { }, // Triggers when last slide is shown
			afterLoad: function () { } // Triggers when slider has loaded
		});
	}
	//====  END  ====//



});
//==== END of $(window).load() ====//










//====  Client Logo Rotation Script  ====//

function pickLogos(num)
{
	var aLogos = new Array("logo-OurClients-AVON.png", "logo-OurClients-CBRE.png", "logo-OurClients-Chevron.png", "logo-OurClients-DelMonte.png", "logo-OurClients-Emerson.png", "logo-OurClients-Huntsman.png", "logo-OurClients-JohnsonJohnson.png", "logo-OurClients-Kaplan.png", "logo-OurClients-Merck.png", "logo-OurClients-Symantec.png", "logo-OurClients-WholeFoods.png", "logo-OurClients-Wyndham.png", "logo-OurClients-WraggeCo.png", "logo-OurClients-ICON.png");

	//  Logos Not In Use  //
	/*	
	logo_hmpg_Intel.gif
	logo_hmpg_GE.gif
	*/

	var aRandom = new Array();
	var count = 0;

	while (count < num)
	{
		bFlag = false;
		var currNum = Math.round((aLogos.length - 1) * Math.random());

		if (count != 0)
		{
			for (var i = 0; i < aRandom.length; i++)
			{
				if (aLogos[currNum] == aRandom[i])
				{
					bFlag = true;
					break;
				}
			}
		}

		if (!bFlag)
		{
			aRandom[count] = aLogos[currNum];
			count += 1;
		}
	}
	$("#ourClientsLogosDisplayer  img:eq(0)").attr("src", "img/" + aRandom[0]);
	$("#ourClientsLogosDisplayer  img:eq(1)").attr("src", "img/" + aRandom[1]);
	$("#ourClientsLogosDisplayer  img:eq(2)").attr("src", "img/" + aRandom[2]);
	$("#ourClientsLogosDisplayer  img:eq(3)").attr("src", "img/" + aRandom[3]);
	$("#ourClientsLogosDisplayer  img:eq(4)").attr("src", "img/" + aRandom[4]);
	$("#ourClientsLogosDisplayer  img:eq(5)").attr("src", "img/" + aRandom[5]);
	$("#ourClientsLogosDisplayer  img:eq(6)").attr("src", "img/" + aRandom[6]);
	$("#ourClientsLogosDisplayer  img:eq(7)").attr("src", "img/" + aRandom[7]);
	$("#ourClientsLogosDisplayer  img:eq(8)").attr("src", "img/" + aRandom[8]);
	$("#ourClientsLogosDisplayer  img:eq(9)").attr("src", "img/" + aRandom[9]);
	$("#ourClientsLogosDisplayer  img:eq(10)").attr("src", "img/" + aRandom[10]);
	$("#ourClientsLogosDisplayer  img:eq(11)").attr("src", "img/" + aRandom[11]);
	$("#ourClientsLogosDisplayer  img:eq(12)").attr("src", "img/" + aRandom[12]);
	$("#ourClientsLogosDisplayer  img:eq(13)").attr("src", "img/" + aRandom[13]);
	//	$("#ourClientsLogosDisplayer .right img:eq(0)").attr("src", "img/"+aRandom[4]);
	//	$("#ourClientsLogosDisplayer .right img:eq(1)").attr("src", "img/"+aRandom[5]);
	//	$("#ourClientsLogosDisplayer .right img:eq(2)").attr("src", "img/"+aRandom[6]);
	//	$("#ourClientsLogosDisplayer .right img:eq(3)").attr("src", "img/"+aRandom[7]); 
}

//==============  END   =================//














