
			var menu_sliding = false;
			var is_ipod = false;
			var img_bar_margin = 100;
			var img_alpha = 0.4;
			var canvasW = 640;
			var canvasH = 480;
			var documentW = 640;
			var documentH = 480;
			var img_bar_w = 0;
			var selected_cat = '';
			var selected_year = '';
			var selected_title = '';
			var selected_img = false;
			var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
			
			var timer;		
			var face_dist = 0;
			var old_mouseX = 0;
			var old_mouseY = 0;
			var mouseX = 0;
			var mouseY = 0;
			/*
			if (mode!="html") {
			//if (mode=="flash") {
				var my_url = "";
				if (page) {
					my_url = page;
				} else {
					var temp_arr =  (document.location.href).split("#/");
					if (temp_arr[1]) {
						temp_arr = temp_arr[1].split("/");
						if (temp_arr[0]) {
							my_url = temp_arr[0];
						}
					}people_face
				}
			// <![CDATA[
				swfobject.embedSWF('preloader.swf', 'flashcontent', '100%', '100%', '10', 
					'expressinstall.swf', {domain: '*',pid:my_url,mode:mode}, {allowscriptaccess: 'always', bgcolor: '#000000', menu: 'false', wmode: 'gpu'}, {id: 'flashcontent'},flash_callback);
			// ]]>
			} else {
				init();
			}
			*/
			/*
			function flash_callback(e) {
				if (!e.success)	{
					window.location = "index.php?"+((page)?"page="+page+"&":"")+"mode=html";
					init();	
				}
			}
			*/
			
			function init() {		
				$(document).ready(function(){
					if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
					{
						is_ipod = true;
						img_bar_margin = 25;
					}
					$('#flashcontent').show();
					canvasH = $(window).height();		
					canvasW = $(window).width();
					documentW = $(document).width();	
					documentH = $(document).height();
					
					$('#flash_mode_lbl').css('opacity',0);
					if (template!="root") {
						$('#footer').hide();
					}
						
					if (!isIE6) {
						if (!is_ipod) {
							$('#menubar #menu').show();
						}
						//alert($('#menu ul').height());
						var init_h = $('#menu ul').height();
						
						if (template!="root") {
							$('#menubar #menu').hide();
							if (!is_ipod) {
							$('#menubar').bind("mouseleave",function(){rollout_menubar();});
							}
						}
						
						if (!is_ipod) {
							$('#menubar').bind("mouseenter",function(){rollover_menubar();});
							//alert($('#menu ul ul li:first-child').length);
							$('#menubar a').bind("mouseenter",function(){
																	  // $('#flash_mode_lbl').html($(this).parent().find('ul li').length);
																	   var my_h =  $(this).parent().find('> ul  a').length*$(this).height();
																	   
																	   var my_h1 = $(this).parent().parent().find('>li a').length*$(this).height();
																	  // $('#flash_mode_lbl').html(my_h1);
																	   //$('#flash_mode_lbl').html(my_h-init_h);
																	   var max_h = Math.max(init_h,my_h,my_h1);
																	   if (my_h>init_h) {
																		   $(this).parent().find('> ul').css('margin-top',-(my_h-init_h));
																		  //$('#flash_mode_lbl').html( $(this).parent().find('> ul')[0].nodeName);
																		  $('#menubar_bg').css('margin-top',-(max_h-init_h)).height(max_h);
																	   } else {
																		  $('#menubar_bg').css('margin-top',-(max_h-init_h)).height(max_h);
																	   }
																	   
																	   });
							$('#menubar a').bind("mouseout",function(){
																		  $('#menubar_bg').css('margin-top',-(0)).height(init_h);
																	   });
						}
					}
					
					if (is_ipod) {
						$("#flash_content, #menubar, #content").css("min-width", "0px").css("min-height", "0px");
						$('body').css("height", "100px");
							$('#menu ul ul ul ul').css('display','none');
							if (template!="root") {
								$('#menu').css('position','absolute');
								$('#menu').hide();
							} else{
								$('#menu').show();
							}
							$('#menubar').bind("click",function(){rollover_menubar();});
							$('#menubar').bind("mouseleave",function(){rollout_menubar();});
						
					} else {					
						$('#flash_mode').show();
					}
					
					$().mousemove( function(e) {
					   mouseX = e.pageX; 
					   mouseY = e.pageY;
					 });
					
					//$('#menu ul ul ul a').bind("mouseenter",function(){$(this).parent().parent().parent().children('a').eq(0).css('background-color','#690000'); });
					//$('#menu ul ul ul a').bind("mouseleave",function(){$(this).parent().parent().parent().children('a').eq(0).css('background-color',''); });
					
					switch (template) {
						//template="work"
						case "root":
							resize_logo ();
							$('#logo').hide().fadeIn(2000);
							if (!is_ipod) {
								//$('#logo').css('margin-top',(canvasH/2-250)+'px');
								$('#footer').show();
							}
							$('#menu ul ul ul ul').css('display','none');
							
							//$('#flash_mode_lbl').hide();
						break;
						case "work":
						case "cat":
						case "subcat":
						case "people_section":
						case "peoplecat":
						case "color":
							$('.project:hover,.project_0:hover,.project_1:hover,.project_2:hover').css('background-color','#000000');
							$('.project,.project_0,.project_1,.project_2').css('background-color','#000000').css('cursor','pointer');;
							if (!is_ipod) {
								$('.project,.project_0,.project_1,.project_2').bind("mouseenter",function(){$(this).stop().animate({backgroundColor:'#c41230'},{duration:300, queue: false});$('.project_thumb',this).slideUp('normal');});
								$('.project,.project_0,.project_1,.project_2').bind("mouseleave",function(){$(this).stop().animate({backgroundColor:'#000000'},{duration:300, queue: false});$('.project_thumb',this).slideDown('normal');});
							}
							if (template=="people_section" || template=="peoplecat" || template=="color") {
								$('#img_bar').hide();
							}
							if (template=="color") {												
								//$('.project_0 a').click(function() { return false; });
								$('.project_0, .project_0 a').bind("click",function(){
													$('#project_movie').show().width(canvasW-40).height(canvasH-80).css('left',20).css('top',40);
													$('#project_movie_bg').show().width(canvasW).height(canvasH).css({opacity:0});
													$('#project_movie_bg').animate({opacity:1-img_alpha},'slow');
													$('#project_movie_bg').bind("click",function(){$(this).hide();$('#project_movie').hide();$('#project_movie').html('');});
														//var mov_path = $('a', this).eq(0).attr('href').replace('.mov','.mp4');
														if ($('a', this).length>0) {
														var mov_path = $('a', this).eq(0).attr('href');
														} else {
														var mov_path = $(this).eq(0).attr('href');
														}
													$('#project_movie').html('<div class="hvlog {width: '+(canvasW-40)+', height: '+(canvasH-100)+', autoplay:\'true\',SCALE:\'ASPECT\',BGCOLOR:\'BLACK\'}"> <a href="'+mov_path+'" rel="enclosure"><img src="mov_bg.png" height="'+(canvasH-100)+'" width="'+(canvasW-40)+'"></a> </div>');
													setup_qt();
													return false;
																	  });
								$('#img_bar').hide();
								if (is_ipod) {
									$('.txt,.container').css('width','auto');
								}
								$('.txt').hide().fadeIn("slow");
							} else {
								$('.project,.project_0,.project_1,.project_2').bind("click",function(){$(location).attr('href',$('a',this).attr("href"));});
							}
							if (template=="people_section"||template=="peoplecat"||template=="color") {
								if ($('.img_bar_thumb a').not('.mov').length>0) {
									if (show_img_bar) {
										if (!is_ipod) {
											setup_project_img($('.img_bar_thumb a').not('.mov').eq(0).parent());
											rollover_project_thumb($('.img_bar_thumb a').not('.mov').eq(0).parent());
										}
									} else {
										if (!is_ipod) {
											setup_general_img($('.img_bar_thumb a').not('.mov').eq(0).parent());
										}
									}
								}
							}
						break;	
						case "newsletter_section":
							$('.newsletter:hover').css('background-color','#333333');
							$('.newsletter').css('background-color','#333333').css('cursor','pointer');;
							$('.newsletter').bind("mouseenter",function(){$(this).animate({backgroundColor:'#c41230'},300);});
							$('.newsletter').bind("mouseleave",function(){$(this).animate({backgroundColor:'#333333'},300);});
							$('.newsletter').bind("click",function(){$(location).attr('href',$('a',this).attr("href"));});
						break;					
						case "project":
						case "environment":
							//template="project"
							$('#thumb_info').show().css('cursor','pointer');
							$('#thumb_credits').show().css('cursor','pointer');
							$('#thumb_link').show().css('cursor','pointer');
							$('#content').css('padding-bottom',img_bar_margin);
							$('.img_bar_thumb').css('cursor','pointer').css('background-color','#666666');;
							//$('.img_bar_thumb a').not('.mov').click(function() { return false; });
							$('.img_bar_thumb a').click(function() { return false; });
							if (!is_ipod) {
								$('.img_bar_thumb').bind("mouseenter",function(){rollover_project_thumb($(this));});
								$('.img_bar_thumb').bind("mouseleave",function(){rollout_project_thumb($(this));});
								$('.img_bar_thumb').bind("click",function(){setup_project_img($(this));});
							} else {
								$('.img_bar_thumb a').bind("click",function(){setup_project_img($(this).parent());});
								$('.img_bar_thumb').bind("click",function(){setup_project_img($(this));});
								
							}
							$('#project_content').hide();
							$('#project_credits').hide();
							//$('#content .title').hide();
							
							if (project_category!=7) {
								if ($('.img_bar_thumb a').not('.mov, .nav').length>0) {
									if (!is_ipod) {
									setup_project_img($('.img_bar_thumb a').not('.mov, .nav').eq(0).parent());
									}
									//rollover_project_thumb($('.img_bar_thumb a').not('.mov, .nav').eq(0).parent());
								}
								setup_project_img($('#thumb_info').eq(0));
								rollover_project_thumb($('#thumb_info').eq(0));
							} else {
								if ($('.img_bar_thumb a').not('.nav').length>0) {
									if (!is_ipod) {
									setup_project_img($('.img_bar_thumb a').not('.mov, .nav').eq(0).parent());
									setup_project_img($('.img_bar_thumb a').not('.nav').eq(0).parent());
									rollover_project_thumb($('.img_bar_thumb a').not('.nav').eq(0).parent());
									}
								}
							}
							if (!is_ipod) {
								img_bar_w = 0;
								$('.img_bar_thumb').each(function(){img_bar_w+=$(this).width();});
								$('#img_bar').width(img_bar_w);
								$('#img_bar').css('position','fixed').css('top',$(document).height()-img_bar_margin);
							} else {
								$('#img_bar').css('position','absolute').css('top',$(document).height()-img_bar_margin);
							}
						break;		
						case "credits":
						case "people":
						case "general":
						case "contact":
						case "search":
						case "newsletter_section":
						case "recruitment_section":
						case "recruitment_general":
						case "subscribe":
							var show_img_bar = false;
							if ($('.img_bar_thumb a').length>2 && template != "contact") {
								show_img_bar = true;
							}
							if (template=="environment") {
								if (!is_ipod) {
									$('#thumb_info').show().css('cursor','pointer');
									if ($('.img_bar_thumb a').not('.mov').length>0) {
										setup_project_img($('.img_bar_thumb a').not('.mov').eq(0).parent());
									}
									
									//if ($('.img_bar_thumb a').not('.mov, .nav').length>0) {
										//$('#bg').html('<img alt="" src="'+$('.img_bar_thumb a').not('.mov, .nav').attr('href')+'" id="bg_img" style="position:absolute;display:none" />');
										//$('#bg_img').load(function(){resize_bg_img(false)});
									//}
									
									setup_project_img($('#thumb_info').eq(0));
									rollover_project_thumb($('#thumb_info').eq(0));
								}
							} else {
								if ($('.img_bar_thumb a').not('.mov').length>0) {
									if (show_img_bar) {
										if (!is_ipod) {
										setup_project_img($('.img_bar_thumb a').not('.mov').eq(0).parent());
										rollover_project_thumb($('.img_bar_thumb a').not('.mov').eq(0).parent());
										}
									} else {
										if (!is_ipod) {
											setup_general_img($('.img_bar_thumb a').not('.mov').eq(0).parent());
										}
									}
								}
							}
							
							if (show_img_bar) {
								$('#thumb_info').show().css('cursor','pointer');
								$('#content').css('padding-bottom',img_bar_margin);
								$('.img_bar_thumb').css('cursor','pointer').css('background-color','#666666');
								$('.img_bar_thumb a').click(function() { return false; });
								$('.img_bar_thumb').bind("mouseenter",function(){rollover_project_thumb($(this));});
								$('.img_bar_thumb').bind("mouseleave",function(){rollout_project_thumb($(this));});
								$('.img_bar_thumb').bind("click",function(){setup_project_img($(this));});
						
								if (!is_ipod) {
									img_bar_w = 0;
									$('.img_bar_thumb').each(function(){img_bar_w+=$(this).width();});
									$('#img_bar').width(img_bar_w);
									$('#img_bar').css('position','fixed').css('top',$(document).height()-img_bar_margin);
								} else {
									$('#img_bar').css('absollute','absolute').css('top',$(document).height()-img_bar_margin);
								}
							} else {
								$('#img_bar').hide();
								//$('#bg').hide();	
							}
							
							if (template=="recruitment_section") {
								$('.rec_position .position_desc').hide();
								$('.rec_position').bind("click",function(){$('.rec_position .position_desc').not($(this).children('div')).slideUp();$('.position_desc', this).slideDown();});
							}
							
							
							
							if (template=="credits") {
							selected_cat = $('#credits_cat').val();
							selected_year = $('#credits_year').val();
							selected_title = $('#credits_title').val();
							setup_credits(true);
							$('.credits_cell_cat').bind("click",function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
															selected_cat = (this_cat);
															/*
															var my_year = '';
															$('.credits_cell_year').each(function(){
																  var id = $(this).attr('id');
																  var id_arr = id.split(':');
																  var this_cat = id_arr[0];
																  var this_year = id_arr[1];
																  if (this_cat==selected_cat) {
																	  if (my_year=='') {
																		  my_year = this_year;
																	  }
																  }
															  });
															selected_year = (my_year);
															*/
															var my_title = '';
															var my_year = '';
															$('.credits_cell_title').each(function(){
																  var id = $(this).attr('id');
																  var id_arr = id.split(':');
																  var this_cat = id_arr[0];
																  var this_year = id_arr[1];
																  var this_title = id_arr[2];
																  if (this_cat==selected_cat) {
																	  if (my_year=='') {
																		  my_year = this_year;
																		  my_title = this_title;
																	  }
																  }
															  });
															selected_year = (my_year);
															selected_title = my_title;
															
															setup_credits();
																 });
							$('.credits_cell_year').bind("click",function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
														  var this_year = id_arr[1];														  
															selected_cat = (this_cat);
															selected_year = (this_year);
														  
															var my_title = '';
															var my_year = '';
															$('.credits_cell_title').each(function(){
																  var id = $(this).attr('id');
																  var id_arr = id.split(':');
																  var this_cat = id_arr[0];
																  var this_year = id_arr[1];
																  var this_title = id_arr[2];
																  if (this_cat==selected_cat&&this_year==selected_year) {
																	  if (my_year=='') {
																		  my_year = this_year;
																		  my_title = this_title;
																	  }
																  }
															  });
							
															selected_title = my_title;
															setup_credits();
																 });
							$('.credits_cell_title').bind("click",function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
														  var this_year = id_arr[1];
														  var this_title = id_arr[2];
															selected_cat = (this_cat);
															selected_year = (this_year);
															selected_title = (this_title);
															setup_credits();
																 });
							}
						break;
					}
					
					$('#flash_mode .menu_icon').bind("mouseenter",function(){$('#flash_mode_lbl').show().animate({opacity:1},300);$('#flash_mode_lbl').html($('img',this).attr('alt'))});
					$('#flash_mode .menu_icon').bind("mouseleave",function(){$('#flash_mode_lbl').hide().css('opacity',0);});
					
					$('#nav div').eq($('#nav div').length-1).width(360);
					
					if (template=="people"||template=="people_section" || template=="peoplecat" || template=="contact") {
						setup_people_face();	
					}
						
					resizeme();
					resizeme();
				});	
		
				$(window).resize(function() {resizeme();});
				
			}
			function resizeme() {
					resize_bg_img(true);					
					canvasH = $(window).height();		
					canvasW = $(window).width();
					documentW = $(document).width();	
					documentH = $(document).height();
					$('#project_movie').width(canvasW-40).height(canvasH-80).css('left',20).css('top',20);
					$('#project_movie_bg').width(canvasW).height(canvasH);
					
					switch (template) {
						case "root":
						resize_logo ();
						break;
					}
					if (!is_ipod) {
						$('#project_content, #project_credits').height(canvasH-190);
						$('#project_content, #project_credits').width(Math.round((canvasW-40)/2));
						$('#project_content, #project_credits').css('padding-right',Math.round((canvasW-40)/2)+16);
					}
			}
			function resize_logo () {
				if (!is_ipod) {
							var logo_h = documentH-320;
							if (logo_h>354) {
								logo_h = 354;
							}
							var logo_y = documentH-320-logo_h+20;
							if (logo_y>documentH/2-354/2) {
								logo_y=documentH/2-354/2;
							}
							$('#logo').css('margin-top',(logo_y)+'px');
							$('#logo').css('height',logo_h+'px');
				}
			}
			function setup_qt() {			
				jQuery.embedquicktime({
				  jquery: 'jquery.js', 
				  plugin: 'jquery.embedquicktime.js'
				});	
			}
			function rollover_menubar() {
				if (!menu_sliding) {
					menu_sliding = true;
					$('#menubar #menu').slideDown('slow',function(){menu_sliding=false;});
				}
			}
			function rollout_menubar() {
				if (!menu_sliding) {
					menu_sliding = true;
					$('#menubar #menu').slideUp('slow',function(){menu_sliding=false;});
				}
			}
			function setup_credits(fast) {
				 $('.credits_cell_1').hide();
				$('.credits_cell_cat').each(function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
														  if (this_cat==selected_cat) {
															$(this).css('color','#ffffff');
														  } else {
																 	 $(this).css('color','#666666');
														  }
													  });
				$('.credits_cell_year').each(function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
														  var this_year = id_arr[1];
														  if (this_cat==selected_cat) {
															  if (fast || is_ipod) {$(this).show();} else {$(this).slideDown('normal');}
															  
															  if (this_year==selected_year) {
																  $(this).css('color','#ffffff');
															  } else {
																 	 $(this).css('color','#666666');
															  }
														  } else {
															  if (fast || is_ipod) {$(this).hide();} else {$(this).slideUp('normal');}
														  }
													  });
				$('.credits_cell_title').each(function(){
														  var id = $(this).attr('id');
														  var id_arr = id.split(':');
														  var this_cat = id_arr[0];
														  var this_year = id_arr[1];
														  var this_title = id_arr[2];
														  if (this_cat==selected_cat) {
															  if (fast || is_ipod) {$(this).show();} else {$(this).slideDown('normal');}
														  } else {
															  if (fast || is_ipod) {$(this).hide();} else {$(this).slideUp('normal');}
														  }
														/*
														if (this_cat==selected_cat&&this_year==selected_year&&this_title==selected_title) {
															  if (fast || is_ipod) {$('.credits_cell_1',this).show();} else {$('.credits_cell_1',this).slideDown('normal');}
															  $(this).css('color','#ffffff');
														} else if (this_cat==selected_cat&&this_year==selected_year) {
															  //$('.credits_cell_1',this).show();
															  if (fast || is_ipod) {$('.credits_cell_1',this).hide();} else {$('.credits_cell_1',this).slideUp('normal');}
															  $(this).css('color','#bbb');
														  } else {
															  //$('.credits_cell_1',this).hide();
															  if (fast || is_ipod) {$('.credits_cell_1',this).hide();} else {$('.credits_cell_1',this).slideUp('normal');}
																  if (is_ipod) {
																	  $(this).hide();
																  } else {
																 	 $(this).css('color','#666666');
																  }
														  }*/
														if (this_cat==selected_cat&&this_year==selected_year) {
															  //$('.credits_cell_1',this).show();
															  if (fast || is_ipod) {$('.credits_cell_1',this).show();} else {$('.credits_cell_1',this).show();}
															  $(this).css('color','#fff');
														  } else {
															  //$('.credits_cell_1',this).hide();
															  if (fast || is_ipod) {$('.credits_cell_1',this).hide();} else {$('.credits_cell_1',this).hide();}
																  if (is_ipod) {
																	  $(this).hide();
																  } else {
																 	 $(this).css('color','#666666');
																  }
														  }
													  });
				
			}
			function resize_bg_img(no_fade,my_alpha) {		
					canvasH = $(window).height();		
					canvasW = $(window).width();
				if ($('#bg_img').length>0) {
					//if ($('#bg_img').width()) {
						var imgsize = $('#bg_img').attr('class');
						var imgsize_arr = imgsize.split('_');
						var oriW = imgsize_arr[1];//$('#bg_img').width();//
						var oriH = imgsize_arr[2];//$('#bg_img').height();//
						if (is_ipod) {
							if (oriW/oriH>canvasW/canvasH) {
								imgW = canvasW;
								imgH = Math.round(oriH/oriW*imgW);
							} else {
								imgH = canvasH;
								imgW = Math.round(oriW/oriH*imgH);
							}
						} else {
							if (oriW/oriH<canvasW/canvasH) {
								imgW = canvasW;
								imgH = Math.round(oriH/oriW*imgW);
							} else {
								imgH = canvasH;
								imgW = Math.round(oriW/oriH*imgH);
							}
						}
						var x0 = (canvasW-imgW)/2;
						var y0 = (canvasH-imgH)/2;
						$('#bg_img').width(imgW).height(imgH).css('left',x0).css('top',y0);
						if (!no_fade) {
							if (my_alpha) {
								$('#bg_img').show();
								$('#bg_img').css({'opacity':0});
								$('#bg_img').animate({'opacity':img_alpha},'slow');
							} else {
								$('#bg_img').fadeIn("slow");
							}
						}
					//}
				}
				resize_img_bar();
			}
			function resize_img_bar() {
				$('#img_bar').css('top',0);
				if (is_ipod) {
					$('#img_bar').css('top',canvasH-img_bar_margin);
				} else {
					$('#img_bar #img_bar_box').width(img_bar_w);
					$('#img_bar').css('top',$(window).height()-img_bar_margin);
					if (canvasW-40>img_bar_w) {
						$('#img_bar').width(img_bar_w);
					} else {
						$('#img_bar').width(canvasW-40);
					}
					
				}
				
			}
			function setup_general_img(elem) {
				if (elem.children('a').length>0) {
					var imgsize = elem.children('a').attr('class').split('_');
					$('#bg').html('<img alt="" src="'+elem.children('a').attr('href')+'" id="bg_img" style="position:absolute;display:none" class="img_'+imgsize[1]+'_'+imgsize[2]+'"/>');
					$('#bg_img').load(function(){resize_bg_img(false,0.5)});
				}
			}
			function setup_img_arrows() {
				if (selected_img) {
					var img_no = selected_img.replace('img_','');
					var img_length = $('.img_bar_thumb .img').length;
					
					if (img_no<1) {
						$('#prev_img').css('opacity',0.5);
						$('#prev_img').attr('name','disabled');
					} else {
						$('#prev_img').css('opacity',1);
						$('#prev_img').attr('name','');
					}
					if (img_no>img_length-2) {
						$('#next_img').css('opacity',0.5);
						$('#next_img').attr('name','disabled');
					} else {
						$('#next_img').css('opacity',1);
						$('#next_img').attr('name','');
					}
				}
				
			}
			function setup_project_img(elem) {
				if (elem.attr('name')!="disabled") {
					if (selected_img) {
						var img_no = selected_img.replace('img_','');
						var img_length = $('.img_bar_thumb .img').length;
					}
					$('#project_movie').html('').hide();
					$('#project_movie_bg').hide();
					if (elem.children('a').not('.mov, .nav').length>0) {
						var imgsize = elem.children('a').attr('class').split('_');
						$('#bg').html('<img alt="" src="'+elem.children('a').attr('href')+'" id="bg_img" style="position:absolute;display:none" class="img_'+imgsize[1]+'_'+imgsize[2]+'" />');
						$('#bg_img').load(function(){resize_bg_img(false);if(is_ipod){rollover_project_thumb(elem);}});
						$('#project_content').hide();
						$('#project_credits').hide();
						//$('#content .title').hide();
						selected_img = elem.find('a img').attr('id');
					} else if (elem.children('.mov').length>0) {
						if (is_ipod) {
							$('#bg').html('');
							rollover_project_thumb(elem);
						}
						$('#project_content').hide();
						$('#project_credits').hide();
						//$('#content .title').hide();
						$('#project_movie').show().width(canvasW-40).height(canvasH-80).css('left',20).css('top',40);
						$('#project_movie_bg').show().width(canvasW).height(canvasH).css({opacity:0});
						$('#project_movie_bg').animate({opacity:1-img_alpha},'slow');
						$('#project_movie_bg').bind("click",function(){$(this).hide();$('#project_movie').hide();$('#project_movie').html('');});
						//$('#bg').html('<img alt="" src="'+elem.children('a').attr('href')+'" id="bg_img" style="position:absolute;display:none" />');
						//var mov_path = elem.children('a').attr('href');
						//if (is_ipod && navigator.platform != 'iPad') {
							//var mov_path = elem.children('a').attr('href').replace('.mov','.mp4');
							var mov_path = elem.children('a').attr('href');
						//}
						$('#project_movie').html('<div class="hvlog {width: '+(canvasW-40)+', height: '+(canvasH-100)+', autoplay:\'true\',SCALE:\'ASPECT\',BGCOLOR:\'BLACK\'}"> <a href="'+mov_path+'" rel="enclosure"><img src="mov_bg.png" height="'+(canvasH-100)+'" width="'+(canvasW-40)+'"></a> </div>');
						setup_qt();
				//$content .= '<div class="movie_panel"><div class="hvlog {width: 640, height: 480}"> <a href="'.$img_link.'" rel="enclosure"> <img src="icon_mov.gif"><br>test title</a> </div></div>';
						//var movwin = window.open(elem.children('a').attr('href'),'mov');
					} else if (elem.attr('id')=="thumb_info") {
						if (elem.attr('name')!="selected") {
							if (is_ipod) {
								$('#bg_img').fadeOut('slow');
							} else {
								$('#bg_img').animate({opacity:img_alpha},'slow');
							}
							$('#project_content').fadeIn("slow");
							$('#project_credits').hide();
							//$('#content .title').fadeIn("slow");
							resize_img_bar();
							//if (is_ipod) {
								rollover_project_thumb(elem);
							//}
							resize_bg_img(true);
						} else {
							if (is_ipod) {
								$('#bg_img').fadeIn('slow');
							} else {
								$('#bg_img').animate({opacity:1},'slow');
							}
							$('#project_content').hide();
							$('#project_credits').hide();
							//$('#content .title').hide();
						}
					} else if (elem.attr('id')=="thumb_credits") {
						if (elem.attr('name')!="selected") {
							if (is_ipod) {
								$('#bg_img').fadeOut('slow');
							} else {
								$('#bg_img').animate({opacity:img_alpha},'slow');
							}
							$('#bg_img').animate({opacity:img_alpha},'slow');
							$('#project_content').hide();
							$('#project_credits').fadeIn("slow");
							//$('#content .title').fadeIn("slow");
							resize_img_bar();
							//if (is_ipod) {
								rollover_project_thumb(elem);
							//}
							resize_bg_img(true);
						} else {
							if (is_ipod) {
								$('#bg_img').fadeIn('slow');
							} else {
								$('#bg_img').animate({opacity:1},'slow');
							}
							$('#project_content').hide();
							$('#project_credits').hide();
							//$('#content .title').hide();
						}
					} else if (elem.attr('id')=="thumb_prev") {
						$(location).attr('href',$('a',elem).attr("href"));
					} else if (elem.attr('id')=="thumb_next") {
						$(location).attr('href',$('a',elem).attr("href"));
					} else if (elem.attr('id')=="thumb_up") {
						$(location).attr('href',$('a',elem).attr("href"));
					} else if (elem.attr('id')=="thumb_link") {
						//$(location).attr('href',$('a',elem).attr("href"));
						//$('a',elem).attr('target', '_blank');
						window.open( $('a',elem).attr('href') );
					} else if (elem.attr('id')=="next_img") {
						if (selected_img) {
							if (img_no<img_length-1) {
								elem = $('.img_bar_thumb #img_'+(parseFloat(img_no)+1)).parent().parent();
								setup_project_img(elem);
								rollover_project_thumb(elem);
							}
						} else {
								elem = $('.img_bar_thumb #img_0').parent().parent();
								setup_project_img(elem);
								rollover_project_thumb(elem);
						}
					} else if (elem.attr('id')=="prev_img") {
						if (img_no>0) {
							elem = $('.img_bar_thumb #img_'+(parseFloat(img_no)-1)).parent().parent();
							setup_project_img(elem);
							rollover_project_thumb(elem);
						}
					}
					if (elem.attr('name')=='selected' && (elem.attr('id')=="thumb_info" || elem.attr('id')=="thumb_credits")) {
						$('.img_bar_thumb').attr('name','');
						rollout_project_thumb($('.img_bar_thumb'));
					} else {
						$('.img_bar_thumb').attr('name','');
						elem.attr('name','selected');
						rollout_project_thumb($('.img_bar_thumb').not(elem));
					}
					setup_img_arrows();
				}
			}
			function rollover_project_thumb(elem) {
				if (elem.attr('name')!="disabled") {
					$(elem).animate({backgroundColor:'#c41230'},300);
					$('img',elem).slideUp('normal');
					$('.lbl',elem).show();
				}
			}
			function rollout_project_thumb(elem) {
				if (elem.attr('name')!="selected") {
					$(elem).animate({backgroundColor:'#666666'},300);
					$('img',elem).slideDown('normal');
					$('.lbl',elem).hide();
				}
			}
			function setup_people_face() {
				face_dist = 0;
				//$('.people_face').hide();
				//$('.people .people_face').eq(0).show();
				//$('.people_u .people_face').eq(0).show();
				//$('.people_m .people_face').eq(0).show();
				//$('.people_b .people_face').eq(0).show();
				//$('.people,.people_u,.people_m,.people_b').bind("mouseenter",function(){face_dist =0 ;timer=setInterval("setup_people_face_timer('"+$(this).attr('id')+"')",100);});
				//$('.people,.people_u,.people_m,.people_b').bind("mouseout",function(){clearInterval(timer);});
				$('.people,.people_u,.people_m,.people_b').each(function(){
																		 if ($('.people_face', this).length>1) {
																			 $('.people_face', this).hide();}
																			 $(this).bind("mouseenter",function(){clearInterval(timer);face_dist =0 ;timer=setInterval("setup_people_face_timer('"+$(this).attr('id')+"')",100);});
																			  $(this).bind("mouseleave",function(){clearInterval(timer);});
																			 $('.people_face', this).eq(0).show();
																			 }
																		 );
				$('.people_face').bind("click",function() {
														var url = $(this).parent().find('a').attr('href');
														window.location = url;
														});
			}
			function setup_people_face_timer(face_id) {
				face_dist -= Math.sqrt(Math.pow(mouseX-old_mouseX,2)+Math.pow(mouseY-old_mouseY,2));
				//$('#flash_mode').html(face_dist);
				if (face_dist <= 0) {
					var my_id = $('#'+face_id).attr('rel');
					if (isNaN(my_id)) {
						my_id = 0;
					}
					var max_id = $('#'+face_id+' .people_face').length;					
					my_id++;
					if (my_id>max_id-1) {
						my_id = 0;
					}
					$('#'+face_id+' .people_face').hide();
					$('#'+face_id+' .people_face').eq(my_id).show();
					
					$('#'+face_id).attr('rel',my_id);
					face_dist = 20;
				}
				old_mouseX = mouseX;
				old_mouseY = mouseY;
				
			}
			init();
