/*
	JavaScript Document for NGRAIN.com
*/
// font replacement
//Cufon.replace('#nav a', {hover:true});
Cufon.replace('.uplink', {hover:true});
Cufon.replace('.section_rollover', {hover:true});
Cufon.replace('.section6_rollover', {hover:true});
Cufon.replace('.products_landing .big', {hover:true});
Cufon.replace('.callout_header', {hover:true});
Cufon.replace('.header', {hover:true});
Cufon.replace('.date_header', {hover:true});
Cufon.replace('.headline', {hover:true});
Cufon.replace('.content h2', {hover:true});

var distance = 0;
var xOrigin = 0;
var yOrigin = 0;

// getCoords for Flash bar
function getCoords() {
	return $('#mouseStatus').text();
}
function uploadcomplete() {
	$("#uploading").hide();
	$("#thank_you").show();
}

// this handles basic form validation on the dynamic salesforce.com html
function validateForm(obj) {
	var noError = true;
	errorMessage1 = "";
	errorMessage2 = "";
	errorMessage3 = "";
	errorMessage4 = "";
	$('.checkValue').removeClass('checkValue');
	$("#error_message").hide();
	if(obj.parent().attr("id")!="share_form") obj.parent().attr("target",'iframeCatcher');
	// form validation
	obj.parent().find("input[type=text],textarea,select").each(function() {
		if ($(this).val() == "" || $(this).val() == null) {
			$(this).addClass('checkValue');
			noError = false;
			errorMessage1 = "<em>- Please fill out all form fields</em><br />";
		}
	});
	// email validiation
	specificEmail = obj.parent().find("#email");
	if (specificEmail.length) {
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (emailPattern.test(specificEmail.val()) == false) {
			specificEmail.addClass('checkValue');
			errorMessage2 = "<em>- Please correct your email address</em><br />";
			noError = false;
		}
	}
	
	//share email validation
	senderEmail = obj.parent().find("#sender_email");
	if (senderEmail.length) {
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (emailPattern.test(senderEmail.val()) == false) {
			senderEmail.addClass('checkValue');
			errorMessage2 = "<em>- Please correct your email address</em><br />";
			noError = false;
		}
	}
	recipientEmail = obj.parent().find("#recipient_email");
	if (recipientEmail.length) {
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if (emailPattern.test(recipientEmail.val()) == false) {
			recipientEmail.addClass('checkValue');
			errorMessage2 += "<em>- Please correct the recipient's address</em><br />";
			noError = false;
		}
	}
	
	// form addition validation
	if (parseInt(obj.parent().find(".Web2CRMfieldOne").text()) + parseInt(obj.parent().find(".Web2CRMfieldTwo").text()) != parseInt(obj.parent().find(".Web2CRMAnswer").val())) {
		obj.parent().find(".Web2CRMAnswer").addClass('checkValue');
		errorMessage4 = "<em>- Please try the human-confirmation question again</em><br />";
		noError = false;
	}
	
	if (noError) {
		return 'valid';
	} else {
		errors = errorMessage1;
		errors += errorMessage2;
		errors += errorMessage3;
		errors += errorMessage4;
		return errors;
	}
}

//if (window.location.href.search("#") == -1) window.location = window.location + "#/";

$(document).ready(function() {


//		$(document).ready(function() {
			$("area.fancy").fancybox({
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});


      $(".news_callout").ThreeDots();
      // { max_rows:1 }

      
      // $(".navi").css('width', $(".navi").children().length+'px');
      $('.feature_container a[target="_blank"]').fancybox({
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9,
				'padding'			: 0,
				'height'			: 460,
				'width'				: 850,
				'autoDimensions'	: false,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'scrolling'			: 'no'
			});

      $('.feature_container a[target="_blank"]').attr('target', '_self');

// console.log('start');

  // if ($(.uplink).attr('target', '_blank')

			$(".vid_460").fancybox({
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9,
				'padding'			: 0,
				'height'			: 460,
				'width'				: 850,
				'autoDimensions'	: false,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'scrolling'			: 'no'
			});

			$(".vid_440").fancybox({
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9,
				'padding'			: 0,
				'height'			: 420,
				'width'				: 850,
				'autoDimensions'	: false,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'scrolling'			: 'no'
			});
//		});



	// salesforce html adjustments
	// change "Submit Query" to "Submit" (IE)
	if ($("input[type=submit]").val() == "Submit Query") $("input[type=submit]").val('SUBMIT');
	// change "Submit Query" to "Submit" (Firefox)
	if ($("input[type=submit]").val() == "") $("input[type=submit]").val('SUBMIT');
	
	//submit forms on 'enter'
	$("input").live("keypress",function (e) {
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
			$(this).parent().find('input[type=submit]').click();
			return false;
		} else {
			return true;
		}
    });
	
	// random generator for contact form
	$(".gray_bg input[name=submit]").before('<label style="width:auto;margin-top:10px;margin-bottom:10px;font-size:11px;">Please answer the following question to validate your request:</label><br clear="all" /><label for="Web2CRMAnswer"><span class="Web2CRMfieldOne"></span>&nbsp;+&nbsp;<span class="Web2CRMfieldTwo"></span>&nbsp;=</label><input class="Web2CRMAnswer" type="text" name="Web2CRMAnswer" value="" /><br />');
	$(".Web2CRMfieldOne").text(Math.ceil(Math.random()*10));
	$(".Web2CRMfieldTwo").text(Math.ceil(Math.random()*10));

	// landing page side bars
	newwidth = ($(document).width() - 959) / 2;
	ie7width = newwidth - 20;
	if (newwidth < 29) {
		$("#landing_viewer_screen_left").width('0');
		$("#landing_viewer_screen_right").width('0');
		$("#header_image").addClass("smallRes");
		$("#container").addClass("smallRes");
	} else {
		if ($.browser.msie && parseInt($.browser.version) == 8) {
			$("#landing_viewer_screen_left").width(ie7width+11);
			$("#landing_viewer_screen_right").width(ie7width+11);
		} else {
			$("#landing_viewer_screen_left").width(newwidth+1);
			$("#landing_viewer_screen_right").width(newwidth);
		}
		$("#container").removeClass("smallRes");
		$("#header_image").removeClass("smallRes");
	}

	$(".screenshot[rel]").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#screenshot_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, top: 50, left: "center", fixed: false  });
	$(".screenshot_rollover").click(function() {
		//img_src = $(screenshot_rollover').attr
		$("#screenshot_overlay").css("visibility","visible");
		$('#screenshot_overlay .gray_bg').html('<div class="header">' + $(this).attr("name") + '</div><br clear="all" /><img style="display:block;" src="' + $(this).attr("href") + '" />');
		$("#screenshot_overlay").overlay().load();
		return false;
	});
	
	$("#landing_viewer_screen_left").click(function() {
		$("#feature_scrollable .prev").click();
	});
	$("#landing_viewer_screen_right").click(function() {
		$("#feature_scrollable .next").click();
	});
	
	$("#callout_form_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#callout_form").click(function() {
		$('#callout_form_overlay .gray_bg').html('<div class="header">FILL OUT THIS FORM FOR MORE INFORMATION</div><iframe name="iframeCatcher" style="height:0px; width:0px; border:0; outline:0; padding:0;"></iframe><div id="callout_error_message"></div>');
		$.get('/inc/process.php', { type: "callout_form", form: $(this).attr("href") }, function(data) {
			$('#callout_form_overlay .gray_bg').html('<div class="header">GET ACCESS TO THE EBOOK<br/><span style="font-size:14px;">Please register by completing all fields below, and receive immediate access to<br/> The Future of Maintenance Training ebook.</span></div><iframe name="iframeCatcher" style="height:0px; width:0px; border:0; outline:0; padding:0;"></iframe><div id="callout_error_message"></div>'+data);
			// random generator for contact form
			$("#callout_form_overlay .gray_bg input[name=submit]").before('<label for="Web2CRMAnswer"><span class="Web2CRMfieldOne"></span>&nbsp;+&nbsp;<span class="Web2CRMfieldTwo"></span>&nbsp;=</label><input class="Web2CRMAnswer" type="text" name="Web2CRMAnswer" value="" /><br />');
			$("#callout_form_overlay .Web2CRMfieldOne").text(Math.ceil(Math.random()*10));
			$("#callout_form_overlay .Web2CRMfieldTwo").text(Math.ceil(Math.random()*10));
			Cufon.replace('.header', {hover:true});
      Cufon.replace('.content h2', {hover:true});
		});
		$("#callout_form_overlay").overlay().load();
		return false;
	});
	
	
	/* $("#register_link[rel]").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 } }); */
	// flash
	$("#flash_bar").height($(document).height());
	$("#flash_bar").flashembed({src: "/flash/deploy/ngrain_sideBar.swf", wmode: 'transparent', onFail: function() {
		document.getElementById("flash_bar").innerHTML = '';
	}});
	
	$("#feature_scrollable").scrollable({ circular: true }).navigator(".navi").autoscroll(6000);

  

	
	$("#tabs a").click(function() {
		var goto = $(this).attr("href").split("#");
		if(goto.length > 1) {
			$("#tabs a.active").removeClass("active");
			$(this).addClass("active");
			$(".gray_bg .content.active").hide(function() {
				$(".gray_bg .content.active").removeClass("active");
				$(".gray_bg ."+goto[1]).show(function() {
					$(".gray_bg ."+goto[1]).addClass("active");
				});
			});
			if($("#header_image").hasClass("multiple")) {
				$("#header_image .active").removeClass("active");
				$("#header_image ."+goto[1]).addClass("active");
			}
			
			window.location.hash = $(this).attr("href");
		}
		return false;
	});
	$(".demo_link").click(function() {
		$("#tabs a.download").click();
	});
	
	$("#career_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$(".career a").click(function() {
		$("#career_overlay #thank_you").hide();
		$("#career_overlay #application_form").hide();
		$("#career_overlay #job_description").show();
		$.get('/inc/process.php', { type: "career", id: $(this).attr("href") }, function(data) {
			$('#career_overlay #job_description').html(data);
			Cufon.replace('.header', {hover:true});
      Cufon.replace('.content h2', {hover:true});
		});
		$("#career_overlay").overlay().load();
		return false;
	});
	
	$("#news_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$(".news_link a").click(function() {
		$('#news_overlay .gray_bg').html("<br /><br /><br />");
		$.get('/inc/process.php', { type: "news", id: $(this).attr("href") }, function(data) {
			$('#news_overlay .gray_bg').html(data);
			Cufon.replace('.header', {hover:true});
      Cufon.replace('.content h2', {hover:true});
		});
		$("#news_overlay").overlay().load();
		return false;
	});
	
	$("#demos_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#footer a#demos_link").click(function() {
		$("#demos_overlay").overlay().load();
		Cufon.replace('.header', {hover:true});
    Cufon.replace('.content h2', {hover:true});
		return false;
	});
	
	$("#contact_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("a.contact_form").click(function() {
		$("#contact_overlay").overlay().load();
		Cufon.replace('.header', {hover:true});
    Cufon.replace('.content h2', {hover:true});
		return false;
	});
	$("#contact_overlay_products").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("a.contact_form_products").click(function() {
		$("#contact_overlay_products").overlay().load();
		Cufon.replace('.header', {hover:true});
    Cufon.replace('.content h2', {hover:true});
		return false;
	});	
	var incoming = location.hash.split("#");
	if (incoming.length > 1) {
		if(incoming[1]=='current-opportunities' && !isNaN(incoming[2])) {
			// display "current opportunities" tab content
			$("#tabs ."+incoming[1]).click();
			
			// display job description
			$("#career_overlay #thank_you").hide();
			$("#career_overlay #application_form").hide();
			$("#career_overlay #job_description").show();
			$.get('/inc/process.php', { type: "career", id: incoming[2] }, function(data) {
				$('#career_overlay #job_description').html(data);
				Cufon.replace('.header', {hover:true});
        Cufon.replace('.content h2', {hover:true});
			});
			$("#career_overlay").overlay().load();

		} else if((incoming[1]=='events' || incoming[1]=='press-releases' || incoming[1]=='coverage') && !isNaN(incoming[2])) {
			// display "current opportunities" tab content
			$("#tabs ."+incoming[1]).click();
			
			$('#news_overlay .gray_bg').html("<br /><br /><br />");
			$.get('/inc/process.php', { type: "news", id: incoming[2]+"#"+incoming[1] }, function(data) {
				$('#news_overlay .gray_bg').html(data);
				Cufon.replace('.header', {hover:true});
        Cufon.replace('.content h2', {hover:true});
			});
			$("#news_overlay").overlay().load();
			
		} else {
			if($("#tabs .active").attr("href") != "#"+incoming[1]) $("#tabs ."+incoming[1]).click();
		}
	}
	
	$("#accordion1").tabs("#accordion1 div.pane", {tabs: 'h3', effect: 'slide', initialIndex: 0});
	$("#accordion2").tabs("#accordion2 div.pane", {tabs: 'h3', effect: 'slide', initialIndex: 0});
	$("#accordion3").tabs("#accordion3 div.pane", {tabs: 'h3', effect: 'slide', initialIndex: 0});

	$("#nv_accordion").tabs("#nv_accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
	var nvApi = $("#nv_accordion").data("tabs");
	var nvIndex = 0;
	$("#nv_accordion h2").click(function() {
	if(nvIndex == nvApi.getIndex()) { nvApi.click(0);}	
	nvIndex = nvApi.getIndex();
	});	
	$("#apply").live("click", function() {
		$("#job_description").fadeOut(function() {
			$("#application_form .content").show();
			$("#application_form").fadeIn();
		});
		return false;
	});
	$("#application_submit").live("click", function() {
		//submit form
		$("#application_form").fadeOut(function() {
			$("#thank_you").fadeIn();
		});
	});
	
	$("#form_submit").click(function() {
		$(this).parent().submit();
		setTimeout('resetFormFields()', 3000);
		return false;
	});
	
	/* demo form submission */
	$("#demo_thanks_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#thanks_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#thanks_overlay_ebook").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#viewer_download_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#vtr_download_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	$("#vda_download_overlay").overlay({ expose:{ color:'#373831', loadSpeed:150, opacity:0.62 }, fixed: false });
	
	
	/*
		overlay forms and forms throughout the site go through a basic form validation
		form validation is handled by function "validateForm"
	*/
	$("#demos_overlay input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			if($(this).hasClass("viewer")) $("#viewer_download_overlay").overlay().load();
			else if($(this).hasClass("vtr")) $("#viewer_download_overlay").overlay().load();
			else $("#demo_thanks_overlay").overlay().load();
		} else {
			$("#demos_error_message").html(result).show();
			return false;
		}
	});
	$("#viewer_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#viewer_download_overlay").overlay().load();
		} else {
			$("#viewer_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#vtt_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#demo_thanks_overlay").overlay().load();
		} else {
			$("#error_message").html(result).show();
			return false;
		}
	});
	$("#vtr_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#vtr_download_overlay").overlay().load();
		} else {
			$("#vtr_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#vda_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#vda_download_overlay").overlay().load();
		} else {
			$("#vda_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#vi_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#demo_thanks_overlay").overlay().load();
		} else {
			$("#vi_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#producer_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#demo_thanks_overlay").overlay().load();
		} else {
			$("#producer_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#knowledge_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#demo_thanks_overlay").overlay().load();
		} else {
			$("#knowledge_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#conversion_demo input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#demo_thanks_overlay").overlay().load();
		} else {
			$("#conversion_demo #error_message").html(result).show();
			return false;
		}
	});
	$("#career_overlay input[name=submit]").click(function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if($("#resume_file").val()=="") {
			if(result=='valid') result = "<em>-Please upload your resume</em>";
			else result += "<em>- Please upload your resume</em>";
		}
		if (result == 'valid') {
			$(this).parent().submit();
//			$("#from_name").val($("#first_name").val() + " " + $("#last_name").val());
			$("#from_name").val($("#first_name").val() + " " + $("#last_name").val() + " RE:" + $("#00N300000066CTB").val());
//			alert("FROM: " + $("#first_name").val() + " " + $("#last_name").val());
			$("#from_email").val($("#email").val());
			//alert("NAME: " + $("#email").val());
			$("#resume_upload").submit();
			setTimeout('resetFormFields()', 3000);
			$(this).parent().parent().hide();
			//$("#thank_you").show();
			$("#uploading").show();
		} else {
			$("#error_message").html(result).fadeIn();
			return false;
		}
	});
	$("#contact_overlay input[name=submit]").click(function() {
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#thanks_overlay").overlay().load();
		} else {
			$("#contact_error_message").html(result).fadeIn();
			return false;
		}
	});
	$("#contact_overlay_products input[name=submit]").click(function() {
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#thanks_overlay").overlay().load();
		} else {
			$("#contact_error_message").html(result).fadeIn();
			return false;
		}
	});
	$("#callout_form_overlay input[name=submit]").live("click",function() {
		$(this).parent().attr("target",'iframeCatcher');
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
			setTimeout('resetFormFields()', 3000);
			$("#thanks_overlay_ebook").overlay().load();
		} else {
			$("#callout_error_message").html(result).fadeIn();
			return false;
		}
	});
	$("#share_form input[name=submit]").click(function() {
		result = validateForm($(this));
		if (result == 'valid') {
			$(this).parent().submit();
		} else {
			$("#share_error_message").html(result).show();
			return false;
		}
	});
	
	
	//press releases
	$(".date_header").click(function() {
		if($(this).next().hasClass("active")) {
			$(this).next().fadeOut(function() {
				$(this).removeClass("active");
			});
		} else {
			$(this).next().fadeIn(function() {
				$(this).addClass("active");
			});
		}
		return false;
	});
});
$(document).mousemove(function(e){
	$("#mousePosition").css("backgroundPosition", String(e.pageX/$(document).width()*28 -14) + "px " + String(e.pageY/$(document).height()*22 -11) + "px");
	distance += Math.abs(xOrigin-e.pageX) + Math.abs(yOrigin-e.pageY);
	xOrigin = e.pageX;
	yOrigin = e.pageY;
	$('#mouseStatus').text("x:" + e.pageX + ' y:' + e.pageY + ' z:' + distance);
}); 


$(window).resize(function() {
	// landing page side bars
	newwidth = ($(document).width() - 959) / 2;
	ie7width = newwidth - 20;
	if (newwidth < 29) {
		$("#landing_viewer_screen_left").width('0');
		$("#landing_viewer_screen_right").width('0');
		$("#header_image").addClass("smallRes");
		$("#container").addClass("smallRes");
	} else {
		if ($.browser.msie && parseInt($.browser.version) == 8) {
			$("#landing_viewer_screen_left").width(ie7width);
			$("#landing_viewer_screen_right").width(ie7width);
		} else {
			$("#landing_viewer_screen_left").width(newwidth);
			$("#landing_viewer_screen_right").width(newwidth);
		}
		$("#header_image").removeClass("smallRes");
		$("#container").removeClass("smallRes");
	}
	
	$("#flash_bar").height($(document).height());
});

$(window).load(function() {
	$('#container').height($('#container').height() + 200);
	$("#flash_bar").height($(document).height());
});

/* reset all form fields after submit */
function resetFormFields() {
	$('form').each(function() {
		$(this)[0].reset();
	});
	$(':input','.gray_bg').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
	$("#demos_error_message, #viewer_demo #error_message, #error_message, #vtr_demo #error_message, #vda_demo #error_message, #vi_demo #error_message, #producer_demo #error_message, #knowledge_demo #error_message, #conversion_demo #error_message, #contact_error_message, #callout_error_message").html('');
}
