﻿
SelFilmId = 0;
SelFilmPart = 0;
SelFragmentId = 0;
Loading = 0;

function SetOpacity(id, fo){
	if (id == SelFilmId) return;
	var img=document.getElementById('img'+id);
	var ttl=document.getElementById('ttl'+id);;
	if (fo) {
		   img.style.filter = "alpha(opacity=100)";
		   img.style.opacity = "1";	
//		   ttl.style.color="#D3330D";	
		   ttl.style.color="#000000";			   
	}
	else {
		   img.style.filter = "alpha(opacity=60)";
		   img.style.opacity = "0.6";	
		   ttl.style.color="gray";		   
	}
}

function PutCollectionSize(){
	var CollectionSize=document.getElementById('CollectionSize');
	var rTxt=this.req.responseText;
	if (rTxt.length == 0) document.location = "eLogin.asp";
	else {
		CollectionSize.innerHTML = rTxt;
		alert("Film is added to collection");
	}
}

function InCollection(id){
	var loader=new net.ContentLoader("../common/in_collection.asp?id=" + id, PutCollectionSize);
}

function PutProjectTitle(){
	var rTxt=this.req.responseText;
	if (rTxt.length == 0) document.location = "eLogin.asp";
	else alert("Film is added to project \"" + rTxt + "\"");
}

function InProject(id){
	var loader=new net.ContentLoader("../common/in_project.asp?id=" + id, PutProjectTitle);
}

function PutRequest(){
	var rTxt=this.req.responseText;
	if (rTxt.length == 0) document.location = "eLogin.asp";
	else alert("Your request for film screening is registered");
}

function InRequests(id){
	var loader=new net.ContentLoader("../common/in_requests.asp?id=" + id, PutRequest);
}

function OpenPoster(p, id){
	var cf = document.getElementById('numpart').attributes.getNamedItem("cf");	
	window.open(p+"/"+cf.value +"/"+cf.value+"_p0"+id+".jpg","","width=710,height=550,menubar=0,status=0,toolbar=0");
}

function GetPart(id){
	if (Loading) return;
	if (SelFilmPart != id) {
		Loading = 1;
		document.movie.SetURL(rf+"rf/common/gm.asp?id="+SelFilmId+"&part="+id+"&sid="+sid+"&uid="+uid);
		document.movie.SetKioskMode(true);		
		document.getElementById('numpart').innerHTML=" &bull;&nbsp;Reel&nbsp;" + id + "";
		var vp=document.getElementById('vp_'+SelFilmPart);
		if (vp) vp.className = "VP_0";
		SelFilmPart=id;
		vp=document.getElementById('vp_'+SelFilmPart);
		if (vp) vp.className = "VP_1";
		Loading = 0;
		// for fragments:
		var tr = document.getElementById(SelFragmentId);
		if (tr) {		
			var img = document.getElementById("fimg_" + SelFragmentId); 
			if (img) if ("tbl_"+SelFilmId==tr.parentNode.getAttribute("id")) {
				if ((frmFrg['prt_'+SelFragmentId].value == SelFilmPart) && (SelFilmPart > 0)) img.src = "../pic/ball_green.png";
				else img.src = "../pic/ball_gray_green.png";
			}
		}		
	}
}

function PutFilm(){
	var rTxt=this.req.responseText; 
	var i = rTxt.indexOf('\x15');	
	var selectFilm=document.getElementById('selectFilm_1');
	var rTxt=this.req.responseText; 
	var i = rTxt.indexOf('\x15');
	selectFilm.innerHTML = rTxt.substring(0, i); 	
	rTxt = rTxt.substring(i+1); 
	i = rTxt.indexOf('\x15');
	selectFilm = document.getElementById('selectFilm_0');	
	selectFilm.innerHTML = rTxt.substring(0, i);
	rTxt = rTxt.substring(i+1);	
	i = rTxt.indexOf('\x15');
	selectFilm = document.getElementById('dParts');	
	selectFilm.innerHTML = rTxt.substring(0, i);
	rTxt = rTxt.substring(i+1);
	i = rTxt.indexOf('\x15');				
	selectFilm = document.getElementById('dLinks');	
	selectFilm.innerHTML = rTxt.substring(0, i);
	rTxt = rTxt.substring(i+1);
	selectFilm=document.getElementById('selectFilm_2');	
	selectFilm.innerHTML = rTxt;

	if (IsPlaginQT) {
		document.movie.SetIsLooping(false);
		
	//	var qtp=document.getElementById('qtp');
	//	qtp.style.display = "none";
		
		selectFilm=document.getElementById('numpart');
		var it = selectFilm.attributes.getNamedItem("it");
		if (parseInt(it.value)) {
			document.movie.SetURL(rf+"rf/common/gm.asp?id="+SelFilmId+"&part=0");
		}
		else { 
			document.movie.SetURL(rf + "rf/pic/e_no_film.jpg");
		//	document.movie.SetURL(rf + "rf/pic/filmdoc.mov");
		//	document.movie.SetIsLooping(true);	
		}
		document.movie.SetKioskMode(true);
	//	qtp.style.display = "inline";
	}
	SelFilmPart = 0;
	Loading = 0;
			 	
}

function getFilm(id, index){
//	alert("getFilm");
	if (Loading) return;
	if (SelFilmId == id) return;	
	var name;
	if (index == 1) name = "get_eFilm";
	if (index == 2) name = "get_eFilmCollection";
	if (index == 3) name = "get_eFilmFrg";	
	Loading = 1;
		
//	document.movie.SetURL(rf+"rf/pic/filmdoc.mov");
//	document.movie.SetIsLooping(true);
//	document.movie.SetControllerVisible(false);

//	var to = setTimeout(1, 1000);

	var loader=new net.ContentLoader(name + ".asp?id=" + id, PutFilm); 
	if (index!=3) {
		var img;
		var ttl;	
		if (SelFilmId) {
			img=document.getElementById('img'+SelFilmId);
			img.style.filter = "alpha(opacity=60)";
			img.style.opacity = "0.6";	
			ttl=document.getElementById('ttl'+SelFilmId);
			ttl.style.color="gray";
		}
		img=document.getElementById('img'+id);
		img.style.filter = "alpha(opacity=100)";
		img.style.opacity = "1";
		ttl=document.getElementById('ttl'+id);
		ttl.style.color="#D3330D";
	}
	SelFilmId = id;	
}



