var step = 1;
    var timeout_id;

    $(document).keydown(function(event){
        if(event.which == 27){
            clearTimeout(timeout_id);
            $("#go_btn").attr("disabled","");
            $("#go_btn").removeClass("domain-submit-disabled");
            $("#go_btn").addClass("domain-submit");
            $("#go_btn").html('Go');

        }
    });
    $(document).ready(function (){
		
        $("#tldSelector").change(function() { $("#tldDisplay").html("." + $("#tldSelector").val()); }) // Sets the tld display when the dropdown selecion is made.
        $('#field_domains-input').focus(); // Focus the cursor on the search box as soon as the page loads
        $('#field_domains-input').val('www.'); // Focus the cursor on the search box as soon as the page loads

        rotatePromoBanners();

        $('body').append('<span style="display:none"><img src="/getImage.php?src=logo.gif" ><img src="/getImage.php?src=30preloader.gif" /></span>');

        $('form[name="form_domain_avail"]').submit(function(){
            $("#go_btn").attr("disabled","disabled");
            $("#go_btn").addClass("domain-submit-disabled");
            butt = $("#go_btn");
            animLoading();
            //$('body').append('<div class="modal_overlay"></div><div class="modal_content"><br><br><br><br><img src="/getImage.php?src=logo.gif" ><br><br><div class="pre"></div><br><br><div class="processing_note" style="font: 12px verdana, arial, sans-serif; color: #515151;"><strong>Finding your Domain Name......</strong><br /><br /></div></div>');
        });
    });
    function animLoading()
    {
        step++;
        if (step == 7) step = 1;

        if (step == 1)
        {
            window.status = 'Processing.   ';
            butt.html('.   ');
        }
        if (step == 2)
        {
            window.status = 'Processing.   ';
            butt.html('.   ');
        }
        if (step == 3)
        {
            window.status = 'Processing..  ';
            butt.html('..  ');
        }
        if (step == 4)
        {
            window.status = 'Processing..  ';
            butt.html('..  ');
        }
        if (step == 5)
        {
            window.status = 'Processing... ';
            butt.html('... ');
        }
        if (step == 6)
        {
            window.status = 'Processing... ';
            butt.html('... ');
        }
        timeout_id = setTimeout("animLoading()", 200);
    }

    function rotatePromoBanners(){
        var mLeft = (305 - $('ul#banner-pagination').width())/2;
        $('ul#banner-pagination').css('margin-left',mLeft);
        $('ul#banner-pagination').css('display','block');
        timer = 6000;
        min = 0;
        i = min;
        max = $('ul#banner-slider li').length - 1;
        t = setTimeout("nextPromoBanner("+i+","+max+","+min+")",timer);
    }

    function nextPromoBanner(i, max, min){
        setPromoBanner(i);
        // send the index back once it reaches the last item
        if(i==max) {
            i=min;
        }else{
            i++;
        }
        t = setTimeout("nextPromoBanner("+i+","+max+","+min+")",timer);
    }
			
		
    $('ul#banner-pagination a').click(function(){
        clearTimeout(t);
        theID = $(this).attr('id');
        theID = theID.substr(6,1);
        setPromoBanner(theID);
        theID++;
        //setTimeout("nextPromoBanner("+theID+","+max+","+min+")",12000);
        return false;
    });

    function check_domain_name(){
        var domain_name = $("#field_domains-input").val();
        domain_name = trim(domain_name);
        if(domain_name=='www.' || domain_name==''){
            $("#error_msg").show();
            return false;
        }
        return true;
    }

    function remove_error_msg(){
        $("#error_msg").hide();
    }

    function setPromoBanner(index){
        // make this banner inactive
        $('ul#banner-slider li.current').removeClass("current");
		
        // make next banner active

        $('ul#banner-slider li#img_banner'+index).addClass("current");
			
        // make this pagination inactive
        $('ul#banner-pagination a.current').removeClass("current");
		
        // make next pagination active
        $('ul#banner-pagination a#banner'+index).addClass("current");
    }


    $(document).ready(function (){
        $("form#homepageDomainSearch").submit( function(){
            searchedDomain = $("#field_domains-input").val();
            try {
                _gaq.push(['_trackPageview', '/searchedDomain/' + searchedDomain ]);
            }
            catch(e){ };
        });
    });

$(document).ready(
	function(){
		$('.testimonials ul').innerfade({
			speed: 500,
			timeout: 9000,
			type: 'sequence',
			containerheight: '120px'
		});
		$('.p-gallery ul').innerfade({
			speed: 500,
			timeout: 5000,
			type: 'sequence',
			containerheight: '124px'
		});
});
