
/* UserVoice add-in */

var uservoiceOptions = {
  /* required */
  key: 'ephox',
  host: 'ephox.uservoice.com', 
  forum: '35216',
  showTab: true,  
  /* optional */
  alignment: 'left',
  background_color:'#7F7F7F', 
  text_color: 'white',
  hover_color: '#262626',
  lang: 'en'
};

function endsWith(str, s){
var reg = new RegExp (s + "$");
return reg.test(str);
}

function _loadUserVoice() {
  if (endsWith(document.location.href, 'demo') == false) {
  var s = document.createElement('script');
  s.setAttribute('type', 'text/javascript');
  s.setAttribute('src', ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js");
  document.getElementsByTagName('head')[0].appendChild(s);
  }
}
_loadSuper = window.onload;
window.onload = (typeof window.onload != 'function') ? _loadUserVoice : function() { _loadSuper(); _loadUserVoice(); };


/* End UserVoice add-in */


/* JQuery */


var $j = jQuery.noConflict();


$j(function() {

    // comment next lines to disable features


    lightBox(); // initialize & configure lightbox script

    easySliderInit();


    //navigation(); // dynamic light selection in the menu (windows7-like)

    ephoxlogo();

    if ($j("#folio").length > 0) folio(500, 0.6); // portfolio sleek image shade (timer, opacity)

    ephoxButtons();

    //if ($j("#tabs").length > 0)	
    $j("#ui-tabs").tabs();

    var currentTab = querySt("tab");
    if (currentTab) {
        $j("#ui-tabs").tabs("select", currentTab);
    }

});


// functions

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}


function ephoxButtons(){
		//all hover and click logic for buttons
		$j(".fg-button:not(.ui-state-disabled)")
		.hover(
			function(){ 
				$j(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$j(this).removeClass("ui-state-hover"); 
			}
		)
		.mousedown(function(){
				$j(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
				if( $j(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $j(this).removeClass("ui-state-active"); }
				else { $j(this).addClass("ui-state-active"); }	
		})
		.mouseup(function(){
			if(! $j(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
				$j(this).removeClass("ui-state-active");
			}
		});
}


/*
	used for home page banner
*/
function easySliderInit(){

	// see http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider
	
	if ($j("#slider").length > 1) {
		
		$j("#slider").easySlider({
			auto: true, 
			continuous: true,
			pause: 8000,
			speed: 300,
			nextText:'',
			prevText:'',
			numeric:true
		});
	}
	return true;
}

//

function navigation() {
	$j("li a", "#nav").
		mousemove(function(e) {
			var relativeY = (e.pageY - this.offsetTop - 45) / 4;
			$j(this).css("backgroundPosition", "center " + relativeY + "px");
		}).
		mouseout(function(e) {
			$j(this).css("backgroundPosition", "center center");
		});
}

//

function ephoxlogo(){

	// see http://plugins.jquery.com/project/imghover
	
	$j('#ephoxlogo').imghover({suffix: '-hovered'});
}

//

function lightBox() {
	$j("a[rel^='lightbox']").prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		default_width: 540,
		default_height: 347,
		autoplay: true, /* Automatically start videos: True/False */
		opacity: 0.5, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		callback: function() { }
	});
}

//

function folio(time, opacity) {
	$j("img", "#folio")
		.css("opacity", 1)
		.hover(
			function() {
				$j(this).stop().animate({ opacity: opacity }, time);
			},
			function() {
				$j(this).stop().animate({ opacity: 1 }, time);
			}
		);
}


//

//

var ie6 = jQuery.browser.msie && parseInt(jQuery.browser.version) < 7;

function betaSignUpCountryChanged(countrySelect) {
    if (countrySelect.value != "United States") {
        document.getElementById("field8164958").selectedIndex = 0;
        document.getElementById("stateRow").style.display = "none";
    } else {
        document.getElementById("stateRow").style.display = "";
    }
}