function button(i, state) {
	var bsrc = i.src;     
	if (bsrc)    
	{
	   	i.src = bsrc.replace(i.state, state);
		i.state = state; 
	}
}

var showlogin = false;
function doLogin () {   
	 if(showlogin){
		loginform.submit();
	 }else{    
		$('login').style.display='block'; 
		var logSlide = new Fx.Slide('login');
		logSlide.hide();
		logSlide.slideIn();
		showlogin=true;
	  }
}            

function initNav() {

	// get all of the buttons
	// var buttons = document.getElementsByClassName('button');
	var buttons = $('nav').getElements('img.button');
	for(var b in buttons) {
		// set default state
		buttons[b].state = 'up';
		buttons[b].onmouseover = function () {
			button(this, 'ro');
		};
		buttons[b].onmouseout = function () {
			button(this, 'up');
		};
		buttons[b].onmousedown = function () {
			button(this, 'dn');
		};
		buttons[b].onmouseup = function () {
			button(this, 'up');
		};
	}
	var buttons = $('nav').getElements('img.sel');
	for(var b in buttons) {
		// set default state
		buttons[b].state = 'up';
		button(buttons[b], 'dn');
		buttons[b].onmouseover = function() {};			
		buttons[b].onmouseout = function() {};
		buttons[b].onmousedown = function() {};
		buttons[b].onmouseup = function() {};
	}
}    


function startVividas(file, fullscreen) {  
	// check if player is active.
    if (getPlayerObject().getPlaybackStatus()>1) 
		terminate();    
	if (fullscreen && !notified)          
	{
		alert('Press Esc to exit full screen mode'); 
		notified = true;
	}
		
	var filename = getVividasURL(file);	
    playPressed(filename, playInBrowser);
	location.href = "vividas.html#"+file  
	$('filename').innerHTML = filename;

} 

function getVividasURL(file)
{
	 return mediaDir + prefix + file + bandwidth + '.viv';
}   
      

function showRandom(num) {
	var list = [];
	var showlist = [];
	list.push({file:'ANZ_4-3', name:'ANZ'});
	list.push({file:'Beat-Escape', name:'Beat Escape'});
	list.push({file:'Beat-Opera', name:'Beat Opera'});
	list.push({file:'Beat-RedCarpet', name:'Beat Red Carpet'});
	list.push({file:'Beat-Whack', name:'Beat Whack'});
	list.push({file:'Chadstone-ChadstonePlace', name:'Chadstone Place'});
	list.push({file:'Dodo-Angels', name:'Dodo Angels'});
	list.push({file:'Dodo-FreeRange', name:'Dodo Free Range'});
	list.push({file:'Dodo-Poker', name:'Dodo Poker'});
	list.push({file:'HP-SalesExcellence', name:'Hewlett Packard'});
	list.push({file:'LaTrobeHealth', name:'LaTrobe Health'});
	list.push({file:'LibertyFinancial', name:'Liberty Financial'});
	list.push({file:'LibertyFinancial-Induction', name:'Liberty Financial - Induction'});
	list.push({file:'Nestle-Dance', name:'Nestle Dance'});
	list.push({file:'Nestle-Slide', name:'Nestle Slide'});
	list.push({file:'NextByte', name:'NextByte'});
	list.push({file:'ParksVictoria-WerribeeMansion', name:'Parks Victoria Werribee Mansion'});
	list.push({file:'PortOfMelbourneAuthority', name:'Port Of Melbourne Authority'});
	list.push({file:'QueenVictoriaNightMarket', name:'Queen Victoria Night Market'});
	list.push({file:'StrataStorage', name:'Strata Storage'});
	list.push({file:'Subaru-Liberty', name:'Subaru Liberty'});
	list.push({file:'Telstra-RideWithUs', name:'Telstra Ride With Us'});

	while(showlist.length < num)
	{
	    var rand = parseInt(Math.random()*list.length);
		showlist.push(list[rand]);
		list.splice(rand,1);
	} 
	    
	for(var i=0;i<showlist.length;i++)
	{
		document.write('<p><a href="vividas.html#'+showlist[i].file+'">');
		document.write('<img src="images/thumbs/'+showlist[i].file+'.jpg" alt="'+showlist[i].name+'" /><br />');
        document.write('<strong>'+showlist[i].name+'</strong></a></p>'); 
	}
}       

function setBandwidth (str, val) {
	Cookie.write('bandwidth', val, {domain:'creatology.com.au'});
	bandwidth = val;   
	updateBandwidthDisplay(val);   
} 
function getBandwidth () {     
	var bw = Cookie.read('bandwidth'); 
	if (bw == null) {          
	   bw = '_384';
	   setBandwidth ('Auto Med 384kbps', bw); 
	}
	updateBandwidthDisplay(bw);  
	return bw;
}                         
function updateBandwidthDisplay(str) {
	 $('_184').className = '';
	 $('_384').className = ''; 
	 $('_644').className = ''; 
	 $(str).className = 'sel';
}           




