/*
why-must-i-be-wasted-to-stay-in-your-world.js
Lewis LaCook
April 2008
driver for jquery javascript functionality
*/



function rand(number){
return Math.floor(Math.random()*number)
} 


	
	

$(document).ready(function(){
     //begin ready
var refreshId1;
var refreshId2;


$("#container").load("why-must-i-be-wasted-to-stay-in-your-world.php", function(){
$("div.flickr_img > *").each(
function (i) {
var $match = $("div.flickr_img > *").eq(i);
refreshId = setInterval(function(){ 
$match.animate({ 
        width: rand(80)+"%",
	height:rand(80)+"%",
        opacity: "0." + rand(9),
        marginLeft: rand(350),
        marginRight: rand(300),
      	marginTop: rand(400),
      }, rand(2500) );
      
},rand(3000));
}
);

$("div.tag > *").each(

function (i) {
var $match = $("div.tag > *").eq(i);
refreshId2 = setInterval(

function(){ 
$match.animate({ 
      
        opacity: "0." + rand(9),
        marginRight: rand(300),
        marginLeft: rand(300),
        marginTop: rand(400),
	fontSize:rand(100)+"px"
      }
      
      , rand(9500) );
}
,rand(30000));

});
});

//hide, then show elements
$("#explain").hide();
// $("div.flickr_img > *").hide();
// $("div.flickr_img > *").show("slow");
// $("div.tag > *").hide();
// $("div.tag > *").show("slow");


//events

//menu action
$(".menu-item").toggle(function()
{
var str=$(this).text();
$("#explain").show("slow");
$("#explain").empty();
if(str=="Control"){
$("#explain").html("<p>Click on the big black box to toggle empty/refresh of the animation's elements</p>");
}
if(str=="Specs"){
$("#explain").load("includes/specs.php");
}
if(str=="Statement"){
$("#explain").load("includes/statement.php");
}
},
function(){
$("#explain").empty();
$("#explain").hide("slow");
});
//end menu action


$("#container").toggle(

function(){
$(this).empty();
clearInterval(refreshId1);
clearInterval(refreshId1);	
$(this).load("why-must-i-be-wasted-to-stay-in-your-world.php",function(){
$("div.flickr_img > *").each(
function (i) {
var $match = $("div.flickr_img > *").eq(i);
refreshId = setInterval(function(){ 
$match.animate({ 
        width: rand(80)+"%",
	height:rand(80)+"%",
        opacity: "0." + rand(9),
      marginLeft: rand(350),
        marginRight: rand(300),
      	marginTop: rand(400),
      }, rand(2500) );
},rand(3000));

}
);

$("div.tag > *").each(

function (i) {
var $match = $("div.tag > *").eq(i);
refreshId2 = setInterval(

function(){ 
$match.animate({ 
      
        opacity: "0." + rand(9),
         marginRight: rand(300),
        marginLeft: rand(300),
        marginTop: rand(400),
	fontSize:rand(100)+"px"
      }
      
      , rand(9500) );
}
,rand(30000));

});
});	


},

function(){
	$("div.flickr_img > *").stop();
	$("div.tag > *").stop();
	$(this).empty();
clearInterval(refreshId1);
clearInterval(refreshId2);

	
}

);


//end ready
   });
