	//Save last opened menu name
	var last_opened_dropdown = "";

    $(document).ready(function() {
		
				var banner_inside_image = $(".banner-container-image").html();
				$(".banner-static-image").html(banner_inside_image);
				$(".banner-container-image").remove(); 
				
				
				var banner_slogan_image = $(".banner-slogan-image").html();
				$(".banner-static-slogan-image").html(banner_slogan_image);
				$(".banner-slogan-image").remove();
				

				$('ul.sf-menu').superfish({ 
					delay:       100,                            // one second delay on mouseout 
					animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
					speed:       'fast',                          // faster animation speed 
					autoArrows:  false,                           // disable generation of arrow mark-up 
					dropShadows: false                            // disable drop shadows 
				}); 
		
				$(".events h2").first().click(function() {
  					 window.location = "http://transitionsonline.com/speaking-amp-workshops/speaking-itinerary/";
				});
				
				$(".toggle").accordion({li: "a",
				autoHeight: false,
				collapsible: true
				});
						
				$("ul > li:last-child").addClass("none");
						
				$('.textfield').wrap('<span>');
						
				$(".bottom-container_top .content form").find('br').css("display", "inline-block");
						
				if($(".banner-img").length > 0)
				{
					$(".banner-img").banner();
				}
					
				//$(function(){
					$('#slides').slides({
					preload: true,
					play:5000
					});
				
					$('#aslides').slides({
					preload: true,
					play: 3000
					});
				//});
		
		
		 //$(document).ready(function() {
    
    //Apply hint and disable search button
    $("#search_word").hint();
    $("#search_submit").attr('disabled','disabled');    
    
    //enable search button only if some value added
    $("#search_word").keyup(
        function(objEvent)
        {
           if(this.value != "")
           {
                $("#search_submit").removeAttr('disabled');
           }
           else
           {
                $("#search_submit").attr('disabled', 'disabled');  
           }
        }
    )    
	
	url = location.href;
	pattern = "bitebankwebsites.com";
	if(url.search(pattern) > 0)
	{
		$("#search_word").unbind('keyup');
		$("a[rel^='prettyPhoto']").attr("href", "javascript:void(0);");
	}
	else
	{
		if ($("a[rel^='prettyPhoto']").length != 0) 
		{
			init_practice_form();
		}
	}
	

});
				
						
// UI SELECT MENU SCRIPT STARTS HERE   
$(document).ready(function(){
    $('select#selectClientLang').selectmenu({style:'dropdown'});
});
// UI SELECT MENU SCRIPT ENDS HERE					
												
						
   //}); 
//Following Script is to solve issues of banner in Firefox 3.6 MAC 
 window.onload = forceBrowserEven;
 window.onresize = forceBrowserEven;

function forceBrowserEven(){
 //Detect Firefox less than 3.6 & Mac
   if (navigator.platform.indexOf("Mac")!=-1 && navigator.userAgent.indexOf("Firefox/3.6")!=-1 && document.width % 2 == 1){
    document.getElementsByTagName('html')[0].style.marginLeft = '-1px';
   }
 };

 /*** This function will fetch form and add html to div ***/
function get_form_data()
{
	ajax_url = "custom/practice_form.php";
	$.ajax({
		type    : "POST",
        url     : ajax_url,
        success : function(response) {  			
            $("#pagewidth").append(response);
        },
        error:function (xhr, ajaxOptions, thrownError){
			alert(xhr.status);
            alert(thrownError);
        }
	});
}

/*** form validation and submit ***/
function submit_form(form)
{
	//add method to validator			
	jQuery.validator.addMethod("greaterThanThree", function(value, element) {
		var selectedItems = 0;
		$("input[@name='itemSelect[]']:checked").each(function() {selectedItems++;});
		if(selectedItems > 2) {return true;}
		return false;
	},"");

	$("#"+form).validate({
		rules : {
			'biggest_challenges[]' : { greaterThanThree : true }
		},
		errorPlacement: function(error, element) {
		error.appendTo( element.parent().next() );
		},
		errorLabelContainer: "#errorRow .appValueColumn",
		errorContainer: "#errorRow, #errorRow td"
	});


	if($("#"+form).valid() == true)
	{
		$("#"+form+" #submit").removeClass("inputbutton");
		$("#"+form+" #submit").addClass("input-disable");
		$("#"+form+" #submit").attr("disabled", "true");
			
		ajax_url = "custom/practice_form.php";
		$.ajax({
			type    : "POST",
            url     : ajax_url,
			data    : $("#"+form).serialize(),
            success : function(response) {                                              
				alert(response);
				$.prettyPhoto.close();
				$("#inline_demo").remove();
				get_form_data();
			},
            error:function (xhr, ajaxOptions, thrownError){
				alert(xhr.status);
                alert(thrownError);
            }
		});
	}
	else
	{
		alert("Please fill all fields");
	}	
}

function init_practice_form()
{
	//fetch form data			
	get_form_data();

	//prettyPhoto initialization
	$("a[rel^='prettyPhoto']").prettyPhoto({
	animation_speed:'normal',
	deeplinking: false,
	theme:'light_square',
	slideshow:false, 
	default_width: 620, 
	default_height: 1550, 
	autoplay_slideshow: false,
    modal:true,
	changepicturecallback:function(){
		$("#inline_demo").html("");	
		
		var h = $(document).height();
		$('.pp_overlay').css("height",h+40);
		$( ".dropdown-div" ).each(function( intIndex ){
			dropdown_width = $(this).width();

				switch($(this).children("a").attr("id"))
				{				
					case 'practice_type':
						$(this).children(".dropdown").width(75);
					break;
					
					case 'dentist_count':
						$(this).children(".dropdown").width(59);
					break;

					case 'patients_count':
						$(this).children(".dropdown").width(70);
					break;

					case 'new_patients_count':
						$(this).children(".dropdown").width(70);
					break;

					case 'gross_production_r':
						$(this).children(".dropdown").width(120);
					break;

					case 'gross_production_h':
						$(this).children(".dropdown").width(110);
					break;

					default:
						if($(this).children(".dropdown").width() < dropdown_width)
						{
							dropdown_width = dropdown_width - 13;
							$(this).children(".dropdown").width(dropdown_width);			
						}
					break;
				}
		});

		$('.dropdown').hide();

		$('.pp_fade a.close').show();

		$('a.select').click(function(e) {	
			var dropdown_name	= $(this).attr('id')+"_dropdown";
			if(last_opened_dropdown != "")
			{
				$('#'+last_opened_dropdown).slideUp('slow');
			}

			$('#'+dropdown_name).slideToggle('slow');
			last_opened_dropdown = dropdown_name;
			e.stopPropagation();
		});

		$('.dropdown span').click(function() {
			$('.dropdown span').each(function(){
				$(this).removeClass('active');
			});
						
			$(this).addClass('active');
			var parent			= $(this).parent();
			var selectName		= parent.attr('cust');
			var selectValue		= $(this).text();
			$('#'+selectName+ " span:first-child").html(selectValue);
			$('#hidden_'+selectName).val(selectValue);
			parent.css("display","none");
					
		});			
	},
	callback: function()
	{
		$("#inline_demo").remove();
		get_form_data();
	},
	markup:'<div class="pp_pic_holder"> \
        <div class="ppt"></div> \
          <div class="pp_content_container"> \
           <div class="pp_left"> \
           <div class="pp_right"> \
            <div class="pp_content"> \
             <div class="pp_loaderIcon"></div> \
             <div class="pp_fade"> \
              <a href="#" class="close pp_close"></a> \
              <div id="pp_full_res"></div> \
              <div class="pp_details"> \
              </div> \
             </div> \
              <div class="box-bottom"> \
                    </div> \
            </div> \
           </div> \
           </div> \
          </div> \
         </div> \
         <div class="pp_overlay"></div>',gallery_markup:'<div class="pp_gallery"> \
           </div>'});

}
