

function SLIDE_start( pic,ttl1)
{
  	document.images.SLIDE_picBox.src = pic[SLIDE_actual].src;
  	document.images.SLIDE_ttl01.src = ttl1[SLIDE_actual].src;
  	document.getElementById('title1').style.marginTop = SLIDE_titletm1[SLIDE_actual]+'px';
  	document.getElementById('title1').style.marginLeft = SLIDE_titlelm1[SLIDE_actual]+'px';
	
	document.images.directorbox.src = DIRECTOR_img[SLIDE_actual].src;
	document.getElementById('director').style.position = "absolute";
	document.getElementById('director').style.marginTop =  DIRECTORtm +'px';
	document.getElementById('director').style.marginLeft = DIRECTOR_lm[SLIDE_actual] +'px';
  
	
	
 	document.images.SLIDE_studioBox.src = SLIDE_stud[SLIDE_actual].src;
  	document.getElementById('studio').style.marginTop = SLIDE_studiotm1[SLIDE_actual]+'px';
  	document.getElementById('studio').style.marginLeft = SLIDE_studiolm1[SLIDE_actual]+'px';
  
  		
	document.images['navigbox'].src = Navig_a[8].src;
	document.getElementById('navigbg').style.position = "absolute";
	document.getElementById('navigbg').style.marginTop = BOXtm +'px';
	document.getElementById('navigbg').style.marginLeft = BOXlm +'px';
	
	
	
	
	setTimeout("removeLoading()",250);
  }

function MORE_start( pic,ttl1, proj_num)
{
  SLIDE_actual= shot_start[proj_num][1][1];
  document.images.SLIDE_picBox.src = pic[SLIDE_actual].src;
  document.images.comentbox.src = COMMENT_img[SLIDE_actual].src;
  document.images.SLIDE_ttl01.src = ttl1[SLIDE_actual].src;
  
  document.getElementById('coment').style.position = "absolute";
  document.getElementById('coment').style.marginTop =  COMMENTtm +'px';
  document.getElementById('coment').style.marginLeft = COMMENTlm +'px';
  
  //document.getElementById('naviginter').style.position = "absolute";
  
  document.getElementById('title1').style.marginTop = SLIDE_titletm1[SLIDE_actual]+'px';
  document.getElementById('title1').style.marginLeft = SLIDE_titlelm1[SLIDE_actual]+'px';
  
  document.images.SLIDE_studioBox.src = SLIDE_stud[SLIDE_actual].src;
  document.getElementById('studio').style.marginTop = SLIDE_studiotm1[SLIDE_actual]+'px';
  document.getElementById('studio').style.marginLeft = SLIDE_studiolm1[SLIDE_actual] + STUDIOtm_offset + 'px';
  

  }

function SLIDE_back(pic,ttl1)
{
  SLIDE_actual--;
  SLIDE_slide(pic,ttl1);
  LoadList();
 }

function SLIDE_forward(pic,ttl1)
{
  SLIDE_actual++;
  SLIDE_slide(pic,ttl1);
  LoadList();
}


function SLIDE_back_more(pic,ttl1)
{
	
  STEP_current--;
  
  if( STEP_current < 1 && PROJ_NUM > 1 ){
	  
	  PROJ_NUM -= 1;
	  STEP_current = window[PROJ_list[PROJ_NUM -1]] ;
	  
  	} else if(STEP_current < 1 && PROJ_NUM == 1){
		
	  	PROJ_NUM = PROJ_list.length;
	  	STEP_current = window[PROJ_list[PROJ_NUM -1]];
 	}
  
  SLIDE_actual= shot_start[PROJ_NUM][STEP_current][ELEM_current];
  SLIDE_slide_more(pic,ttl1);
  BeforeAfter();
  LoadList();
  
  
 }

function SLIDE_forward_more(pic,ttl1)
{
	
  STEP_current++;
  
  
  
  if( STEP_current > window[PROJ_list[PROJ_NUM -1]] && PROJ_NUM < PROJ_list.length  ){

	  	PROJ_NUM  += 1;
	  	STEP_current = 1;

  	} else  if (STEP_current > window[PROJ_list[PROJ_NUM -1]] && PROJ_NUM == PROJ_list.length){
	  			PROJ_NUM =1;
	  			STEP_current = 1;
			}
 	
  
  
  
  
  SLIDE_actual= shot_start[PROJ_NUM][STEP_current][ELEM_current];
  SLIDE_slide_more(pic,ttl1);
  BeforeAfter();
  LoadList();
  
  
}

function SLIDE_slide_more( pic,ttl1)
{


  document.images.SLIDE_picBox.src = pic[SLIDE_actual].src;
  document.images.comentbox.src = COMMENT_img[SLIDE_actual].src;
  document.images.SLIDE_ttl01.src = ttl1[SLIDE_actual].src;
  
  document.getElementById('coment').style.position = "absolute";
  document.getElementById('coment').style.marginTop =  COMMENTtm +'px';
  document.getElementById('coment').style.marginLeft = COMMENTlm +'px';
  
 // document.getElementById('naviginter').style.position = "absolute";
  
  document.getElementById('title1').style.marginTop = SLIDE_titletm1[SLIDE_actual]+'px';
  document.getElementById('title1').style.marginLeft = SLIDE_titlelm1[SLIDE_actual]+'px';
  document.images.SLIDE_studioBox.src = SLIDE_stud[SLIDE_actual].src;
  document.getElementById('studio').style.marginTop = SLIDE_studiotm1[SLIDE_actual]+'px';
  document.getElementById('studio').style.marginLeft = SLIDE_studiolm1[SLIDE_actual]+ STUDIOtm_offset + 'px';
 }

function SLIDE_slide( pic,ttl1)
{

  	if (SLIDE_actual > (SLIDE_count)) SLIDE_actual=1;
  	if (SLIDE_actual < 1) SLIDE_actual = SLIDE_count;

  	document.images.SLIDE_picBox.src = pic[SLIDE_actual].src;
  	document.images.SLIDE_ttl01.src = ttl1[SLIDE_actual].src;
  	document.getElementById('title1').style.marginTop = SLIDE_titletm1[SLIDE_actual]+'px';
  	document.getElementById('title1').style.marginLeft = SLIDE_titlelm1[SLIDE_actual]+'px';
  
	document.images.directorbox.src = DIRECTOR_img[SLIDE_actual].src;
	document.getElementById('director').style.position = "absolute";
	document.getElementById('director').style.marginTop =  DIRECTORtm +'px';
	document.getElementById('director').style.marginLeft = DIRECTOR_lm[SLIDE_actual] +'px';
	
  	document.images.SLIDE_studioBox.src = SLIDE_stud[SLIDE_actual].src;
  	document.getElementById('studio').style.marginTop = SLIDE_studiotm1[SLIDE_actual]+'px';
  	document.getElementById('studio').style.marginLeft = SLIDE_studiolm1[SLIDE_actual]+'px';
 }


function NEWlink (mlink)
{
	window.open(mlink[SLIDE_actual])
}

function Over(tname, ttl,i)
{
	document.images[tname].src = ttl[i].src;	
}

function Out(tname, ttl,i)
{
	
	document.images[tname].src = ttl[i].src;	
}



function Overmore(i)
{
	document.images['ListBox'+i].src = List_line_b[i].src;
	document.images['ListImgBox'+i].src = List_Img_b[i].src;
}

function Outmore(i)
{
	
	document.images['ListBox'+i].src = List_line_a[i].src;	
	document.images['ListImgBox'+i].src = List_Img_a[i].src;
}



function LoadNavigation(page)
{
	for (i = 1; i<= 7; i++)
	{
	document.images['NavBox'+i].src = Navig_a[i].src;
	
	}
	document.images['NavBox'+page].src = Navig_b[page].src;
}	

function LoadDemoNavigation()
{
	for (i = 3; i<= 7; i++)
	{
	document.images['NavBox'+i].src = demoNavig_a[i].src;
	
	}
	
}

function LoadNavigationmore(page)
{
	for (i = 3; i<= 7; i++)
	{
	document.images['NavBox'+i].src = Navig_a[i].src;
	
	}
	document.images['NavBox'+page].src = Navig_b[page].src;
}	


function LoadList()
{
	for (i = 1; i<= List_length; i++)
		{
	
		document.images['ListBox'+i].src = List_line_a[i].src; 
		document.getElementById('list'+i).style.marginTop = List_topm + List_height/List_length * (i-1) +'px';
		document.getElementById('list'+i).style.marginLeft = List_leftm +'px';
		
			for (k=1; k<= LIST_position.length; k++)
				{
					position=LIST_position[k];
					
				if (SLIDE_actual == position)
					{
					document.getElementById('list'+i).style.marginLeft = List_rightm - List_elem_length[i]  +'px';
				
					}
				}
		}
	
}



function LoadGallery()
{
	
		
	var k = 0;
	var l = 0;
	var top;
	var left;
	
	for (i = 1; i<= Gal_length; i++)
		{
	
		document.images['ListBox'+i].src = List_line_a[i].src; 
		document.images['ListImgBox'+i].src = List_Img_a[i].src;
		
		top = Gal_topm + l*List_img_height + l*(Gal_height - List_img_height*Gal_vert)/(Gal_vert -1);
		left = Gal_leftm + k*List_img_width + k*(960 - 2*Gal_leftm - List_img_width*Gal_horis)/(Gal_horis - 1);
		
		document.getElementById('listimg'+i).style.marginTop = top +'px';
		document.getElementById('listimg'+i).style.marginLeft = left +'px';
		
		document.getElementById('list'+i).style.marginTop = top + List_img_height + List_elem_gap +'px';
		document.getElementById('list'+i).style.marginLeft = left + List_img_width/2 - List_elem_length[i]/2 + 'px';
		
		k += 1;
		
		if( k == Gal_horis) {
			k = 0;
			l += 1;
		}

		}
	
		setTimeout("removeLoading()",50);
}


function GoToMovie(Movie)
{
	SLIDE_actual = Movie;
	SLIDE_slide(SLIDE_img,SLIDE_ttl1);
  	LoadList();
	
}

function GoToMovie_more(Movie)
{	
	 
	location.href ="moreimg.html?"+ Movie;


}

function readpar()
{
	PROJ_NUM = window.location.search.substring(1);
	PROJ_NUM *= 1;
}

function GoToPage(Page)
{
	if(Page == "film")
	{
		location.href ="features.html";
		
		
	} else if( Page == "more") 
			{
				
				location.href ="more.html";
				
			} else if ( Page == "contact")
					{
						location.href ="contact.html";
						
					} else if ( Page == "about")
						{
							location.href ="about.html";
						} else if ( Page == "tv")
						{
							location.href ="tv.html";
						}
	
}



function DemoGoToPage(Page)
{
	if(Page == "film")
	{
		location.href ="../../And_Company_04/pages/features.html";
		
		
	} else if( Page == "more") 
			{
				
				location.href ="../../And_Company_04/pages/more.html";
				
			} else if ( Page == "contact")
					{
						location.href ="../../And_Company_04/pages/contact.html";
						
					} else if ( Page == "about")
						{
							location.href ="../../And_Company_04/pages/about.html";
						} else if ( Page == "tv")
						{
							location.href ="../../And_Company_04/pages/tv.html";
						}
	
}



function BeforeAfter(){
			

	
	
	
	var dynNav= new Array();

	for(var i=1; i<= numelem; i++){
		
		if (document.getElementById('circle'+i)) {
				
			var child = document.getElementById('circle'+i);
        	var parent = document.getElementById('banda');
         	parent.removeChild(child);
		}
		
	}
	
	numelem = window[PROJ_list[PROJ_NUM-1] + '_' + [STEP_current] + '_length'];
	
	for(var i=1; i<= numelem; i++){
		
		
        dynNav[i] = document.createElement("div");
		
        dynNav[i].id = "circle"+i;

		document.getElementById('banda').appendChild(dynNav[i]);
		
		
		document.getElementById('circle'+i).innerHTML = '<img borger="0" name="dynNavBox'+i+'">';

		if (i == 1){
			document.images['dynNavBox'+ i].src = Navig_c[7+i].src;
		} else {
			document.images['dynNavBox'+ i].src = Navig_a[7+i].src;
		}
		
		
		dynNav[i].onclick =  loadimg(i);
		
		document.getElementById('circle'+i).style.position = "absolute";
		document.getElementById('circle'+i).style.marginTop = BUTTONtm +'px';
		document.getElementById('circle'+i).style.marginLeft = BUTTONlm - ( numelem - i)*BUTTONgap +'px';
		document.getElementById('circle'+i).style.cursor = "pointer"
//		document.getElementById('circle1').style.zIndex = 100;

		
	}
	
		
		
		document.images['navigbox'].src = Navig_a[12].src;
		document.getElementById('navigbg').style.position = "absolute";
		document.getElementById('navigbg').style.marginTop = BOXtm +'px';
		document.getElementById('navigbg').style.marginLeft = BOXlm +'px';
		
	
		
//		document.getElementById('naviginter').style.position = "absolute";
//		document.getElementById('navigbg').style.zIndex = 10;
		
//		alert(1)
		
		
	
	 setTimeout("removeLoading()",50);
												
													
	
}


function loadimg(i){
	
	return function(){
		
		for(j = 1; j <= numelem; j++){
			
				if (j == i){
				document.images['dynNavBox'+ j].src = Navig_c[7+j].src;
				} else {
				document.images['dynNavBox'+ j].src = Navig_a[7+j].src;
				}
		}
		
		SLIDE_actual= shot_start[PROJ_NUM][STEP_current][i];
		SLIDE_slide_more(SLIDE_img,SLIDE_ttl1);
		LoadList();
		

			
	}
	}







// FADE IN AND FADE OUT AND TIMING FUNCTIONS


  var oInterval;
  var MAX_WITHOUT_ACTIVITY=5000; //number of milliseconds without activity before reload.
  var visible=1;
  
  function InitPage() {
	
    var oHid_h = document.getElementById("hid_lastActivity_h");
    var oHid_mn = document.getElementById("hid_lastActivity_mn");
    var oHid_s = document.getElementById("hid_lastActivity_s");
    var oDate=new Date();
    oHid_h.value = oDate.getHours();
    oHid_mn.value = oDate.getMinutes();
    oHid_s.value = oDate.getSeconds();
	
    oInterval = window.setInterval("VerifyActivity()", 2000); // check every 10 seconds    
  }

  function Activity() {
    var oHid_h = document.getElementById("hid_lastActivity_h");
    var oHid_mn = document.getElementById("hid_lastActivity_mn");
    var oHid_s = document.getElementById("hid_lastActivity_s");
    var oDate=new Date();
    oHid_h.value = oDate.getHours();
    oHid_mn.value = oDate.getMinutes();
    oHid_s.value = oDate.getSeconds();
	if(visible== 0){
		allfade();
	   visible = 1;
	}
  }
  
  function VerifyActivity() {
    var oHid_h = document.getElementById("hid_lastActivity_h");
    var oHid_mn = document.getElementById("hid_lastActivity_mn");
    var oHid_s = document.getElementById("hid_lastActivity_s");
    var oDate=new Date(); // current date and time
	
    var oLastActDate=new Date(oDate.getFullYear(), oDate.getMonth(), oDate.getDate(), oHid_h.value, oHid_mn.value, oHid_s.value); // last activity date and time.

	
    if ((oDate.valueOf() - oLastActDate.valueOf()) > MAX_WITHOUT_ACTIVITY && visible ==1) {
  //     alert("Are you sleeping ? You didn't do anything during the past " + (MAX_WITHOUT_ACTIVITY /1000) + " seconds.");
	   allfade();
	   visible = 0;
  	}
  }
  
  
  
  
  
 




function allfade(){
	fade('fade');

}	
	


var TimeToFadeDown = 1500.0;
var TimeToFadeUp = 100.0;

function fade(eid)
{
	
  var element = document.getElementById(eid);
  if(element == null)
    return;
  
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
	  TimeToFade = TimeToFadeDown;
    }
    else
    {
      element.FadeState = -2;
	  TimeToFade = TimeToFadeUp; 
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}







function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
  
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}


function removeElementById(el) {

          var node = document.getElementById(el);

          if (node) {

              node.parentNode.removeChild(node);

          }

      }

      function removeLoading() {
		  
          removeElementById("loading");

      }











