$(document).ready(function(){
    function get(el) {
        if($(el).length > 0) {
            return true;
        }
    }
    
    if($.browser.msie && $.browser.version == 6) {
    	$('#header').children().children('ul').children('li').hover(function(){
            $(this).css({backgroundImage: "url('/assets/images/nav/tabLeft.gif')", backgroundRepeat: "no-repeat", backgroundPosition: "top left"}).children('span').css({backgroundImage: "url('/assets/images/nav/tabRight.gif')", backgroundRepeat: "no-repeat", backgroundPosition: "top right"}).end().children('ul').css({left: "-6px"});
    	}, function() {
            $(this).css({background: "none"}).children('span').css('background', 'none').end().children('ul').css({left: "-99999px"});
            
    	});
    }
    
    if(get('.sec')) {
        lightMeUp = function(){
             $('.sec table a').css("opacity", "0.8").lightBox({fixedNavigation:true}).hover(function(){
                  $(this).stop().fadeTo(150, 1);
              }, function() {
                  $(this).stop().fadeTo(500, 0.8);
              });
         }
        lightboxScript = document.createElement('script');
        lightboxScript.type = "text/javascript";
        lightboxScript.charset = "utf-8";
        lightboxScript.src = "/assets/js/jquery.lightbox-0.5.min.js";
        lightboxCSSString = '<link rel="stylesheet" href="/assets/css/jquery.lightbox-0.5.css" type="text/css" media="screen" title="Default Style" charset="utf-8"/>';
        $('head').append(lightboxCSSString);
        $('body').append(lightboxScript);
        lightboxScript.onload = lightMeUp(); 
    }
 
    //home hovers
    $('.homeButton').hover(function(){
       $(this).addClass('homeButtonOn');
     }, function() {  
         $(this).removeClass('homeButtonOn');
        
    }).click(function(){
        window.location = $(this).children('h2').children('a').attr('href');
    });
    
    
    $('.prod').css('cursor', 'pointer');
    $('.prod').hover(function(){
        $(this).css('backgroundColor', '#6b6b6b').children('div').children().css('color', '#fff');
    }, function() {
        $(this).css('backgroundColor', '#f1f2f2').children('div').children().css('color', '#6b6b6b');
        
    }).click(function(){
        window.location = $(this).children('div').children('a').attr('href');
    });
 
    // switching content stuff
    $('#innerRight #parent ul li').each(function(i){
        tag = $(this).children().children().html();
        tag = tag.replace(/ /g, "_");
        $("#switchContent p:eq("+i+")").attr('tag', tag);
       // alert($(this).attr('tag'));
    });

});
firstTime = true;
function pageRequest(addressStr) {
    if(firstTime) {
        titlePrefix = $('h1').html();
        firstTime = false;
    }
    var xmlSrc;
	if (addressStr == "#/") {
	    $('h1').html(titlePrefix);
	    $('#innerRight li a').removeClass('on');
		$('li#parent').children('a').addClass('on');
	   xmlSrc = $('li#parent').children('a').attr('xmlSrc');
	   $('#switchContent p').hide();
	   $('#topContent').show();
	} else {
	    titleSuffix = $("a[href='" + addressStr + "']").children('span').html();
        titleTag = titleSuffix.replace(/ /g, "_");
	    // Highlights the correct menu item based on the address string, and returns the xmlSrc property from it's parent div
	    $('#innerRight li a').removeClass('on');
    	$("a[href='" + addressStr + "']").addClass('on');
    	$('h1').html(titlePrefix+ " &ndash; " +titleSuffix);
    	xmlSrc = $("a[href='" + addressStr + "']").attr('xmlSrc');
    	$("#topContent").hide();
    	$('#switchContent p').hide();
    //	alert(titleTag);
  	   $("#switchContent p[tag='"+titleTag+"']").show();
	}
	return xmlSrc;
	
}

function setFlashHeight(value) {
	
	var flashObject = document.getElementById("flashViewer");
	if (flashObject) flashObject.height = value;
	
	if (navigator.userAgent.toLowerCase().indexOf("safari")!=-1) {
		
		var properFlashObject = document.getElementById("flashViewer");
		if (properFlashObject) properFlashObject.height = value;
		
	}
	
}
