// JavaScript Document

var gPg = 0;
var tOut = '';
var inc = 0;

jQuery(function($) {
					if ($('.gallery_prototype').length) {
		$('.carousel div').events({
			mouseover: function(){
				if ($(this).attr('class')!='current') {
					$('.carousel div').removeClass('highlight');
					$(this).addClass('highlight'); 
					$('span', this).attr('style','display: block');
				}
			},
			mouseout: function(){
				if ($(this).attr('class')!='current') {
					$('.carousel div').removeClass('highlight');
					if ($(this).attr('class')!='highlight'&&$(this).attr('class')!='current') {
						$('span', this).attr('style','display: none');
					}
				}
			},
			click: function(){
				if ($(this).attr('class')!='current') {
					$('.carousel  div').removeClass('highlight').removeClass('current');
					$('span', this).attr('style','display: none');
					$(this).addClass('current');
					$('.main_img_overlay').html($('div',this).html());
					$('.main_img img').attr('src',$('img',this).attr('alt'));
				}
			}
		});
		
		$('.thumbs_right a').click(function(event){
			event.preventDefault();
			if ($('.carousel div:has(img)').length<=((gPg+1)*4)) return false; 
			gPg++;
			$('.carousel').animate({marginLeft:"-"+(gPg*280)+"px"},750);							
		});
		
		$('.thumbs_left a').click(function(event){
			event.preventDefault();
			if ((gPg-1)<0) return false;
			gPg--;
			$('.carousel').animate({marginLeft:"-"+(gPg*280)+"px"},750);							
		});
		
		$('.carousel div:first').click();
		$('.main_img').attr('style','visibility: visible; display: none;').fadeIn('slow');
		
	}
	//======================== Code to hide news background when there is no news =================
	if($('.header_box_news_text ul').length){
	    if($('.header_box_news_text ul li').length == 0){
	        //set opacity to 0
	        $('.headernews_bg').css("opacity", 0);
	    }   
	}
	//======================== Code to secondary nav when it is blank =================
	if($('ul .submenu.display').length){
	    if($('ul .submenu.display li').length == 0){
	        //set opacity to 0
	        $('ul .submenu.display').removeClass('display');
	    }  
	}
// ========================== Code that generates play icon over lay utilizes the make_play class
	
	if ($('.video_clip').length) {
		$('.video_clip').wrap('<div></div>');
		$('.video_clip').parent().prepend('<div class="play_over">&nbsp;</div>');
	}
	//======= homepage flash
	if ($('#flashSWF').length){
	    if (swfobject.hasFlashPlayerVersion("9.0.0")) {
		        var flashvars = {};
		        var params = {};
		        params.wmode = "transparent";
		        params.allowScriptAccess = "always"; 
		        var attributes = {};
		        attributes.align = "top";
		        swfobject.embedSWF("flash/gaylord_splash.swf", "flashSWF", "805", "395", "6.0.0", false, flashvars, params, attributes);
	        } else {					
	            //console.log("hello");	    			    
	           showNews();
	        };
    }
    //============= news ticker ==================================
    //$('#newsticker').load("/tickerproxy.aspx #tickercontent");
    if($('.news_feed').length){
       $.ajax({
			      url: "tickerproxy.aspx",
			      dataType: "xml",
			      success: function(rssfeed){ 
			  		    var newnews = $("<ul>").attr("class", "newsticker");
					    $(rssfeed).find("item").each(function()
					    {
						    thisTitle = $(this).find("title").text();
						    thisLink = $(this).find("link").text();
						    newnews.append("<li><a href='" +thisLink+"' target='_blank'>"+thisTitle+"</a></li>");
					    });
					    newnews.append("</ul>");
					    newnews.appendTo(".news_feed");
					    // news ticker    	
    				
				        mImg=$('.news_feed ul li').length;
				        text_change_finish();
                        setInterval('text_change();',5000);      				  
				    }//end success function
	     });//end ajax
	 }//end if news_feed

;})

jQuery.fn.events = function(o){
    for (var i in o) {
        this.bind(i, o[i]);
    }
    return this;
};

function showNews(){
    //fade in news module
    $('.flash_box_news').fadeIn('slow', function() {
        // Animation complete
      })
}
