// preload flash
$.flashExpressInstaller = '/assets/swf/expressInstall.swf';

function frontBanner(xmlSrc) {
	return $.flash({
		swf: '/assets/swf/homeBanner.swf',
		height: 381,
		width: 966,
		params: {
			bgcolor: "#130c09",
			scale: "noscale",
			menu: "false",
			flashvars: {
				xmlSrc: xmlSrc,
				playIntro: 0,
    			introGenres: "rock,hiphop,jazz,reggae,folk,metal,...at the hippo"
			}
		}
	});
}

function playerFunc(xmlSrc) {
    bigPlayer = $.flash({
         swf: '/assets/swf/musicPlayer.swf',
         height: 194,
         width: 377,
         params: {
         	 bgcolor: "#2c1b13",
             scale: "noscale",
             menu: "false",
             flashvars: {   
                 xmlSrc: xmlSrc   
             }
         }   
    });
    return bigPlayer
}


function mediaViewer(xmlSrc) {
	return $.flash({
		swf: '/assets/swf/mediaViewer.swf',
		height: 640,
		width: 617,
		params: {
			bgcolor: "#2c1b13",
			scale: "noscale",
			menu: "false",
			flashvars: {
				xmlSrc: xmlSrc
			}
		}
	});
}


function miniPlayerFunc(trackSrc) {
    miniPlayer = $.flash({
         swf: '/assets/swf/musicPlayer.swf',
         height: 92,
         width: 326,
         params: {
         	 bgcolor: "#2c1b13",
             scale: "noscale",
             menu: "false",
             flashvars: {   
                 xmlSrc: trackSrc,
                 mini: "true"  
             }
         }   
    });

    return miniPlayer
}


$(document).ready(function(){

// flash insertion
    if($('#homeFlash').length  > 0) {
        $('#homeFlash').html(frontBanner($('#homeFlash').attr('xmlSrc')));
    
    }
    if($('#jukebox').length  > 0) {
        $('#jukebox').html(playerFunc($('#jukebox').attr('xmlSrc')));
    	
    }
    
    if($('#mediaFlash').length  > 0) {
        $('#mediaFlash').html(mediaViewer($('#mediaFlash').attr('xmlSrc')));
    	
    }

	
	$('.gigRight').each(function(){
	    trackSrc = $(this).attr('trackSrc');
	    $(this).html(miniPlayerFunc(trackSrc));
	});
    
//other
// hover function for inputs and images
    $('.hover').hover(function(){
		$(this).attr('src', $(this).attr('src').replace(/\.(\w{3})/g, "Hover.$1"));
	},function() {
		$(this).attr('src', $(this).attr('src').replace(/Hover\.(\w{3})/g, ".$1"));
	});
// homepage functions
	$('#hMiddle div:odd').addClass('light');

    $('.longLinks div').hover(function(){
        $(this).addClass('eHover');
    }, function() {  
        $(this).removeClass('eHover');
    }).click(function() {
       window.location = $(this).children('a').attr('href'); 
    });
    
//internal page functions
    $('#threeLeft .newsLinks div:odd').addClass('light');
    

	
//band listings page
    $('#wrap .bandListings table').addClass('withJs').children().children('tr').hover(function(){
        $(this).addClass('hover');
     }, function() { 
       $(this).removeClass('hover');
    });
	$('.bandListings table tr:odd').addClass('darker');

//forum functions

    $('#goToFind').hide();
    $('#goTo a').toggle(function(){
        $('#goToFind').fadeIn('fast');
        return false;
    }, function() {
        $('#goToFind').fadeOut('fast');
        return false;
        
    });
//pay functions
    
    $('#secWhat').hide();
    $('.payPage label span').css({ cursor: 'pointer', fontSize: '12px'}).toggle(function(){
        $('#secWhat').slideDown('fast');
     }, function() { 
         $('#secWhat').slideUp('fast');
    });
    try {
        cost = $('#unitCost span').html(); 
    }
    catch(nope) {
        //dont worry about it, wrong page.
    }
    $('#ctl00_cphContent_ddlNumberTicketsRequired').change(function() {
        price = cost*$(this).val();
        $('#totalCost span').html("&pound;"+price);
    });
    
// sIFR stuff

title = $('#inner h1').html();
configText = "color: #2f1c14; font-size: 25px;";

if(title != null) {
    if (title.length <= 64) {
        configText = "color: #2f1c14; font-size: 25px;";

    } else if(title.length <= 69){
        configText = "color: #2f1c14; font-size: 20px;";
        $('#inner h1').addClass('smaller');
    } else if(title.length <= 88) {
        configText = "color: #2f1c14; font-size: 16px;";
        $('#inner h1').addClass('smallerStill');

    } else {
        configText = "color: #2f1c14; font-size: 16px;";
        title = title.substring(0, 85) + "&hellip;";
         $('#inner h1').html(title).addClass('smallerStill');        
    }

}    
/*sifrScript = document.createElement('script');
sifrScript.type = "text/javascript";
sifrScript.charset = "utf-8";
sifrScript.src = "/assets/js/sifrConfig.js"; */
//sifrScript = '<script src="/assets/js/sifrConfig.js" type="text/javascript" charset="utf-8"></script>';
//$('body').append(sifrScript);

getGoing(configText);

});