// Javascript for Kino1 

//Global variables
var posterCount = 5;
var pos1 = 1;
var galleryCount = 3;

function setPosterCount(count) { posterCount = count; }
function setGalleryCount(count) { galleryCount = count; } 

function showFloater(parent,id) {
	var floatId = "float_" + id;
	var floatObject = document.getElementById(floatId);
	floatObject.style.display = "block";
	floatObject.style.visibility = "visible";

}

function hideFloater(parent,id) {
	var floatId = "float_" + id;
	var floatObject = document.getElementById(floatId);
	floatObject.style.display = "none";	
	floatObject.style.visibility = "hidden";
}

function scroll(direction) {
	if (direction == "left") {
		pos1 = pos1 - 3; 
		pos2 = pos1 + 1; 
		pos3 = pos1 + 2; 
		if (pos1 < 1) {	pos1 = posterCount + pos1;	}
		if (pos2 < 1) {	pos2 = posterCount + pos2;	}
		if (pos3 < 1) {	pos3 = posterCount + pos3;	}
		setTimeout("copyDIV('poster_1','div_' + pos1)",100);
		setTimeout("copyDIV('poster_2','div_' + pos2)",200);
		setTimeout("copyDIV('poster_3','div_' + pos3)",300);
	} else if (direction == "right") {
		pos1 = pos1 + 3; 
		pos2 = pos1 + 1; 
		pos3 = pos1 + 2; 
		if (pos1 > posterCount) { pos1 = pos1 - posterCount; }
		if (pos2 > posterCount) { pos2 = pos2 - posterCount; }	
		if (pos3 > posterCount) { pos3 = pos3 - posterCount; }	
		setTimeout("copyDIV('poster_3','div_' + pos3)",100);
		setTimeout("copyDIV('poster_2','div_' + pos2)",200);
		setTimeout("copyDIV('poster_1','div_' + pos1)",300);
	}
	document.getElementById('arrowRight').blur(); document.getElementById('arrowLeft').blur();	
}

function scrollGallery(direction) {
	if (direction == "left") {
		pos1 = pos1 - 3; 
		pos2 = pos1 + 1; 
		pos3 = pos1 + 2; 
		if (pos1 < 1) {	pos1 = galleryCount + pos1;	}
		if (pos2 < 1) {	pos2 = galleryCount + pos2;	}
		if (pos3 < 1) {	pos3 = galleryCount + pos3;	}
		setTimeout("copyDIV('image_1','hiddenImage_' + pos1)",100);
		setTimeout("copyDIV('image_2','hiddenImage_' + pos2)",200);
		setTimeout("copyDIV('image_3','hiddenImage_' + pos3)",300);
	} else if (direction == "right") {
		pos1 = pos1 + 3; 
		pos2 = pos1 + 1; 
		pos3 = pos1 + 2; 
		if (pos1 > galleryCount) { pos1 = pos1 - galleryCount ; }
		if (pos2 > galleryCount) { pos2 = pos2 - galleryCount; }	
		if (pos3 > galleryCount) { pos3 = pos3 - galleryCount; }	
		setTimeout("copyDIV('image_3','hiddenImage_' + pos3)",100);
		setTimeout("copyDIV('image_2','hiddenImage_' + pos2)",200);
		setTimeout("copyDIV('image_1','hiddenImage_' + pos1)",300);
	}
	document.getElementById('galleri_rightarrow').blur(); document.getElementById('galleri_leftarrow').blur();	
}

function openWindow(theURL,winName,features) { 
	window.open(theURL,winName,features);
}

function copyDIV(id1,id2) {
	if (document.getElementById(id1) && document.getElementById(id2)) {
		document.getElementById(id1).innerHTML = document.getElementById(id2).innerHTML;	
	}
}

function hideLayer(id) {
	if (document.getElementById) { var s = document.getElementById(id).style; } 
	if (s) { s.display = "none"; }
}

function showLayer(id) {
	if (document.getElementById) { var s = document.getElementById(id).style; } 
	if (s) { s.display = "block"; }
}

function showInfo(infoId,titleId,minId) { 
	showLayer(infoId);
	copyDIV(titleId,minId);
}

function hideInfo(infoId,titleId,maxId) {
	hideLayer(infoId);
	copyDIV(titleId,maxId);
}

function fadeIn(position) {
	var Color= new Array(); 
	Color[11] = "a00022"; Color[10] = "90001f"; Color[9] = "80001b"; 
	Color[8]  = "700018"; Color[7]  = "600014"; Color[6] = "500011"; 
	Color[5]  = "40000e"; Color[4]  = "30000a"; Color[3] = "200007"; 
	Color[2]  = "100003"; Color[1]  = "000000";	
	if (position >= 1) {
		document.getElementById('fade').style.backgroundColor = "#" + Color[position];
		if (position > 1) {
			position -= 1;	setTimeout("fadeIn("+position+")", 50);
		} else {
			position -= 1; setTimeout("fadeIn("+position+")", 50);
		}
	}
}

function showTrailer(url) {
	hideLayer('trailerContent');
	setTrailerContent(url);
	showLayer('emptyDIV');
	//fadeIn(11);	
	setTimeout("hideLayer('emptyDIV')",599);	
	setTimeout("showLayer('trailerContent')",600);	
}

function hideTrailer() {
	hideLayer('trailerContent');
}

function showProgram() {
	showLayer('alleVisninger');
	copyDIV('visninger_knapp','skjul_visningerDIV');
}

function hideProgram() {
	hideLayer('alleVisninger');
	copyDIV('visninger_knapp','se_visningerDIV');
}




function setTrailerContent(url) {
	var trailer = document.getElementById('quicktimeTrailer');	
	trailer.innerHTML = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"  width="750" height="400" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
							 + '<param name="src" value="' + url + '">'	
							 + '<param name="bgcolor" value="#000000">'
							 + '<param name="pluginspage" value="http://www.apple.com/quicktime/download/">'
							 + '<param name="controller" value="true">'
							 + '<param name="target" value="myself">'
							 + '<param name="href" value="' + url + '">'
							 + '<embed src="' + url + '" width="750" height="400" controller="true" target="myself" pluginspage="http://www.apple.com/quicktime/download/">'
							 + '</embed>'
							 + '</object>';
}

function BuyLinkWithTime(TimeOfDay, BuyURL, firmid)
{
	var buywindow;
	if (BuyURL)	{
		BuyURL = BuyURL + "&source=Alta";
		buywindow = "window.open(\"" + BuyURL + "\", \"nettbillett\", \"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=580,height=530\");return false;";
		if (BuyURL.substring(0, 7) == "UTSOLGT"){
			document.write("<span class='kjop_stroke'>");
			document.write(TimeOfDay);
			document.write("</span>");	
		} else {
			document.write("<a href='filmweb' onclick='" + buywindow + "' class='link_kjop'>" + TimeOfDay + "</a>");
		}
	} else {
	document.write("<span class='kjop_stroke'>");
	document.write(TimeOfDay);
	document.write("</span>");	
	}
	document.write("&nbsp;&nbsp;");
}

function toggleNewsLetter() {
	if (document.getElementById('textField')) {	
		var textField = document.getElementById('textField');	
		if (textField) { 
			
			if (textField.value == "") {
				textField.value = "Din e-postadresse";
			} else {	
				textField.value = ""; 
			}
		}
	}	
}

// Macromedia rollovers
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var disappeardelay=250 
var enableanchorlink=0 
var hidemenu_onclick=1 
var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left") + 5
dropmenuobj.y=getposOffset(obj, "top") - 10
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
MM_swapImgRestore()
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}


