// JavaScript Document
$(document).ready(function(){

var itemclicked = "false";
$("#assomenu").hide();

$("#assomenubtn").click(function () {
	$("#assomenu").slideToggle("fast");
});


	$("#footerFake").hide(1200, function() {
		$(".loading").hide();
	});


$("#categories a").click(function () {
 
  var clicked = $(this).attr('id');

 	if (itemclicked == "true") {
 		itemclicked = "false";
 		for(l=0;l<100;l++) {
 			$("#dick"+l+"container").hide(0); //hide old FLV div.
    		$("#dick"+l+"content").slideUp(200);
    		$("#fakediv").hide(600, function() {
    		$("#dick"+l+"open").animate({ opacity: '0' }, 200);
    		$("#dick"+l+"open").animate({ width: '1' }, 300);
    		$("#dick"+l).removeClass("picked");
    		
    		});
		}
	    $("#fakediv").show(600, function() {
		for(t=0;t<100;t++) {
			$("#dick"+t+" a").animate({opacity: 1.0}, 400)
			$("#dick"+t+" a").removeClass("picked");
			if($("#dick"+t+" a").attr('id')	!= clicked && clicked != "all") {
				$("#dick"+t+" a").animate({opacity: 0.2}, 300);
				}
			}
    		$("#fakediv").hide(0);
    	});	

 	} else {
 	
 	for(t=0;t<100;t++) {
 	$("#dick"+t+" a").animate({opacity: 1.0}, 400)
		if($("#dick"+t+" a").attr('id')	!= clicked && clicked != "all") {
			$("#dick"+t+" a").animate({opacity: 0.2}, 300);
		}
 	} 	
 }
 
 });




for(t=0;t<100;t++) {
$('#gallery'+t+' a').lightBox();

	$("a").jFade({
		trigger: "mouseover",
		property: 'color',
		start: '2b2b2b',
		end: 'b1ab9d',
		steps: 12,
		duration: 12
	}).jFade({
		trigger: "mouseout",
		property: 'color',
		start: 'b1ab9d',
		end: '2b2b2b',
		steps: 12,
		duration: 12
	});
}

$("#biograpghy").hide(0);
$("#biograpghyBtn").click(function () {
	$("#biograpghy").slideToggle(200);
});


$("#allNews").hide(0);
$("#allNewsBtn").click(function () {
	$("#allNews").slideToggle(300);
});


theDiv = "none";
    		
	for(u=1;u<100;u++) {
        
         $("#dick"+u+"open").animate({ height: '35' });
         $("#dick"+u+"open").animate({ width: '1', opacity: '0' });
    	 $("#dick"+u+"content").hide(0);
    			 
				 
    			 $("#dick"+u).click(function () {
    			 
    	   			itemclicked = "true";	
    	   			var pressed = "#"+this.id;
   					
   					if ($(pressed+" a").attr('class') != "picked") {
   					
   						$.blockUI({  
          					centerY: 0,
           					overlayCSS: { backgroundColor: '#f7f7f7' },
           
            				message: $('#loader'),  
            				css: { 
            					border: 'none',  
            					backgroundColor: '#f7f7f7', 
            					'-webkit-border-radius': '10px', 
            					'-moz-border-radius': '10px', 
           						top: '20px', left: '', right: '20px', width: '20px', height: '20px'	 }  
        					}); 
         
        				setTimeout($.unblockUI, 2000);  		
    	 			
    	 			for(e=0;e<100;e++) {
    	 				$("#dick"+e+" a").removeClass("picked");
    	 			}
    	 			for(e=0;e<100;e++) {
    	 				$("#dick"+e+"content").slideUp("fast");
    	 			}
    	 			
    	 			$("#fakediv").hide(0);
    	 	 	
    	 			if (theDiv != "none") {
    	
    	 				$(theDiv+"container").hide(0); //hide old FLV div.
    			 		$(theDiv+"content").slideUp(200);
    			 		
    			 		$("#fakediv").hide(600, function() {
    			 			$(theDiv+"open").animate({ opacity: '0' }, 200);
    			 			$(theDiv+"open").animate({ width: '1' }, 300);
    			 			$(theDiv).removeClass("picked");
    			 			
    			 			$("#fakediv").hide(0);
    			 		
    			 		});
    			 		
    				}
   					
   					theDiv = "#"+this.id;
   					theDivId = this.id;
   					theId = this;
   					
   					$(theDiv+"container").hide(); //hide FLV div.
   					$(theDiv+" a").addClass("picked");
   					
   				
   					$("#fakediv").slideUp(0, function() {
   	 				$(theDiv+"open").animate({ opacity: '100' }, 1);
			
   	 				$("#fakediv").show(600, function() {
   	 						
   	 				var pos = $(theId).offset();
   	 			//	theWidth = $(document).width() - pos.left - $(theId).width() - 45;
   	 				theWidth = 1000 - pos.left - $(theId).width();
   	 						
   	 				$(theDiv+"open").animate({ width: ""+theWidth+"" }, 300);    					
	    					
	    					$("#fakediv").hide(600, function() {
	    		
	    						$(theDiv+"content").slideDown(300);
	    		
	    							$("#fakediv").show(600, function() {
	    								$(theDiv+"container").show(0);
	    								$("#fakediv").hide();
	    	  
	    	  //alert($(theDiv+"open").attr('class'));
	    	  if ($(theDiv+"open").attr('class') != "unfloat") {
	    	    			
	    	    			
	    	    	var movie=$(theDiv+"open").attr('class');
	    	    	


	    	    	
	    	    	
				
	    	    		//alert(movie.substr(8));	
	    	    								
	    var s1 = new SWFObject("http://christopherhewitt.com/lib/player/player.swf","ply","512","288","9","#000000");
		s1.addParam("allowfullscreen","true");
					s1.addParam("allowscriptaccess","always");
					s1.addParam("flashvars","file=http://www.mellstroms.langustus.com/newsite/admin/flvfiles/video/v"+theDivId+".flv&controlbar=none&image=http://www.mellstroms.langustus.com/newsite/admin/flvfiles/video/i"+theDivId+".png");
					s1.write(theDivId+"container");
    						
	    								}
	    							});
	  		  				   });	    					
       					  });
       			 	 });
       			 	 
       			 	} 
       			 	 
        		});
    	
    }
  
});
