﻿	
	
	function openWin(URL, wid, hei) {
		if(!wid) { wid = "740"; }
		if(!hei) { hei =  "700"; }
		aWindow=window.open(URL,"_blank","width="+wid+",height="+hei+",toolbar=1"+",menubar=1"+",status=1"+",resizable=1"+",directories=1"+",location=1"+",scrollbars=1");
	}



// Reval Product Client Login on click event
	function openRevalApp() {
	  if (typeof (AppWindow) != 'undefined' && !AppWindow.closed) {
	      AppWindow.focus();
	      return;
	  }

	  var aH = window.screen.availHeight - 50;
	  var aW = window.screen.availWidth - 9;

	  try
	  {
	    var urlstring = "";
        if(location.host.indexOf('r2') == 0) {urlstring = "https://r2pd01.reval.com/default_login.asp?src=www";}
        else if(location.host.indexOf('r3') == 0) {urlstring = "https://r3pd01.reval.com/default_login.asp?src=www";}
	    else {urlstring = "https://r1pd01.reval.com/default_login.asp?src=www";}
	    
	    var AppWindow = window.open(urlstring,'RevalAppWindow', 'top=0,left=0,height=' + aH + ',width=' + aW + ',toolbar=no,menubar=no,location=no,status=yes,resizable=yes', true);
	  }
	  catch (e)
	  {
	    alert('exception caught: ' + e.description);
	  }

	}


	// search box enter key pressed event 
	function searchKeyPress(e, method) {
		// look for window.event in case event isn't passed in
		if (window.event) { e = window.event; }

		if (e.keyCode == 13)
		{	
			//if(method == 'login') {
			//	submitForm();
			//}
			//else
			if(method == 'search') {
				window.setTimeout('searchFunc()',10);
			}
		}
	}
	// search function
	function searchFunc() { 
		if (document.getElementById('SearchBox').value == document.getElementById('SearchBox').defaultValue)
		{
		    alert("Please enter a search value")
		    return;
		}
		if (document.getElementById('SearchBox').value == "")
		{
		    alert("Please enter a search value")
		    return;
		}
		window.location = "/search/Pages/default.aspx?k=" + document.getElementById('SearchBox').value;
	}
	// clears search's input onfocus
	function clearText(thefield){
		if (thefield.defaultValue==thefield.value)
		thefield.value = "";
	} 
	function resetText(thefield){
		if (thefield.value=="")
		thefield.value = thefield.defaultValue;
	} 
	function printPage(){
		window.print();
	}
	
// Homepage banner switch thumbnail function	
	function switchNivoThumbnail() {
		var newSrcAttr = (jQuery(this).parent().hasClass('active')) ? 'rel2' : 'rel';
		jQuery(this).attr('src',jQuery("#banner-slider img").eq(jQuery(this).parent().attr('rel')).attr(newSrcAttr));
	}



// jQuery DOM finished loading event
	jQuery(function() {
	
		// Homepage Banner setup
		jQuery('#banner-slider').nivoSlider({
		    effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
		    animSpeed: 100, // Slide transition speed
	        pauseTime: 8000, // How long each slide will show
	        controlNavThumbs: true, // Use thumbnails for Control Nav
	        controlNavThumbsFromRel: true, // Use image rel for thumbs
			directionNav: false, // Next & Prev navigation
			afterChange: function(){ // Triggers after a slide transition
			
				jQuery('#banner-slider .nivo-controlNav a').each(function() {
					if(jQuery(this).hasClass('active')) {jQuery(this).children().first().hide();jQuery(this).children().last().css("display","inline");}
					else {jQuery(this).children().last().hide();jQuery(this).children().first().css("display","inline");}

				});
				
			},
			afterLoad: function(){// Create alternative thumbnails

jQuery("#banner-slider").css("visibility","visible");
				
				jQuery('#banner-slider .nivo-controlNav a img').each(function() {
					var thumb = jQuery(this);
					var selectThumb = thumb.clone();
					selectThumb.attr('src',jQuery("#banner-slider img").eq(thumb.parent().attr('rel')).attr('rel2'));
					
					if(thumb.parent().hasClass('active')) {thumb.hide();selectThumb.css("display","inline");}
					else {selectThumb.hide();thumb.css("display","inline");}
					
					selectThumb.insertAfter(thumb);
					
				});
			} 
		});
		// Homepage banner thumbnail on hover event
		jQuery('#banner-slider .nivo-controlNav a img').hover(function() {
			//if(!jQuery(this).parent().hasClass('active')) jQuery(this).attr('src',jQuery("#banner-slider img").eq(jQuery(this).parent().attr('rel')).attr('rel2'))
			if(!jQuery(this).parent().hasClass('active')) {jQuery(this).parent().children().first().hide();jQuery(this).parent().children().last().css("display","inline");}
			
		},function() {
			//if(!jQuery(this).parent().hasClass('active')) jQuery(this).attr('src',jQuery("#banner-slider img").eq(jQuery(this).parent().attr('rel')).attr('rel'))
			if(!jQuery(this).parent().hasClass('active')) {jQuery(this).parent().children().last().hide();jQuery(this).parent().children().first().css("display","inline");}
			
		});
		
		
		
		// Request Demo button on click event
		jQuery("#mid-left .request-demo-wrapper a").click(function() {
			jInputElem = jQuery("#mid-left .request-demo-wrapper input");
			if(jInputElem.val().indexOf("@",0) < 1)
				alert("Please enter an Email Address");
			else
				window.location.href = "http://downloads.reval.com/forms/request-demo-colorbox?email="+jInputElem.val();
		})	
		
		// Infographics hover events 
		jQuery("img[src$='/SiteCollectionImages/Infographics/Reval_InfoCircle-CM-LM1.gif']").hover(
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-CM-LM2.gif")},
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-CM-LM1.gif")});
		jQuery("img[src$='/SiteCollectionImages/Infographics/Reval_InfoCircle-FRM1.gif']").hover(
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-FRM2.gif")},
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-FRM1.gif")});
		jQuery("img[src$='/SiteCollectionImages/Infographics/Reval_InfoCircle-HAC1.gif']").hover(
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-HAC2.gif")},
			function() {jQuery(this).attr("src","/SiteCollectionImages/Infographics/Reval_InfoCircle-HAC1.gif")});

		
		// Some small modifications to imvrove display when editing 
		jQuery("div[id$='RichHtmlField_displayContent']").css("padding","0px");
		jQuery("div[id$='_RichHtmlField']").find(".ms-formfieldcontainer").addClass("editing");
		
	});


