$(function()
{
    $('#news-tabs').tabs();
	$('#updates ul li:odd').oneline({
		height: '27px',
		rightFade: '/assets/images/fade/fade-to-E4E4E4.png',
		leftFade: '/assets/images/fade/fade-from-E4E4E4.png'})
		.addClass('odd');
	
	$('#updates ul li:even').oneline({
		height: '27px',
		rightFade: '/assets/images/fade/fade-to-FFF.png',
		leftFade: '/assets/images/fade/fade-from-FFF.png'});
	
	var tickerAPI = $('#ticker-scrollable').scrollable({
		size: 8,
		items: 'ol.items',
		prev: '#ticker-prev',
		next: '#ticker-next',
		api: true
	});
	var nextGameIdx = $('#ticker-scrollable ol li.nextgame').prevAll().length-5;
	tickerAPI.seekTo(nextGameIdx);
	
	$('#nav > li').not('#tickets').hover(
		function() {
			$('#nav > li').not($(this)).children('ul').hide();
			$('#ticket-nav').hide();
			$(this).children('ul').show();
		},
		function() {
			$(this).children('ul').hide();
		}
	);
	$('#nav > li#tickets').hover(
		function() {
			$('#nav > li').not($(this)).children('ul').hide();
			$('#ticket-nav').show();
		},
		function() {
			$('#ticket-nav').hide();
		}
	);
	
	$('#ticker-prev, #ticker-next').click(function(ev)
	{
	    ev.preventDefault();
	});
	
    $('#txtSearch')
        .keypress(function(ev)
        {
            var key = ev.which || ev.keyCode;
            if (key == 13)
            {
                ev.preventDefault();
                search();
            }
        });
    $('#btnSearch').click(function(ev)
    {
            ev.preventDefault();
            search();
    });
    
    correctPNG();
    showme('imgPlayerShotLeft');
    setFormAction();
    IsPageLoaded = true;

});

function search()
{
    top.location.href = 'http://www.google.com/search?q=site:www.idahosteelheads.com%20' + 
        $('#txtSearch').val();

}
function writeFlash(oeTags)
{
    document.write(oeTags);
}


var thickBoxID = "";

function thickOn(obj)
{
    thickBoxID = obj;
    showme(obj);
}

function thickOff()
{
    hideme(thickBoxID);
}

function hideme(obj)
{
    if (typeof(obj) == "string")
    {
        obj = document.getElementById(obj);
    }
    if (obj != null)
    {
        if (obj.style.display == "block")
	    {
	        obj.style.display = "none";
	    } 
	    else if (obj.className == 'show')
	    {
	        obj.className = 'hide';
	    }
	}
    
}
function showme(obj)
{
    if (typeof(obj) == "string")
    {
        obj = document.getElementById(obj);
    }
    if (obj != null)
    {
        if (obj.style.display == "none")
	    {
	        obj.style.display = "block";
	    } 
	    else if (obj.className == 'hide')
	    {
	        obj.className = 'show';
	    }
	}
}


function tabClick(tabId, tabs)
{
    for(var idx = 0; idx < tabs.length; idx++)
    {
        document.getElementById(tabs[idx]).className = "";
        hideme(tabs[idx] + "Content");
        //alert(document.getElementById(tabs[0] + "Content").style.display);
    }
    document.getElementById(tabId).className = "current";
    showme(tabId + "Content");
        //alert(document.getElementById(tabId + "Content").style.display);
    
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5 && version < 7) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }       
}


function relatedLink(onLink)
{
    for(var idx = 0; idx < links.length; idx++)
    {
        hideme(links[idx]);
    }
    showme(onLink);    
    return false;
}

function toggleme(obj)
{
    if (typeof(obj) == "string")
    {
        obj = document.getElementById(obj);
    }
    if (obj != null)
    {
        if (obj.style.display == "none")
	    {
	        obj.style.display = "block";
	    }
	    else if (obj.style.display == "block")
	    {
	        obj.style.display = "none";
	    } 
	    else if (obj.className == 'hide')
	    {
	        obj.className = 'show';
	    }
	    else if (obj.className == "show")
	    {
	        obj.className = 'hide';
	    }
	}
}

function showmessage(message)
{
    showmessage(message, '');
}

function showmessage(message, spanclass)
{
    var literal = document.getElementById('liClientMessage');
    literal.innerHTML = '<div id="divMessageJS" class="messagebox" style="display: block;">' +
        '<div class="header">Message</div><p><span class="' +
        spanclass + '">' + message + '</span><br /></p><br /><p><a href="javascript:hideme(\'divMessageJS\');" class="closebtn">x close window</a></p></div>';
}

 //pop up function default
function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{
    newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}

function openPhotoPopup(img, w, h)
{
    var url = "/detailphotopopup.aspx?img=" + img + "&w=" + w + "&h=" + h;
    openNewWindow(url, img, "resizable=yes,width=460,height=400");
}

function openSlideshow(album)
{
    var url = "/slideshowpopup.aspx?h=225&w=575&album=" + album;
    openNewWindow(url, album, "resizable=yes,width=675,height=325");
}

function openVideo(video)
{
    var url = "/assets/flv/videopopup.aspx?h=240&w=360&video=" + video;
    openNewWindow(url, video, "resizable=yes,width=480,height=340");
}

function openRegionalMap(region)
{
    var url = "/mappopup.aspx?h=400&w=550&region=" + region;
    openNewWindow(url, region, "resizable=yes,width=650,height=500");
}

function setFormAction()
{
    var myForm = document.forms['aspnetForm'];
    if (!myForm) {
        myForm = document.aspnetForm;
    }
    if (myForm != null)
    {
        myForm.action = top.location.href;
        if (top.location.href.indexOf(".aspx") < 0)
        {
            myForm.action += "index.aspx";
        }
    }
}

