function popChatLive() {
	url = 'http://sightmax.fullsail.com/SightMaxAgentInterface/PreChatSurvey.aspx?accountID=1&siteID=1&queueID=2';
	var NewWindow = window.open(url, 'chatWindow','width=490,height=490,resizable=0,scrollbars=no,menubar=no,status=no');				
}



//request info drop down- 08/2010
var bWasRequestInfoLoaded = false,
	bIsRequestInfoDropDownVisible = false,
	windowWidth,
	windowHeight;

//function that adds the request info form via ajax
function addRequestInfoDropDown() {
	bIsRequestInfoDropDownVisible = true;
	addRequestInfoDropDownMask();
	$('#requestInfoDropDownBottom').show();
	$('#topLinks').css({'z-index': 12})
	$('#topRightTab').css({'top': '-9px'});
	$('#topLinks').animate({'top': '0px'});
	
	$('#requestInfoDropDownWrapper').load('/index.cfm?fuseaction=brazil.requestInfo #requestInfoFormWrapper', function() {
		$('#requestInfoFormWrapper').hide();
		$('#requestInfoDropDownWrapper .col380').hide().remove().appendTo('#requestInfoDropDownWrapper');
		$('#requestInfoDropDownWrapper .requestFormWrapper').hide().remove().appendTo('#requestInfoDropDownWrapper');
		$('#riddWrapper #requestInfoFormWrapper').remove();
		$('#riddWrapper .tanForm552_top').remove();
		$('#riddWrapper .tanForm552_bottom').remove();
		$('#riddWrapper #requestInfoForm').remove();
		$('#riddWrapper .leadForm').attr('id', 'requestInfoDropDownForm');
		$('#riddWrapper .leadForm input.submitButton').attr('id', 'requestInfoDropDownSubmitButton').removeAttr('onclick');
		$('#requestInfoSubmitGif').remove().appendTo('#requestInfoDropDownWrapper')
		var topLinksHeight = $('#topLinks').height(),
			requestInfoButtonHeight = ($('#requestInfoLink').height() + 9),
			topLinksTop = (-(topLinksHeight - requestInfoButtonHeight))+'px';
			
		formOnLoadFunctions();
		$('#requestInfoDropDownWrapper .col380, #requestInfoDropDownWrapper .requestFormWrapper ').fadeIn();
		$('#requestInfoLoadingGif').fadeOut();
	})
	bWasRequestInfoLoaded = true;
}

//function that shows the request info if its already been loaded
function showRequestInfoDropDown() {
	bIsRequestInfoDropDownVisible = true;
	addRequestInfoDropDownMask();
	$('#requestInfoDropDownBottom').show();
	$('#topLinks').css({'z-index': 12})
	$('#topRightTab').css({'top': '-9px'});
	$('#topLinks').animate({'top': '0px'});
}

function addRequestInfoDropDownMask() {
	determineWindowSize();
	$('<div class="riddMask"></div>')
		.appendTo('#topBarWrapper')
		.css({'width': windowWidth, 'height': windowHeight});
};
function removeRequestInfoDropDownMask() {
	$('.riddMask').remove();
}

function determineWindowSize() {
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function hideRequestInfoDropDown() {
	bIsRequestInfoDropDownVisible = false;
	removeRequestInfoDropDownMask();
	var topLinksHeight = $('#topLinks').height(),
		requestInfoButtonHeight = ($('#requestInfoLink').height() + 9),
		topLinksTop = (-(topLinksHeight - requestInfoButtonHeight))+'px';
	
	$('#topLinks').animate(
		{'top': topLinksTop},
		"normal",
		function(){
			$('#requestInfoDropDownBottom').hide();
			$('#topRightTab').css({'top': '0px'});
			$('#topLinks').css({'z-index': 10})
		}
	);
}

$("#requestInfoDropDownSubmitButton").live("click",function(){
	var passedValidation = validateForm();

	if (passedValidation) {
		// Gather up form values and append to url
		formValues = collectRequestInfoDropDownFormValues("requestInfoDropDownForm");
		path = "/index.cfm?fuseaction=brazil.requestInfo&" + formValues;
		
		$('#requestInfoSubmitGif').fadeIn();
		
		// Submit the form.
		var mnc = $("#requestInfoDropDownForm input[name='mnc']").val();
		$.ajax({
			url: path,
			success: function(){
				$('#requestInfoDropDownThankYouWrapper').load('/index.cfm?fuseaction=brazil.requestInfoThankYou #requestInfoThankYouWrapper', function(){
					pageTracker._trackPageview('/request-info/thank-you');
					$('#requestInfoDropDownWrapper .col380, #requestInfoDropDownWrapper .requestFormWrapper').fadeOut('normal', function() {
						$('#riddWrapper').animate({'height':'400px'}, 'slow');
					});
					$('#requestInfoDropDownThankYouWrapper').hide().fadeIn('normal', function(){
						setTimeout("hideRequestInfoDropDown()", 8000);
					})
					$('#requestInfoSubmitGif').fadeOut();
					$('<div id="iframeTrackingPixelHolder"></div>')
						.html('<iframe id="pixelframe" src="index.cfm?fuseaction=pageTracking.trackingPixels&step=process&mnc=' + mnc + '" width="1" height="1" />')
						.appendTo('body');
				})
			}
		});
	}
	return false;
});

$('#riddWrapper .additionalPhone').live('click', function() {
	var nNumberOfActiveAdditionalPhoneFields = $(this).parent().parent().parent().find('.additionalPhoneField').length
	if (nNumberOfActiveAdditionalPhoneFields == 0) {
		$('#riddWrapper').animate({'height': '873px'});
	} else if (nNumberOfActiveAdditionalPhoneFields == 1) {
		$('#riddWrapper').animate({'height': '917px'});
	}
})

function collectRequestInfoDropDownFormValues(formID) {
	var formElements = document.getElementById(formID).elements;
		var valueString = "";
		var fieldValue;
		var fieldName;
		var blnAppend = true;
		var blnIsCheckRadio = false;
	
		for (var i=0; i < formElements.length; i++) {
			
			// Look to see if we're looking at a checkbox or radio element
			if ((formElements[i].type == 'checkbox') || (formElements[i].type == 'radio')) {
				blnIsCheckRadio = true;	
			}
			
			if ((blnIsCheckRadio) && (!formElements[i].checked)) {
				blnAppend = false;
			}
			
			if (blnAppend) {
				// If it's not the first item, append an ampersand
				if (i != 0) { valueString = valueString + "&";}
				valueString = valueString + formElements[i].name + "=" + formElements[i].value;	
			}
			
			// Reset
			blnAppend = true;
			blnIsCheckRadio = false;
			
		}
		return valueString;
}





$(document).ready(function() {
//---hoverIntent------<http://cherne.net/brian/resources/jquery.hoverIntent.html>------------------------------//
(	function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:0,interval:0,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);


//---request info drop down------------------------------------------------------------------------------------//

	$('#topLinks #requestInfoLink a').live('click', function(e) {
		e.preventDefault();
		if(bIsRequestInfoDropDownVisible) {
			hideRequestInfoDropDown();
		} else if(!bIsRequestInfoDropDownVisible) {
			if(!bWasRequestInfoLoaded) {
				
				pageTracker._trackPageview('/requestInfo-ajax');
				addRequestInfoDropDown();
			} else {
				showRequestInfoDropDown();
			}
		}
	})
	$('#closeRequestInfo, .riddMask').live('click', function(e) {
		e.preventDefault();
		hideRequestInfoDropDown();
	})

	$(window).resize(function() {
		determineWindowSize();
		$('.riddMask').css({'width': windowWidth, 'height': windowHeight});
	})

//---navDropDown-----------------------------------------------------------------------------------------------//
	function addNavDropDown(){
		var nPrimaryNavBgWidth = 15000;
		var nLinkLeftPosition = $(this).find('.navBar1Buttons').position().left;
		var nLinkWidth = $(this).find('.navBar1Buttons').width();
		var nPrimaryNavBgX = ( ( nLinkLeftPosition + (nLinkWidth / 2) )- (nPrimaryNavBgWidth / 2) )
		$('#navBar1Bg').css('background-position', nPrimaryNavBgX+'px -41px')
		$(this).addClass("hovering");
		$(this).find("div.dropdown")
			.animate({"height": "toggle"}, {duration: 200}, "swing");
	}
	
	function removeNavDropDown(){
		$('#navBar1Bg').css('background-position', '0px -41px')
		$(this).removeClass("hovering");
		$(this).find("div.dropdown")
			.animate({"height": "toggle"}, {duration: 200}, "swing");
	}
	
	var navDropDownConfig = {
		interval: 50,
		sensitivity: 1,
		over: addNavDropDown,
		timeout: 0,
		out: removeNavDropDown
	};
	
	$(".navDropDown").hoverIntent(navDropDownConfig)
	
	//---searchBox--------------------------------------------------------------------------------------------------//
	$("#searchField").focus(function(){
		if ($(this).val() == "SEARCH") {
			$(this).val("");	
		}
	});
	
	$("#searchField").blur(function(){
		if ($(this).val() == "") {
			$(this).val("SEARCH");	
		}
	});	  
	
	$("#navBar1 .navDropDown .navBar1Buttons #about").addClass("aboutActive");	
	
	
	var monthName = ["jan", "feb", "mar", "apr", "may", "jun",
					 "jul", "aug", "sep", "oct", "nov", "dec"];

	var currentMonth = new Date();
	var calendarPage = new String();
	calendarPage = "Calendar-" + monthName[currentMonth.getMonth()] + ".html";
	var calendar = document.getElementById("calendar");
	calendar.onclick = function () {
		// alert("Hello");
		document.location.href = calendarPage; // this code works
	}	
});
