
/* 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 */





$(function() {

    // comment next lines to disable features
  
 contact();
    lightBox(); // initialize & configure lightbox script

    contactUs();
    
	tooltip5();
	
	tooltip4();
	
	tooltip3();
	
	tooltip2();
	
	slideit();
	
	siteswitch();

    easySliderInit();
    easySliderInit1();
    easyInit1();
    date();
    comment();
   
  

    //navigation(); // dynamic light selection in the menu (windows7-like)

    ephoxlogo();

    if ($("#folio").length > 0) folio(500, 0.6); // portfolio sleek image shade (timer, opacity)

    ephoxButtons();

    //if ($("#tabs").length > 0)
    /*$("#ui-tabs").tabs();

    var currentTab = querySt("tab");
    if (currentTab) {
		$("#ui-tabs").tabs("select", currentTab);
    }*/

});


// functions
function date() {
$("#edit-field-date-event-0-value-date").keyup(function () {
      var value = $(this).val();
      $("#edit-date").val(value);
    }).keyup();
}


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
		$(".fg-button:not(.ui-state-disabled)")
		.hover(
			function(){ 
				$(this).addClass("ui-state-hover");
			},
			function(){ 
				$(this).removeClass("ui-state-hover");
			}
		)
		.mousedown(function(){
				$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
				if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){$(this).removeClass("ui-state-active");}
				else {$(this).addClass("ui-state-active");}
		})
		.mouseup(function(){
			if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
				$(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 ($("#slider").length > 0) {
		
		$("#slider").easySlider({
				auto: true,
		continuous: true,
		pause: 8000,
		speed: 300,
		controlsBefore:	'<div id="control_wrapper">',
		controlsAfter:	'</div>',
		nextText:'',
		prevText:'',
		numeric:true
		});
	}
	return true;
}
function easySliderInit1(){

	// see http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider

	if ($("#quote").length > 0) {

		$("#quote").easySlider1({
				auto: true,
		continuous: true,
		pause: 12000,
		speed: 400,
		controlsBefore:	'<div id="control_wrapper1">',
		controlsAfter:	'</div>',
		nextText:'',
		prevText:'',
		numeric:true
		});
	}
	return true;
}
//
function easyInit1(){


for( var i=1; i<7; i++){
    $('#block-views-Quotes-block_2 .views-row-'+i).appendTo('#intro1 ol#control li#control'+i+' a');
}

}
function navigation() {
	$("li a", "#nav").
		mousemove(function(e) {
			var relativeY = (e.pageY - this.offsetTop - 45) / 4;
			$(this).css("backgroundPosition", "center " + relativeY + "px");
		}).
		mouseout(function(e) {
			$(this).css("backgroundPosition", "center center");
		});
}

//

function ephoxlogo(){

	// see http://plugins.jquery.com/project/imghover
	
	$('#ephoxlogo').imghover({
		suffix: '-hovered',
		fade: false,
		fadeSpeed: 200
	});
}

//

function lightBox() {
  
	$("a[rel^='lightbox']").prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		autoplay: true, /* Automatically start videos: True/False */
		opacity: 0.5, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allow_resize: true, /* Resize the photos bigger than viewport. 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 */
		callback: function() { }
	});
        
}
function contactUs(){
    $('.prettyPhoto').prettyPhoto({
		animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		autoplay: true, /* Automatically start videos: True/False */
		opacity: 0.5, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allow_resize: false, /* Resize the photos bigger than viewport. true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function() { }
	});
  
}
//

function folio(time, opacity) {
	$("img", "#folio")
		.css("opacity", 1)
		.hover(
			function() {
				$(this).stop().animate({opacity: opacity}, time);
			},
			function() {
				$(this).stop().animate({opacity: 1}, time);
			}
		);
}

//

function tooltip5() {
    $(document).ready(function() {
      $.fn.qtip.styles.tooltip5 = {
        border: 0,
        width: 188,
        background: '#333333',
        color: '#ffffff',
        font: 'italic 12px Trebuchet MS, Arial, sans-serif',
        lineHeight: '18px',
        padding: '15px 20px 18px 20px'
      },
      $('a.tool_tip_5').qtip({
        position: {
          corner: {
            target: 'topLeft',
            tooltip: 'bottomLeft'
          },
          adjust: { 
			x: -20,
			y: 0
	      }
        },
        style: 'tooltip5',
        show: {
          effect: {
            type: function(length) {
              this.animate({top: '-=10px', queue: false}, 0).animate({top: '+=10px', opacity: 'toggle', queue: false}, length);
            },
            length: 150
          }
        }
      });
    });
}

function tooltip4() {
    $(document).ready(function() {
      $.fn.qtip.styles.tooltip4 = {
        border: 0,
        width: 234,
        background: '#333333',
        color: '#ffffff',
        font: 'italic 12px Trebuchet MS, Arial, sans-serif',
        lineHeight: '18px',
        padding: '15px 20px 18px 20px'
      },
      $('a.tool_tip_4').qtip({
        position: {
          corner: {
            target: 'topLeft',
            tooltip: 'bottomLeft'
          },
          adjust: { 
			x: -20,
			y: 0
	      }
        },
        style: 'tooltip4',
        show: {
          effect: {
            type: function(length) {
              this.animate({top: '-=10px', queue: false}, 0).animate({top: '+=10px', opacity: 'toggle', queue: false}, length);
            },
            length: 150
          }
        }
      });
    });
}

function tooltip3() {
    $(document).ready(function() {
      $.fn.qtip.styles.tooltip3 = {
        border: 0,
        width: 312,
        background: '#333333',
        color: '#ffffff',
        font: 'italic 12px Trebuchet MS, Arial, sans-serif',
        lineHeight: '18px',
        padding: '15px 20px 18px 20px'
      },
      $('a.tool_tip_3').qtip({
        position: {
          corner: {
            target: 'topLeft',
            tooltip: 'bottomLeft'
          },
          adjust: { 
			x: -20,
			y: 0
	      }
        },
        style: 'tooltip3',
        show: {
          effect: {
            type: function(length) {
              this.animate({top: '-=10px', queue: false}, 0).animate({top: '+=10px', opacity: 'toggle', queue: false}, length);
            },
            length: 150
          }
        }
      });
    });
}

function tooltip2() {
    $(document).ready(function() {
      $.fn.qtip.styles.tooltip2 = {
        border: 0,
        width: 469.5,
        background: '#333333',
        color: '#ffffff',
        font: 'italic 12px Trebuchet MS, Arial, sans-serif',
        lineHeight: '18px',
        padding: '15px 20px 18px 20px'
      },
      $('a.tool_tip_2').qtip({
        position: {
          corner: {
            target: 'topLeft',
            tooltip: 'bottomLeft'
          },
          adjust: { 
			x: -20,
			y: 0
	      }
        },
        style: 'tooltip2',
        show: {
          effect: {
            type: function(length) {
              this.animate({top: '-=10px', queue: false}, 0).animate({top: '+=10px', opacity: 'toggle', queue: false}, length);
            },
            length: 150
          }
        }
      });
    });
}

//

function slideit() {
	$('a.anchorLink').click( function() {
	    var x = $(this.hash);
	    if( x.length ) {
	      $('html,body').animate( {scrollTop: x.offset().top - 20}, 1100 );
	      location.hash = this.hash;
	      return false;
	     }
	  });
}

//

function siteswitch() {
	$(document).ready(function() {
		$('.switcherlist').width($('.switcherlist').width());
		$('#topnav').hover(
			function() {
				$('.switcher', this).addClass('slidedown');
				$('.switcherlist', this).slideDown(200);
			},
			function() {
				obj = this;
				$('.switcherlist', this).slideUp(100, function(){$('.switcher', obj).removeClass('slidedown');});
			}
		);
	});
}

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 = "";
    }

}


 function popup() {
     
   $(document).ready(function(){
        $("a[rel^='prettyPhoto']").prettyPhoto({
            animationSpeed: 'normal',
            padding: 40,
            opacity: 0.35,
            showTitle: true,
            allowresize: true,
            counter_separator_label: '/',
            theme: 'dark_rounded'
        });
    });
     }


  function trynow() {
     
                 $(document).ready(function() {
 
                     $('#draggableview_try_now_1 a').each(function(){
                          var some_val =  $(this).html();
                     $(this).html('<span>'+some_val+'</span>');
                    });


                     $('#draggableview_try_now_1 .draggable a').addClass('botton-try');
                     $('.botton-block').appendTo('.for-botton');

                });
                }




 function suport() {

                 $(document).ready(function() {
                  
                  
                  $('#draggableview_Suport_1 ul a').wrap(document.createElement("li"));
                      
                                         
                    
                     });
                }
                 
     function search() {

         $(document).ready(function() {

                   $('#block-search-0').appendTo('.search-support');

       });
 }
 
 function feature() {
    $(document).ready(function(){
        $('.right-feature .text .field-item:first-child').addClass("grid_6 alpha");
        $('.right-feature .text .field-item:last-child').addClass("grid_6 omega");
    })


 }


  function pngfix() {
    $(document).ready(function(){
        $('img').addClass("ie6fix");
         })


 }
  function ephoxsupport() {
 $(document).ready(function() {
                   $('#block-search-0').appendTo('.search .grid_8');
         });

 }
   function comment() {
 $(document).ready(function() {
                   $('.page-comment #comment-form').appendTo('.page-comment .comment-preview');
         });

 }
    function contact() {
 $(document).ready(function() {
     $('#contact-tab').click(function() {

         $('.pp_pic_holder').css('width', '620px !important')
     });
                  
         });

 }
 
(function($){
	
	$.randomImage = {
		defaults: {
			
			//you can change these defaults to your own preferences.
			path: '/sites/all/themes/tinymce/img/ads/', //change this to the path of your images
			myImages: ['ad1.jpg', 'ad2.jpg' ] //put image names in this bracket. ex: 'harold.jpg', 'maude.jpg', 'etc'
			
		}			
	}
	
	$.fn.extend({
			randomImage:function(config) {
				
				var config = $.extend({}, $.randomImage.defaults, config); 
				
				 return this.each(function() {
						
						var imageNames = config.myImages;
						
						//get size of array, randomize a number from this
						// use this number as the array index

						var imageNamesSize = imageNames.length;

						var lotteryNumber = Math.floor(Math.random()*imageNamesSize);

						var winnerImage = imageNames[lotteryNumber];

						var fullPath = config.path + winnerImage;
						
						
						//put this image into DOM at class of randomImage
						// alt tag will be image filename.
						$(this).attr( {
										src: fullPath,
										alt: winnerImage
									});
					
				});	
			}
	});
})(jQuery);


