///alert("scroller loaded");
var count;
var imgs;
 //alert("in doc");
$(document).ready(function(){
  // alert("loaded");
    if ( typeof( window[ 'logo_array' ] ) != "undefined" ) {
         if(logo_array.length >0)
         {
              $("#"+logo_div).html(addLogos(logo_array));
              $("#"+logo_div).css("text-align","center");
         }
   }
   if ( typeof( window[ 'test_array' ] ) != "undefined" ) {
         if(test_array.length >0)
         {
              $("#"+logo_div).html(addTestimonial(test_array));
         }
   }

    if ( typeof( window[ 'wit_array' ] ) != "undefined" ) {
         if(wit_array.length >0)
         {
              $("#"+logo_div).html(addWIT(wit_array));
         }
   }
   if ( typeof( window[ 'feat_array' ] ) != "undefined" ) {
         if(feat_array.length >0)
         {
              $("#"+logo_div).html(addFeatured(feat_array));
              $("#"+logo_div).addClass("flush_bottom");
              setSlideShow();
         }
   }
    
    $("#content_area").each(function(){
        //alert(this.scrollHeight);
        if(this.scrollHeight> 520)
        {
            $('#content_area')
            .bind('mousewheel', function(event, delta) {
                if(delta < 0)
                {
                    newpos = ($(".handle").position().top) + 30;
                    if(newpos > 530 - ($(".handle").height()))
                        newpos = 530 - ($(".handle").height());
                }else
                {
                    newpos = ($(".handle").position().top) - 30;
                    if(newpos < 0)
                        newpos = 0;
                }
                
                $(".handle").css("top", newpos);
                var percentage = ((newpos*100)/$(".handle").parent().height())/100;
                $("#content_area").scrollTop($("#content_area").attr("scrollHeight")*percentage);
                return false;
            });

            $(this).parent().prepend("<div class='scroll_vert height_350'><div class='handle hide'></div></div>");
            $(".handle").css("height",(520*((520*100)/this.scrollHeight)/100));
            $('.handle').draggable({ axis: 'y', containment: 'parent', cursor: 'pointer', scroll: true, drag: function(event, ui){
                    var percentage = ((ui.position.top*100)/$(this).parent().height())/100;
                    $("#content_area").scrollTop($("#content_area").attr("scrollHeight")*percentage);
                }
             });
        }
    });

    

    $("#golf_tourny_content").each(function(){
        //alert(this.scrollHeight);
        if(this.scrollHeight> 285)
        {
            $('#golf_tourny_content')
            .bind('mousewheel', function(event, delta) {
                if(delta < 0)
                {
                    newpos = ($(".handle").position().top) + 30;
                    if(newpos > 285 - ($(".handle").height()))
                        newpos = 285 - ($(".handle").height());
                }else
                {
                    newpos = ($(".handle").position().top) - 30;
                    if(newpos < 0)
                        newpos = 0;
                }

                $(".handle").css("top", newpos);
                var percentage = ((newpos*100)/$(".handle").parent().height())/100;
                $("#golf_tourny_content").scrollTop($("#golf_tourny_content").attr("scrollHeight")*percentage);
                return false;
            });

            $(this).parent().prepend("<div class='scroll_vert golf_scroll'><div class='handle hide'></div></div>");
            $(".handle").css("height",(285*((285*100)/this.scrollHeight)/100));
            $('.handle').draggable({ axis: 'y', containment: 'parent', cursor: 'pointer', scroll: true, drag: function(event, ui){
                    var percentage = ((ui.position.top*100)/$(this).parent().height())/100;
                    $("#golf_tourny_content").scrollTop($("#golf_tourny_content").attr("scrollHeight")*percentage);
                }
             });
        }
    });
    
    
    
});

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function addLogos(arr, link_title)
{
    if(link_title === undefined)
    {
        link_title = "";
    }
    var html = "<img style='z-index:1;' src='/images/logos_top.jpg' />";
    html+= link_title;
    for(x=0;x<arr.length;x++)
    {
        html+="<a href='"+arr[x][1]+"' target='_blank'><img src='/images/"+arr[x][0]+"' /></a>";
    }
    return html;
        //$("#logos_holder_divisions").html("hello");
       
}

function addTestimonial(arr)
{
    var html = "<img style='z-index:1;' src='/images/logos_top.jpg' /><p class='quote_body'>&quot;Shaner solutions has been the best operational decision we have made for our hotels.  They have provided us the best support possible in accounting, while at the same time reducing our costs.  Their team members really care about our hotels staff and it shows in the way they approach business every day&quot;</p><p class='cred'>Sanjeev Misra, President<br />Atira Hotels</p>";
    html+="<div class='quote_break'></div>";
    html += "<p class='quote_body'>&quot;The people of Shaner  solutions are valuable business partners who allow us to run our operations in an effieicnt manner. Beyond the tactical support, they provide on-target strategis counsel that gives Crescent Hospitality a competitive business edge.&quot;</p><p class='cred'>Michael George, President and CEO <br />Crescent Hospitality Corporation</p>";
        //$("#logos_holder_divisions").html("hello");
        return html;
}

function addWIT(arr)
{
    var html = "<img style='z-index:1;' src='/images/logos_top.jpg' />";
    html+="<div id='wit'><div><img src='/images/WIT.png' /></div>";
    html += "<div class='wit_header'>Shaner WIT</div>";
    html+= "<p>Our Commitment to do Whatever It Takes Shaner fosters an environment of teamwork by encouraging each associate to fulfill their role as part of the bigger picture — contributing to the guest, the company and the community. From all levels of the company, Shaner demonstrates a total commitment to do \"Whatever it Takes\".</p>";
    html+= "<p>Shaner associates are mentored and empowered to anticipate the needs of internal and external customers, addressing those needs quickly and confidently. The WIT program is designed to make service a fun challenge, turning unhappy customers into loyal customers.</p>";
    html+= "</div>";
        //$("#logos_holder_divisions").html("hello");
        return html;
}

function addFeatured(arr)
{
    //alert("featured");
    html ='<div id="featured_sub"><div id="featured_title">Featured Hotel</div><div id="featured_photo"><img src="/images/featured_hotel_1.png" width="277" /><img src="/images/featured_hotel_2.png" width="277" /><img src="/images/featured_hotel_3.png" width="277" /><img src="/images/featured_hotel_4.png" width="277" /><img src="/images/featured_hotel_5.png" width="277" /></div><div id="featured_content"><div class="featured_logo"><img src="/images/featured_courtyard_2.png" /></div><div class="hotel_name"><a href="http://www.marriott.com/hotels/travel/jaxjv-courtyard-jacksonville-beach-oceanfront/" target="_blank">Jacksonville Beach Courtyard</a></div><div class="hotel_city">Jacksonville Beach, Florida</div><div class="hotel_text">The Courtyard By Marriott Jacksonville Beach Oceanfront is the newest addition to the Jacksonville Beach Florida area. With spacious and comfortable guestrooms you will enjoy the many amenities while enjoying the views of the Atlantic Ocean. Just a half hour from downtown Jacksonville and minutes away from some of the best shopping in the area, Jacksonville Beach is a great destination for business travelers or the family vacationers.</div></div></div>';
    return html;
}

function setSlideShow()
{
    //alert("in slide show");
    count=0;
    imgs = jQuery.makeArray($("#featured_photo img"));

    $("#featured_photo img").css("z-index", 4);
    $(imgs[0]).show();
    inter = setInterval(function(){
        $(imgs[count%imgs.length]).css("z-index", 5);
        $(imgs[(count+1)%imgs.length]).show();
        $(imgs[count++%imgs.length]).fadeOut("slow",function(){
            $(this).css("z-index", 4);
        })
    }, 5000);
}
  