$(document).ready( function() {
	$("#liveintent_follow_us_btn").click(function(){return false;});
	
	$("#fdbk_tab").click(function(){
		_gaq.push(['_trackEvent', 'feedbackGetSatisfaction-btn', 'clicked']);	
	});
	
	$("#LiveIntentTag .trigger").click(function() {
		var showTag = function () {
			$("#LiveIntentTag .trigger").fadeOut("slow", function(){
				$("#LiveIntentTag .tagTxt").fadeIn("slow");
			});
		};
		$("#LiveIntentTag").animate({
			        width: "915px"
			      }, 600, "linear", showTag() );
	});
	
	$("#LiveIntentTag .btn-close-expand").click(function(){
		var hideTag = function () {
			$("#LiveIntentTag .tagTxt").fadeOut("fast", function(){
				$("#LiveIntentTag .trigger").fadeIn("slow");
			});
		};
		$("#LiveIntentTag").animate({
	        width: "150px"
	      }, 1100, "linear", hideTag());
	});
	
	$("#LoginTrigger").qtip({
		show: {
			when: {
				event: "click"
			}
		},
		hide: 'unfocus', 
		position: {
			corner: { 
				target: 'bottomMiddle', 
				tooltip: 'topRight' 
			}
		},
		style: {
			border: {
				width: 5,
				radius: 10
		  	},
		  	padding: 10, 
		  	tip: true, 
		  	name: 'light'
		  	
		},
		content: $("#LoginContainer").html()
	});
	
	
	if ($.browser.msie) {
		$("#Featured").css("width", "931px").css("height", "60px");
	}
	
	// If Carousel Exists
	
	var carouselTiming = {
			speed: 2000,
			timeout: 5000
	};
	if (document.getElementById("HowitworksSection")){ 
			carouselTiming = {
				speed: 1000,
				timeout: 5400
			};
	}
	if (document.getElementById("LiveIntentCycle")) {
		$(".tout1").fadeIn("slow");
		setTimeout(function(){$(".tout2").fadeIn("slow");}, 500);
		$("#LiveIntentCycle").cycle({
			pager: '#CycleControl', 
			pagerAnchorBuilder: function(idx, slide) { 
				// return selector string for existing anchor 
				return '#CycleControl li:eq(' + idx + ') a'; 
			},
			speed: carouselTiming.speed,
			timeout:  carouselTiming.timeout,
			pause:  1 
		});
		
		$('#PauseCtrl').click(function() { 
		    $('#LiveIntentCycle').cycle('pause'); 
		    $(this).hide();
		    $("#PlayCtrl").show();
		});
		
		$('#PlayCtrl').click(function() { 
		    $('#LiveIntentCycle').cycle('resume');
		    $(this).hide();
		    $("#PauseCtrl").show();
		});
		
		$("#LiveIntentCycle li").click(function(){
			_gaq.push(['_trackEvent', 'homeWebslideSignup', 'clicked']);
			window.location = "signup.php";
		});
		
		$(".imgBtn").each(function() {
			$(this).qtip({			
				show: {
					solo: true
				},
				content: {
		            text: "<img src='" + $(this).attr('rel') + "' />",
		            title: {
		               text: $(this).attr("title")
		            }
		        },
	         	position: {
					corner: { 
						target: 'topMiddle', 
						tooltip: 'bottomMiddle' 
					}
				},
				style: {
					border: {
						width: 5,
						radius: 10
				  	},
				  	padding: 10, 
				  	tip: true, 
				  	name: 'cream',
				  	height: 200,
				  	width: 290
				}
			});
		});
	}
	
	// If Form Exists 
	
	if (document.getElementById("LiveIntentBetaForm")){
		$("#LiveIntentBetaForm").validate({
			rules: {
				terms: "required"
			}, 
			messages: {
			first_name: "*Please enter your first name.",
			last_name: "*Please enter your last name.",
			email: {
		       required: "*Please include your email.",
		       email: "Please enter in the form of name@domain.com"
		     },
		    company: "*Please enter your company name.",
		    country: "*Please enter a country.",
		    URL: "*Please enter a valid URL.  Example: http://www.domain.com",
		    terms: "You must agree to the terms and conditions.",
		    "00NA0000001rAi5": "Please enter your twitter handle."
	    	 
		   }
		});
		$("#BetaFormSubmit").click(function(){
			$("#LiveIntentBetaForm").submit();
		});
	}
});